super-three 0.163.0 → 0.165.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 (197) hide show
  1. package/README.md +3 -3
  2. package/build/three.cjs +1127 -452
  3. package/build/three.module.js +1127 -452
  4. package/build/three.module.min.js +2 -2
  5. package/examples/jsm/animation/CCDIKSolver.js +4 -2
  6. package/examples/jsm/controls/TransformControls.js +1 -1
  7. package/examples/jsm/environments/RoomEnvironment.js +1 -5
  8. package/examples/jsm/exporters/GLTFExporter.js +45 -1
  9. package/examples/jsm/exporters/USDZExporter.js +13 -5
  10. package/examples/jsm/helpers/ViewHelper.js +32 -67
  11. package/examples/jsm/libs/draco/README.md +2 -2
  12. package/examples/jsm/libs/tween.module.js +75 -64
  13. package/examples/jsm/lines/LineMaterial.js +1 -15
  14. package/examples/jsm/lines/LineSegments2.js +15 -0
  15. package/examples/jsm/lines/Wireframe.js +16 -1
  16. package/examples/jsm/loaders/DRACOLoader.js +1 -1
  17. package/examples/jsm/loaders/EXRLoader.js +283 -99
  18. package/examples/jsm/loaders/FBXLoader.js +24 -13
  19. package/examples/jsm/loaders/GLTFLoader.js +55 -0
  20. package/examples/jsm/loaders/KTX2Loader.js +3 -6
  21. package/examples/jsm/loaders/LDrawLoader.js +3 -2
  22. package/examples/jsm/loaders/MMDLoader.js +31 -12
  23. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  24. package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
  25. package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
  26. package/examples/jsm/math/Octree.js +26 -20
  27. package/examples/jsm/modifiers/CurveModifier.js +11 -9
  28. package/examples/jsm/nodes/Nodes.js +15 -13
  29. package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
  30. package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
  31. package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
  32. package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
  33. package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
  34. package/examples/jsm/nodes/accessors/MaterialNode.js +109 -3
  35. package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
  36. package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
  37. package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
  38. package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
  39. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
  40. package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
  41. package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
  42. package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
  43. package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
  44. package/examples/jsm/nodes/accessors/TextureNode.js +21 -3
  45. package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
  46. package/examples/jsm/nodes/accessors/UVNode.js +2 -46
  47. package/examples/jsm/nodes/code/FunctionNode.js +0 -8
  48. package/examples/jsm/nodes/core/AttributeNode.js +15 -3
  49. package/examples/jsm/nodes/core/ContextNode.js +6 -0
  50. package/examples/jsm/nodes/core/Node.js +23 -2
  51. package/examples/jsm/nodes/core/NodeBuilder.js +25 -18
  52. package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
  53. package/examples/jsm/nodes/core/OutputStructNode.js +3 -6
  54. package/examples/jsm/nodes/core/PropertyNode.js +11 -0
  55. package/examples/jsm/nodes/core/VaryingNode.js +40 -9
  56. package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
  57. package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
  58. package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
  59. package/examples/jsm/nodes/display/PassNode.js +3 -1
  60. package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
  61. package/examples/jsm/nodes/display/ViewportNode.js +5 -3
  62. package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
  63. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
  64. package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  65. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
  66. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  67. package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
  68. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +210 -12
  69. package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
  70. package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
  71. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +20 -5
  72. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
  73. package/examples/jsm/nodes/lighting/EnvironmentNode.js +11 -2
  74. package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
  75. package/examples/jsm/nodes/lighting/LightsNode.js +28 -1
  76. package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
  77. package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
  78. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +11 -7
  79. package/examples/jsm/nodes/materials/Materials.js +4 -0
  80. package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
  81. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
  82. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  83. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +94 -6
  84. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
  85. package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
  86. package/examples/jsm/nodes/materials/NodeMaterial.js +43 -45
  87. package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
  88. package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
  89. package/examples/jsm/nodes/math/HashNode.js +2 -2
  90. package/examples/jsm/nodes/pmrem/PMREMUtils.js +1 -1
  91. package/examples/jsm/nodes/shadernode/ShaderNode.js +57 -41
  92. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  93. package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
  94. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  95. package/examples/jsm/objects/Lensflare.js +2 -2
  96. package/examples/jsm/physics/JoltPhysics.js +281 -0
  97. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  98. package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
  99. package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
  100. package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
  101. package/examples/jsm/renderers/common/Attributes.js +2 -0
  102. package/examples/jsm/renderers/common/Background.js +3 -3
  103. package/examples/jsm/renderers/common/Bindings.js +17 -0
  104. package/examples/jsm/renderers/common/ChainMap.js +18 -48
  105. package/examples/jsm/renderers/common/ClippingContext.js +5 -5
  106. package/examples/jsm/renderers/common/Pipelines.js +2 -2
  107. package/examples/jsm/renderers/common/RenderBundle.js +18 -0
  108. package/examples/jsm/renderers/common/RenderBundles.js +38 -0
  109. package/examples/jsm/renderers/common/RenderList.js +10 -1
  110. package/examples/jsm/renderers/common/RenderObject.js +49 -1
  111. package/examples/jsm/renderers/common/Renderer.js +268 -25
  112. package/examples/jsm/renderers/common/Textures.js +1 -1
  113. package/examples/jsm/renderers/common/Uniform.js +1 -1
  114. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +13 -17
  115. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
  116. package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
  117. package/examples/jsm/renderers/common/nodes/Nodes.js +31 -47
  118. package/examples/jsm/renderers/webgl/WebGLBackend.js +7 -21
  119. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +5 -1
  120. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +23 -5
  121. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +114 -13
  122. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -21
  123. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +80 -46
  124. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +85 -12
  125. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -1
  126. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
  127. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
  128. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
  129. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
  130. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  131. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  132. package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
  133. package/examples/jsm/utils/GPUStatsPanel.js +2 -0
  134. package/examples/jsm/utils/SceneUtils.js +60 -1
  135. package/examples/jsm/utils/SortUtils.js +8 -5
  136. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  137. package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
  138. package/package.json +3 -2
  139. package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
  140. package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
  141. package/src/animation/tracks/StringKeyframeTrack.js +10 -1
  142. package/src/constants.js +1 -1
  143. package/src/core/Object3D.js +2 -0
  144. package/src/core/Raycaster.js +6 -2
  145. package/src/core/RenderTarget.js +8 -0
  146. package/src/extras/PMREMGenerator.js +12 -11
  147. package/src/loaders/FileLoader.js +5 -1
  148. package/src/loaders/LoaderUtils.js +3 -1
  149. package/src/loaders/MaterialLoader.js +1 -0
  150. package/src/loaders/ObjectLoader.js +1 -0
  151. package/src/materials/Material.js +2 -0
  152. package/src/materials/MeshPhysicalMaterial.js +20 -0
  153. package/src/objects/BatchedMesh.js +114 -1
  154. package/src/objects/Line.js +66 -43
  155. package/src/renderers/WebGLRenderer.js +371 -109
  156. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
  157. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
  158. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
  159. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
  160. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
  161. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
  162. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
  163. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
  164. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
  165. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
  166. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
  167. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
  168. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  169. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
  170. package/src/renderers/shaders/ShaderChunk.js +0 -2
  171. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
  172. package/src/renderers/shaders/ShaderLib.js +1 -0
  173. package/src/renderers/webgl/WebGLBackground.js +24 -3
  174. package/src/renderers/webgl/WebGLBufferRenderer.js +36 -0
  175. package/src/renderers/webgl/WebGLCapabilities.js +33 -1
  176. package/src/renderers/webgl/WebGLExtensions.js +3 -1
  177. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +36 -0
  178. package/src/renderers/webgl/WebGLLights.js +9 -12
  179. package/src/renderers/webgl/WebGLMaterials.js +7 -5
  180. package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
  181. package/src/renderers/webgl/WebGLProgram.js +5 -36
  182. package/src/renderers/webgl/WebGLPrograms.js +19 -14
  183. package/src/renderers/webgl/WebGLRenderStates.js +8 -4
  184. package/src/renderers/webgl/WebGLShadowMap.js +25 -25
  185. package/src/renderers/webgl/WebGLTextures.js +206 -129
  186. package/src/renderers/webgl/WebGLUtils.js +3 -21
  187. package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
  188. package/src/renderers/webxr/WebXRManager.js +8 -6
  189. package/src/textures/CompressedArrayTexture.js +14 -0
  190. package/src/textures/DataArrayTexture.js +14 -0
  191. package/src/textures/DepthTexture.js +1 -3
  192. package/src/utils.js +30 -1
  193. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -318
  194. package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
  195. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -792
  196. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
  197. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
