Skip to content

Commit 26b6b53

Browse files
mrdoobclaude
andcommitted
LightProbeVolume: Rename to LightProbeGrid and improve nomenclature.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b8d8990 commit 26b6b53

14 files changed

Lines changed: 168 additions & 168 deletions

examples/jsm/helpers/LightProbeVolumeHelper.js renamed to examples/jsm/helpers/LightProbeGridHelper.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ import {
88
} from 'three';
99

1010
/**
11-
* Visualizes an {@link LightProbeVolume} by rendering a sphere at each
11+
* Visualizes an {@link LightProbeGrid} by rendering a sphere at each
1212
* probe position, shaded with the probe's L1 spherical harmonics.
1313
*
1414
* Uses a single `InstancedMesh` draw call for all probes.
1515
*
1616
* ```js
17-
* const helper = new LightProbeVolumeHelper( probeGrid );
17+
* const helper = new LightProbeGridHelper( probes );
1818
* scene.add( helper );
1919
* ```
2020
*
2121
* @augments InstancedMesh
22-
* @three_import import { LightProbeVolumeHelper } from 'three/addons/helpers/LightProbeVolumeHelper.js';
22+
* @three_import import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
2323
*/
24-
class LightProbeVolumeHelper extends InstancedMesh {
24+
class LightProbeGridHelper extends InstancedMesh {
2525

2626
/**
2727
* Constructs a new irradiance probe grid helper.
2828
*
29-
* @param {LightProbeVolume} probeGrid - The probe grid to visualize.
29+
* @param {LightProbeGrid} probes - The probe grid to visualize.
3030
* @param {number} [sphereSize=0.12] - The radius of each probe sphere.
3131
*/
32-
constructor( probeGrid, sphereSize = 0.12 ) {
32+
constructor( probes, sphereSize = 0.12 ) {
3333

3434
const geometry = new SphereGeometry( sphereSize, 16, 16 );
3535

3636
const material = new ShaderMaterial( {
3737

3838
uniforms: {
3939

40-
probeGridSH: { value: null },
41-
probeGridResolution: { value: new Vector3() },
40+
probesSH: { value: null },
41+
probesResolution: { value: new Vector3() },
4242

4343
},
4444

@@ -63,27 +63,27 @@ class LightProbeVolumeHelper extends InstancedMesh {
6363
6464
precision highp sampler3D;
6565
66-
uniform sampler3D probeGridSH;
67-
uniform vec3 probeGridResolution;
66+
uniform sampler3D probesSH;
67+
uniform vec3 probesResolution;
6868
6969
varying vec3 vWorldNormal;
7070
varying vec3 vUVW;
7171
7272
void main() {
7373
74-
// Atlas UV mapping — must match light_probe_volume_pars_fragment.glsl.js
75-
float nz = probeGridResolution.z;
74+
// Atlas UV mapping — must match lightprobes_pars_fragment.glsl.js
75+
float nz = probesResolution.z;
7676
float paddedSlices = nz + 2.0;
7777
float atlasDepth = 7.0 * paddedSlices;
7878
float uvZBase = vUVW.z * nz + 1.0;
7979
80-
vec4 s0 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase ) / atlasDepth ) );
81-
vec4 s1 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
82-
vec4 s2 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
83-
vec4 s3 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
84-
vec4 s4 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
85-
vec4 s5 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
86-
vec4 s6 = texture( probeGridSH, vec3( vUVW.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
80+
vec4 s0 = texture( probesSH, vec3( vUVW.xy, ( uvZBase ) / atlasDepth ) );
81+
vec4 s1 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
82+
vec4 s2 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
83+
vec4 s3 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
84+
vec4 s4 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
85+
vec4 s5 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
86+
vec4 s6 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
8787
8888
// Unpack 9 vec3 SH L2 coefficients
8989
@@ -127,32 +127,32 @@ class LightProbeVolumeHelper extends InstancedMesh {
127127

128128
} );
129129

130-
const res = probeGrid.resolution;
130+
const res = probes.resolution;
131131
const count = res.x * res.y * res.z;
132132

133133
super( geometry, material, count );
134134

135135
/**
136136
* The probe grid to visualize.
137137
*
138-
* @type {LightProbeVolume}
138+
* @type {LightProbeGrid}
139139
*/
140-
this.probeGrid = probeGrid;
140+
this.probes = probes;
141141

142-
this.type = 'LightProbeVolumeHelper';
142+
this.type = 'LightProbeGridHelper';
143143

144144
this.update();
145145

146146
}
147147

148148
/**
149149
* Rebuilds instance matrices and UVW attributes from the current probe grid.
150-
* Call this after changing `probeGrid` or after re-baking.
150+
* Call this after changing `probes` or after re-baking.
151151
*/
152152
update() {
153153

154-
const probeGrid = this.probeGrid;
155-
const res = probeGrid.resolution;
154+
const probes = this.probes;
155+
const res = probes.resolution;
156156
const count = res.x * res.y * res.z;
157157

158158
// Resize instance matrix buffer if needed
@@ -177,12 +177,12 @@ class LightProbeVolumeHelper extends InstancedMesh {
177177

178178
for ( let ix = 0; ix < res.x; ix ++ ) {
179179

180-
// Remap to texel centers (must match light_probe_volume_pars_fragment.glsl.js)
180+
// Remap to texel centers (must match lightprobes_pars_fragment.glsl.js)
181181
uvwArray[ i * 3 ] = ( ix + 0.5 ) / res.x;
182182
uvwArray[ i * 3 + 1 ] = ( iy + 0.5 ) / res.y;
183183
uvwArray[ i * 3 + 2 ] = ( iz + 0.5 ) / res.z;
184184

185-
probeGrid.getProbePosition( ix, iy, iz, probePos );
185+
probes.getProbePosition( ix, iy, iz, probePos );
186186
matrix.makeTranslation( probePos.x, probePos.y, probePos.z );
187187
this.setMatrixAt( i, matrix );
188188

@@ -200,8 +200,8 @@ class LightProbeVolumeHelper extends InstancedMesh {
200200

201201
// Update texture uniforms
202202

203-
this.material.uniforms.probeGridSH.value = probeGrid.texture;
204-
this.material.uniforms.probeGridResolution.value.copy( probeGrid.resolution );
203+
this.material.uniforms.probesSH.value = probes.texture;
204+
this.material.uniforms.probesResolution.value.copy( probes.resolution );
205205

206206
}
207207

@@ -218,4 +218,4 @@ class LightProbeVolumeHelper extends InstancedMesh {
218218

219219
}
220220

221-
export { LightProbeVolumeHelper };
221+
export { LightProbeGridHelper };
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ const ATLAS_PADDING = 1;
7575
* Baking is fully GPU-resident: cubemap rendering, SH projection, and
7676
* texture packing all happen on the GPU with zero CPU readback.
7777
*
78-
* @three_import import { LightProbeVolume } from 'three/addons/lighting/LightProbeVolume.js';
78+
* @three_import import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';
7979
*/
80-
class LightProbeVolume extends Object3D {
80+
class LightProbeGrid extends Object3D {
8181

8282
/**
8383
* Constructs a new irradiance probe grid.
@@ -102,7 +102,7 @@ class LightProbeVolume extends Object3D {
102102
* @readonly
103103
* @default true
104104
*/
105-
this.isLightProbeVolume = true;
105+
this.isLightProbeGrid = true;
106106

107107
/**
108108
* The full width of the volume along X.
@@ -138,7 +138,7 @@ class LightProbeVolume extends Object3D {
138138

139139
/**
140140
* The world-space bounding box for the grid. Updated automatically
141-
* by {@link LightProbeVolume#bake}.
141+
* by {@link LightProbeGrid#bake}.
142142
*
143143
* @type {Box3}
144144
*/
@@ -332,7 +332,7 @@ class LightProbeVolume extends Object3D {
332332
renderer.setScissor( _savedScissor );
333333
renderer.setScissorTest( savedScissorTest );
334334

335-
// console.log( `LightProbeVolume: bake complete ${ ( performance.now() - t0 ).toFixed( 1 ) }ms` );
335+
// console.log( `LightProbeGrid: bake complete ${ ( performance.now() - t0 ).toFixed( 1 ) }ms` );
336336

337337
this.visible = true;
338338

@@ -648,4 +648,4 @@ function _ensureBatchTarget( totalProbes ) {
648648

649649
}
650650

651-
export { LightProbeVolume };
651+
export { LightProbeGrid };

examples/webgl_lightprobes.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828

2929
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3030
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
31-
import { LightProbeVolume } from 'three/addons/lighting/LightProbeVolume.js';
32-
import { LightProbeVolumeHelper } from 'three/addons/helpers/LightProbeVolumeHelper.js';
31+
import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';
32+
import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
3333

3434
let camera, scene, renderer, controls;
35-
let probeGrid, probeGridHelper;
35+
let probes, probesHelper;
3636

3737
init();
3838

@@ -155,31 +155,31 @@
155155

156156
async function bakeWithResolution( resolution ) {
157157

158-
if ( probeGrid ) {
158+
if ( probes ) {
159159

160-
scene.remove( probeGrid );
161-
probeGrid.dispose();
160+
scene.remove( probes );
161+
probes.dispose();
162162

163163
}
164164

165-
probeGrid = new LightProbeVolume( 5.6, 4.7, 5.6, resolution, resolution, resolution );
166-
probeGrid.position.set( 0, 2.45, 0 );
167-
probeGrid.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
168-
probeGrid.visible = params.enabled;
169-
scene.add( probeGrid );
165+
probes = new LightProbeGrid( 5.6, 4.7, 5.6, resolution, resolution, resolution );
166+
probes.position.set( 0, 2.45, 0 );
167+
probes.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
168+
probes.visible = params.enabled;
169+
scene.add( probes );
170170

171171
// Update debug visualization
172172

173-
if ( ! probeGridHelper ) {
173+
if ( ! probesHelper ) {
174174

175-
probeGridHelper = new LightProbeVolumeHelper( probeGrid );
176-
probeGridHelper.visible = params.showProbes;
177-
scene.add( probeGridHelper );
175+
probesHelper = new LightProbeGridHelper( probes );
176+
probesHelper.visible = params.showProbes;
177+
scene.add( probesHelper );
178178

179179
} else {
180180

181-
probeGridHelper.probeGrid = probeGrid;
182-
probeGridHelper.update();
181+
probesHelper.probes = probes;
182+
probesHelper.update();
183183

184184
}
185185

@@ -198,7 +198,7 @@
198198
const gui = new GUI();
199199
gui.add( params, 'enabled' ).name( 'GI' ).onChange( ( value ) => {
200200

201-
probeGrid.visible = value;
201+
probes.visible = value;
202202

203203
} );
204204
gui.add( params, 'resolution', 2, 12, 1 ).name( 'Resolution' ).onFinishChange( ( value ) => {
@@ -208,7 +208,7 @@
208208
} );
209209
gui.add( params, 'showProbes' ).name( 'Show Probes' ).onChange( ( value ) => {
210210

211-
probeGridHelper.visible = value;
211+
probesHelper.visible = value;
212212

213213
} );
214214

0 commit comments

Comments
 (0)