From bff70d275acf03547e808d50d79c6ac893e3ea0b Mon Sep 17 00:00:00 2001 From: Kalila <69767640+digisomni@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:36:18 +0800 Subject: [PATCH 1/2] Fix metadata parsing in the case of parent TransformNodes. --- src/modules/scene/LODManager.ts | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/modules/scene/LODManager.ts b/src/modules/scene/LODManager.ts index ae2659d8..363a55a7 100644 --- a/src/modules/scene/LODManager.ts +++ b/src/modules/scene/LODManager.ts @@ -124,15 +124,34 @@ export class LODManager { } private static getMetadataFromMesh(mesh: AbstractMesh | Mesh | InstancedMesh) { - const metadata: Nullable = mesh.metadata?.gltf?.extras; + const meshExtras = mesh.metadata?.gltf?.extras; + const parentExtras = mesh.parent?.metadata?.gltf?.extras; + const meshMetadata: MeshMetadata = { - vircadia_lod_mode: metadata?.vircadia_lod_mode, - vircadia_lod_auto: metadata?.vircadia_lod_auto, - vircadia_lod_distance: metadata?.vircadia_lod_distance, - vircadia_lod_size: metadata?.vircadia_lod_size, - vircadia_lod_hide: metadata?.vircadia_lod_hide, - vircadia_billboard_mode: metadata?.vircadia_billboard_mode, + vircadia_lod_mode: undefined, + vircadia_lod_auto: undefined, + vircadia_lod_distance: undefined, + vircadia_lod_size: undefined, + vircadia_lod_hide: undefined, + vircadia_billboard_mode: undefined }; + + if (meshExtras === null || meshExtras === undefined && parentExtras !== null || parentExtras !== undefined) { + meshMetadata.vircadia_lod_mode = parentExtras?.vircadia_lod_mode; + meshMetadata.vircadia_lod_auto = parentExtras?.vircadia_lod_auto; + meshMetadata.vircadia_lod_distance = parentExtras?.vircadia_lod_distance; + meshMetadata.vircadia_lod_size = parentExtras?.vircadia_lod_size; + meshMetadata.vircadia_lod_hide = parentExtras?.vircadia_lod_hide; + meshMetadata.vircadia_billboard_mode = parentExtras?.vircadia_billboard_mode; + } else { + meshMetadata.vircadia_lod_mode = meshExtras?.vircadia_lod_mode; + meshMetadata.vircadia_lod_auto = meshExtras?.vircadia_lod_auto; + meshMetadata.vircadia_lod_distance = meshExtras?.vircadia_lod_distance; + meshMetadata.vircadia_lod_size = meshExtras?.vircadia_lod_size; + meshMetadata.vircadia_lod_hide = meshExtras?.vircadia_lod_hide; + meshMetadata.vircadia_billboard_mode = meshExtras?.vircadia_billboard_mode; + } + return meshMetadata; } From b2b9c8eeaa9be91d0b5263b1057fd8e2418565ea Mon Sep 17 00:00:00 2001 From: Kalila <69767640+digisomni@users.noreply.github.com> Date: Thu, 19 Oct 2023 01:07:51 +0800 Subject: [PATCH 2/2] Attempt another fix. --- .../{lightComponent.ts => LightComponent.ts} | 0 ...materialComponent.ts => MaterialComponent.ts} | 0 .../{shapeComponent.ts => ShapeComponent.ts} | 0 .../entity/components/components/index.ts | 16 ++++++++-------- 4 files changed, 8 insertions(+), 8 deletions(-) rename src/modules/entity/components/components/{lightComponent.ts => LightComponent.ts} (100%) rename src/modules/entity/components/components/{materialComponent.ts => MaterialComponent.ts} (100%) rename src/modules/entity/components/components/{shapeComponent.ts => ShapeComponent.ts} (100%) diff --git a/src/modules/entity/components/components/lightComponent.ts b/src/modules/entity/components/components/LightComponent.ts similarity index 100% rename from src/modules/entity/components/components/lightComponent.ts rename to src/modules/entity/components/components/LightComponent.ts diff --git a/src/modules/entity/components/components/materialComponent.ts b/src/modules/entity/components/components/MaterialComponent.ts similarity index 100% rename from src/modules/entity/components/components/materialComponent.ts rename to src/modules/entity/components/components/MaterialComponent.ts diff --git a/src/modules/entity/components/components/shapeComponent.ts b/src/modules/entity/components/components/ShapeComponent.ts similarity index 100% rename from src/modules/entity/components/components/shapeComponent.ts rename to src/modules/entity/components/components/ShapeComponent.ts diff --git a/src/modules/entity/components/components/index.ts b/src/modules/entity/components/components/index.ts index bb1d7ddf..9a1e7bac 100644 --- a/src/modules/entity/components/components/index.ts +++ b/src/modules/entity/components/components/index.ts @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -export { KeyLightComponent } from "./KeyLightComponent.js"; -export { HazeComponent } from "./HazeComponent.js"; -export { SkyboxComponent } from "./SkyboxComponent.js"; -export { ModelComponent } from "./ModelComponent.js"; -export { ImageComponent } from "./ImageComponent.js"; -export { MaterialComponent } from "./MaterialComponent.js"; -export { ShapeComponent } from "./ShapeComponent.js"; -export { LightEntityComponent } from "./LightComponent.js"; +export { KeyLightComponent } from "./KeyLightComponent"; +export { HazeComponent } from "./HazeComponent"; +export { SkyboxComponent } from "./SkyboxComponent"; +export { ModelComponent } from "./ModelComponent"; +export { ImageComponent } from "./ImageComponent"; +export { MaterialComponent } from "./MaterialComponent"; +export { ShapeComponent } from "./ShapeComponent"; +export { LightEntityComponent } from "./LightComponent";