This commit is contained in:
sebseb7
2025-08-25 09:31:37 +02:00
parent 7f64c3ca74
commit 3250291c67

View File

@@ -394,6 +394,18 @@ function setupLighting() {
pointLight.position.set(-10, 10, 10);
scene.add(pointLight);
// Camera light - follows the camera to illuminate from viewing angle
window.cameraLight = new THREE.PointLight(0xffffff, 1.0, 200);
window.cameraLight.position.copy(camera.position);
scene.add(window.cameraLight);
// Additional camera spotlight for focused illumination
window.cameraSpotlight = new THREE.SpotLight(0xffffff, 0.8, 100, Math.PI / 4, 0.3);
window.cameraSpotlight.position.copy(camera.position);
window.cameraSpotlight.target.position.set(0, 0, 0); // Point at origin initially
scene.add(window.cameraSpotlight);
scene.add(window.cameraSpotlight.target);
// Interior point lights (will be repositioned when model loads) - increased intensity
window.interiorLight = new THREE.PointLight(0xffffff, 0.8, 50);
window.interiorLight.position.set(0, 0, 0); // Will be moved to model center
@@ -408,6 +420,8 @@ function setupLighting() {
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.8);
scene.add(hemiLight);
console.log('✨ Camera lights added - they will follow your view');
// Create environment map for glass reflections
setupEnvironmentMap();
}
@@ -695,6 +709,16 @@ function centerModelAndControls(object) {
window.interiorLight2.distance = maxDimension * 1.5;
}
// Update camera lights to target the model center
if (window.cameraLight) {
window.cameraLight.distance = maxDimension * 3; // Adjust range based on model size
}
if (window.cameraSpotlight) {
window.cameraSpotlight.target.position.copy(center);
window.cameraSpotlight.distance = maxDimension * 2;
}
// Update controls
controls.update();
@@ -758,6 +782,19 @@ function animate() {
// Update controls
controls.update();
// Update camera lights to follow camera position
if (window.cameraLight) {
window.cameraLight.position.copy(camera.position);
}
if (window.cameraSpotlight) {
window.cameraSpotlight.position.copy(camera.position);
// Make spotlight point towards the orbit controls target (model center)
if (controls && controls.target) {
window.cameraSpotlight.target.position.copy(controls.target);
}
}
// Clear and render with proper transparency sorting
renderer.clear();
renderer.render(scene, camera);