@combeenation/3d-viewer 6.4.0 → 6.4.1-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/3d-viewer",
3
- "version": "6.4.0",
3
+ "version": "6.4.1-beta1",
4
4
  "description": "Combeenation 3D Viewer",
5
5
  "homepage": "https://github.com/Combeenation/3d-viewer#readme",
6
6
  "bugs": {
@@ -1,4 +1,5 @@
1
1
  import { applyMaterialAfterTexturesLoaded, getOrCreateMaterial, injectNodeMetadata } from './babylonHelper';
2
+ import { sleep } from './resourceHelper';
2
3
  import { ISceneLoaderPlugin } from '@babylonjs/core/Loading/sceneLoader';
3
4
  import { Material } from '@babylonjs/core/Materials/material';
4
5
  import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
@@ -56,8 +57,8 @@ export const getMaterialPostLoadObserver = function (concerningMesh: Mesh) {
56
57
  const scene = concerningMesh.getScene();
57
58
 
58
59
  // can't check `isEnabled` immediatly, since the enabled state of parents and childs is not synced yet
59
- // postpone to "when scene ready" to ensure a correct parent-child enable relation
60
- await scene.whenReadyAsync();
60
+ // postpone one cycle to ensure a correct parent-child enable relation
61
+ await sleep(0);
61
62
 
62
63
  const hasBeenEnabled = concerningMesh.isEnabled(true);
63
64
  const materialMissing = has(concerningMesh.metadata, missingMaterialMetadataName);
@@ -72,7 +73,7 @@ export const getMaterialPostLoadObserver = function (concerningMesh: Mesh) {
72
73
 
73
74
  // remove all "enable" observers that were assigned to the concerning mesh
74
75
  // the mesh got visible and therefore the observers are not needed anymore
75
- enableObserverMap[concerningMesh.id].forEach(entry => {
76
+ enableObserverMap[concerningMesh.id]?.forEach(entry => {
76
77
  const currNode = scene.getMeshById(entry.currNodeId);
77
78
  currNode?.onEnabledStateChangedObservable.remove(entry.observer);
78
79
  });