Skip to content

Commit

Permalink
Fix some bugs (#1016)
Browse files Browse the repository at this point in the history
* add AvatarAttach component to engine

* fix removing 'assets' from url

* allow URL's for Textures
  • Loading branch information
nicoecheza authored Oct 4, 2024
1 parent 2a0de2c commit be05f6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isAssetNode } from '../../../ProjectAssetExplorer/utils'
import { AssetCatalogResponse } from '../../../../lib/data-layer/remote-data-layer'
import { isValidInput } from '../../GltfInspector/utils'
import { removeBasePath } from '../../../../lib/logic/remove-base-path'
import { isValidHttpsUrl } from '../../../../lib/utils/url'

export const fromTexture = (base: string, value: TextureUnion): TextureInput => {
switch (value.tex?.$case) {
Expand All @@ -27,9 +28,10 @@ export const fromTexture = (base: string, value: TextureUnion): TextureInput =>
}
case 'texture':
default:
const src = value?.tex?.texture.src ?? ''
return {
type: Texture.TT_TEXTURE,
src: toString(removeBasePath(base, value?.tex?.texture.src ?? '')),
src: isValidHttpsUrl(src) ? src : removeBasePath(base, src),
wrapMode: toString(value?.tex?.texture.wrapMode),
filterMode: toString(value?.tex?.texture.filterMode)
}
Expand Down Expand Up @@ -61,11 +63,12 @@ export const toTexture = (base: string, value?: TextureInput): TextureUnion => {
}
}
default:
const src = value?.src || ''
return {
tex: {
$case: 'texture',
texture: {
src: value?.src ? toString(base ? base + '/' + value.src : value.src) : '',
src: isValidHttpsUrl(src) ? src : (src && base ? base + '/' : '') + src,
wrapMode: toNumber(value?.wrapMode ?? '0', TextureWrapMode.TWM_REPEAT),
filterMode: toNumber(value?.filterMode ?? '0', TextureFilterMode.TFM_POINT)
}
Expand All @@ -78,6 +81,6 @@ export const isTexture = (value: string): boolean => value.endsWith('.png')
export const isModel = (node: TreeNode): node is AssetNodeItem => isAssetNode(node) && isTexture(node.name)

export function isValidTexture(value: any, files?: AssetCatalogResponse): boolean {
if (typeof value === 'string' && files) return isValidInput(files, value)
if (typeof value === 'string' && files) return isValidHttpsUrl(value) || isValidInput(files, value)
return false
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const fromVideoPlayer =
(base: string) =>
(value: PBVideoPlayer): VideoPlayerInput => {
return {
src: removeBasePath(base, value.src),
src: isValidHttpsUrl(value.src) ? value.src : removeBasePath(base, value.src),
loop: value.loop,
playing: value.playing,
volume: volumeFromVideoPlayer(value.volume)
Expand Down
4 changes: 4 additions & 0 deletions packages/@dcl/inspector/src/lib/sdk/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum CoreComponents {
ANIMATOR = 'core::Animator',
AUDIO_SOURCE = 'core::AudioSource',
AUDIO_STREAM = 'core::AudioStream',
AVATAR_ATTACH = 'core::AvatarAttach',
GLTF_CONTAINER = 'core::GltfContainer',
NETWORK_ENTITY = 'core-schema::Network-Entity',
MATERIAL = 'core::Material',
Expand Down Expand Up @@ -171,6 +172,7 @@ export type SdkComponents = {
Animator: ReturnType<typeof components.Animator>
AudioSource: ReturnType<typeof components.AudioSource>
AudioStream: ReturnType<typeof components.AudioStream>
AvatarAttach: ReturnType<typeof components.AvatarAttach>
Billboard: ReturnType<typeof components.Billboard>
GltfContainer: ReturnType<typeof components.GltfContainer>
Material: ReturnType<typeof components.Material>
Expand All @@ -193,6 +195,7 @@ export function createComponents(engine: IEngine): SdkComponents {
const Animator = components.Animator(engine)
const AudioSource = components.AudioSource(engine)
const AudioStream = components.AudioStream(engine)
const AvatarAttach = components.AvatarAttach(engine)
const Billboard = components.Billboard(engine)
const GltfContainer = components.GltfContainer(engine)
const Material = components.Material(engine)
Expand All @@ -214,6 +217,7 @@ export function createComponents(engine: IEngine): SdkComponents {
Animator,
AudioSource,
AudioStream,
AvatarAttach,
Billboard,
GltfContainer,
Material,
Expand Down

0 comments on commit be05f6f

Please sign in to comment.