diff --git a/packages/frontend/src/world/room/controller.ts b/packages/frontend/src/world/room/controller.ts index e624668252..c052d9abbd 100644 --- a/packages/frontend/src/world/room/controller.ts +++ b/packages/frontend/src/world/room/controller.ts @@ -199,7 +199,6 @@ export class RoomController { } public addObject(type: string) { - console.log(type); if (this.worker != null) { this.worker.postMessage({ type: 'addObject', objectType: type }); } else if (this.engine != null) { diff --git a/packages/frontend/src/world/room/objects/ceilingFanLight.ts b/packages/frontend/src/world/room/objects/ceilingFanLight.ts index 4e8cfd1431..3628245142 100644 --- a/packages/frontend/src/world/room/objects/ceilingFanLight.ts +++ b/packages/frontend/src/world/room/objects/ceilingFanLight.ts @@ -21,6 +21,8 @@ export const ceilingFanLight = defineObject({ const rotor = model.findMesh('Rotor'); model.bakeExcludeMeshes = [rotor, ...rotor.getChildMeshes()]; + let animationObserver: BABYLON.Observer; + return { onInited: () => { rotor.rotation = rotor.rotationQuaternion != null ? rotor.rotationQuaternion.toEulerAngles() : rotor.rotation; @@ -30,12 +32,17 @@ export const ceilingFanLight = defineObject({ { frame: 100, value: Math.PI * 2 }, ]); rotor.animations = [anim]; - scene.onAfterAnimationsObservable.add(() => { + animationObserver = scene.onAfterAnimationsObservable.add(() => { room?.sr.updateMesh([rotor, ...rotor.getChildMeshes()]); }); scene.beginAnimation(rotor, 0, 100, true); }, interactions: {}, + dispose: () => { + if (animationObserver != null) { + scene.onAfterAnimationsObservable.remove(animationObserver); + } + }, }; }, }); diff --git a/packages/frontend/src/world/room/objects/radiometer.ts b/packages/frontend/src/world/room/objects/radiometer.ts index 0ccee9abe4..506c5fb651 100644 --- a/packages/frontend/src/world/room/objects/radiometer.ts +++ b/packages/frontend/src/world/room/objects/radiometer.ts @@ -15,10 +15,12 @@ export const radiometer = defineObject({ }, placement: 'top', hasCollisions: false, - createInstance: ({ scene, model }) => { + createInstance: ({ room, scene, model }) => { const vanes = model.findTransformNode('__X_VANES__'); model.bakeExcludeMeshes = [...vanes.getChildMeshes()]; + let animationObserver: BABYLON.Observer; + return { onInited: () => { vanes.rotation = vanes.rotationQuaternion != null ? vanes.rotationQuaternion.toEulerAngles() : vanes.rotation; @@ -28,9 +30,17 @@ export const radiometer = defineObject({ { frame: 240, value: Math.PI * 2 }, ]); vanes.animations = [anim]; + animationObserver = scene.onAfterAnimationsObservable.add(() => { + room?.sr.updateMesh([...vanes.getChildMeshes()]); + }); scene.beginAnimation(vanes, 0, 240, true); }, interactions: {}, + dispose: () => { + if (animationObserver != null) { + scene.onAfterAnimationsObservable.remove(animationObserver); + } + }, }; }, });