super-three 0.154.1 → 0.156.0

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 (172) hide show
  1. package/build/three.cjs +360 -160
  2. package/build/three.js +360 -160
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +355 -161
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/controls/OrbitControls.js +155 -25
  7. package/examples/jsm/csm/CSMShader.js +35 -1
  8. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  9. package/examples/jsm/exporters/USDZExporter.js +1 -0
  10. package/examples/jsm/interactive/SelectionHelper.js +7 -0
  11. package/examples/jsm/libs/tween.module.js +790 -735
  12. package/examples/jsm/libs/utif.module.js +1644 -1558
  13. package/examples/jsm/loaders/DDSLoader.js +46 -3
  14. package/examples/jsm/loaders/EXRLoader.js +4 -4
  15. package/examples/jsm/loaders/FBXLoader.js +3 -1
  16. package/examples/jsm/loaders/GLTFLoader.js +25 -10
  17. package/examples/jsm/loaders/KTX2Loader.js +128 -79
  18. package/examples/jsm/loaders/LDrawLoader.js +1 -1
  19. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  20. package/examples/jsm/loaders/MMDLoader.js +10 -7
  21. package/examples/jsm/loaders/NRRDLoader.js +3 -3
  22. package/examples/jsm/loaders/PLYLoader.js +1 -1
  23. package/examples/jsm/loaders/RGBELoader.js +48 -66
  24. package/examples/jsm/loaders/STLLoader.js +7 -0
  25. package/examples/jsm/loaders/TGALoader.js +10 -10
  26. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  27. package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
  28. package/examples/jsm/misc/Volume.js +4 -6
  29. package/examples/jsm/nodes/Nodes.js +8 -6
  30. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +29 -3
  31. package/examples/jsm/nodes/accessors/CubeTextureNode.js +20 -3
  32. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +15 -4
  33. package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
  34. package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
  35. package/examples/jsm/nodes/accessors/MaterialNode.js +73 -61
  36. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
  37. package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
  39. package/examples/jsm/nodes/accessors/TextureNode.js +54 -9
  40. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  41. package/examples/jsm/nodes/core/AttributeNode.js +2 -2
  42. package/examples/jsm/nodes/core/LightingModel.js +7 -9
  43. package/examples/jsm/nodes/core/Node.js +28 -3
  44. package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
  45. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  46. package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
  47. package/examples/jsm/nodes/core/PropertyNode.js +6 -0
  48. package/examples/jsm/nodes/core/StackNode.js +4 -4
  49. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  50. package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
  51. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  52. package/examples/jsm/nodes/display/ViewportNode.js +19 -5
  53. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
  54. package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
  55. package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
  56. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
  57. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  58. package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
  59. package/examples/jsm/nodes/lighting/AONode.js +1 -1
  60. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
  61. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
  62. package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
  63. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
  64. package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
  65. package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
  66. package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
  67. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  68. package/examples/jsm/nodes/materials/Materials.js +2 -0
  69. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
  70. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
  71. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  72. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
  73. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
  74. package/examples/jsm/nodes/materials/NodeMaterial.js +61 -26
  75. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  76. package/examples/jsm/nodes/math/HashNode.js +35 -0
  77. package/examples/jsm/nodes/shadernode/ShaderNode.js +6 -2
  78. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  79. package/examples/jsm/objects/Reflector.js +1 -9
  80. package/examples/jsm/objects/Refractor.js +0 -8
  81. package/examples/jsm/offscreen/scene.js +0 -1
  82. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  83. package/examples/jsm/postprocessing/MaskPass.js +4 -1
  84. package/examples/jsm/postprocessing/OutputPass.js +33 -14
  85. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  86. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  87. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  88. package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
  89. package/examples/jsm/renderers/common/Backend.js +11 -8
  90. package/examples/jsm/renderers/common/Background.js +22 -20
  91. package/examples/jsm/renderers/common/Binding.js +14 -0
  92. package/examples/jsm/renderers/common/Bindings.js +7 -10
  93. package/examples/jsm/renderers/common/Geometries.js +1 -1
  94. package/examples/jsm/renderers/common/Pipelines.js +96 -47
  95. package/examples/jsm/renderers/common/RenderContext.js +1 -0
  96. package/examples/jsm/renderers/common/RenderContexts.js +41 -5
  97. package/examples/jsm/renderers/common/RenderList.js +12 -4
  98. package/examples/jsm/renderers/common/RenderObject.js +26 -6
  99. package/examples/jsm/renderers/common/RenderObjects.js +10 -7
  100. package/examples/jsm/renderers/common/Renderer.js +82 -42
  101. package/examples/jsm/renderers/common/SampledTexture.js +2 -1
  102. package/examples/jsm/renderers/common/Sampler.js +1 -1
  103. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  104. package/examples/jsm/renderers/common/Textures.js +172 -20
  105. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
  106. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
  107. package/examples/jsm/renderers/common/nodes/Nodes.js +58 -13
  108. package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
  109. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
  110. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  111. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  112. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  113. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
  114. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  115. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  116. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
  117. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +320 -84
  118. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  119. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +120 -66
  120. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  121. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
  122. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +96 -5
  123. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
  124. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +117 -139
  125. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +60 -142
  126. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +7 -6
  127. package/examples/jsm/shaders/FilmShader.js +11 -54
  128. package/examples/jsm/shaders/OutputShader.js +19 -2
  129. package/examples/jsm/shaders/SAOShader.js +0 -13
  130. package/examples/jsm/shaders/SSAOShader.js +33 -26
  131. package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
  132. package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
  133. package/package.json +2 -2
  134. package/src/Three.js +3 -0
  135. package/src/animation/PropertyBinding.js +1 -1
  136. package/src/audio/Audio.js +6 -0
  137. package/src/cameras/CubeCamera.js +1 -4
  138. package/src/constants.js +4 -1
  139. package/src/core/BufferAttribute.js +20 -0
  140. package/src/core/Object3D.js +2 -15
  141. package/src/core/RenderTarget.js +122 -0
  142. package/src/core/UniformsGroup.js +2 -2
  143. package/src/geometries/CapsuleGeometry.js +1 -1
  144. package/src/loaders/DataTextureLoader.js +19 -2
  145. package/src/materials/Material.js +2 -2
  146. package/src/math/Vector2.js +2 -2
  147. package/src/math/Vector3.js +3 -3
  148. package/src/math/Vector4.js +4 -4
  149. package/src/objects/Line.js +1 -1
  150. package/src/objects/Mesh.js +1 -1
  151. package/src/objects/Points.js +1 -1
  152. package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
  153. package/src/renderers/WebGLRenderTarget.js +3 -110
  154. package/src/renderers/WebGLRenderer.js +83 -57
  155. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
  156. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  157. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  158. package/src/renderers/webgl/WebGLBackground.js +5 -14
  159. package/src/renderers/webgl/WebGLGeometries.js +5 -1
  160. package/src/renderers/webgl/WebGLMaterials.js +1 -1
  161. package/src/renderers/webgl/WebGLProgram.js +2 -0
  162. package/src/renderers/webgl/WebGLPrograms.js +19 -3
  163. package/src/renderers/webgl/WebGLTextures.js +101 -16
  164. package/src/renderers/webgl/WebGLUtils.js +27 -20
  165. package/src/textures/CompressedCubeTexture.js +19 -0
  166. package/src/textures/Texture.js +2 -2
  167. package/src/utils.js +9 -1
  168. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
  169. package/examples/jsm/renderers/common/RenderTarget.js +0 -15
  170. package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
  171. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
  172. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
