From f6677aa02cafc91ba927cad0be10a9bda9351261 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Mon, 6 Apr 2026 21:28:16 +0900 Subject: [PATCH] wip --- .../src/utility/room/objects/laptopPc.ts | 5 +++ .../utility/room/objects/woodRingFloorLamp.ts | 40 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/utility/room/objects/laptopPc.ts b/packages/frontend/src/utility/room/objects/laptopPc.ts index 9ea294ace6..35f85484e5 100644 --- a/packages/frontend/src/utility/room/objects/laptopPc.ts +++ b/packages/frontend/src/utility/room/objects/laptopPc.ts @@ -133,6 +133,11 @@ export const laptopPc = defineObject({ const angle = options.openAngle; hutaNode.rotationQuaternion = null; hutaNode.rotation.x = -angle; + if (angle <= -Math.PI / 2) { + light.intensity = 0; + } else { + light.intensity = 20000 * options.screenBrightness; + } model.updated(); }; diff --git a/packages/frontend/src/utility/room/objects/woodRingFloorLamp.ts b/packages/frontend/src/utility/room/objects/woodRingFloorLamp.ts index 84508bab8e..76056d4935 100644 --- a/packages/frontend/src/utility/room/objects/woodRingFloorLamp.ts +++ b/packages/frontend/src/utility/room/objects/woodRingFloorLamp.ts @@ -19,10 +19,23 @@ export const woodRingFloorLamp = defineObject({ type: 'color', label: 'Body color', }, + lightColor: { + type: 'color', + label: 'Light color', + }, + lightBrightness: { + type: 'range', + label: 'Light brightness', + min: 0, + max: 1, + step: 0.01, + }, }, default: { shadeColor: [0.21, 0.04, 0], bodyColor: [0.05, 0.05, 0.05], + lightColor: [1, 0.5, 0.2], + lightBrightness: 0.5, }, }, placement: 'floor', @@ -46,19 +59,42 @@ export const woodRingFloorLamp = defineObject({ applyBodyColor(); const lamps = model.findMeshes('__X_LAMP__'); + const lights: BABYLON.SpotLight[] = []; for (const lamp of lamps) { const light = new BABYLON.SpotLight('', new BABYLON.Vector3(0/*cm*/, 0/*cm*/, 0), new BABYLON.Vector3(0, -1, 0), Math.PI / 1, 2, scene, room?.lightContainer != null); light.parent = lamp; - light.diffuse = new BABYLON.Color3(1.0, 0.5, 0.2); - light.intensity = 5000; light.range = 100/*cm*/; if (room?.lightContainer != null) room.lightContainer.addLight(light); + lights.push(light); } + const applyLightColor = () => { + const [r, g, b] = options.lightColor; + for (const light of lights) { + light.diffuse = new BABYLON.Color3(r, g, b); + } + }; + + applyLightColor(); + + const applyLightBrightness = () => { + for (const light of lights) { + light.intensity = 10000 * options.lightBrightness; + } + for (const lamp of lamps) { + const emissive = lamp.material as BABYLON.PBRMaterial; + emissive.emissiveIntensity = options.lightBrightness * 5; + } + }; + + applyLightBrightness(); + return { onOptionsUpdated: ([k, v]) => { applyShadeColor(); applyBodyColor(); + applyLightColor(); + applyLightBrightness(); }, interactions: {}, };