Sync with Gitea: update scene, lights, camera; add models and textures
This commit is contained in:
31
js/scene.js
31
js/scene.js
@@ -1,6 +1,7 @@
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
||||
import { setupLights, setupRoomLights } from './lights.js';
|
||||
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
|
||||
import { setupLights, setupRoomLights, setupLEDStrip } from './lights.js';
|
||||
import { camera } from './camera.js';
|
||||
|
||||
const canvas = document.getElementById('scene');
|
||||
@@ -22,6 +23,22 @@ renderer.toneMappingExposure = 0.3;
|
||||
// Свет
|
||||
setupLights(scene);
|
||||
|
||||
// ===== HDRI =====
|
||||
const rgbeLoader = new RGBELoader();
|
||||
rgbeLoader.load(
|
||||
'textures/hdri_1.exr',
|
||||
(texture) => {
|
||||
texture.mapping = THREE.EquirectangularReflectionMapping;
|
||||
scene.environment = texture;
|
||||
scene.background = texture;
|
||||
console.log('HDRI загружен: textures/hdri_1.exr');
|
||||
},
|
||||
undefined,
|
||||
(error) => {
|
||||
console.error('HDRI LOAD ERROR', error);
|
||||
}
|
||||
);
|
||||
|
||||
// ===== ROOM =====
|
||||
export let room = null; // Экспортируем для вращения
|
||||
const loader = new GLTFLoader();
|
||||
@@ -30,17 +47,17 @@ loader.load(
|
||||
(gltf) => {
|
||||
room = gltf.scene;
|
||||
|
||||
// Центрируем модель
|
||||
// Центрируем модель по Y (только вверх/вниз)
|
||||
const box = new THREE.Box3().setFromObject(room);
|
||||
const center = box.getCenter(new THREE.Vector3());
|
||||
room.position.sub(center);
|
||||
|
||||
// Масштаб 1:1 так как модель уже в метрах
|
||||
room.scale.set(1, 1, 1);
|
||||
const centerY = (box.min.y + box.max.y) / 2;
|
||||
room.position.y = -centerY;
|
||||
|
||||
// Инициализируем свет комнаты
|
||||
setupRoomLights(room);
|
||||
|
||||
// LED-ленты на ceilinglight_001 - ceilinglight_004
|
||||
setupLEDStrip(room);
|
||||
|
||||
scene.add(room);
|
||||
},
|
||||
undefined,
|
||||
|
||||
Reference in New Issue
Block a user