1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 19:15:52 +02:00
This commit is contained in:
syuilo
2026-02-20 16:33:35 +09:00
parent aae03a914d
commit bba7076eca
6 changed files with 32 additions and 5 deletions

View File

@@ -3,18 +3,39 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js';
export const colorBox = defineObject({
id: 'colorBox',
name: 'Color Box',
options: {
schema: {},
default: {},
schema: {
color: {
type: 'color',
label: 'Color',
},
},
default: {
color: [1, 1, 1],
},
},
placement: 'floor',
createInstance: () => {
createInstance: ({ options, root }) => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyColor = () => {
const [r, g, b] = options.color;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
applyColor();
return {
onOptionsUpdated: ([k, v]) => {
applyColor();
},
interactions: {},
};
},