1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-18 15:25:36 +02:00
Files
misskey/packages/frontend/src/world/room/objects/speaker.ts
syuilo fa2b1d6096 wip
2026-04-29 09:53:29 +09:00

58 lines
1.2 KiB
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 speaker = defineObject({
id: 'speaker',
name: 'Speaker',
options: {
schema: {
outerColor: {
type: 'color',
label: 'Outer Color',
},
innerColor: {
type: 'color',
label: 'Inner Color',
},
},
default: {
outerColor: [0.45, 0.8, 0],
innerColor: [0, 0, 0],
},
},
placement: 'top',
hasCollisions: false,
hasTexture: false,
canPreMeshesMerging: true,
createInstance: ({ options, model }) => {
const outerMaterial = model.findMaterial('__X_COVER__');
const innerMaterial = model.findMaterial('__X_BODY__');
const applyOuterColor = () => {
const [r, g, b] = options.outerColor;
outerMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
const applyInnerColor = () => {
const [r, g, b] = options.innerColor;
innerMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
applyOuterColor();
applyInnerColor();
return {
onOptionsUpdated: ([k, v]) => {
applyOuterColor();
applyInnerColor();
},
interactions: {},
};
},
});