super-three 0.162.0 → 0.164.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 (187) hide show
  1. package/build/three.cjs +847 -1226
  2. package/build/three.module.js +846 -1225
  3. package/build/three.module.min.js +2 -2
  4. package/examples/jsm/animation/CCDIKSolver.js +4 -2
  5. package/examples/jsm/controls/TransformControls.js +3 -3
  6. package/examples/jsm/exporters/GLTFExporter.js +66 -5
  7. package/examples/jsm/exporters/USDZExporter.js +22 -1
  8. package/examples/jsm/geometries/TextGeometry.js +10 -2
  9. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  10. package/examples/jsm/libs/draco/README.md +2 -2
  11. package/examples/jsm/libs/fflate.module.js +694 -496
  12. package/examples/jsm/lines/LineMaterial.js +0 -2
  13. package/examples/jsm/loaders/3MFLoader.js +2 -0
  14. package/examples/jsm/loaders/EXRLoader.js +351 -97
  15. package/examples/jsm/loaders/FBXLoader.js +1 -1
  16. package/examples/jsm/loaders/GLTFLoader.js +59 -0
  17. package/examples/jsm/loaders/KTX2Loader.js +3 -10
  18. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  19. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  20. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  21. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  22. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  23. package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
  24. package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
  25. package/examples/jsm/math/Octree.js +26 -20
  26. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  27. package/examples/jsm/nodes/Nodes.js +10 -4
  28. package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
  29. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  30. package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
  31. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  32. package/examples/jsm/nodes/accessors/MaterialNode.js +107 -3
  33. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
  35. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  36. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  38. package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
  39. package/examples/jsm/nodes/accessors/TextureNode.js +51 -10
  40. package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
  41. package/examples/jsm/nodes/code/FunctionNode.js +0 -8
  42. package/examples/jsm/nodes/core/Node.js +63 -4
  43. package/examples/jsm/nodes/core/NodeBuilder.js +26 -25
  44. package/examples/jsm/nodes/core/NodeFrame.js +10 -10
  45. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  46. package/examples/jsm/nodes/core/OutputStructNode.js +2 -1
  47. package/examples/jsm/nodes/core/PropertyNode.js +10 -0
  48. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  49. package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
  50. package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
  51. package/examples/jsm/nodes/display/PassNode.js +17 -1
  52. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  53. package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
  54. package/examples/jsm/nodes/display/ViewportNode.js +4 -2
  55. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  56. package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
  57. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  58. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  59. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  60. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
  61. package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  62. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
  63. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  64. package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
  65. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +164 -10
  66. package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
  67. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
  68. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
  69. package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -70
  70. package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
  71. package/examples/jsm/nodes/lighting/LightsNode.js +11 -1
  72. package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
  73. package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
  74. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +10 -6
  75. package/examples/jsm/nodes/materials/Materials.js +1 -0
  76. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
  77. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  78. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +76 -5
  79. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
  80. package/examples/jsm/nodes/materials/NodeMaterial.js +55 -43
  81. package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
  82. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  83. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  84. package/examples/jsm/nodes/shadernode/ShaderNode.js +3 -9
  85. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  86. package/examples/jsm/objects/QuadMesh.js +7 -23
  87. package/examples/jsm/physics/JoltPhysics.js +281 -0
  88. package/examples/jsm/physics/RapierPhysics.js +4 -4
  89. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  90. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  91. package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
  92. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  93. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  94. package/examples/jsm/renderers/common/Animation.js +3 -0
  95. package/examples/jsm/renderers/common/Background.js +8 -8
  96. package/examples/jsm/renderers/common/ClippingContext.js +1 -1
  97. package/examples/jsm/renderers/common/Info.js +11 -19
  98. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  99. package/examples/jsm/renderers/common/RenderContext.js +1 -1
  100. package/examples/jsm/renderers/common/RenderList.js +1 -1
  101. package/examples/jsm/renderers/common/RenderObject.js +47 -5
  102. package/examples/jsm/renderers/common/RenderObjects.js +1 -1
  103. package/examples/jsm/renderers/common/Renderer.js +153 -21
  104. package/examples/jsm/renderers/common/Textures.js +1 -1
  105. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +773 -0
  106. package/examples/jsm/renderers/common/nodes/Nodes.js +34 -63
  107. package/examples/jsm/renderers/webgl/WebGLBackend.js +146 -36
  108. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +145 -0
  109. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +9 -3
  110. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
  111. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  112. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +64 -7
  113. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +6 -23
  114. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +77 -60
  115. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -4
  116. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +29 -1
  117. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  118. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
  119. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  120. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  121. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  122. package/examples/jsm/utils/SceneUtils.js +60 -1
  123. package/examples/jsm/utils/TextureUtils.js +1 -1
  124. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  125. package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
  126. package/package.json +1 -1
  127. package/src/Three.js +0 -1
  128. package/src/animation/AnimationClip.js +1 -1
  129. package/src/constants.js +3 -3
  130. package/src/core/Object3D.js +10 -7
  131. package/src/core/RenderTarget.js +8 -0
  132. package/src/extras/PMREMGenerator.js +21 -11
  133. package/src/loaders/FileLoader.js +1 -1
  134. package/src/loaders/MaterialLoader.js +1 -0
  135. package/src/loaders/ObjectLoader.js +2 -0
  136. package/src/materials/Material.js +2 -0
  137. package/src/materials/MeshPhysicalMaterial.js +20 -0
  138. package/src/materials/ShaderMaterial.js +0 -4
  139. package/src/math/Spherical.js +4 -5
  140. package/src/objects/BatchedMesh.js +27 -3
  141. package/src/objects/InstancedMesh.js +10 -0
  142. package/src/objects/Line.js +66 -43
  143. package/src/renderers/WebGLRenderer.js +130 -158
  144. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
  145. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
  146. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  147. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  148. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  149. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  150. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  151. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
  152. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  153. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
  154. package/src/renderers/shaders/ShaderChunk.js +0 -2
  155. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
  156. package/src/renderers/shaders/ShaderLib.js +2 -1
  157. package/src/renderers/shaders/UniformsUtils.js +10 -1
  158. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  159. package/src/renderers/webgl/WebGLBackground.js +18 -3
  160. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  161. package/src/renderers/webgl/WebGLBufferRenderer.js +35 -21
  162. package/src/renderers/webgl/WebGLCapabilities.js +35 -13
  163. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  164. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  165. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +35 -21
  166. package/src/renderers/webgl/WebGLLights.js +6 -32
  167. package/src/renderers/webgl/WebGLMaterials.js +8 -3
  168. package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
  169. package/src/renderers/webgl/WebGLProgram.js +21 -52
  170. package/src/renderers/webgl/WebGLPrograms.js +24 -31
  171. package/src/renderers/webgl/WebGLRenderStates.js +13 -7
  172. package/src/renderers/webgl/WebGLShadowMap.js +25 -25
  173. package/src/renderers/webgl/WebGLState.js +15 -59
  174. package/src/renderers/webgl/WebGLTextures.js +138 -292
  175. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  176. package/src/renderers/webgl/WebGLUtils.js +9 -78
  177. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  178. package/src/renderers/webxr/WebXRManager.js +4 -6
  179. package/src/scenes/Scene.js +7 -1
  180. package/src/textures/Texture.js +11 -1
  181. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  182. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -320
  183. package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
  184. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -794
  185. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
  186. package/src/renderers/WebGL1Renderer.js +0 -7
  187. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
