Skip to content

Commit 4cf573d

Browse files
mrdoobclaude
andcommitted
Examples: Fix lightprobes complex scene issues.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2b460e2 commit 4cf573d

2 files changed

Lines changed: 22 additions & 26 deletions

File tree

362 Bytes
Loading

examples/webgl_lightprobes_complex.html

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
const wallMaterial = new THREE.MeshStandardMaterial( { color: 0xcccccc, side: THREE.BackSide } );
5555
const whiteMat = new THREE.MeshStandardMaterial( { color: 0xeeeeee } );
5656

57-
// Left room (warm/red): x=-8 to 0, z=-4 to 4, y=0 to 5
57+
// Room shell: x=-8 to 8, z=-4 to 4, y=0 to 5
5858

59-
const leftRoom = new THREE.Mesh( new THREE.BoxGeometry( 8, 5, 8 ), wallMaterial );
60-
leftRoom.position.set( - 4, 2.5, 0 );
61-
leftRoom.receiveShadow = true;
62-
scene.add( leftRoom );
59+
const room = new THREE.Mesh( new THREE.BoxGeometry( 16, 5, 8 ), wallMaterial );
60+
room.position.set( 0, 2.5, 0 );
61+
room.receiveShadow = true;
62+
scene.add( room );
6363

6464
const redWall = new THREE.Mesh(
6565
new THREE.PlaneGeometry( 8, 5 ),
@@ -69,13 +69,6 @@
6969
redWall.position.set( - 7.99, 2.5, 0 );
7070
scene.add( redWall );
7171

72-
// Right room (cool/blue): x=0 to 8, z=-4 to 4, y=0 to 5
73-
74-
const rightRoom = new THREE.Mesh( new THREE.BoxGeometry( 8, 5, 8 ), wallMaterial.clone() );
75-
rightRoom.position.set( 4, 2.5, 0 );
76-
rightRoom.receiveShadow = true;
77-
scene.add( rightRoom );
78-
7972
const blueWall = new THREE.Mesh(
8073
new THREE.PlaneGeometry( 8, 5 ),
8174
new THREE.MeshStandardMaterial( { color: 0x0044ff } )
@@ -174,19 +167,19 @@
174167

175168
// Stepped blocks near red wall
176169
const step1 = new THREE.Mesh( new THREE.BoxGeometry( 1.5, 0.5, 1 ), whiteMat );
177-
step1.position.set( - 6.5, 0.25, 2 );
170+
step1.position.set( - 7, 0.25, 0 );
178171
step1.castShadow = true;
179172
step1.receiveShadow = true;
180173
scene.add( step1 );
181174

182175
const step2 = new THREE.Mesh( new THREE.BoxGeometry( 1.0, 1.0, 1 ), whiteMat );
183-
step2.position.set( - 6.5, 0.5, 2 );
176+
step2.position.set( - 7, 0.5, 0 );
184177
step2.castShadow = true;
185178
step2.receiveShadow = true;
186179
scene.add( step2 );
187180

188181
const step3 = new THREE.Mesh( new THREE.BoxGeometry( 0.5, 1.5, 1 ), whiteMat );
189-
step3.position.set( - 6.5, 0.75, 2 );
182+
step3.position.set( - 7, 0.75, 0 );
190183
step3.castShadow = true;
191184
step3.receiveShadow = true;
192185
scene.add( step3 );
@@ -222,15 +215,15 @@
222215
new THREE.TorusKnotGeometry( 0.3, 0.1, 64, 16 ),
223216
new THREE.MeshStandardMaterial( { color: 0xff44aa, metalness: 0.2, roughness: 0.5 } )
224217
);
225-
torusKnot.position.set( 4, 1.5, 0 );
218+
torusKnot.position.set( 4, 1.65, 0 );
226219
torusKnot.castShadow = true;
227220
torusKnot.receiveShadow = true;
228221
scene.add( torusKnot );
229222

230223
// Tall cone sculpture
231224
const sculpture = new THREE.Mesh(
232225
new THREE.ConeGeometry( 0.4, 2.5, 5 ),
233-
new THREE.MeshStandardMaterial( { color: 0xeeeeee } )
226+
whiteMat
234227
);
235228
sculpture.position.set( 6.5, 1.25, - 1.5 );
236229
sculpture.castShadow = true;
@@ -284,7 +277,7 @@
284277

285278
async function bakeWithResolution( resolution ) {
286279

287-
// Left volume
280+
// Remove both volumes before baking to prevent feedback
288281

289282
if ( probesLeft ) {
290283

@@ -293,25 +286,28 @@
293286

294287
}
295288

296-
probesLeft = new LightProbeGrid( 7.8, 4.7, 7.6, resolution, resolution, resolution );
297-
probesLeft.position.set( - 3.9, 2.45, 0 );
298-
probesLeft.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
299-
probesLeft.visible = params.enabled;
300-
scene.add( probesLeft );
301-
302-
// Right volume
303-
304289
if ( probesRight ) {
305290

306291
scene.remove( probesRight );
307292
probesRight.dispose();
308293

309294
}
310295

296+
// Bake both volumes
297+
298+
probesLeft = new LightProbeGrid( 7.8, 4.7, 7.6, resolution, resolution, resolution );
299+
probesLeft.position.set( - 3.9, 2.45, 0 );
300+
probesLeft.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
301+
probesLeft.visible = params.enabled;
302+
311303
probesRight = new LightProbeGrid( 7.8, 4.7, 7.6, resolution, resolution, resolution );
312304
probesRight.position.set( 3.9, 2.45, 0 );
313305
probesRight.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
314306
probesRight.visible = params.enabled;
307+
308+
// Add both after baking
309+
310+
scene.add( probesLeft );
315311
scene.add( probesRight );
316312

317313
// Update debug visualization

0 commit comments

Comments
 (0)