-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsceneSetup.js
More file actions
49 lines (40 loc) · 1.77 KB
/
sceneSetup.js
File metadata and controls
49 lines (40 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// sceneSetup.js start
import * as THREE from 'three';
import { createDynamicBackground } from './timeBasedBackground.js';
export function setupScene() {
const scene = new THREE.Scene();
// 1. Create dynamic background system and store reference
const backgroundSystem = createDynamicBackground(scene);
scene.userData.backgroundSystem = backgroundSystem;
// 2. Lighting setup optimized for the cube background
const ambientLight = new THREE.AmbientLight(0xffffff, 0.7);
ambientLight.name = 'MainAmbientLight';
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.9);
directionalLight.name = 'MainDirectionalLight';
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);
// 3. Helpers (smaller size to match typical content)
const gridHelper = new THREE.GridHelper(15, 15, 0x555555, 0x333333);
gridHelper.name = 'MainGridHelper';
scene.add(gridHelper);
const axesHelper = new THREE.AxesHelper(5);
axesHelper.name = 'MainAxesHelper';
scene.add(axesHelper);
// 4. Set initial background bounds (will be updated when content loads)
backgroundSystem.updateSize(
new THREE.Vector3(-20, -5, -20), // Min bounds
new THREE.Vector3(20, 15, 20) // Max bounds
);
console.log('[Scene] Scene initialized with dynamic background cube');
return scene;
}
// Export background update function for other modules
export function updateSceneBackground(scene, minBounds, maxBounds) {
if (scene.userData.backgroundSystem?.updateSize) {
scene.userData.backgroundSystem.updateSize(minBounds, maxBounds);
} else {
console.warn('Background system not available for update');
}
}
// sceneSetup.js end