@@ -2845,7 +2845,7 @@ class AnimationParser {
2845
2845
 
2846
2846
  const quaternionValues = [];
2847
2847
 
2848
- if ( ! values || ! times ) return new QuaternionKeyframeTrack( modelName + '.quaternion', [], [] );
2848
+ if ( ! values || ! times ) return new QuaternionKeyframeTrack( modelName + '.quaternion', [ 0 ], [ 0 ] );
2849
2849
 
2850
2850
  for ( let i = 0; i < values.length; i += 3 ) {
2851
2851
 
@@ -85,6 +85,12 @@ class GLTFLoader extends Loader {
85
85
 
86
86
  } );
87
87
 
88
+ this.register( function ( parser ) {
89
+
90
+ return new GLTFMaterialsDispersionExtension( parser );
91
+
92
+ } );
93
+
88
94
  this.register( function ( parser ) {
89
95
 
90
96
  return new GLTFTextureBasisUExtension( parser );
@@ -491,6 +497,7 @@ const EXTENSIONS = {
491
497
  KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
492
498
  KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
493
499
  KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
500
+ KHR_MATERIALS_DISPERSION: 'KHR_materials_dispersion',
494
501
  KHR_MATERIALS_IOR: 'KHR_materials_ior',
495
502
  KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
496
503
  KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
@@ -824,6 +831,52 @@ class GLTFMaterialsClearcoatExtension {
824
831
 
825
832
  }
826
833
 
834
+ /**
835
+ * Materials dispersion Extension
836
+ *
837
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
838
+ */
839
+ class GLTFMaterialsDispersionExtension {
840
+
841
+ constructor( parser ) {
842
+
843
+ this.parser = parser;
844
+ this.name = EXTENSIONS.KHR_MATERIALS_DISPERSION;
845
+
846
+ }
847
+
848
+ getMaterialType( materialIndex ) {
849
+
850
+ const parser = this.parser;
851
+ const materialDef = parser.json.materials[ materialIndex ];
852
+
853
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
854
+
855
+ return MeshPhysicalMaterial;
856
+
857
+ }
858
+
859
+ extendMaterialParams( materialIndex, materialParams ) {
860
+
861
+ const parser = this.parser;
862
+ const materialDef = parser.json.materials[ materialIndex ];
863
+
864
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
865
+
866
+ return Promise.resolve();
867
+
868
+ }
869
+
870
+ const extension = materialDef.extensions[ this.name ];
871
+
872
+ materialParams.dispersion = extension.dispersion !== undefined ? extension.dispersion : 0;
873
+
874
+ return Promise.resolve();
875
+
876
+ }
877
+
878
+ }
879
+
827
880
  /**
828
881
  * Iridescence Materials Extension
829
882
  *
@@ -2627,6 +2680,12 @@ class GLTFParser {
2627
2680
 
2628
2681
  } ) ).then( function () {
2629
2682
 
2683
+ for ( const scene of result.scenes ) {
2684
+
2685
+ scene.updateMatrixWorld();
2686
+
2687
+ }
2688
+
2630
2689
  onLoad( result );
2631
2690
 
2632
2691
  } );
@@ -31,13 +31,13 @@ import {
31
31
  RGB_ETC1_Format,
32
32
  RGB_ETC2_Format,
33
33
  RGB_PVRTC_4BPPV1_Format,
34
- RGB_S3TC_DXT1_Format,
35
34
  RGBA_ASTC_4x4_Format,
36
35
  RGBA_ASTC_6x6_Format,
37
36
  RGBA_BPTC_Format,
38
37
  RGBA_ETC2_EAC_Format,
39
38
  RGBA_PVRTC_4BPPV1_Format,
40
39
  RGBA_S3TC_DXT5_Format,
40
+ RGBA_S3TC_DXT1_Format,
41
41
  RGBAFormat,
42
42
  RGFormat,
43
43
  SRGBColorSpace,
@@ -160,13 +160,6 @@ class KTX2Loader extends Loader {
160
160
  || renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
161
161
  };
162
162
 
163
- if ( renderer.capabilities.isWebGL2 ) {
164
-
165
- // https://github.com/mrdoob/three.js/pull/22928
166
- this.workerConfig.etc1Supported = false;
167
-
168
- }
169
-
170
163
  }
171
164
 
172
165
  return this;
@@ -391,7 +384,7 @@ KTX2Loader.EngineFormat = {
391
384
  RGB_ETC1_Format: RGB_ETC1_Format,
392
385
  RGB_ETC2_Format: RGB_ETC2_Format,
393
386
  RGB_PVRTC_4BPPV1_Format: RGB_PVRTC_4BPPV1_Format,
394
- RGB_S3TC_DXT1_Format: RGB_S3TC_DXT1_Format,
387
+ RGBA_S3TC_DXT1_Format: RGBA_S3TC_DXT1_Format,
395
388
  };
396
389
 
397
390
 
@@ -607,7 +600,7 @@ KTX2Loader.BasisWorker = function () {
607
600
  if: 'dxtSupported',
608
601
  basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
609
602
  transcoderFormat: [ TranscoderFormat.BC1, TranscoderFormat.BC3 ],
610
- engineFormat: [ EngineFormat.RGB_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
603
+ engineFormat: [ EngineFormat.RGBA_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
611
604
  priorityETC1S: 4,
612
605
  priorityUASTC: 5,
613
606
  needsPowerOfTwo: false,
@@ -3,7 +3,6 @@
3
3
 
4
4
  import {
5
5
  ClampToEdgeWrapping,
6
- DataTexture,
7
6
  Data3DTexture,
8
7
  FileLoader,
9
8
  FloatType,
@@ -144,19 +143,6 @@ export class LUT3dlLoader extends Loader {
144
143
 
145
144
  }
146
145
 
147
- const texture = new DataTexture();
148
- texture.image.data = data;
149
- texture.image.width = size;
150
- texture.image.height = size * size;
151
- texture.format = RGBAFormat;
152
- texture.type = this.type;
153
- texture.magFilter = LinearFilter;
154
- texture.minFilter = LinearFilter;
155
- texture.wrapS = ClampToEdgeWrapping;
156
- texture.wrapT = ClampToEdgeWrapping;
157
- texture.generateMipmaps = false;
158
- texture.needsUpdate = true;
159
-
160
146
  const texture3D = new Data3DTexture();
161
147
  texture3D.image.data = data;
162
148
  texture3D.image.width = size;
@@ -174,7 +160,6 @@ export class LUT3dlLoader extends Loader {
174
160
 
175
161
  return {
176
162
  size,
177
- texture,
178
163
  texture3D,
179
164
  };
180
165
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  import {
4
4
  ClampToEdgeWrapping,
5
- DataTexture,
6
5
  Data3DTexture,
7
6
  FileLoader,
8
7
  FloatType,
@@ -127,18 +126,6 @@ export class LUTCubeLoader extends Loader {
127
126
 
128
127
  }
129
128
 
130
- const texture = new DataTexture();
131
- texture.image.data = data;
132
- texture.image.width = size;
133
- texture.image.height = size * size;
134
- texture.type = this.type;
135
- texture.magFilter = LinearFilter;
136
- texture.minFilter = LinearFilter;
137
- texture.wrapS = ClampToEdgeWrapping;
138
- texture.wrapT = ClampToEdgeWrapping;
139
- texture.generateMipmaps = false;
140
- texture.needsUpdate = true;
141
-
142
129
  const texture3D = new Data3DTexture();
143
130
  texture3D.image.data = data;
144
131
  texture3D.image.width = size;
@@ -158,7 +145,6 @@ export class LUTCubeLoader extends Loader {
158
145
  size,
159
146
  domainMin,
160
147
  domainMax,
161
- texture,
162
148
  texture3D,
163
149
  };
164
150
 
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Loader,
3
3
  TextureLoader,
4
- DataTexture,
5
4
  Data3DTexture,
6
5
  RGBAFormat,
7
6
  UnsignedByteType,
@@ -124,18 +123,6 @@ export class LUTImageLoader extends Loader {
124
123
  parse( dataArray, size ) {
125
124
 
126
125
  const data = new Uint8Array( dataArray );
127
- const texture = new DataTexture();
128
- texture.image.data = data;
129
- texture.image.width = size;
130
- texture.image.height = size * size;
131
- texture.format = RGBAFormat;
132
- texture.type = UnsignedByteType;
133
- texture.magFilter = LinearFilter;
134
- texture.minFilter = LinearFilter;
135
- texture.wrapS = ClampToEdgeWrapping;
136
- texture.wrapT = ClampToEdgeWrapping;
137
- texture.generateMipmaps = false;
138
- texture.needsUpdate = true;
139
126
 
140
127
  const texture3D = new Data3DTexture();
141
128
  texture3D.image.data = data;
@@ -154,7 +141,6 @@ export class LUTImageLoader extends Loader {
154
141
 
155
142
  return {
156
143
  size,
157
- texture,
158
144
  texture3D,
159
145
  };
160
146
 
@@ -36,6 +36,12 @@ class RGBMLoader extends DataTextureLoader {
36
36
 
37
37
  const texture = new CubeTexture();
38
38
 
39
+ for ( let i = 0; i < 6; i ++ ) {
40
+
41
+ texture.images[ i ] = undefined;
42
+
43
+ }
44
+
39
45
  let loaded = 0;
40
46
 
41
47
  const scope = this;
@@ -75,6 +81,16 @@ class RGBMLoader extends DataTextureLoader {
75
81
 
76
82
  }
77
83
 
84
+ loadCubemapAsync( urls, onProgress ) {
85
+
86
+ return new Promise( ( resolve, reject ) => {
87
+
88
+ this.loadCubemap( urls, resolve, onProgress, reject );
89
+
90
+ } );
91
+
92
+ }
93
+
78
94
  parse( buffer ) {
79
95
 
80
96
  const img = UPNG.decode( buffer );
@@ -800,7 +800,7 @@ class VRMLLoader extends Loader {
800
800
  break;
801
801
 
802
802
  case 'rotation':
803
- const axis = new Vector3( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
803
+ const axis = new Vector3( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] ).normalize();
804
804
  const angle = fieldValues[ 3 ];
805
805
  object.quaternion.setFromAxisAngle( axis, angle );
806
806
  break;
@@ -651,10 +651,13 @@ class IFFParser {
651
651
  // LAYR: number[U2], flags[U2], pivot[VEC12], name[S0], parent[U2]
652
652
  parseLayer( length ) {
653
653
 
654
+ var number = this.reader.getUint16();
655
+ var flags = this.reader.getUint16(); // If the least significant bit of flags is set, the layer is hidden.
656
+ var pivot = this.reader.getFloat32Array( 3 ); // Note: this seems to be superflous, as the geometry is translated when pivot is present
654
657
  var layer = {
655
- number: this.reader.getUint16(),
656
- flags: this.reader.getUint16(), // If the least significant bit of flags is set, the layer is hidden.
657
- pivot: this.reader.getFloat32Array( 3 ), // Note: this seems to be superflous, as the geometry is translated when pivot is present
658
+ number: number,
659
+ flags: flags, // If the least significant bit of flags is set, the layer is hidden.
660
+ pivot: [ - pivot[ 0 ], pivot[ 1 ], pivot[ 2 ] ], // Note: this seems to be superflous, as the geometry is translated when pivot is present
658
661
  name: this.reader.getString(),
659
662
  };
660
663
 
@@ -676,8 +679,8 @@ class IFFParser {
676
679
  this.currentPoints = [];
677
680
  for ( var i = 0; i < length / 4; i += 3 ) {
678
681
 
679
- // z -> -z to match three.js right handed coords
680
- this.currentPoints.push( this.reader.getFloat32(), this.reader.getFloat32(), - this.reader.getFloat32() );
682
+ // x -> -x to match three.js right handed coords
683
+ this.currentPoints.push( - this.reader.getFloat32(), this.reader.getFloat32(), this.reader.getFloat32() );
681
684
 
682
685
  }
683
686
 
@@ -270,7 +270,13 @@ const GouraudShader = {
270
270
 
271
271
  #endif
272
272
 
273
- #include <lightmap_fragment>
273
+ #ifdef USE_LIGHTMAP
274
+
275
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
276
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
277
+ reflectedLight.indirectDiffuse += lightMapIrradiance;
278
+
279
+ #endif
274
280
 
275
281
  reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
276
282
 
@@ -4,7 +4,8 @@ import {
4
4
  Plane,
5
5
  Sphere,
6
6
  Triangle,
7
- Vector3
7
+ Vector3,
8
+ Layers
8
9
  } from 'three';
9
10
  import { Capsule } from '../math/Capsule.js';
10
11
 
@@ -89,6 +90,7 @@ class Octree {
89
90
 
90
91
  this.subTrees = [];
91
92
  this.triangles = [];
93
+ this.layers = new Layers();
92
94
 
93
95
  }
94
96
 
@@ -478,38 +480,42 @@ class Octree {
478
480
 
479
481
  if ( obj.isMesh === true ) {
480
482
 
481
- let geometry, isTemp = false;
483
+ if ( this.layers.test( obj.layers ) ) {
482
484
 
483
- if ( obj.geometry.index !== null ) {
485
+ let geometry, isTemp = false;
484
486
 
485
- isTemp = true;
486
- geometry = obj.geometry.toNonIndexed();
487
+ if ( obj.geometry.index !== null ) {
487
488
 
488
- } else {
489
+ isTemp = true;
490
+ geometry = obj.geometry.toNonIndexed();
489
491
 
490
- geometry = obj.geometry;
492
+ } else {
491
493
 
492
- }
494
+ geometry = obj.geometry;
493
495
 
494
- const positionAttribute = geometry.getAttribute( 'position' );
496
+ }
495
497
 
496
- for ( let i = 0; i < positionAttribute.count; i += 3 ) {
498
+ const positionAttribute = geometry.getAttribute( 'position' );
497
499
 
498
- const v1 = new Vector3().fromBufferAttribute( positionAttribute, i );
499
- const v2 = new Vector3().fromBufferAttribute( positionAttribute, i + 1 );
500
- const v3 = new Vector3().fromBufferAttribute( positionAttribute, i + 2 );
500
+ for ( let i = 0; i < positionAttribute.count; i += 3 ) {
501
501
 
502
- v1.applyMatrix4( obj.matrixWorld );
503
- v2.applyMatrix4( obj.matrixWorld );
504
- v3.applyMatrix4( obj.matrixWorld );
502
+ const v1 = new Vector3().fromBufferAttribute( positionAttribute, i );
503
+ const v2 = new Vector3().fromBufferAttribute( positionAttribute, i + 1 );
504
+ const v3 = new Vector3().fromBufferAttribute( positionAttribute, i + 2 );
505
505
 
506
- this.addTriangle( new Triangle( v1, v2, v3 ) );
506
+ v1.applyMatrix4( obj.matrixWorld );
507
+ v2.applyMatrix4( obj.matrixWorld );
508
+ v3.applyMatrix4( obj.matrixWorld );
507
509
 
508
- }
510
+ this.addTriangle( new Triangle( v1, v2, v3 ) );
511
+
512
+ }
513
+
514
+ if ( isTemp ) {
509
515
 
510
- if ( isTemp ) {
516
+ geometry.dispose();
511
517
 
512
- geometry.dispose();
518
+ }
513
519
 
514
520
  }
515
521
 
@@ -171,12 +171,6 @@ class GPUComputationRenderer {
171
171
 
172
172
  this.init = function () {
173
173
 
174
- if ( renderer.capabilities.isWebGL2 === false && renderer.extensions.has( 'OES_texture_float' ) === false ) {
175
-
176
- return 'No OES_texture_float support for float textures.';
177
-
178
- }
179
-
180
174
  if ( renderer.capabilities.maxVertexTextures === 0 ) {
181
175
 
182
176
  return 'No support for vertex shader textures.';
@@ -26,7 +26,7 @@ export { default as NodeUniform } from './core/NodeUniform.js';
26
26
  export { default as NodeVar } from './core/NodeVar.js';
27
27
  export { default as NodeVarying } from './core/NodeVarying.js';
28
28
  export { default as ParameterNode, parameter } from './core/ParameterNode.js';
29
- export { default as PropertyNode, property, varyingProperty, output, diffuseColor, roughness, metalness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, shininess, dashSize, gapSize, pointWidth } from './core/PropertyNode.js';
29
+ export { default as PropertyNode, property, varyingProperty, output, diffuseColor, roughness, metalness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, shininess, dashSize, gapSize, pointWidth, alphaT, anisotropy, anisotropyB, anisotropyT } from './core/PropertyNode.js';
30
30
  export { default as StackNode, stack } from './core/StackNode.js';
31
31
  export { default as TempNode } from './core/TempNode.js';
32
32
  export { default as UniformGroupNode, uniformGroup, objectGroup, renderGroup, frameGroup } from './core/UniformGroupNode.js';
@@ -64,7 +64,6 @@ export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
64
64
  export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
65
65
  export { default as RotateNode, rotate } from './utils/RotateNode.js';
66
66
  export { default as SetNode } from './utils/SetNode.js';
67
- export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
68
67
  export { default as SplitNode } from './utils/SplitNode.js';
69
68
  export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
70
69
  export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
@@ -76,7 +75,7 @@ export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
76
75
  export * from './shadernode/ShaderNode.js';
77
76
 
78
77
  // accessors
79
- export { TBNViewMatrix, parallaxDirection, parallaxUV } from './accessors/AccessorsUtils.js';
78
+ export { TBNViewMatrix, parallaxDirection, parallaxUV, transformedBentNormalView } from './accessors/AccessorsUtils.js';
80
79
  export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
81
80
  export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
82
81
  export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
@@ -85,8 +84,10 @@ export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixIn
85
84
  export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
86
85
  export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
87
86
  export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
88
- export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
87
+ export { default as BatchNode, batch } from './accessors/BatchNode.js';
88
+ export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector } from './accessors/MaterialNode.js';
89
89
  export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
90
+ export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
90
91
  export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
91
92
  export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
92
93
  export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
@@ -157,9 +158,14 @@ export { default as LightingNode /* @TODO: lighting (abstract), light */ } from
157
158
  export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
158
159
  export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
159
160
  export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
161
+ export { default as IrradianceNode } from './lighting/IrradianceNode.js';
160
162
  export { default as AONode } from './lighting/AONode.js';
161
163
  export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
162
164
 
165
+ // pmrem
166
+ export { default as PMREMNode, pmremTexture } from './pmrem/PMREMNode.js';
167
+ export * as PMREMUtils from './pmrem/PMREMUtils.js';
168
+
163
169
  // procedural
164
170
  export { default as CheckerNode, checker } from './procedural/CheckerNode.js';
165
171
 
@@ -1,10 +1,25 @@
1
1
  import { bitangentView } from './BitangentNode.js';
2
- import { normalView } from './NormalNode.js';
2
+ import { normalView, transformedNormalView } from './NormalNode.js';
3
3
  import { tangentView } from './TangentNode.js';
4
4
  import { mat3 } from '../shadernode/ShaderNode.js';
5
+ import { mix } from '../math/MathNode.js';
6
+ import { anisotropy, anisotropyB, roughness } from '../core/PropertyNode.js';
5
7
  import { positionViewDirection } from './PositionNode.js';
6
8
 
7
9
  export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
8
10
 
9
11
  export const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
10
12
  export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
13
+
14
+ export const transformedBentNormalView = ( () => {
15
+
16
+ // https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy
17
+
18
+ let bentNormal = anisotropyB.cross( positionViewDirection );
19
+ bentNormal = bentNormal.cross( anisotropyB ).normalize();
20
+ bentNormal = mix( bentNormal, transformedNormalView, anisotropy.mul( roughness.oneMinus() ).oneMinus().pow2().pow2() ).normalize();
21
+
22
+ return bentNormal;
23
+
24
+
25
+ } )();
@@ -0,0 +1,78 @@
1
+ import Node, { addNodeClass } from '../core/Node.js';
2
+ import { normalLocal } from './NormalNode.js';
3
+ import { positionLocal } from './PositionNode.js';
4
+ import { nodeProxy, vec3, mat3, mat4, int, ivec2, float } from '../shadernode/ShaderNode.js';
5
+ import { textureLoad } from './TextureNode.js';
6
+ import { textureSize } from './TextureSizeNode.js';
7
+ import { attribute } from '../core/AttributeNode.js';
8
+ import { tangentLocal } from './TangentNode.js';
9
+
10
+ class BatchNode extends Node {
11
+
12
+ constructor( batchMesh ) {
13
+
14
+ super( 'void' );
15
+
16
+ this.batchMesh = batchMesh;
17
+
18
+
19
+ this.instanceColorNode = null;
20
+
21
+ this.batchingIdNode = null;
22
+
23
+ }
24
+
25
+ setup( builder ) {
26
+
27
+ // POSITION
28
+
29
+ if ( this.batchingIdNode === null ) {
30
+
31
+ this.batchingIdNode = attribute( 'batchId' );
32
+
33
+ }
34
+
35
+ const matriceTexture = this.batchMesh._matricesTexture;
36
+
37
+ const size = textureSize( textureLoad( matriceTexture ), 0 );
38
+ const j = float( int( this.batchingIdNode ) ).mul( 4 ).toVar();
39
+
40
+ const x = int( j.mod( size ) );
41
+ const y = int( j ).div( int( size ) );
42
+ const batchingMatrix = mat4(
43
+ textureLoad( matriceTexture, ivec2( x, y ) ),
44
+ textureLoad( matriceTexture, ivec2( x.add( 1 ), y ) ),
45
+ textureLoad( matriceTexture, ivec2( x.add( 2 ), y ) ),
46
+ textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
47
+ );
48
+
49
+
50
+ const bm = mat3(
51
+ batchingMatrix[ 0 ].xyz,
52
+ batchingMatrix[ 1 ].xyz,
53
+ batchingMatrix[ 2 ].xyz
54
+ );
55
+
56
+ positionLocal.assign( batchingMatrix.mul( positionLocal ) );
57
+
58
+ const transformedNormal = normalLocal.div( vec3( bm[ 0 ].dot( bm[ 0 ] ), bm[ 1 ].dot( bm[ 1 ] ), bm[ 2 ].dot( bm[ 2 ] ) ) );
59
+
60
+ const batchingNormal = bm.mul( transformedNormal ).xyz;
61
+
62
+ normalLocal.assign( batchingNormal );
63
+
64
+ if ( builder.hasGeometryAttribute( 'tangent' ) ) {
65
+
66
+ tangentLocal.mulAssign( bm );
67
+
68
+ }
69
+
70
+ }
71
+
72
+ }
73
+
74
+ export default BatchNode;
75
+
76
+ export const batch = nodeProxy( BatchNode );
77
+
78
+ addNodeClass( 'batch', BatchNode );
@@ -5,7 +5,7 @@ import { positionView } from './PositionNode.js';
5
5
  import { diffuseColor, property } from '../core/PropertyNode.js';
6
6
  import { tslFn } from '../shadernode/ShaderNode.js';
7
7
  import { loop } from '../utils/LoopNode.js';
8
- import { smoothstep } from '../math/MathNode.js';
8
+ import { smoothstep } from '../math/MathNode.js';
9
9
  import { uniforms } from './UniformsNode.js';
10
10
 
11
11
  class ClippingNode extends Node {
@@ -78,7 +78,7 @@ class ClippingNode extends Node {
78
78
 
79
79
  plane = clippingPlanes.element( i );
80
80
 
81
- distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
81
+ distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
82
82
  distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
83
83
 
84
84
  unionClipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ).oneMinus() );
@@ -126,6 +126,7 @@ class ClippingNode extends Node {
126
126
  } );
127
127
 
128
128
  clipped.discard();
129
+
129
130
  }
