60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import * as THREE from 'three';
|
||
|
||
/**
|
||
* Базовый свет сцены (Ambient + Directional)
|
||
*/
|
||
export function setupLights(scene) {
|
||
const ambient = new THREE.AmbientLight(0xffffff, 1.3);
|
||
scene.add(ambient);
|
||
|
||
const key = new THREE.DirectionalLight(0xffffff, 0.8);
|
||
key.position.set(5, 6, 4);
|
||
scene.add(key);
|
||
|
||
const fill = new THREE.DirectionalLight(0xffffff, 0.2);
|
||
fill.position.set(-5, 3, -4);
|
||
scene.add(fill);
|
||
}
|
||
|
||
/**
|
||
* Потолочные споты, привязанные к Spot_*
|
||
*/
|
||
export function setupRoomLights(room) {
|
||
const spotNames = [
|
||
'Spot_001','Spot_002','Spot_003','Spot_004',
|
||
'Spot_005','Spot_006','Spot_007','Spot_008'
|
||
];
|
||
|
||
spotNames.forEach((spotName) => {
|
||
const spotObject = room.getObjectByName(spotName);
|
||
if (!spotObject) {
|
||
console.warn(`Объект не найден: ${spotName}`);
|
||
return;
|
||
}
|
||
|
||
// === СПОТ-СВЕТ ===
|
||
const spotLight = new THREE.SpotLight(0xffffff, 5, 80, Math.PI/4, 0.5, 1);
|
||
spotObject.add(spotLight);
|
||
spotLight.position.set(0, 0, 0);
|
||
|
||
// === Target по -Z (вниз) ===
|
||
spotObject.add(spotLight.target);
|
||
spotLight.target.position.set(0, 0, -1);
|
||
spotLight.target.updateMatrixWorld(true);
|
||
|
||
// === ВИЗУАЛЬНАЯ ТОЧКА ИСТОЧНИКА (сфера) ===
|
||
const bulb = new THREE.Mesh(
|
||
new THREE.SphereGeometry(0.02, 12, 12),
|
||
new THREE.MeshStandardMaterial({
|
||
color: 0xffffff,
|
||
emissive: 0xffffff,
|
||
emissiveIntensity: 2
|
||
})
|
||
);
|
||
bulb.position.set(0, 0, 0);
|
||
spotObject.add(bulb);
|
||
|
||
console.log(`Спот корректно создан: ${spotName}`);
|
||
});
|
||
}
|