Skip to content

Commit

Permalink
Merge pull request #195 from vircadia/feature/lod
Browse files Browse the repository at this point in the history
Fix metadata parsing in the case of parent TransformNodes.
  • Loading branch information
digisomni authored Oct 21, 2023
2 parents 5ba8cdd + b2b9c8e commit 87fe6c7
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/modules/scene/LODManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,34 @@ export class LODManager {
}

private static getMetadataFromMesh(mesh: AbstractMesh | Mesh | InstancedMesh) {
const metadata: Nullable<MeshMetadata> = mesh.metadata?.gltf?.extras;
const meshExtras = mesh.metadata?.gltf?.extras;

Check warning on line 127 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe assignment of an `any` value

Check warning on line 127 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe member access .gltf on an `any` value
const parentExtras = mesh.parent?.metadata?.gltf?.extras;

Check warning on line 128 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe assignment of an `any` value

Check warning on line 128 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe member access .gltf on an `any` value

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;

Check warning on line 140 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe assignment of an `any` value

Check warning on line 140 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe member access .vircadia_lod_mode on an `any` value
meshMetadata.vircadia_lod_auto = parentExtras?.vircadia_lod_auto;

Check warning on line 141 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe assignment of an `any` value

Check warning on line 141 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe member access .vircadia_lod_auto on an `any` value
meshMetadata.vircadia_lod_distance = parentExtras?.vircadia_lod_distance;

Check warning on line 142 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe assignment of an `any` value

Check warning on line 142 in src/modules/scene/LODManager.ts

View workflow job for this annotation

GitHub Actions / 🎉 Deploy

Unsafe member access .vircadia_lod_distance on an `any` value
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;
}

Expand Down

0 comments on commit 87fe6c7

Please sign in to comment.