@@ -2051,14 +2051,18 @@ class GeometryParser {
2051
2051
  // Triangulate n-gon using earcut
2052
2052
 
2053
2053
  const vertices = [];
2054
-
2054
+ // in morphing scenario vertexPositions represent morphPositions
2055
+ // while baseVertexPositions represent the original geometry's positions
2056
+ const positions = geoInfo.baseVertexPositions || geoInfo.vertexPositions;
2055
2057
  for ( let i = 0; i < facePositionIndexes.length; i += 3 ) {
2056
2058
 
2057
- vertices.push( new Vector3(
2058
- geoInfo.vertexPositions[ facePositionIndexes[ i ] ],
2059
- geoInfo.vertexPositions[ facePositionIndexes[ i + 1 ] ],
2060
- geoInfo.vertexPositions[ facePositionIndexes[ i + 2 ] ]
2061
- ) );
2059
+ vertices.push(
2060
+ new Vector3(
2061
+ positions[ facePositionIndexes[ i ] ],
2062
+ positions[ facePositionIndexes[ i + 1 ] ],
2063
+ positions[ facePositionIndexes[ i + 2 ] ]
2064
+ )
2065
+ );
2062
2066
 
2063
2067
  }
2064
2068
 
@@ -2071,6 +2075,12 @@ class GeometryParser {
2071
2075
 
2072
2076
  }
2073
2077
 
2078
+ // When vertices is an array of [0,0,0] elements (which is the case for vertices not participating in morph)
2079
+ // the triangulationInput will be an array of [0,0] elements
2080
+ // resulting in an array of 0 triangles being returned from ShapeUtils.triangulateShape
2081
+ // leading to not pushing into buffers.vertex the redundant vertices (the vertices that are not morphed).
2082
+ // That's why, in order to support morphing scenario, "positions" is looking first for baseVertexPositions,
2083
+ // so that we don't end up with an array of 0 triangles for the faces not participating in morph.
2074
2084
  triangles = ShapeUtils.triangulateShape( triangulationInput, [] );
2075
2085
 
2076
2086
  } else {
@@ -2225,17 +2235,18 @@ class GeometryParser {
2225
2235
  // Normal and position attributes only have data for the vertices that are affected by the morph
2226
2236
  genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) {
2227
2237
 
2228
- const vertexIndices = ( parentGeoNode.PolygonVertexIndex !== undefined ) ? parentGeoNode.PolygonVertexIndex.a : [];
2238
+ const basePositions = parentGeoNode.Vertices !== undefined ? parentGeoNode.Vertices.a : [];
2239
+ const baseIndices = parentGeoNode.PolygonVertexIndex !== undefined ? parentGeoNode.PolygonVertexIndex.a : [];
2229
2240
 
2230
- const morphPositionsSparse = ( morphGeoNode.Vertices !== undefined ) ? morphGeoNode.Vertices.a : [];
2231
- const indices = ( morphGeoNode.Indexes !== undefined ) ? morphGeoNode.Indexes.a : [];
2241
+ const morphPositionsSparse = morphGeoNode.Vertices !== undefined ? morphGeoNode.Vertices.a : [];
2242
+ const morphIndices = morphGeoNode.Indexes !== undefined ? morphGeoNode.Indexes.a : [];
2232
2243
 
2233
2244
  const length = parentGeo.attributes.position.count * 3;
2234
2245
  const morphPositions = new Float32Array( length );
2235
2246
 
2236
- for ( let i = 0; i < indices.length; i ++ ) {
2247
+ for ( let i = 0; i < morphIndices.length; i ++ ) {
2237
2248
 
2238
- const morphIndex = indices[ i ] * 3;
2249
+ const morphIndex = morphIndices[ i ] * 3;
2239
2250
 
2240
2251
  morphPositions[ morphIndex ] = morphPositionsSparse[ i * 3 ];
2241
2252
  morphPositions[ morphIndex + 1 ] = morphPositionsSparse[ i * 3 + 1 ];
@@ -2245,9 +2256,9 @@ class GeometryParser {
2245
2256
 
2246
2257
  // TODO: add morph normal support
2247
2258
  const morphGeoInfo = {
2248
- vertexIndices: vertexIndices,
2259
+ vertexIndices: baseIndices,
2249
2260
  vertexPositions: morphPositions,
2250
-
2261
+ baseVertexPositions: basePositions
2251
2262
  };
2252
2263
 
2253
2264
  const morphBuffers = this.genBuffers( morphGeoInfo );
@@ -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
  *
@@ -3264,6 +3317,8 @@ class GLTFParser {
3264
3317
 
3265
3318
  }
3266
3319
 
3320
+ assignExtrasToUserData( texture, sourceDef );
3321
+
3267
3322
  texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri );
3268
3323
 
3269
3324
  return texture;
@@ -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,9 +160,6 @@ class KTX2Loader extends Loader {
160
160
  || renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
161
161
  };
162
162
 
163
- // https://github.com/mrdoob/three.js/pull/22928
164
- this.workerConfig.etc1Supported = false;
165
-
166
163
  }
167
164
 
168
165
  return this;
@@ -387,7 +384,7 @@ KTX2Loader.EngineFormat = {
387
384
  RGB_ETC1_Format: RGB_ETC1_Format,
388
385
  RGB_ETC2_Format: RGB_ETC2_Format,
389
386
  RGB_PVRTC_4BPPV1_Format: RGB_PVRTC_4BPPV1_Format,
390
- RGB_S3TC_DXT1_Format: RGB_S3TC_DXT1_Format,
387
+ RGBA_S3TC_DXT1_Format: RGBA_S3TC_DXT1_Format,
391
388
  };
392
389
 
393
390
 
@@ -603,7 +600,7 @@ KTX2Loader.BasisWorker = function () {
603
600
  if: 'dxtSupported',
604
601
  basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
605
602
  transcoderFormat: [ TranscoderFormat.BC1, TranscoderFormat.BC3 ],
606
- engineFormat: [ EngineFormat.RGB_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
603
+ engineFormat: [ EngineFormat.RGBA_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
607
604
  priorityETC1S: 4,
608
605
  priorityUASTC: 5,
609
606
  needsPowerOfTwo: false,
@@ -1974,7 +1974,7 @@ class LDrawLoader extends Loader {
1974
1974
 
1975
1975
  }
1976
1976
 
1977
- parse( text, onLoad ) {
1977
+ parse( text, onLoad, onError ) {
1978
1978
 
1979
1979
  this.partsCache
1980
1980
  .parseModel( text, this.materialLibrary )
@@ -1985,7 +1985,8 @@ class LDrawLoader extends Loader {
1985
1985
  group.userData.fileName = '';
1986
1986
  onLoad( group );
1987
1987
 
1988
- } );
1988
+ } )
1989
+ .catch( onError );
1989
1990
 
1990
1991
  }
1991
1992
 
@@ -131,22 +131,40 @@ class MMDLoader extends Loader {
131
131
 
132
132
  }
133
133
 
134
- const modelExtension = this._extractExtension( url ).toLowerCase();
134
+ const parser = this._getParser();
135
+ const extractModelExtension = this._extractModelExtension;
135
136
 
136
- // Should I detect by seeing header?
137
- if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) {
137
+ this.loader
138
+ .setMimeType( undefined )
139
+ .setPath( this.path )
140
+ .setResponseType( 'arraybuffer' )
141
+ .setRequestHeader( this.requestHeader )
142
+ .setWithCredentials( this.withCredentials )
143
+ .load( url, function ( buffer ) {
138
144
 
139
- if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) );
145
+ try {
140
146
 
141
- return;
147
+ const modelExtension = extractModelExtension( buffer );
142
148
 
143
- }
149
+ if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) {
144
150
 
145
- this[ modelExtension === 'pmd' ? 'loadPMD' : 'loadPMX' ]( url, function ( data ) {
151
+ if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) );
146
152
 
147
- onLoad( builder.build( data, resourcePath, onProgress, onError ) );
153
+ return;
148
154
 
149
- }, onProgress, onError );
155
+ }
156
+
157
+ const data = modelExtension === 'pmd' ? parser.parsePmd( buffer, true ) : parser.parsePmx( buffer, true );
158
+
159
+ onLoad( builder.build( data, resourcePath, onProgress, onError ) );
160
+
161
+ } catch ( e ) {
162
+
163
+ if ( onError ) onError( e );
164
+
165
+ }
166
+
167
+ }, onProgress, onError );
150
168
 
