mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-17 05:35:31 +02:00
58 lines
1.2 KiB
TypeScript
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 '../engine.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',
|
|
createInstance: ({ options, model }) => {
|
|
const outerMesh = model.findMesh('__X_COVER__');
|
|
const outerMaterial = outerMesh.material as BABYLON.PBRMaterial;
|
|
|
|
const innerMesh = model.findMesh('__X_BODY__');
|
|
const innerMaterial = innerMesh.material as BABYLON.PBRMaterial;
|
|
|
|
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: {},
|
|
};
|
|
},
|
|
});
|