1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 15:45:43 +02:00
Files
misskey/packages/frontend/src/world/room/objects/newtonsCradle.ts
syuilo 6cca5706f7 wip
2026-04-17 15:31:56 +09:00

45 lines
905 B
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
export const newtonsCradle = defineObject({
id: 'newtonsCradle',
name: 'newtonsCradle',
options: {
schema: {
frameColor: {
type: 'color',
label: 'Frame color',
},
},
default: {
frameColor: [0.15, 0.15, 0.15],
},
},
placement: 'top',
hasCollisions: false,
createInstance: ({ options, model }) => {
const frameMaterial = model.findMaterial('__X_FRAME__');
const applyFrameColor = () => {
const [r, g, b] = options.frameColor;
frameMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
applyFrameColor();
return {
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'frameColor': applyFrameColor(); break;
}
},
interactions: {},
};
},
});