g
This commit is contained in:
37
src/index.js
37
src/index.js
@@ -394,6 +394,18 @@ function setupLighting() {
|
|||||||
pointLight.position.set(-10, 10, 10);
|
pointLight.position.set(-10, 10, 10);
|
||||||
scene.add(pointLight);
|
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
|
// Interior point lights (will be repositioned when model loads) - increased intensity
|
||||||
window.interiorLight = new THREE.PointLight(0xffffff, 0.8, 50);
|
window.interiorLight = new THREE.PointLight(0xffffff, 0.8, 50);
|
||||||
window.interiorLight.position.set(0, 0, 0); // Will be moved to model center
|
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);
|
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.8);
|
||||||
scene.add(hemiLight);
|
scene.add(hemiLight);
|
||||||
|
|
||||||
|
console.log('✨ Camera lights added - they will follow your view');
|
||||||
|
|
||||||
// Create environment map for glass reflections
|
// Create environment map for glass reflections
|
||||||
setupEnvironmentMap();
|
setupEnvironmentMap();
|
||||||
}
|
}
|
||||||
@@ -695,6 +709,16 @@ function centerModelAndControls(object) {
|
|||||||
window.interiorLight2.distance = maxDimension * 1.5;
|
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
|
// Update controls
|
||||||
controls.update();
|
controls.update();
|
||||||
|
|
||||||
@@ -758,6 +782,19 @@ function animate() {
|
|||||||
// Update controls
|
// Update controls
|
||||||
controls.update();
|
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
|
// Clear and render with proper transparency sorting
|
||||||
renderer.clear();
|
renderer.clear();
|
||||||
renderer.render(scene, camera);
|
renderer.render(scene, camera);
|
||||||
|
|||||||
Reference in New Issue
Block a user