three-gpu-pathtracer 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1004 -981
  3. package/build/index.module.js +7413 -6902
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +7446 -6933
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +73 -73
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +346 -346
  11. package/src/core/PathTracingSceneGenerator.js +69 -69
  12. package/src/core/QuiltPathTracingRenderer.js +223 -223
  13. package/src/detectors/CompatibilityDetector.js +38 -0
  14. package/src/detectors/MaterialCompileDetector.js +50 -0
  15. package/src/detectors/PrecisionDetector.js +85 -0
  16. package/src/detectors/PrecisionMaterial.js +160 -0
  17. package/src/index.js +40 -36
  18. package/src/materials/MaterialBase.js +56 -56
  19. package/src/materials/debug/GraphMaterial.js +243 -243
  20. package/src/materials/fullscreen/AlphaDisplayMaterial.js +50 -48
  21. package/src/materials/fullscreen/BlendMaterial.js +67 -67
  22. package/src/materials/fullscreen/DenoiseMaterial.js +142 -142
  23. package/src/materials/fullscreen/GradientMapMaterial.js +82 -0
  24. package/src/materials/pathtracing/LambertPathTracingMaterial.js +296 -296
  25. package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +118 -196
  26. package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +177 -179
  27. package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +84 -81
  28. package/src/materials/pathtracing/glsl/directLightContribution.glsl.js +93 -0
  29. package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +323 -317
  30. package/src/materials/pathtracing/glsl/renderStructs.glsl.js +50 -0
  31. package/src/materials/pathtracing/glsl/traceScene.glsl.js +52 -54
  32. package/src/materials/surface/AmbientOcclusionMaterial.js +207 -207
  33. package/src/materials/surface/FogVolumeMaterial.js +23 -23
  34. package/src/objects/EquirectCamera.js +13 -13
  35. package/src/objects/PhysicalCamera.js +42 -28
  36. package/src/objects/PhysicalSpotLight.js +25 -14
  37. package/src/objects/ShapedAreaLight.js +22 -12
  38. package/src/shader/bsdf/bsdfSampling.glsl.js +499 -490
  39. package/src/shader/bsdf/fog.glsl.js +22 -23
  40. package/src/shader/bsdf/ggx.glsl.js +102 -102
  41. package/src/shader/bsdf/iridescence.glsl.js +135 -135
  42. package/src/shader/bsdf/sheen.glsl.js +98 -98
  43. package/src/shader/common/arraySamplerTexelFetch.glsl.js +25 -25
  44. package/src/shader/common/bvhAnyHit.glsl.js +76 -76
  45. package/src/shader/common/fresnel.glsl.js +98 -98
  46. package/src/shader/common/intersectShapes.glsl.js +62 -62
  47. package/src/shader/common/math.glsl.js +81 -81
  48. package/src/shader/common/utils.glsl.js +116 -116
  49. package/src/shader/rand/pcg.glsl.js +57 -57
  50. package/src/shader/rand/sobol.glsl.js +256 -256
  51. package/src/shader/sampling/equirectSampling.glsl.js +62 -62
  52. package/src/shader/sampling/lightSampling.glsl.js +223 -223
  53. package/src/shader/sampling/shapeSampling.glsl.js +86 -86
  54. package/src/shader/structs/cameraStruct.glsl.js +13 -13
  55. package/src/shader/structs/equirectStruct.glsl.js +13 -14
  56. package/src/shader/structs/fogMaterialBvh.glsl.js +62 -62
  57. package/src/shader/structs/lightsStruct.glsl.js +78 -78
  58. package/src/shader/structs/materialStruct.glsl.js +207 -207
  59. package/src/textures/GradientEquirectTexture.js +35 -35
  60. package/src/textures/ProceduralEquirectTexture.js +75 -75
  61. package/src/uniforms/AttributesTextureArray.js +35 -35
  62. package/src/uniforms/EquirectHdrInfoUniform.js +269 -277
  63. package/src/uniforms/FloatAttributeTextureArray.js +169 -169
  64. package/src/uniforms/IESProfilesTexture.js +100 -100
  65. package/src/uniforms/LightsInfoUniformStruct.js +212 -212
  66. package/src/uniforms/MaterialsTexture.js +503 -503
  67. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  68. package/src/uniforms/RenderTarget2DArray.js +97 -97
  69. package/src/uniforms/utils.js +30 -30
  70. package/src/utils/BlurredEnvMapGenerator.js +116 -116
  71. package/src/utils/GeometryPreparationUtils.js +214 -214
  72. package/src/utils/IESLoader.js +325 -325
  73. package/src/utils/SobolNumberMapGenerator.js +80 -80
  74. package/src/utils/UVUnwrapper.js +101 -101
  75. package/src/utils/macroify.js +9 -9
  76. package/src/workers/PathTracingSceneWorker.js +42 -42