@@ -27,6 +27,7 @@ import {
27
27
  Skeleton,
28
28
  SkinnedMesh,
29
29
  SrcAlphaFactor,
30
+ SRGBColorSpace,
30
31
  TextureLoader,
31
32
  Uint16BufferAttribute,
32
33
  Vector3,
@@ -1133,17 +1134,18 @@ class MaterialBuilder {
1133
1134
  * MMDToonMaterial doesn't have ambient. Set it to emissive instead.
1134
1135
  * It'll be too bright if material has map texture so using coef 0.2.
1135
1136
  */
1136
- params.diffuse = new Color().fromArray( material.diffuse );
1137
+ params.diffuse = new Color().setRGB(
1138
+ material.diffuse[ 0 ],
1139
+ material.diffuse[ 1 ],
1140
+ material.diffuse[ 2 ],
1141
+ SRGBColorSpace
1142
+ );
1137
1143
  params.opacity = material.diffuse[ 3 ];
1138
- params.specular = new Color().fromArray( material.specular );
1144
+ params.specular = new Color().setRGB( ...material.specular, SRGBColorSpace );
1139
1145
  params.shininess = material.shininess;
1140
- params.emissive = new Color().fromArray( material.ambient );
1146
+ params.emissive = new Color().setRGB( ...material.ambient, SRGBColorSpace );
1141
1147
  params.transparent = params.opacity !== 1.0;
1142
1148
 
1143
- params.diffuse.convertSRGBToLinear();
1144
- params.specular.convertSRGBToLinear();
1145
- params.emissive.convertSRGBToLinear();
1146
-
1147
1149
  //
1148
1150
 
1149
1151
  params.fog = true;
@@ -1452,6 +1454,7 @@ class MaterialBuilder {
1452
1454
  t.flipY = false;
1453
1455
  t.wrapS = RepeatWrapping;
1454
1456
  t.wrapT = RepeatWrapping;
1457
+ t.colorSpace = SRGBColorSpace;
1455
1458
 
1456
1459
  for ( let i = 0; i < texture.readyCallbacks.length; i ++ ) {
1457
1460
 
@@ -473,10 +473,10 @@ class NRRDLoader extends Loader {
473
473
 
474
474
  volume.inverseMatrix = new Matrix4();
475
475
  volume.inverseMatrix.copy( volume.matrix ).invert();
476
-
476
+
477
477
  volume.RASDimensions = [
478
- Math.floor( volume.xLength * spacingX ),
479
- Math.floor( volume.yLength * spacingY ),
478
+ Math.floor( volume.xLength * spacingX ),
479
+ Math.floor( volume.yLength * spacingY ),
480
480
  Math.floor( volume.zLength * spacingZ )
481
481
  ];
482
482
 
@@ -706,7 +706,7 @@ class PLYLoader extends Loader {
706
706
  // ascii section using \r\n as line endings
707
707
  if ( hasCRNL === true ) i ++;
708
708
 
709
- return { headerText: lines.join( '\r' ) + '\r', headerLength: i };
709
+ return { headerText: lines.join( '\r' ) + '\r', headerLength: i };
710
710
 
711
711
  }
712
712
 
@@ -25,10 +25,6 @@ class RGBELoader extends DataTextureLoader {
25
25
  parse( buffer ) {
26
26
 
27
27
  const
28
- /* return codes for rgbe routines */
29
- //RGBE_RETURN_SUCCESS = 0,
30
- RGBE_RETURN_FAILURE = - 1,
31
-
32
28
  /* default error routine. change this to change error handling */
33
29
  rgbe_read_error = 1,
34
30
  rgbe_write_error = 2,
@@ -38,19 +34,14 @@ class RGBELoader extends DataTextureLoader {
38
34
 
39
35
  switch ( rgbe_error_code ) {
40
36
 
41
- case rgbe_read_error: console.error( 'THREE.RGBELoader Read Error: ' + ( msg || '' ) );
42
- break;
43
- case rgbe_write_error: console.error( 'THREE.RGBELoader Write Error: ' + ( msg || '' ) );
44
- break;
45
- case rgbe_format_error: console.error( 'THREE.RGBELoader Bad File Format: ' + ( msg || '' ) );
46
- break;
37
+ case rgbe_read_error: throw new Error( 'THREE.RGBELoader: Read Error: ' + ( msg || '' ) );
38
+ case rgbe_write_error: throw new Error( 'THREE.RGBELoader: Write Error: ' + ( msg || '' ) );
39
+ case rgbe_format_error: throw new Error( 'THREE.RGBELoader: Bad File Format: ' + ( msg || '' ) );
47
40
  default:
48
- case rgbe_memory_error: console.error( 'THREE.RGBELoader: Error: ' + ( msg || '' ) );
41
+ case rgbe_memory_error: throw new Error( 'THREE.RGBELoader: Memory Error: ' + ( msg || '' ) );
49
42
 
50
43
  }
51
44
 
52
- return RGBE_RETURN_FAILURE;
53
-
54
45
  },
55
46
 
56
47
  /* offsets to red, green, and blue components in a data (float) pixel */
@@ -138,14 +129,14 @@ class RGBELoader extends DataTextureLoader {
138
129
 
139
130
  if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
140
131
 
141
- return rgbe_error( rgbe_read_error, 'no header found' );
132
+ rgbe_error( rgbe_read_error, 'no header found' );
142
133
 
143
134
  }
144
135
 
145
136
  /* if you want to require the magic token then uncomment the next line */
146
137
  if ( ! ( match = line.match( magic_token_re ) ) ) {
147
138
 
148
- return rgbe_error( rgbe_format_error, 'bad initial token' );
139
+ rgbe_error( rgbe_format_error, 'bad initial token' );
149
140
 
150
141
  }
151
142
 
@@ -199,13 +190,13 @@ class RGBELoader extends DataTextureLoader {
199
190
 
200
191
  if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) {
201
192
 
202
- return rgbe_error( rgbe_format_error, 'missing format specifier' );
193
+ rgbe_error( rgbe_format_error, 'missing format specifier' );
203
194
 
204
195
  }
205
196
 
206
197
  if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) {
207
198
 
208
- return rgbe_error( rgbe_format_error, 'missing image size specifier' );
199
+ rgbe_error( rgbe_format_error, 'missing image size specifier' );
209
200
 
210
201
  }
211
202
 
@@ -231,7 +222,7 @@ class RGBELoader extends DataTextureLoader {
231
222
 
232
223
  if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) {
233
224
 
234
- return rgbe_error( rgbe_format_error, 'wrong scanline width' );
225
+ rgbe_error( rgbe_format_error, 'wrong scanline width' );
235
226
 
236
227
  }
237
228
 
@@ -239,7 +230,7 @@ class RGBELoader extends DataTextureLoader {
239
230
 
240
231
  if ( ! data_rgba.length ) {
241
232
 
242
- return rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' );
233
+ rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' );
243
234
 
244
235
  }
245
236
 
@@ -255,7 +246,7 @@ class RGBELoader extends DataTextureLoader {
255
246
 
256
247
  if ( pos + 4 > buffer.byteLength ) {
257
248
 
258
- return rgbe_error( rgbe_read_error );
249
+ rgbe_error( rgbe_read_error );
259
250
 
260
251
  }
261
252
 
@@ -266,7 +257,7 @@ class RGBELoader extends DataTextureLoader {
266
257
 
267
258
  if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) {
268
259
 
269
- return rgbe_error( rgbe_format_error, 'bad rgbe scanline format' );
260
+ rgbe_error( rgbe_format_error, 'bad rgbe scanline format' );
270
261
 
271
262
  }
272
263
 
@@ -282,7 +273,7 @@ class RGBELoader extends DataTextureLoader {
282
273
 
283
274
  if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
284
275
 
285
- return rgbe_error( rgbe_format_error, 'bad scanline data' );
276
+ rgbe_error( rgbe_format_error, 'bad scanline data' );
286
277
 
287
278
  }
288
279
 
@@ -362,70 +353,61 @@ class RGBELoader extends DataTextureLoader {
362
353
  byteArray.pos = 0;
363
354
  const rgbe_header_info = RGBE_ReadHeader( byteArray );
364
355
 
365
- if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) {
366
-
367
- const w = rgbe_header_info.width,
368
- h = rgbe_header_info.height,
369
- image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
370
-
371
- if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
372
-
373
- let data, type;
374
- let numElements;
375
-
376
- switch ( this.type ) {
377
-
378
- case FloatType:
356
+ const w = rgbe_header_info.width,
357
+ h = rgbe_header_info.height,
358
+ image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
379
359
 
380
- numElements = image_rgba_data.length / 4;
381
- const floatArray = new Float32Array( numElements * 4 );
382
360
 
383
- for ( let j = 0; j < numElements; j ++ ) {
361
+ let data, type;
362
+ let numElements;
384
363
 
385
- RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );
364
+ switch ( this.type ) {
386
365
 
387
- }
366
+ case FloatType:
388
367
 
389
- data = floatArray;
390
- type = FloatType;
391
- break;
368
+ numElements = image_rgba_data.length / 4;
369
+ const floatArray = new Float32Array( numElements * 4 );
392
370
 
393
- case HalfFloatType:
371
+ for ( let j = 0; j < numElements; j ++ ) {
394
372
 
395
- numElements = image_rgba_data.length / 4;
396
- const halfArray = new Uint16Array( numElements * 4 );
373
+ RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );
397
374
 
398
- for ( let j = 0; j < numElements; j ++ ) {
375
+ }
399
376
 
400
- RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );
377
+ data = floatArray;
378
+ type = FloatType;
379
+ break;
401
380
 
402
- }
381
+ case HalfFloatType:
403
382
 
404
- data = halfArray;
405
- type = HalfFloatType;
406
- break;
383
+ numElements = image_rgba_data.length / 4;
384
+ const halfArray = new Uint16Array( numElements * 4 );
407
385
 
408
- default:
386
+ for ( let j = 0; j < numElements; j ++ ) {
409
387
 
410
- console.error( 'THREE.RGBELoader: unsupported type: ', this.type );
411
- break;
388
+ RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );
412
389
 
413
390
  }
414
391
 
415
- return {
416
- width: w, height: h,
417
- data: data,
418
- header: rgbe_header_info.string,
419
- gamma: rgbe_header_info.gamma,
420
- exposure: rgbe_header_info.exposure,
421
- type: type
422
- };
392
+ data = halfArray;
393
+ type = HalfFloatType;
394
+ break;
423
395
 
424
- }
396
+ default:
397
+
398
+ throw new Error( 'THREE.RGBELoader: unsupported type: ', this.type );
399
+ break;
425
400
 
426
401
  }
427
402
 
428
- return null;
403
+ return {
404
+ width: w, height: h,
405
+ data: data,
406
+ header: rgbe_header_info.string,
407
+ gamma: rgbe_header_info.gamma,
408
+ exposure: rgbe_header_info.exposure,
409
+ type: type
410
+ };
429
411
 
430
412
  }
431
413
 
@@ -274,6 +274,7 @@ class STLLoader extends Loader {
274
274
  const geometry = new BufferGeometry();
275
275
  const patternSolid = /solid([\s\S]*?)endsolid/g;
276
276
  const patternFace = /facet([\s\S]*?)endfacet/g;
277
+ const patternName = /solid\s(.+)/;
277
278
  let faceCounter = 0;
278
279
 
279
280
  const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
@@ -282,6 +283,7 @@ class STLLoader extends Loader {
282
283
 
283
284
  const vertices = [];
284
285
  const normals = [];
286
+ const groupNames = [];
285
287
 
286
288
  const normal = new Vector3();
287
289
 
@@ -297,6 +299,9 @@ class STLLoader extends Loader {
297
299
 
298
300
  const solid = result[ 0 ];
299
301
 
302
+ const name = ( result = patternName.exec( solid ) ) !== null ? result[ 1 ] : '';
303
+ groupNames.push( name );
304
+
300
305
  while ( ( result = patternFace.exec( solid ) ) !== null ) {
301
306
 
302
307
  let vertexCountPerFace = 0;
@@ -345,6 +350,8 @@ class STLLoader extends Loader {
345
350
  const start = startVertex;
346
351
  const count = endVertex - startVertex;
347
352
 
353
+ geometry.userData.groupNames = groupNames;
354
+
348
355
  geometry.addGroup( start, count, groupCount );
349
356
  groupCount ++;
350
357
 
@@ -25,7 +25,7 @@ class TGALoader extends DataTextureLoader {
25
25
  case TGA_TYPE_RLE_INDEXED:
26
26
  if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1 ) {
27
27
 
28
- console.error( 'THREE.TGALoader: Invalid type colormap data for indexed type.' );
28
+ throw new Error( 'THREE.TGALoader: Invalid type colormap data for indexed type.' );
29
29
 
30
30
  }
31
31
 
@@ -39,7 +39,7 @@ class TGALoader extends DataTextureLoader {
39
39
  case TGA_TYPE_RLE_GREY:
40
40
  if ( header.colormap_type ) {
41
41
 
42
- console.error( 'THREE.TGALoader: Invalid type colormap data for colormap type.' );
42
+ throw new Error( 'THREE.TGALoader: Invalid type colormap data for colormap type.' );
43
43
 
44
44
  }
45
45
 
@@ -48,12 +48,12 @@ class TGALoader extends DataTextureLoader {
48
48
  // What the need of a file without data ?
49
49
 
50
50
  case TGA_TYPE_NO_DATA:
51
- console.error( 'THREE.TGALoader: No data.' );
51
+ throw new Error( 'THREE.TGALoader: No data.' );
52
52
 
53
53
  // Invalid type ?
54
54
 
55
55
  default:
56
- console.error( 'THREE.TGALoader: Invalid type "%s".', header.image_type );
56
+ throw new Error( 'THREE.TGALoader: Invalid type ' + header.image_type );
57
57
 
58
58
  }
59
59
 
@@ -61,7 +61,7 @@ class TGALoader extends DataTextureLoader {
61
61
 
62
62
  if ( header.width <= 0 || header.height <= 0 ) {
63
63
 
64
- console.error( 'THREE.TGALoader: Invalid image size.' );
64
+ throw new Error( 'THREE.TGALoader: Invalid image size.' );
65
65
 
66
66
  }
67
67
 
@@ -70,7 +70,7 @@ class TGALoader extends DataTextureLoader {
70
70
  if ( header.pixel_size !== 8 && header.pixel_size !== 16 &&
71
71
  header.pixel_size !== 24 && header.pixel_size !== 32 ) {
72
72
 
73
- console.error( 'THREE.TGALoader: Invalid pixel size "%s".', header.pixel_size );
73
+ throw new Error( 'THREE.TGALoader: Invalid pixel size ' + header.pixel_size );
74
74
 
75
75
  }
76
76
 
@@ -365,7 +365,7 @@ class TGALoader extends DataTextureLoader {
365
365
  break;
366
366
 
367
367
  default:
368
- console.error( 'THREE.TGALoader: Format not supported.' );
368
+ throw new Error( 'THREE.TGALoader: Format not supported.' );
369
369
  break;
370
370
 
371
371
  }
@@ -391,7 +391,7 @@ class TGALoader extends DataTextureLoader {
391
391
  break;
392
392
 
393
393
  default:
394
- console.error( 'THREE.TGALoader: Format not supported.' );
394
+ throw new Error( 'THREE.TGALoader: Format not supported.' );
395
395
  break;
396
396
 
397
397
  }
@@ -422,7 +422,7 @@ class TGALoader extends DataTextureLoader {
422
422
  TGA_ORIGIN_UL = 0x02,
423
423
  TGA_ORIGIN_UR = 0x03;
424
424
 
425
- if ( buffer.length < 19 ) console.error( 'THREE.TGALoader: Not enough data to contain header.' );
425
+ if ( buffer.length < 19 ) throw new Error( 'THREE.TGALoader: Not enough data to contain header.' );
426
426
 
427
427
  let offset = 0;
428
428
 
@@ -450,7 +450,7 @@ class TGALoader extends DataTextureLoader {
450
450
 
451
451
  if ( header.id_length + offset > buffer.length ) {
452
452
 
453
- console.error( 'THREE.TGALoader: No data.' );
453
+ throw new Error( 'THREE.TGALoader: No data.' );
454
454
 
455
455
  }
456
456
 
@@ -960,7 +960,7 @@ class VRMLLoader extends Loader {
960
960
 
961
961
  // if the appearance field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
962
962
 
963
- let material = new MeshBasicMaterial( {
963
+ let material = new MeshBasicMaterial( {
964
964
  name: Loader.DEFAULT_MATERIAL_NAME,
965
965
  color: 0x000000
966
966
  } );
@@ -3,10 +3,8 @@ import {
3
3
  ClampToEdgeWrapping,
4
4
  DataTexture,
5
5
  FloatType,
6
- LinearSRGBColorSpace,
7
6
  Mesh,
8
7
  NearestFilter,
9
- NoToneMapping,
10
8
  PlaneGeometry,
11
9
  RGBAFormat,
12
10
  Scene,
@@ -400,14 +398,9 @@ class GPUComputationRenderer {
400
398
 
401
399
  const currentXrEnabled = renderer.xr.enabled;
402
400
  const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
403
- const currentOutputColorSpace = renderer.outputColorSpace;
404
- const currentToneMapping = renderer.toneMapping;
405
401
 
406
402
  renderer.xr.enabled = false; // Avoid camera modification
407
403
  renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
408
- renderer.outputColorSpace = LinearSRGBColorSpace;
409
- renderer.toneMapping = NoToneMapping;
410
-
411
404
  mesh.material = material;
412
405
  renderer.setRenderTarget( output );
413
406
  renderer.render( scene, camera );
@@ -415,8 +408,6 @@ class GPUComputationRenderer {
415
408
 
416
409
  renderer.xr.enabled = currentXrEnabled;
417
410
  renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
418
- renderer.outputColorSpace = currentOutputColorSpace;
419
- renderer.toneMapping = currentToneMapping;
420
411
 
421
412
  renderer.setRenderTarget( currentRenderTarget );
422
413
 
@@ -340,20 +340,18 @@ class Volume {
340
340
 
341
341
  }
342
342
 
343
-
344
- let iLength, jLength;
345
-
346
- if( ! this.segmentation ) {
343
+ if ( ! this.segmentation ) {
347
344
 
348
345
  firstDirection.applyMatrix4( volume.inverseMatrix ).normalize();
349
346
  secondDirection.applyMatrix4( volume.inverseMatrix ).normalize();
350
347
  axisInIJK.applyMatrix4( volume.inverseMatrix ).normalize();
351
348
 
352
349
  }
350
+
353
351
  firstDirection.arglet = 'i';
354
352
  secondDirection.arglet = 'j';
355
- iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
356
- jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
353
+ const iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
354
+ const jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
357
355
  const planeWidth = Math.abs( iLength * firstSpacing );
358
356
  const planeHeight = Math.abs( jLength * secondSpacing );
359
357
 
@@ -12,7 +12,7 @@ export { default as CacheNode, cache } from './core/CacheNode.js';
12
12
  export { default as ConstNode } from './core/ConstNode.js';
13
13
  export { default as ContextNode, context, label } from './core/ContextNode.js';
14
14
  export { default as IndexNode, vertexIndex, instanceIndex } from './core/IndexNode.js';
15
- export { default as LightingModel, lightingModel } from './core/LightingModel.js';
15
+ export { default as LightingModel } from './core/LightingModel.js';
16
16
  export { default as Node, addNodeClass, createNodeFromType } from './core/Node.js';
17
17
  export { default as NodeAttribute } from './core/NodeAttribute.js';
18
18
  export { default as NodeBuilder } from './core/NodeBuilder.js';
@@ -24,12 +24,13 @@ export { default as NodeKeywords } from './core/NodeKeywords.js';
24
24
  export { default as NodeUniform } from './core/NodeUniform.js';
25
25
  export { default as NodeVar } from './core/NodeVar.js';
26
26
  export { default as NodeVarying } from './core/NodeVarying.js';
27
- export { default as PropertyNode, property, diffuseColor, roughness, metalness, specularColor, shininess } from './core/PropertyNode.js';
27
+ export { default as PropertyNode, property, output, diffuseColor, roughness, metalness, specularColor, shininess } from './core/PropertyNode.js';
28
28
  export { default as StackNode, stack } from './core/StackNode.js';
29
29
  export { default as TempNode } from './core/TempNode.js';
30
30
  export { default as UniformNode, uniform } from './core/UniformNode.js';
31
31
  export { default as VarNode, temp } from './core/VarNode.js';
32
32
  export { default as VaryingNode, varying } from './core/VaryingNode.js';
33
+ export { default as OutputStructNode, outputStruct } from './core/OutputStructNode.js';
33
34
 
34
35
  import * as NodeUtils from './core/NodeUtils.js';
35
36
  export { NodeUtils };
@@ -38,6 +39,7 @@ export { NodeUtils };
38
39
  export { default as MathNode, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward } from './math/MathNode.js';
39
40
  export { default as OperatorNode, add, sub, mul, div, remainder, equal, assign, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, xor, bitAnd, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
40
41
  export { default as CondNode, cond } from './math/CondNode.js';
42
+ export { default as HashNode, hash } from './math/HashNode.js';
41
43
 
42
44
  // utils
43
45
  export { default as ArrayElementNode } from './utils/ArrayElementNode.js';
@@ -82,10 +84,11 @@ export { default as PositionNode, positionGeometry, positionLocal, positionWorld
82
84
  export { default as ReferenceNode, reference } from './accessors/ReferenceNode.js';
83
85
  export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
84
86
  export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
85
- export { default as SceneNode, backgroundBlurriness } from './accessors/SceneNode.js';
87
+ export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
86
88
  export { default as StorageBufferNode, storage } from './accessors/StorageBufferNode.js';
87
89
  export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
88
90
  export { default as TextureNode, texture, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
91
+ export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
89
92
  export { default as UVNode, uv } from './accessors/UVNode.js';
90
93
  export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
91
94
 
@@ -155,7 +158,6 @@ export * from './materials/Materials.js';
155
158
  export * from './materialx/MaterialXNodes.js';
156
159
 
157
160
  // functions
158
- export { default as BRDF_BlinnPhong } from './functions/BSDF/BRDF_BlinnPhong.js';
159
161
  export { default as BRDF_GGX } from './functions/BSDF/BRDF_GGX.js';
160
162
  export { default as BRDF_Lambert } from './functions/BSDF/BRDF_Lambert.js';
161
163
  export { default as D_GGX } from './functions/BSDF/D_GGX.js';
@@ -168,5 +170,5 @@ export { getDistanceAttenuation } from './lighting/LightUtils.js';
168
170
  export { default as getGeometryRoughness } from './functions/material/getGeometryRoughness.js';
169
171
  export { default as getRoughness } from './functions/material/getRoughness.js';
170
172
 
171
- export { default as phongLightingModel } from './functions/PhongLightingModel.js';
172
- export { default as physicalLightingModel } from './functions/PhysicalLightingModel.js';
173
+ export { default as PhongLightingModel } from './functions/PhongLightingModel.js';
174
+ export { default as PhysicalLightingModel } from './functions/PhysicalLightingModel.js';
@@ -1,12 +1,12 @@
1
1
  import InputNode from '../core/InputNode.js';
2
2
  import { addNodeClass } from '../core/Node.js';
3
3
  import { varying } from '../core/VaryingNode.js';
4
- import { nodeObject } from '../shadernode/ShaderNode.js';
4
+ import { nodeObject, addNodeElement } from '../shadernode/ShaderNode.js';
5
5
  import { InterleavedBufferAttribute, InterleavedBuffer, StaticDrawUsage, DynamicDrawUsage } from 'three';
6
6
 
7
7
  class BufferAttributeNode extends InputNode {
8
8
 
9
- constructor( value, bufferType, bufferStride = 0, bufferOffset = 0 ) {
9
+ constructor( value, bufferType = null, bufferStride = 0, bufferOffset = 0 ) {
10
10
 
11
11
  super( value, bufferType );
12
12
 
@@ -19,17 +19,41 @@ class BufferAttributeNode extends InputNode {
19
19
  this.usage = StaticDrawUsage;
20
20
  this.instanced = false;
21
21
 
22
+ this.attribute = null;
23
+
24
+ if ( value && value.isBufferAttribute === true ) {
25
+
26
+ this.attribute = value;
27
+ this.usage = value.usage;
28
+ this.instanced = value.isInstancedBufferAttribute;
29
+
30
+ }
31
+
32
+ }
33
+
34
+ getNodeType( builder ) {
35
+
36
+ if ( this.bufferType === null ) {
37
+
38
+ this.bufferType = builder.getTypeFromAttribute( this.attribute );
39
+
40
+ }
41
+
42
+ return this.bufferType;
43
+
22
44
  }
23
45
 
24
46
  construct( builder ) {
25
47
 
48
+ if ( this.attribute !== null ) return;
49
+
26
50
  const type = this.getNodeType( builder );
27
51
  const array = this.value;
28
52
  const itemSize = builder.getTypeLength( type );
29
53
  const stride = this.bufferStride || itemSize;
30
54
  const offset = this.bufferOffset;
31
55
 
32
- const buffer = new InterleavedBuffer( array, stride );
56
+ const buffer = array.isInterleavedBuffer === true ? array : new InterleavedBuffer( array, stride );
33
57
  const bufferAttribute = new InterleavedBufferAttribute( buffer, itemSize, offset );
34
58
 
35
59
  buffer.setUsage( this.usage );
@@ -96,4 +120,6 @@ export const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferA
96
120
  export const instancedBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
97
121
  export const instancedDynamicBufferAttribute = ( array, type, stride, offset ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
98
122
 
123
+ addNodeElement( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
124
+
99
125
  addNodeClass( BufferAttributeNode );
@@ -2,6 +2,8 @@ import TextureNode from './TextureNode.js';
2
2
  import UniformNode from '../core/UniformNode.js';
3
3
  import { reflectVector } from './ReflectVectorNode.js';
4
4
  import { addNodeClass } from '../core/Node.js';
5
+ import { colorSpaceToLinear } from '../display/ColorSpaceNode.js';
6
+ import { expression } from '../code/ExpressionNode.js';
5
7
  import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
6
8
 
7
9
  class CubeTextureNode extends TextureNode {
@@ -26,6 +28,8 @@ class CubeTextureNode extends TextureNode {
26
28
 
27
29
  }
28
30
 
31
+ setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for CubeTextureNode
32
+
29
33
  generate( builder, output ) {
30
34
 
31
35
  const { uvNode, levelNode } = builder.getNodeProperties( this );
@@ -50,6 +54,7 @@ class CubeTextureNode extends TextureNode {
50
54
 
51
55
  } else {
52
56
 
57
+ const nodeType = this.getNodeType( builder );
53
58
  const nodeData = builder.getDataFromNode( this );
54
59
 
55
60
  let propertyName = nodeData.propertyName;
@@ -79,12 +84,24 @@ class CubeTextureNode extends TextureNode {
79
84
 
80
85
  builder.addLineFlowCode( `${propertyName} = ${snippet}` );
81
86
 
82
- nodeData.snippet = snippet;
83
- nodeData.propertyName = propertyName;
87
+ if ( builder.context.tempWrite !== false ) {
88
+
89
+ nodeData.snippet = snippet;
90
+ nodeData.propertyName = propertyName;
91
+
92
+ }
93
+
94
+ }
95
+
96
+ let snippet = propertyName;
97
+
98
+ if ( builder.needsColorSpaceToLinear( this.value ) ) {
99
+
100
+ snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).construct( builder ).build( builder, nodeType );
84
101
 
85
102
  }
86
103
 
87
- return builder.format( propertyName, 'vec4', output );
104
+ return builder.format( snippet, 'vec4', output );
88
105
 
89
106
  }
90
107