1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 18:45:35 +02:00
This commit is contained in:
syuilo
2026-04-17 15:39:12 +09:00
parent 6cca5706f7
commit 02c6e1b876
3 changed files with 19 additions and 3 deletions

View File

@@ -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) {

View File

@@ -21,6 +21,8 @@ export const ceilingFanLight = defineObject({
const rotor = model.findMesh('Rotor');
model.bakeExcludeMeshes = [rotor, ...rotor.getChildMeshes()];
let animationObserver: BABYLON.Observer<BABYLON.Scene>;
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);
}
},
};
},
});

View File

@@ -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<BABYLON.Scene>;
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);
}
},
};
},
});