@@ -1,325 +1,325 @@
1
- import {
2
- DataTexture,
3
- FileLoader,
4
- FloatType,
5
- LinearFilter,
6
- RedFormat,
7
- MathUtils,
8
- Loader,
9
- } from 'three';
10
-
11
- function IESLamp( text ) {
12
-
13
- const _self = this;
14
-
15
- const textArray = text.split( '\n' );
16
-
17
- let lineNumber = 0;
18
- let line;
19
-
20
- _self.verAngles = [ ];
21
- _self.horAngles = [ ];
22
-
23
- _self.candelaValues = [ ];
24
-
25
- _self.tiltData = { };
26
- _self.tiltData.angles = [ ];
27
- _self.tiltData.mulFactors = [ ];
28
-
29
- function textToArray( text ) {
30
-
31
- text = text.trim(); // remove leading or trailing spaces
32
- text = text.replace( /,/g, ' ' ); // replace commas with spaces
33
- text = text.replace( /\s\s+/g, ' ' ); // replace white space/tabs etc by single whitespace
34
-
35
- const array = text.split( ' ' );
36
-
37
- return array;
38
-
39
- }
40
-
41
- function readArray( count, array ) {
42
-
43
- while ( true ) {
44
-
45
- const line = textArray[ lineNumber ++ ];
46
- const lineData = textToArray( line );
47
-
48
- for ( let i = 0; i < lineData.length; ++ i ) {
49
-
50
- array.push( Number( lineData[ i ] ) );
51
-
52
- }
53
-
54
- if ( array.length === count )
55
- break;
56
-
57
- }
58
-
59
- }
60
-
61
- function readTilt() {
62
-
63
- let line = textArray[ lineNumber ++ ];
64
- let lineData = textToArray( line );
65
-
66
- _self.tiltData.lampToLumGeometry = Number( lineData[ 0 ] );
67
-
68
- line = textArray[ lineNumber ++ ];
69
- lineData = textToArray( line );
70
-
71
- _self.tiltData.numAngles = Number( lineData[ 0 ] );
72
-
73
- readArray( _self.tiltData.numAngles, _self.tiltData.angles );
74
- readArray( _self.tiltData.numAngles, _self.tiltData.mulFactors );
75
-
76
- }
77
-
78
- function readLampValues() {
79
-
80
- const values = [ ];
81
- readArray( 10, values );
82
-
83
- _self.count = Number( values[ 0 ] );
84
- _self.lumens = Number( values[ 1 ] );
85
- _self.multiplier = Number( values[ 2 ] );
86
- _self.numVerAngles = Number( values[ 3 ] );
87
- _self.numHorAngles = Number( values[ 4 ] );
88
- _self.gonioType = Number( values[ 5 ] );
89
- _self.units = Number( values[ 6 ] );
90
- _self.width = Number( values[ 7 ] );
91
- _self.length = Number( values[ 8 ] );
92
- _self.height = Number( values[ 9 ] );
93
-
94
- }
95
-
96
- function readLampFactors() {
97
-
98
- const values = [ ];
99
- readArray( 3, values );
100
-
101
- _self.ballFactor = Number( values[ 0 ] );
102
- _self.blpFactor = Number( values[ 1 ] );
103
- _self.inputWatts = Number( values[ 2 ] );
104
-
105
- }
106
-
107
- while ( true ) {
108
-
109
- line = textArray[ lineNumber ++ ];
110
-
111
- if ( line.includes( 'TILT' ) ) {
112
-
113
- break;
114
-
115
- }
116
-
117
- }
118
-
119
- if ( ! line.includes( 'NONE' ) ) {
120
-
121
- if ( line.includes( 'INCLUDE' ) ) {
122
-
123
- readTilt();
124
-
125
- } else {
126
-
127
- // TODO:: Read tilt data from a file
128
-
129
- }
130
-
131
- }
132
-
133
- readLampValues();
134
-
135
- readLampFactors();
136
-
137
- // Initialize candela value array
138
- for ( let i = 0; i < _self.numHorAngles; ++ i ) {
139
-
140
- _self.candelaValues.push( [ ] );
141
-
142
- }
143
-
144
- // Parse Angles
145
- readArray( _self.numVerAngles, _self.verAngles );
146
- readArray( _self.numHorAngles, _self.horAngles );
147
-
148
- // Parse Candela values
149
- for ( let i = 0; i < _self.numHorAngles; ++ i ) {
150
-
151
- readArray( _self.numVerAngles, _self.candelaValues[ i ] );
152
-
153
- }
154
-
155
- // Calculate actual candela values, and normalize.
156
- for ( let i = 0; i < _self.numHorAngles; ++ i ) {
157
-
158
- for ( let j = 0; j < _self.numVerAngles; ++ j ) {
159
-
160
- _self.candelaValues[ i ][ j ] *= _self.candelaValues[ i ][ j ] * _self.multiplier
161
- * _self.ballFactor * _self.blpFactor;
162
-
163
- }
164
-
165
- }
166
-
167
- let maxVal = - 1;
168
- for ( let i = 0; i < _self.numHorAngles; ++ i ) {
169
-
170
- for ( let j = 0; j < _self.numVerAngles; ++ j ) {
171
-
172
- const value = _self.candelaValues[ i ][ j ];
173
- maxVal = maxVal < value ? value : maxVal;
174
-
175
- }
176
-
177
- }
178
-
179
- const bNormalize = true;
180
- if ( bNormalize && maxVal > 0 ) {
181
-
182
- for ( let i = 0; i < _self.numHorAngles; ++ i ) {
183
-
184
- for ( let j = 0; j < _self.numVerAngles; ++ j ) {
185
-
186
- _self.candelaValues[ i ][ j ] /= maxVal;
187
-
188
- }
189
-
190
- }
191
-
192
- }
193
-
194
- }
195
-
196
- export class IESLoader extends Loader {
197
-
198
- _getIESValues( iesLamp ) {
199
-
200
- const width = 360;
201
- const height = 180;
202
- const size = width * height;
203
-
204
- const data = new Float32Array( size );
205
-
206
- function interpolateCandelaValues( phi, theta ) {
207
-
208
- let phiIndex = 0, thetaIndex = 0;
209
- let startTheta = 0, endTheta = 0, startPhi = 0, endPhi = 0;
210
-
211
- for ( let i = 0; i < iesLamp.numHorAngles - 1; ++ i ) { // numHorAngles = horAngles.length-1 because of extra padding, so this wont cause an out of bounds error
212
-
213
- if ( theta < iesLamp.horAngles[ i + 1 ] || i == iesLamp.numHorAngles - 2 ) {
214
-
215
- thetaIndex = i;
216
- startTheta = iesLamp.horAngles[ i ];
217
- endTheta = iesLamp.horAngles[ i + 1 ];
218
-
219
- break;
220
-
221
- }
222
-
223
- }
224
-
225
- for ( let i = 0; i < iesLamp.numVerAngles - 1; ++ i ) {
226
-
227
- if ( phi < iesLamp.verAngles[ i + 1 ] || i == iesLamp.numVerAngles - 2 ) {
228
-
229
- phiIndex = i;
230
- startPhi = iesLamp.verAngles[ i ];
231
- endPhi = iesLamp.verAngles[ i + 1 ];
232
-
233
- break;
234
-
235
- }
236
-
237
- }
238
-
239
- const deltaTheta = endTheta - startTheta;
240
- const deltaPhi = endPhi - startPhi;
241
-
242
- if ( deltaPhi === 0 ) // Outside range
243
- return 0;
244
-
245
- const t1 = deltaTheta === 0 ? 0 : ( theta - startTheta ) / deltaTheta;
246
- const t2 = ( phi - startPhi ) / deltaPhi;
247
-
248
- const nextThetaIndex = deltaTheta === 0 ? thetaIndex : thetaIndex + 1;
249
-
250
- const v1 = MathUtils.lerp( iesLamp.candelaValues[ thetaIndex ][ phiIndex ], iesLamp.candelaValues[ nextThetaIndex ][ phiIndex ], t1 );
251
- const v2 = MathUtils.lerp( iesLamp.candelaValues[ thetaIndex ][ phiIndex + 1 ], iesLamp.candelaValues[ nextThetaIndex ][ phiIndex + 1 ], t1 );
252
- const v = MathUtils.lerp( v1, v2, t2 );
253
-
254
- return v;
255
-
256
- }
257
-
258
- const startTheta = iesLamp.horAngles[ 0 ], endTheta = iesLamp.horAngles[ iesLamp.numHorAngles - 1 ];
259
- for ( let i = 0; i < size; ++ i ) {
260
-
261
- let theta = i % width;
262
- const phi = Math.floor( i / width );
263
-
264
- if ( endTheta - startTheta !== 0 && ( theta < startTheta || theta >= endTheta ) ) { // Handle symmetry for hor angles
265
-
266
- theta %= endTheta * 2;
267
- if ( theta > endTheta )
268
- theta = endTheta * 2 - theta;
269
-
270
- }
271
-
272
- data[ i ] = interpolateCandelaValues( phi, theta );
273
-
274
- }
275
-
276
- return data;
277
-
278
- }
279
-
280
- load( url, onLoad, onProgress, onError ) {
281
-
282
- const loader = new FileLoader( this.manager );
283
- loader.setResponseType( 'text' );
284
- loader.setCrossOrigin( this.crossOrigin );
285
- loader.setWithCredentials( this.withCredentials );
286
- loader.setPath( this.path );
287
- loader.setRequestHeader( this.requestHeader );
288
-
289
- const texture = new DataTexture( null, 360, 180, RedFormat, FloatType );
290
- texture.minFilter = LinearFilter;
291
- texture.magFilter = LinearFilter;
292
-
293
- loader.load( url, text => {
294
-
295
- const iesLamp = new IESLamp( text );
296
-
297
- texture.image.data = this._getIESValues( iesLamp );
298
- texture.needsUpdate = true;
299
-
300
- if ( onLoad !== undefined ) {
301
-
302
- onLoad( texture );
303
-
304
- }
305
-
306
- }, onProgress, onError );
307
-
308
- return texture;
309
-
310
- }
311
-
312
- parse( text ) {
313
-
314
- const iesLamp = new IESLamp( text );
315
- const texture = new DataTexture( null, 360, 180, RedFormat, FloatType );
316
- texture.minFilter = LinearFilter;
317
- texture.magFilter = LinearFilter;
318
- texture.image.data = this._getIESValues( iesLamp );
319
- texture.needsUpdate = true;
320
-
321
- return texture;
322
-
323
- }
324
-
325
- }
1
+ import {
2
+ DataTexture,
3
+ FileLoader,
4
+ FloatType,
5
+ LinearFilter,
6
+ RedFormat,
7
+ MathUtils,
8
+ Loader,
9
+ } from 'three';
10
+
11
+ function IESLamp( text ) {
12
+
13
+ const _self = this;
14
+
15
+ const textArray = text.split( '\n' );
16
+
17
+ let lineNumber = 0;
18
+ let line;
19
+
20
+ _self.verAngles = [ ];
21
+ _self.horAngles = [ ];
22
+
23
+ _self.candelaValues = [ ];
24
+
25
+ _self.tiltData = { };
26
+ _self.tiltData.angles = [ ];
27
+ _self.tiltData.mulFactors = [ ];
28
+
29
+ function textToArray( text ) {
30
+
31
+ text = text.trim(); // remove leading or trailing spaces
32
+ text = text.replace( /,/g, ' ' ); // replace commas with spaces
33
+ text = text.replace( /\s\s+/g, ' ' ); // replace white space/tabs etc by single whitespace
34
+
35
+ const array = text.split( ' ' );
36
+
37
+ return array;
38
+
39
+ }
40
+
41
+ function readArray( count, array ) {
42
+
43
+ while ( true ) {
44
+
45
+ const line = textArray[ lineNumber ++ ];
46
+ const lineData = textToArray( line );
47
+
48
+ for ( let i = 0; i < lineData.length; ++ i ) {
49
+
50
+ array.push( Number( lineData[ i ] ) );
51
+
52
+ }
53
+
54
+ if ( array.length === count )
55
+ break;
56
+
57
+ }
58
+
59
+ }
60
+
61
+ function readTilt() {
62
+
63
+ let line = textArray[ lineNumber ++ ];
64
+ let lineData = textToArray( line );
65
+
66
+ _self.tiltData.lampToLumGeometry = Number( lineData[ 0 ] );
67
+
68
+ line = textArray[ lineNumber ++ ];
69
+ lineData = textToArray( line );
70
+
71
+ _self.tiltData.numAngles = Number( lineData[ 0 ] );
72
+
73
+ readArray( _self.tiltData.numAngles, _self.tiltData.angles );
74
+ readArray( _self.tiltData.numAngles, _self.tiltData.mulFactors );
75
+
76
+ }
77
+
78
+ function readLampValues() {
79
+
80
+ const values = [ ];
81
+ readArray( 10, values );
82
+
83
+ _self.count = Number( values[ 0 ] );
84
+ _self.lumens = Number( values[ 1 ] );
85
+ _self.multiplier = Number( values[ 2 ] );
86
+ _self.numVerAngles = Number( values[ 3 ] );
87
+ _self.numHorAngles = Number( values[ 4 ] );
88
+ _self.gonioType = Number( values[ 5 ] );
89
+ _self.units = Number( values[ 6 ] );
90
+ _self.width = Number( values[ 7 ] );
91
+ _self.length = Number( values[ 8 ] );
92
+ _self.height = Number( values[ 9 ] );
93
+
94
+ }
95
+
96
+ function readLampFactors() {
97
+
98
+ const values = [ ];
99
+ readArray( 3, values );
100
+
101
+ _self.ballFactor = Number( values[ 0 ] );
102
+ _self.blpFactor = Number( values[ 1 ] );
103
+ _self.inputWatts = Number( values[ 2 ] );
104
+
105
+ }
106
+
107
+ while ( true ) {
108
+
109
+ line = textArray[ lineNumber ++ ];
110
+
111
+ if ( line.includes( 'TILT' ) ) {
112
+
113
+ break;
114
+
115
+ }
116
+
117
+ }
118
+
119
+ if ( ! line.includes( 'NONE' ) ) {
120
+
121
+ if ( line.includes( 'INCLUDE' ) ) {
122
+
123
+ readTilt();
124
+
125
+ } else {
126
+
127
+ // TODO:: Read tilt data from a file
128
+
129
+ }
130
+
131
+ }
132
+
133
+ readLampValues();
134
+
135
+ readLampFactors();
136
+
137
+ // Initialize candela value array
138
+ for ( let i = 0; i < _self.numHorAngles; ++ i ) {
139
+
140
+ _self.candelaValues.push( [ ] );
141
+
142
+ }
143
+
144
+ // Parse Angles
145
+ readArray( _self.numVerAngles, _self.verAngles );
146
+ readArray( _self.numHorAngles, _self.horAngles );
147
+
148
+ // Parse Candela values
149
+ for ( let i = 0; i < _self.numHorAngles; ++ i ) {
150
+
151
+ readArray( _self.numVerAngles, _self.candelaValues[ i ] );
152
+
153
+ }
154
+
155
+ // Calculate actual candela values, and normalize.
156
+ for ( let i = 0; i < _self.numHorAngles; ++ i ) {
157
+
158
+ for ( let j = 0; j < _self.numVerAngles; ++ j ) {
159
+
160
+ _self.candelaValues[ i ][ j ] *= _self.candelaValues[ i ][ j ] * _self.multiplier
161
+ * _self.ballFactor * _self.blpFactor;
162
+
163
+ }
164
+
165
+ }
166
+
167
+ let maxVal = - 1;
168
+ for ( let i = 0; i < _self.numHorAngles; ++ i ) {
169
+
170
+ for ( let j = 0; j < _self.numVerAngles; ++ j ) {
171
+
172
+ const value = _self.candelaValues[ i ][ j ];
173
+ maxVal = maxVal < value ? value : maxVal;
174
+
175
+ }
176
+
177
+ }
178
+
179
+ const bNormalize = true;
180
+ if ( bNormalize && maxVal > 0 ) {
181
+
182
+ for ( let i = 0; i < _self.numHorAngles; ++ i ) {
183
+
184
+ for ( let j = 0; j < _self.numVerAngles; ++ j ) {
185
+
186
+ _self.candelaValues[ i ][ j ] /= maxVal;
187
+
188
+ }
189
+
190
+ }
191
+
192
+ }
193
+
194
+ }
195
+
196
+ export class IESLoader extends Loader {
197
+
198
+ _getIESValues( iesLamp ) {
199
+
200
+ const width = 360;
201
+ const height = 180;
202
+ const size = width * height;
203
+
204
+ const data = new Float32Array( size );
205
+
206
+ function interpolateCandelaValues( phi, theta ) {
207
+
208
+ let phiIndex = 0, thetaIndex = 0;
209
+ let startTheta = 0, endTheta = 0, startPhi = 0, endPhi = 0;
210
+
211
+ for ( let i = 0; i < iesLamp.numHorAngles - 1; ++ i ) { // numHorAngles = horAngles.length-1 because of extra padding, so this wont cause an out of bounds error
212
+
213
+ if ( theta < iesLamp.horAngles[ i + 1 ] || i == iesLamp.numHorAngles - 2 ) {
214
+
215
+ thetaIndex = i;
216
+ startTheta = iesLamp.horAngles[ i ];
217
+ endTheta = iesLamp.horAngles[ i + 1 ];
218
+
219
+ break;
220
+
221
+ }
222
+
223
+ }
224
+
225
+ for ( let i = 0; i < iesLamp.numVerAngles - 1; ++ i ) {
226
+
227
+ if ( phi < iesLamp.verAngles[ i + 1 ] || i == iesLamp.numVerAngles - 2 ) {
228
+
229
+ phiIndex = i;
230
+ startPhi = iesLamp.verAngles[ i ];
231
+ endPhi = iesLamp.verAngles[ i + 1 ];
232
+
233
+ break;
234
+
235
+ }
236
+
237
+ }
238
+
239
+ const deltaTheta = endTheta - startTheta;
240
+ const deltaPhi = endPhi - startPhi;
241
+
242
+ if ( deltaPhi === 0 ) // Outside range
243
+ return 0;
244
+
245
+ const t1 = deltaTheta === 0 ? 0 : ( theta - startTheta ) / deltaTheta;
246
+ const t2 = ( phi - startPhi ) / deltaPhi;
247
+
248
+ const nextThetaIndex = deltaTheta === 0 ? thetaIndex : thetaIndex + 1;
249
+
250
+ const v1 = MathUtils.lerp( iesLamp.candelaValues[ thetaIndex ][ phiIndex ], iesLamp.candelaValues[ nextThetaIndex ][ phiIndex ], t1 );
251
+ const v2 = MathUtils.lerp( iesLamp.candelaValues[ thetaIndex ][ phiIndex + 1 ], iesLamp.candelaValues[ nextThetaIndex ][ phiIndex + 1 ], t1 );
252
+ const v = MathUtils.lerp( v1, v2, t2 );
253
+
254
+ return v;
255
+
256
+ }
257
+
258
+ const startTheta = iesLamp.horAngles[ 0 ], endTheta = iesLamp.horAngles[ iesLamp.numHorAngles - 1 ];
259
+ for ( let i = 0; i < size; ++ i ) {
260
+
261
+ let theta = i % width;
262
+ const phi = Math.floor( i / width );
263
+
264
+ if ( endTheta - startTheta !== 0 && ( theta < startTheta || theta >= endTheta ) ) { // Handle symmetry for hor angles
265
+
266
+ theta %= endTheta * 2;
267
+ if ( theta > endTheta )
268
+ theta = endTheta * 2 - theta;
269
+
270
+ }
271
+
272
+ data[ i ] = interpolateCandelaValues( phi, theta );
273
+
274
+ }
275
+
276
+ return data;
277
+
278
+ }
279
+
280
+ load( url, onLoad, onProgress, onError ) {
281
+
282
+ const loader = new FileLoader( this.manager );
283
+ loader.setResponseType( 'text' );
284
+ loader.setCrossOrigin( this.crossOrigin );
285
+ loader.setWithCredentials( this.withCredentials );
286
+ loader.setPath( this.path );
287
+ loader.setRequestHeader( this.requestHeader );
288
+
289
+ const texture = new DataTexture( null, 360, 180, RedFormat, FloatType );
290
+ texture.minFilter = LinearFilter;
291
+ texture.magFilter = LinearFilter;
292
+
293
+ loader.load( url, text => {
294
+
295
+ const iesLamp = new IESLamp( text );
296
+
297
+ texture.image.data = this._getIESValues( iesLamp );
298
+ texture.needsUpdate = true;
299
+
300
+ if ( onLoad !== undefined ) {
301
+
302
+ onLoad( texture );
303
+
304
+ }
305
+
306
+ }, onProgress, onError );
307
+
308
+ return texture;
309
+
310
+ }
311
+
312
+ parse( text ) {
313
+
314
+ const iesLamp = new IESLamp( text );
315
+ const texture = new DataTexture( null, 360, 180, RedFormat, FloatType );
316
+ texture.minFilter = LinearFilter;
317
+ texture.magFilter = LinearFilter;
318
+ texture.image.data = this._getIESValues( iesLamp );
319
+ texture.needsUpdate = true;
320
+
321
+ return texture;
322
+
323
+ }
324
+
325
+ }