diff --git a/packages/frontend/src/world/room/objects/lavaLamp.ts b/packages/frontend/src/world/room/objects/lavaLamp.ts index 0482b9c673..9f411bbc17 100644 --- a/packages/frontend/src/world/room/objects/lavaLamp.ts +++ b/packages/frontend/src/world/room/objects/lavaLamp.ts @@ -59,6 +59,8 @@ export const lavaLamp = defineObject({ applyLightColor(); + let animationObserver: BABYLON.Observer; + return { onInited: () => { const light = new BABYLON.PointLight('lavaLampLight', new BABYLON.Vector3(0, cm(11), 0), scene, room?.lightContainer != null); @@ -90,6 +92,10 @@ export const lavaLamp = defineObject({ sphere2.animations = [anim]; scene.beginAnimation(sphere2, 0, 500, true, 0.6); + animationObserver = scene.onAfterAnimationsObservable.add(() => { + room?.sr.updateMesh([sphere, sphere2], false); + }); + const emitter = new BABYLON.TransformNode('emitter', scene); emitter.parent = root; emitter.position = new BABYLON.Vector3(0, cm(10), 0); @@ -123,7 +129,11 @@ export const lavaLamp = defineObject({ case 'lightColor': applyLightColor(); break; } }, + dispose: () => { + if (animationObserver != null) { + scene.onAfterAnimationsObservable.remove(animationObserver); + } + }, }; }, - });