1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-16 12:05:26 +02:00
Files
misskey/packages/frontend/src/utility/room/objects/ceilingFanLight.ts
2026-04-04 18:14:45 +09:00

38 lines
1.0 KiB
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',
receiveShadows: false,
castShadows: false,
createInstance: ({ scene, model }) => {
const rotor = model.findMesh('Rotor');
model.bakeExcludeMeshes = [rotor, ...rotor.getChildMeshes()];
return {
onInited: () => {
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];
scene.beginAnimation(rotor, 0, 100, true);
},
interactions: {},
};
},
});