151
169
  }
152
170
 
@@ -358,10 +376,11 @@ class MMDLoader extends Loader {
358
376
 
359
377
  // private methods
360
378
 
361
- _extractExtension( url ) {
379
+ _extractModelExtension( buffer ) {
362
380
 
363
- const index = url.lastIndexOf( '.' );
364
- return index < 0 ? '' : url.slice( index + 1 );
381
+ const decoder = new TextDecoder( 'utf-8' );
382
+ const bytes = new Uint8Array( buffer, 0, 3 );
383
+ return decoder.decode( bytes ).toLowerCase();
365
384
 
366
385
  }
367
386
 
@@ -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
 
@@ -5,12 +5,13 @@ const TEXTURE_HEIGHT = 4;
5
5
 
6
6
  import {
7
7
  DataTexture,
8
+ DataUtils,
8
9
  RGBAFormat,
9
- FloatType,
10
+ HalfFloatType,
10
11
  RepeatWrapping,
11
12
  Mesh,
12
13
  InstancedMesh,
13
- NearestFilter,
14
+ LinearFilter,
14
15
  DynamicDrawUsage,
15
16
  Matrix4
16
17
  } from 'three';
@@ -22,18 +23,19 @@ import {
22
23
  */
23
24
  export function initSplineTexture( numberOfCurves = 1 ) {
24
25
 
25
- const dataArray = new Float32Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
26
+ const dataArray = new Uint16Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
26
27
  const dataTexture = new DataTexture(
27
28
  dataArray,
28
29
  TEXTURE_WIDTH,
29
30
  TEXTURE_HEIGHT * numberOfCurves,
30
31
  RGBAFormat,
31
- FloatType
32
+ HalfFloatType
32
33
  );
33
34
 
34
35
  dataTexture.wrapS = RepeatWrapping;
35
36
  dataTexture.wrapY = RepeatWrapping;
36
- dataTexture.magFilter = NearestFilter;
37
+ dataTexture.magFilter = LinearFilter;
38
+ dataTexture.minFilter = LinearFilter;
37
39
  dataTexture.needsUpdate = true;
38
40
 
39
41
  return dataTexture;
@@ -81,10 +83,10 @@ function setTextureValue( texture, index, x, y, z, o ) {
81
83
  const image = texture.image;
82
84
  const { data } = image;
83
85
  const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
84
- data[ index * CHANNELS + i + 0 ] = x;
85
- data[ index * CHANNELS + i + 1 ] = y;
86
- data[ index * CHANNELS + i + 2 ] = z;
87
- data[ index * CHANNELS + i + 3 ] = 1;
86
+ data[ index * CHANNELS + i + 0 ] = DataUtils.toHalfFloat( x );
87
+ data[ index * CHANNELS + i + 1 ] = DataUtils.toHalfFloat( y );
88
+ data[ index * CHANNELS + i + 2 ] = DataUtils.toHalfFloat( z );
89
+ data[ index * CHANNELS + i + 3 ] = DataUtils.toHalfFloat( 1 );
88
90
 
89
91
  }
90
92
 
@@ -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';
@@ -75,36 +75,37 @@ export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
75
75
  export * from './shadernode/ShaderNode.js';
76
76
 
77
77
  // accessors
78
- export { TBNViewMatrix, parallaxDirection, parallaxUV } from './accessors/AccessorsUtils.js';
78
+ export { TBNViewMatrix, parallaxDirection, parallaxUV, transformedBentNormalView } from './accessors/AccessorsUtils.js';
79
79
  export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
80
- export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
80
+ export * from './accessors/BitangentNode.js';
81
81
  export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
82
82
  export { default as BufferNode, buffer } from './accessors/BufferNode.js';
83
- export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar, cameraLogDepth } from './accessors/CameraNode.js';
83
+ export * from './accessors/CameraNode.js';
84
84
  export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
85
85
  export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
86
86
  export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
87
87
  export { default as BatchNode, batch } from './accessors/BatchNode.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';
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, materialDispersion } from './accessors/MaterialNode.js';
89
89
  export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
90
90
  export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
91
91
  export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
92
92
  export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
93
- export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
93
+ export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale, modelWorldMatrixInverse } from './accessors/ModelNode.js';
94
94
  export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
95
- export { default as NormalNode, normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView, transformedNormalWorld, transformedClearcoatNormalView } from './accessors/NormalNode.js';
95
+ export * from './accessors/NormalNode.js';
96
96
  export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
97
97
  export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
98
- export { default as PositionNode, positionGeometry, positionLocal, positionWorld, positionWorldDirection, positionView, positionViewDirection } from './accessors/PositionNode.js';
98
+ export * from './accessors/PositionNode.js';
99
99
  export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
100
- export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
100
+ export * from './accessors/ReflectVectorNode.js';
101
101
  export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
102
102
  export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
103
103
  export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
104
- export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
104
+ export * from './accessors/TangentNode.js';
105
105
  export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
106
- export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
107
- export { default as UVNode, uv } from './accessors/UVNode.js';
106
+ export { default as StorageTextureNode, storageTexture, textureStore, storageTextureReadOnly, storageTextureReadWrite } from './accessors/StorageTextureNode.js';
107
+ export { default as Texture3DNode, texture3D } from './accessors/Texture3DNode.js';
108
+ export * from './accessors/UVNode.js';
108
109
  export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
109
110
 
110
111
  // display
@@ -125,7 +126,7 @@ export { default as GaussianBlurNode, gaussianBlur } from './display/GaussianBlu
125
126
  export { default as AfterImageNode, afterImage } from './display/AfterImageNode.js';
126
127
  export { default as AnamorphicNode, anamorphic } from './display/AnamorphicNode.js';
127
128
 
128
- export { default as PassNode, pass, depthPass } from './display/PassNode.js';
129
+ export { default as PassNode, pass, texturePass, depthPass } from './display/PassNode.js';
129
130
 
130
131
  // code
131
132
  export { default as ExpressionNode, expression } from './code/ExpressionNode.js';
@@ -158,6 +159,7 @@ export { default as LightingNode /* @TODO: lighting (abstract), light */ } from
158
159
  export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
159
160
  export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
160
161
  export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
162
+ export { default as IrradianceNode } from './lighting/IrradianceNode.js';
161
163
  export { default as AONode } from './lighting/AONode.js';
162
164
  export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
163
165
 
@@ -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
+ } )();