1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 19:15:52 +02:00
Files
misskey/packages/frontend/src/utility/room/objects/ceilingFanLight.ts
syuilo aae03a914d wip
2026-02-20 13:15:34 +09:00

34 lines
997 B
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js';
export const ceilingFanLight = defineObject({
id: 'ceilingFanLight',
name: 'Ceiling Fan Light',
options: {
schema: {},
default: {},
},
placement: 'ceiling',
createInstance: ({ room, root }) => {
return {
onInited: () => {
const rotor = root.getChildMeshes().find(m => m.name === 'Rotor') as BABYLON.Mesh;
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([
{ frame: 0, value: 0 },
{ frame: 100, value: Math.PI * 2 },
]);
rotor.animations = [anim];
room.scene.beginAnimation(rotor, 0, 100, true);
},
interactions: {},
};
},
});