mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 15:45:43 +02:00
45 lines
905 B
TypeScript
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: {},
|
|
};
|
|
},
|
|
});
|