mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-19 14:45:38 +02:00
wip
This commit is contained in:
@@ -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: {},
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user