From be05f6f78db7c2fea51caecd540b2dac2d6a1261 Mon Sep 17 00:00:00 2001 From: Nicolas Echezarreta Date: Fri, 4 Oct 2024 08:33:06 -0700 Subject: [PATCH] Fix some bugs (#1016) * add AvatarAttach component to engine * fix removing 'assets' from url * allow URL's for Textures --- .../EntityInspector/MaterialInspector/Texture/utils.ts | 9 ++++++--- .../EntityInspector/VideoPlayerInspector/utils.ts | 2 +- packages/@dcl/inspector/src/lib/sdk/components/index.ts | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/@dcl/inspector/src/components/EntityInspector/MaterialInspector/Texture/utils.ts b/packages/@dcl/inspector/src/components/EntityInspector/MaterialInspector/Texture/utils.ts index 2166113e1..4bb275c70 100644 --- a/packages/@dcl/inspector/src/components/EntityInspector/MaterialInspector/Texture/utils.ts +++ b/packages/@dcl/inspector/src/components/EntityInspector/MaterialInspector/Texture/utils.ts @@ -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) { @@ -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) } @@ -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) } @@ -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 } diff --git a/packages/@dcl/inspector/src/components/EntityInspector/VideoPlayerInspector/utils.ts b/packages/@dcl/inspector/src/components/EntityInspector/VideoPlayerInspector/utils.ts index b7a8ffce6..f9559b2cb 100644 --- a/packages/@dcl/inspector/src/components/EntityInspector/VideoPlayerInspector/utils.ts +++ b/packages/@dcl/inspector/src/components/EntityInspector/VideoPlayerInspector/utils.ts @@ -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) diff --git a/packages/@dcl/inspector/src/lib/sdk/components/index.ts b/packages/@dcl/inspector/src/lib/sdk/components/index.ts index 4bcc439ab..30f48c6d4 100644 --- a/packages/@dcl/inspector/src/lib/sdk/components/index.ts +++ b/packages/@dcl/inspector/src/lib/sdk/components/index.ts @@ -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', @@ -171,6 +172,7 @@ export type SdkComponents = { Animator: ReturnType AudioSource: ReturnType AudioStream: ReturnType + AvatarAttach: ReturnType Billboard: ReturnType GltfContainer: ReturnType Material: ReturnType @@ -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) @@ -214,6 +217,7 @@ export function createComponents(engine: IEngine): SdkComponents { Animator, AudioSource, AudioStream, + AvatarAttach, Billboard, GltfContainer, Material,