130
131
 
131
132
  } )();
@@ -1,9 +1,10 @@
1
1
  import Node, { addNodeClass } from '../core/Node.js';
2
+ import { varyingProperty } from '../core/PropertyNode.js';
2
3
  import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
3
4
  import { normalLocal } from './NormalNode.js';
4
5
  import { positionLocal } from './PositionNode.js';
5
6
  import { nodeProxy, vec3, mat3, mat4 } from '../shadernode/ShaderNode.js';
6
- import { DynamicDrawUsage, InstancedInterleavedBuffer } from 'three';
7
+ import { DynamicDrawUsage, InstancedInterleavedBuffer, InstancedBufferAttribute } from 'three';
7
8
 
8
9
  class InstanceNode extends Node {
9
10
 
@@ -15,15 +16,18 @@ class InstanceNode extends Node {
15
16
 
16
17
  this.instanceMatrixNode = null;
17
18
 
19
+ this.instanceColorNode = null;
20
+
18
21
  }
19
22
 
20
23
  setup( /*builder*/ ) {
21
24
 
22
25
  let instanceMatrixNode = this.instanceMatrixNode;
23
26
 
27
+ const instanceMesh = this.instanceMesh;
28
+
24
29
  if ( instanceMatrixNode === null ) {
25
30
 
26
- const instanceMesh = this.instanceMesh;
27
31
  const instanceAttribute = instanceMesh.instanceMatrix;
28
32
  const buffer = new InstancedInterleavedBuffer( instanceAttribute.array, 16, 1 );
29
33
 
@@ -43,6 +47,17 @@ class InstanceNode extends Node {
43
47
 
44
48
  }
45
49
 
50
+ const instanceColorAttribute = instanceMesh.instanceColor;
51
+
52
+ if ( instanceColorAttribute && this.instanceColorNode === null ) {
53
+
54
+ const buffer = new InstancedBufferAttribute( instanceColorAttribute.array, 3 );
55
+ const bufferFn = instanceColorAttribute.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
56
+
57
+ this.instanceColorNode = vec3( bufferFn( buffer, 'vec3', 3, 0 ) );
58
+
59
+ }
60
+
46
61
  // POSITION
47
62
 
48
63
  const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
@@ -60,6 +75,14 @@ class InstanceNode extends Node {
60
75
  positionLocal.assign( instancePosition );
61
76
  normalLocal.assign( instanceNormal );
62
77
 
78
+ // COLOR
79
+
80
+ if ( this.instanceColorNode !== null ) {
81
+
82
+ varyingProperty( 'vec3', 'vInstanceColor' ).assign( this.instanceColorNode );
83
+
84
+ }
85
+
63
86
  }
64
87
 
65
88
  }