1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-19 14:45:38 +02:00
This commit is contained in:
syuilo
2026-04-08 12:40:40 +09:00
parent 682c5417cb
commit 5736b43149
2 changed files with 52 additions and 16 deletions

View File

@@ -11,19 +11,52 @@ export const tv = defineObject({
id: 'tv',
name: 'TV',
options: {
schema: {},
default: {},
schema: {
screenBrightness: {
type: 'range',
label: 'Screen brightness',
min: 0,
max: 1,
step: 0.01,
},
},
default: {
screenBrightness: 0.5,
},
},
placement: 'top',
createInstance: ({ room, model }) => {
createInstance: ({ options, room, model, scene }) => {
const matrix = model.root.getWorldMatrix(true);
const scale = new BABYLON.Vector3();
matrix.decompose(scale);
const light = new BABYLON.SpotLight('', new BABYLON.Vector3(0/*cm*/, 30/*cm*/ / Math.abs(scale.y), 0), new BABYLON.Vector3(0, 0, 1), Math.PI / 1, 2, scene, room?.lightContainer != null);
light.parent = model.root;
light.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
light.range = 150/*cm*/;
if (room?.lightContainer != null) room.lightContainer.addLight(light);
const screenMesh = model.findMesh('__TV_SCREEN__');
screenMesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.UVKind, true);
model.bakeExcludeMeshes = [screenMesh];
initTv(room, screenMesh);
const { material: screenMaterial } = initTv(room, screenMesh);
const applyScreenBrightness = () => {
const b = options.screenBrightness;
screenMaterial.emissiveColor = new BABYLON.Color3(b, b, b);
light.intensity = 70000 * b;
};
applyScreenBrightness();
return {
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'screenBrightness': applyScreenBrightness(); break;
}
},
interactions: {},
};
},