Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs #1016

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading