diff --git a/packages/frontend/src/utility/room/objects/cardboardBox.ts b/packages/frontend/src/utility/room/objects/cardboardBox.ts index 3d83e9b94b..9554bf5b02 100644 --- a/packages/frontend/src/utility/room/objects/cardboardBox.ts +++ b/packages/frontend/src/utility/room/objects/cardboardBox.ts @@ -25,16 +25,16 @@ export const cardboardBox = defineObject({ createInstance: ({ scene, options, root }) => { return { onInited: () => { - const boxMesh = root.getChildMeshes().find(m => m.name === 'Box') as BABYLON.Mesh; - if (options.variation === 'mikan') { - const tex = new BABYLON.Texture('/client-assets/room/objects/cardboard-box/textures/mikan.png', scene, false, false); - (boxMesh.material as BABYLON.PBRMaterial).albedoTexture = tex; - (boxMesh.material as BABYLON.PBRMaterial).albedoColor = new BABYLON.Color3(1, 1, 1); - } else if (options.variation === 'aizon') { - const tex = new BABYLON.Texture('/client-assets/room/objects/cardboard-box/textures/aizon.png', scene, false, false); - (boxMesh.material as BABYLON.PBRMaterial).albedoTexture = tex; - (boxMesh.material as BABYLON.PBRMaterial).albedoColor = new BABYLON.Color3(1, 1, 1); - } + //const boxMesh = root.getChildMeshes().find(m => m.name === 'Box') as BABYLON.Mesh; + //if (options.variation === 'mikan') { + // const tex = new BABYLON.Texture('/client-assets/room/objects/cardboard-box/textures/mikan.png', scene, false, false); + // (boxMesh.material as BABYLON.PBRMaterial).albedoTexture = tex; + // (boxMesh.material as BABYLON.PBRMaterial).albedoColor = new BABYLON.Color3(1, 1, 1); + //} else if (options.variation === 'aizon') { + // const tex = new BABYLON.Texture('/client-assets/room/objects/cardboard-box/textures/aizon.png', scene, false, false); + // (boxMesh.material as BABYLON.PBRMaterial).albedoTexture = tex; + // (boxMesh.material as BABYLON.PBRMaterial).albedoColor = new BABYLON.Color3(1, 1, 1); + //} }, interactions: {}, }; diff --git a/packages/frontend/src/utility/room/objects/ceilingFanLight.ts b/packages/frontend/src/utility/room/objects/ceilingFanLight.ts index 7fd6159c73..04cc829a0b 100644 --- a/packages/frontend/src/utility/room/objects/ceilingFanLight.ts +++ b/packages/frontend/src/utility/room/objects/ceilingFanLight.ts @@ -16,10 +16,10 @@ export const ceilingFanLight = defineObject({ placement: 'ceiling', receiveShadows: false, castShadows: false, - createInstance: ({ scene, root }) => { + createInstance: ({ scene, model }) => { return { onInited: () => { - const rotor = root.getChildMeshes().find(m => m.name === 'Rotor') as BABYLON.Mesh; + const rotor = model.findMesh('Rotor'); rotor.rotation = rotor.rotationQuaternion != null ? rotor.rotationQuaternion.toEulerAngles() : rotor.rotation; const anim = new BABYLON.Animation('', 'rotation.y', 60, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); anim.setKeys([ diff --git a/packages/frontend/src/utility/room/objects/tabletopDigitalClock.ts b/packages/frontend/src/utility/room/objects/tabletopDigitalClock.ts index aa4b51b9da..b13140a151 100644 --- a/packages/frontend/src/utility/room/objects/tabletopDigitalClock.ts +++ b/packages/frontend/src/utility/room/objects/tabletopDigitalClock.ts @@ -33,41 +33,41 @@ export const tabletopDigitalClock = defineObject({ }, }, placement: 'top', - createInstance: ({ room, options, root }) => { + createInstance: ({ room, options, model }) => { const segmentMeshes = { - '1a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1A__')), - '1b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1B__')), - '1c': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1C__')), - '1d': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1D__')), - '1e': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1E__')), - '1f': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1F__')), - '1g': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1G__')), - '2a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2A__')), - '2b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2B__')), - '2c': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2C__')), - '2d': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2D__')), - '2e': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2E__')), - '2f': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2F__')), - '2g': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_2G__')), - '3a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3A__')), - '3b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3B__')), - '3c': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3C__')), - '3d': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3D__')), - '3e': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3E__')), - '3f': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3F__')), - '3g': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_3G__')), - '4a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4A__')), - '4b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4B__')), - '4c': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4C__')), - '4d': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4D__')), - '4e': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4E__')), - '4f': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4F__')), - '4g': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_4G__')), + '1a': model.findMesh('__TIME_7SEG_1A__'), + '1b': model.findMesh('__TIME_7SEG_1B__'), + '1c': model.findMesh('__TIME_7SEG_1C__'), + '1d': model.findMesh('__TIME_7SEG_1D__'), + '1e': model.findMesh('__TIME_7SEG_1E__'), + '1f': model.findMesh('__TIME_7SEG_1F__'), + '1g': model.findMesh('__TIME_7SEG_1G__'), + '2a': model.findMesh('__TIME_7SEG_2A__'), + '2b': model.findMesh('__TIME_7SEG_2B__'), + '2c': model.findMesh('__TIME_7SEG_2C__'), + '2d': model.findMesh('__TIME_7SEG_2D__'), + '2e': model.findMesh('__TIME_7SEG_2E__'), + '2f': model.findMesh('__TIME_7SEG_2F__'), + '2g': model.findMesh('__TIME_7SEG_2G__'), + '3a': model.findMesh('__TIME_7SEG_3A__'), + '3b': model.findMesh('__TIME_7SEG_3B__'), + '3c': model.findMesh('__TIME_7SEG_3C__'), + '3d': model.findMesh('__TIME_7SEG_3D__'), + '3e': model.findMesh('__TIME_7SEG_3E__'), + '3f': model.findMesh('__TIME_7SEG_3F__'), + '3g': model.findMesh('__TIME_7SEG_3G__'), + '4a': model.findMesh('__TIME_7SEG_4A__'), + '4b': model.findMesh('__TIME_7SEG_4B__'), + '4c': model.findMesh('__TIME_7SEG_4C__'), + '4d': model.findMesh('__TIME_7SEG_4D__'), + '4e': model.findMesh('__TIME_7SEG_4E__'), + '4f': model.findMesh('__TIME_7SEG_4F__'), + '4g': model.findMesh('__TIME_7SEG_4G__'), }; - const colonMeshes = root.getChildMeshes().filter(m => m.name.includes('__TIME_7SEG_COLON__')); + const colonMeshes = model.findMeshes('__TIME_7SEG_COLON__'); - const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh; + const bodyMesh = model.findMesh('__X_BODY__'); const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial; const applyBodyColor = () => { diff --git a/packages/frontend/src/utility/room/objects/tv.ts b/packages/frontend/src/utility/room/objects/tv.ts index b84b21538f..da1a3e6b56 100644 --- a/packages/frontend/src/utility/room/objects/tv.ts +++ b/packages/frontend/src/utility/room/objects/tv.ts @@ -15,8 +15,8 @@ export const tv = defineObject({ default: {}, }, placement: 'top', - createInstance: ({ room, root }) => { - const screenMesh = root.getChildMeshes().find(m => m.name.includes('__TV_SCREEN__')) as BABYLON.Mesh; + createInstance: ({ room, model }) => { + const screenMesh = model.findMesh('__TV_SCREEN__'); screenMesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true); initTv(room, screenMesh);