1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-26 18:24:36 +02:00
This commit is contained in:
syuilo
2026-04-08 13:20:09 +09:00
parent 58acbac7ef
commit 970efb3440
4 changed files with 22 additions and 6 deletions

View File

@@ -5,7 +5,7 @@
import * as BABYLON from '@babylonjs/core'; import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js'; import { defineObject } from '../engine.js';
import { initTv } from '../utility.js'; import { createPlaneUvMapper, initTv } from '../utility.js';
export const tv = defineObject({ export const tv = defineObject({
id: 'tv', id: 'tv',
@@ -46,7 +46,15 @@ export const tv = defineObject({
model.bakeExcludeMeshes = [screenMesh]; model.bakeExcludeMeshes = [screenMesh];
const { material: screenMaterial } = initTv(room, screenMesh); const screenMaterial = model.findMaterial('__X_SCREEN__');
const { dispose: disposeTv } = initTv(room, screenMesh);
//const videoTexture = new BABYLON.VideoTexture('', 'http://syu-win.local:3000/files/97986924-b99e-4fe1-993d-9caf010cca59', room.scene, false, true); ;
//screenMaterial.emissiveTexture = videoTexture;
//videoTexture.video.muted = true;
//videoTexture.video.volume = 0;
//videoTexture.video.loop = true;
const applyScreenBrightness = () => { const applyScreenBrightness = () => {
const b = options.screenBrightness; const b = options.screenBrightness;
@@ -56,6 +64,17 @@ export const tv = defineObject({
applyScreenBrightness(); applyScreenBrightness();
//const updateUv = createPlaneUvMapper(screenMesh);
//const applyFit = () => {
// const tex = screenMaterial.emissiveTexture;
// if (tex == null) return;
// const srcAspect = 16 / 9;
// const targetAspect = 16 / 9;
// updateUv(srcAspect, targetAspect, 'cover');
// model.updated();
//};
//applyFit();
const bodyMaterial = model.findMaterial('__X_BODY__'); const bodyMaterial = model.findMaterial('__X_BODY__');
const applyBodyColor = () => { const applyBodyColor = () => {

View File

@@ -285,14 +285,13 @@ const TV_PROGRAMS = {
export function initTv(room: RoomEngine, screenMesh: BABYLON.Mesh) { export function initTv(room: RoomEngine, screenMesh: BABYLON.Mesh) {
const tvProgramId = 'shopping'; const tvProgramId = 'shopping';
const tvProgram = TV_PROGRAMS[tvProgramId]; const tvProgram = TV_PROGRAMS[tvProgramId];
const tvScreenMaterial = new BABYLON.PBRMaterial('tvScreenMaterial', room.scene); const tvScreenMaterial = screenMesh.material as BABYLON.PBRMaterial;
tvScreenMaterial.albedoColor = new BABYLON.Color3(0, 0, 0); tvScreenMaterial.albedoColor = new BABYLON.Color3(0, 0, 0);
tvScreenMaterial.ambientColor = new BABYLON.Color3(0, 0, 0); tvScreenMaterial.ambientColor = new BABYLON.Color3(0, 0, 0);
tvScreenMaterial.roughness = 1; tvScreenMaterial.roughness = 1;
tvScreenMaterial.emissiveTexture = new BABYLON.Texture(`/client-assets/room/tv/${tvProgramId}/${tvProgramId}.png`, room.scene, false, false); tvScreenMaterial.emissiveTexture = new BABYLON.Texture(`/client-assets/room/tv/${tvProgramId}/${tvProgramId}.png`, room.scene, false, false);
tvScreenMaterial.emissiveTexture.level = 1.0; tvScreenMaterial.emissiveTexture.level = 1.0;
tvScreenMaterial.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5); tvScreenMaterial.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5);
tvScreenMaterial.freeze();
const uvs = screenMesh.getVerticesData(BABYLON.VertexBuffer.UVKind)!; const uvs = screenMesh.getVerticesData(BABYLON.VertexBuffer.UVKind)!;
const uvIndexes = getPlaneUvIndexes(screenMesh); const uvIndexes = getPlaneUvIndexes(screenMesh);
@@ -336,9 +335,7 @@ export function initTv(room: RoomEngine, screenMesh: BABYLON.Mesh) {
applyTvTexture(0); applyTvTexture(0);
return { return {
material: tvScreenMaterial,
dispose() { dispose() {
tvScreenMaterial.dispose();
}, },
}; };
} }