@plastic-software/three 0.182.0 → 0.183.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 (298) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +11520 -10877
  3. package/build/three.core.js +11732 -11340
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +509 -262
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +7 -11
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +3072 -2607
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +3071 -2607
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/Addons.js +0 -3
  14. package/examples/jsm/animation/CCDIKSolver.js +2 -2
  15. package/examples/jsm/controls/ArcballControls.js +3 -3
  16. package/examples/jsm/controls/OrbitControls.js +103 -0
  17. package/examples/jsm/effects/AnaglyphEffect.js +102 -7
  18. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -0
  20. package/examples/jsm/exporters/EXRExporter.js +1 -1
  21. package/examples/jsm/exporters/GLTFExporter.js +131 -4
  22. package/examples/jsm/exporters/USDZExporter.js +22 -3
  23. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  24. package/examples/jsm/helpers/ViewHelper.js +67 -8
  25. package/examples/jsm/inspector/Inspector.js +21 -5
  26. package/examples/jsm/inspector/tabs/Console.js +39 -5
  27. package/examples/jsm/inspector/tabs/Parameters.js +16 -0
  28. package/examples/jsm/inspector/ui/Style.js +25 -1
  29. package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
  30. package/examples/jsm/lines/LineMaterial.js +6 -0
  31. package/examples/jsm/loaders/3MFLoader.js +2 -2
  32. package/examples/jsm/loaders/AMFLoader.js +2 -2
  33. package/examples/jsm/loaders/ColladaLoader.js +24 -4026
  34. package/examples/jsm/loaders/EXRLoader.js +5 -5
  35. package/examples/jsm/loaders/FBXLoader.js +2 -2
  36. package/examples/jsm/loaders/GCodeLoader.js +34 -8
  37. package/examples/jsm/loaders/GLTFLoader.js +122 -171
  38. package/examples/jsm/loaders/KMZLoader.js +5 -5
  39. package/examples/jsm/loaders/KTX2Loader.js +5 -5
  40. package/examples/jsm/loaders/LWOLoader.js +7 -39
  41. package/examples/jsm/loaders/NRRDLoader.js +2 -2
  42. package/examples/jsm/loaders/PCDLoader.js +3 -2
  43. package/examples/jsm/loaders/USDLoader.js +100 -40
  44. package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
  45. package/examples/jsm/loaders/VRMLLoader.js +77 -0
  46. package/examples/jsm/loaders/VTKLoader.js +37 -24
  47. package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
  48. package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
  49. package/examples/jsm/loaders/usd/USDAParser.js +447 -366
  50. package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
  51. package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
  52. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
  53. package/examples/jsm/objects/LensflareMesh.js +1 -1
  54. package/examples/jsm/objects/Sky.js +76 -4
  55. package/examples/jsm/objects/SkyMesh.js +114 -7
  56. package/examples/jsm/objects/Water.js +4 -3
  57. package/examples/jsm/objects/Water2.js +5 -3
  58. package/examples/jsm/objects/WaterMesh.js +5 -7
  59. package/examples/jsm/physics/JoltPhysics.js +7 -5
  60. package/examples/jsm/physics/RapierPhysics.js +6 -4
  61. package/examples/jsm/postprocessing/EffectComposer.js +7 -5
  62. package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
  63. package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
  64. package/examples/jsm/renderers/SVGRenderer.js +2 -2
  65. package/examples/jsm/shaders/GTAOShader.js +19 -6
  66. package/examples/jsm/shaders/HalftoneShader.js +12 -1
  67. package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
  68. package/examples/jsm/shaders/SAOShader.js +17 -4
  69. package/examples/jsm/shaders/SSAOShader.js +11 -1
  70. package/examples/jsm/shaders/SSRShader.js +6 -5
  71. package/examples/jsm/shaders/VignetteShader.js +1 -1
  72. package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
  73. package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
  74. package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
  75. package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
  76. package/examples/jsm/tsl/display/BloomNode.js +5 -5
  77. package/examples/jsm/tsl/display/CRT.js +150 -0
  78. package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
  79. package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
  80. package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
  81. package/examples/jsm/tsl/display/FXAANode.js +2 -2
  82. package/examples/jsm/tsl/display/GTAONode.js +2 -2
  83. package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
  84. package/examples/jsm/tsl/display/GodraysNode.js +624 -0
  85. package/examples/jsm/tsl/display/LensflareNode.js +1 -1
  86. package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
  87. package/examples/jsm/tsl/display/OutlineNode.js +3 -3
  88. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
  89. package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
  90. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
  91. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  92. package/examples/jsm/tsl/display/SMAANode.js +2 -2
  93. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  94. package/examples/jsm/tsl/display/SSGINode.js +2 -2
  95. package/examples/jsm/tsl/display/SSRNode.js +7 -7
  96. package/examples/jsm/tsl/display/SSSNode.js +2 -2
  97. package/examples/jsm/tsl/display/Shape.js +29 -0
  98. package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
  99. package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
  100. package/examples/jsm/tsl/display/TRAANode.js +9 -12
  101. package/examples/jsm/tsl/display/TransitionNode.js +1 -1
  102. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  103. package/examples/jsm/tsl/math/Bayer.js +40 -1
  104. package/examples/jsm/utils/LDrawUtils.js +1 -1
  105. package/package.json +11 -19
  106. package/src/Three.Core.js +1 -1
  107. package/src/Three.TSL.js +5 -9
  108. package/src/Three.WebGPU.Nodes.js +2 -0
  109. package/src/Three.WebGPU.js +3 -0
  110. package/src/Three.js +1 -0
  111. package/src/animation/AnimationAction.js +1 -1
  112. package/src/animation/AnimationClip.js +1 -1
  113. package/src/animation/AnimationMixer.js +6 -0
  114. package/src/animation/KeyframeTrack.js +46 -7
  115. package/src/animation/PropertyMixer.js +4 -4
  116. package/src/audio/Audio.js +1 -1
  117. package/src/audio/AudioListener.js +5 -3
  118. package/src/cameras/Camera.js +32 -2
  119. package/src/cameras/CubeCamera.js +20 -0
  120. package/src/constants.js +30 -1
  121. package/src/core/Clock.js +7 -0
  122. package/src/core/Object3D.js +56 -4
  123. package/src/core/RenderTarget.js +3 -4
  124. package/src/extras/PMREMGenerator.js +4 -8
  125. package/src/geometries/TorusGeometry.js +8 -3
  126. package/src/helpers/CameraHelper.js +3 -0
  127. package/src/helpers/DirectionalLightHelper.js +4 -1
  128. package/src/helpers/HemisphereLightHelper.js +3 -0
  129. package/src/helpers/PointLightHelper.js +0 -24
  130. package/src/helpers/SpotLightHelper.js +3 -0
  131. package/src/lights/LightShadow.js +15 -3
  132. package/src/lights/webgpu/IESSpotLight.js +2 -1
  133. package/src/loaders/Cache.js +28 -0
  134. package/src/loaders/FileLoader.js +1 -1
  135. package/src/loaders/ImageBitmapLoader.js +8 -3
  136. package/src/loaders/Loader.js +6 -0
  137. package/src/loaders/ObjectLoader.js +18 -1
  138. package/src/materials/MeshLambertMaterial.js +9 -0
  139. package/src/materials/MeshPhongMaterial.js +9 -0
  140. package/src/materials/nodes/Line2NodeMaterial.js +5 -5
  141. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
  142. package/src/materials/nodes/NodeMaterial.js +15 -24
  143. package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
  144. package/src/math/Line3.js +3 -5
  145. package/src/math/MathUtils.js +10 -10
  146. package/src/math/Matrix4.js +35 -26
  147. package/src/math/Quaternion.js +3 -29
  148. package/src/math/Vector3.js +3 -3
  149. package/src/math/interpolants/BezierInterpolant.js +108 -0
  150. package/src/nodes/Nodes.js +87 -68
  151. package/src/nodes/TSL.js +2 -5
  152. package/src/nodes/accessors/Arrays.js +1 -1
  153. package/src/nodes/accessors/Bitangent.js +5 -5
  154. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  155. package/src/nodes/accessors/Camera.js +149 -28
  156. package/src/nodes/accessors/InstanceNode.js +105 -40
  157. package/src/nodes/accessors/Normal.js +9 -9
  158. package/src/nodes/accessors/Position.js +34 -2
  159. package/src/nodes/accessors/SceneProperties.js +53 -0
  160. package/src/nodes/accessors/SkinningNode.js +12 -24
  161. package/src/nodes/accessors/StorageBufferNode.js +0 -19
  162. package/src/nodes/accessors/StorageTextureNode.js +37 -1
  163. package/src/nodes/accessors/Tangent.js +3 -3
  164. package/src/nodes/accessors/Texture3DNode.js +6 -34
  165. package/src/nodes/accessors/TextureNode.js +58 -22
  166. package/src/nodes/accessors/UniformArrayNode.js +2 -0
  167. package/src/nodes/core/MRTNode.js +48 -2
  168. package/src/nodes/core/Node.js +29 -3
  169. package/src/nodes/core/NodeBuilder.js +115 -40
  170. package/src/nodes/core/NodeError.js +28 -0
  171. package/src/nodes/core/NodeUtils.js +5 -3
  172. package/src/nodes/core/OutputStructNode.js +12 -10
  173. package/src/nodes/core/ParameterNode.js +2 -1
  174. package/src/nodes/core/StackNode.js +9 -8
  175. package/src/nodes/core/StackTrace.js +139 -0
  176. package/src/nodes/core/StructNode.js +15 -0
  177. package/src/nodes/core/SubBuildNode.js +1 -1
  178. package/src/nodes/core/UniformNode.js +2 -1
  179. package/src/nodes/core/VarNode.js +1 -1
  180. package/src/nodes/core/VaryingNode.js +1 -18
  181. package/src/nodes/display/BlendModes.js +0 -64
  182. package/src/nodes/display/ColorAdjustment.js +17 -0
  183. package/src/nodes/display/ColorSpaceNode.js +3 -3
  184. package/src/nodes/display/NormalMapNode.js +2 -2
  185. package/src/nodes/display/PassNode.js +21 -2
  186. package/src/nodes/display/RenderOutputNode.js +3 -3
  187. package/src/nodes/display/ScreenNode.js +2 -1
  188. package/src/nodes/display/ToneMappingNode.js +1 -1
  189. package/src/nodes/display/ToonOutlinePassNode.js +2 -2
  190. package/src/nodes/display/ViewportDepthNode.js +52 -4
  191. package/src/nodes/display/ViewportTextureNode.js +21 -4
  192. package/src/nodes/fog/Fog.js +18 -35
  193. package/src/nodes/functions/PhysicalLightingModel.js +25 -3
  194. package/src/nodes/geometry/RangeNode.js +4 -2
  195. package/src/nodes/gpgpu/ComputeNode.js +5 -4
  196. package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
  197. package/src/nodes/lighting/EnvironmentNode.js +28 -3
  198. package/src/nodes/lighting/PointShadowNode.js +24 -12
  199. package/src/nodes/lighting/ShadowFilterNode.js +15 -43
  200. package/src/nodes/lighting/ShadowNode.js +54 -32
  201. package/src/nodes/math/ConditionalNode.js +2 -2
  202. package/src/nodes/math/MathNode.js +3 -40
  203. package/src/nodes/math/OperatorNode.js +2 -1
  204. package/src/nodes/pmrem/PMREMUtils.js +9 -15
  205. package/src/nodes/tsl/TSLCore.js +13 -10
  206. package/src/nodes/utils/DebugNode.js +11 -11
  207. package/src/nodes/utils/JoinNode.js +2 -2
  208. package/src/nodes/utils/LoopNode.js +1 -1
  209. package/src/nodes/utils/MemberNode.js +1 -1
  210. package/src/nodes/utils/RTTNode.js +1 -1
  211. package/src/nodes/utils/ReflectorNode.js +2 -3
  212. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  213. package/src/nodes/utils/UVUtils.js +4 -2
  214. package/src/objects/BatchedMesh.js +22 -12
  215. package/src/objects/InstancedMesh.js +11 -0
  216. package/src/renderers/WebGLRenderer.js +34 -60
  217. package/src/renderers/common/Backend.js +21 -0
  218. package/src/renderers/common/Background.js +7 -4
  219. package/src/renderers/common/BindGroup.js +1 -9
  220. package/src/renderers/common/Bindings.js +20 -5
  221. package/src/renderers/common/BlendMode.js +143 -0
  222. package/src/renderers/common/BundleGroup.js +1 -1
  223. package/src/renderers/common/CubeRenderTarget.js +50 -6
  224. package/src/renderers/common/Geometries.js +17 -3
  225. package/src/renderers/common/Lighting.js +5 -21
  226. package/src/renderers/common/Pipelines.js +4 -4
  227. package/src/renderers/common/PostProcessing.js +8 -206
  228. package/src/renderers/common/RenderBundles.js +2 -1
  229. package/src/renderers/common/RenderContext.js +16 -0
  230. package/src/renderers/common/RenderContexts.js +33 -56
  231. package/src/renderers/common/RenderLists.js +2 -1
  232. package/src/renderers/common/RenderObject.js +2 -3
  233. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  234. package/src/renderers/common/RenderObjects.js +18 -2
  235. package/src/renderers/common/RenderPipeline.js +203 -17
  236. package/src/renderers/common/Renderer.js +207 -40
  237. package/src/renderers/common/Sampler.js +4 -4
  238. package/src/renderers/common/StorageBuffer.js +13 -1
  239. package/src/renderers/common/Textures.js +16 -0
  240. package/src/renderers/common/TimestampQueryPool.js +5 -3
  241. package/src/renderers/common/Uniform.js +8 -0
  242. package/src/renderers/common/UniformsGroup.js +60 -0
  243. package/src/renderers/common/XRManager.js +2 -2
  244. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  245. package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
  246. package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
  247. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
  248. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
  249. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
  250. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
  251. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
  252. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
  253. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
  254. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
  255. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
  256. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
  257. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
  258. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
  259. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
  260. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  261. package/src/renderers/shaders/ShaderLib.js +4 -2
  262. package/src/renderers/shaders/UniformsLib.js +0 -3
  263. package/src/renderers/webgl/WebGLBackground.js +2 -2
  264. package/src/renderers/webgl/WebGLBindingStates.js +99 -27
  265. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  266. package/src/renderers/webgl/WebGLGeometries.js +10 -7
  267. package/src/renderers/webgl/WebGLMaterials.js +12 -0
  268. package/src/renderers/webgl/WebGLObjects.js +3 -1
  269. package/src/renderers/webgl/WebGLProgram.js +2 -2
  270. package/src/renderers/webgl/WebGLPrograms.js +10 -4
  271. package/src/renderers/webgl/WebGLRenderLists.js +15 -0
  272. package/src/renderers/webgl/WebGLShadowMap.js +5 -4
  273. package/src/renderers/webgl/WebGLState.js +12 -17
  274. package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
  275. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
  276. package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
  277. package/src/renderers/webgpu/WebGPUBackend.js +58 -9
  278. package/src/renderers/webgpu/WebGPURenderer.js +1 -0
  279. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
  280. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
  281. package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
  282. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
  283. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
  284. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
  285. package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
  286. package/src/renderers/webxr/WebXRManager.js +2 -2
  287. package/src/textures/Texture.js +2 -2
  288. package/src/utils.js +246 -3
  289. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
  290. package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
  291. package/examples/jsm/shaders/GodRaysShader.js +0 -333
  292. package/src/nodes/accessors/SceneNode.js +0 -145
  293. package/src/nodes/code/ScriptableNode.js +0 -726
  294. package/src/nodes/code/ScriptableValueNode.js +0 -253
  295. package/src/nodes/display/PosterizeNode.js +0 -65
  296. package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
  297. package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
  298. package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
@@ -25,7 +25,7 @@ import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
25
25
  import { vertexColor } from '../../nodes/accessors/VertexColorNode.js';
26
26
  import { premultiplyAlpha } from '../../nodes/display/BlendModes.js';
27
27
  import { subBuild } from '../../nodes/core/SubBuildNode.js';
28
- import { error, warn } from '../../utils.js';
28
+ import { error } from '../../utils.js';
29
29
 
30
30
  /**
31
31
  * Base class for all node materials.
@@ -240,6 +240,14 @@ class NodeMaterial extends Material {
240
240
  */
241
241
  this.maskNode = null;
242
242
 
243
+ /**
244
+ * This node can be used to implement a shadow mask for the material.
245
+ *
246
+ * @type {?Node<bool>}
247
+ * @default null
248
+ */
249
+ this.maskShadowNode = null;
250
+
243
251
  /**
244
252
  * The local vertex positions are computed based on multiple factors like the
245
253
  * attribute data, morphing or skinning. This node property allows to overwrite
@@ -390,26 +398,6 @@ class NodeMaterial extends Material {
390
398
  */
391
399
  this.contextNode = null;
392
400
 
393
- // Deprecated properties
394
-
395
- Object.defineProperty( this, 'shadowPositionNode', { // @deprecated, r176
396
-
397
- get: () => {
398
-
399
- return this.receivedShadowPositionNode;
400
-
401
- },
402
-
403
- set: ( value ) => {
404
-
405
- warn( 'NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".' );
406
-
407
- this.receivedShadowPositionNode = value;
408
-
409
- }
410
-
411
- } );
412
-
413
401
  }
414
402
 
415
403
  /**
@@ -527,9 +515,11 @@ class NodeMaterial extends Material {
527
515
 
528
516
  builder.addStack();
529
517
 
530
- const mvp = subBuild( this.setupVertex( builder ), 'VERTEX' );
518
+ const mvp = this.setupVertex( builder );
519
+
520
+ const vertexNode = subBuild( this.vertexNode || mvp, 'VERTEX' );
531
521
 
532
- const vertexNode = this.vertexNode || mvp;
522
+ builder.context.clipSpace = vertexNode;
533
523
 
534
524
  builder.stack.outputNode = vertexNode;
535
525
 
@@ -795,7 +785,7 @@ class NodeMaterial extends Material {
795
785
 
796
786
  this.setupPosition( builder );
797
787
 
798
- builder.context.vertex = builder.removeStack();
788
+ builder.context.position = builder.removeStack();
799
789
 
800
790
  return modelViewProjection;
801
791
 
@@ -1339,6 +1329,7 @@ class NodeMaterial extends Material {
1339
1329
  this.backdropAlphaNode = source.backdropAlphaNode;
1340
1330
  this.alphaTestNode = source.alphaTestNode;
1341
1331
  this.maskNode = source.maskNode;
1332
+ this.maskShadowNode = source.maskShadowNode;
1342
1333
 
1343
1334
  this.positionNode = source.positionNode;
1344
1335
  this.geometryNode = source.geometryNode;
@@ -173,6 +173,7 @@ class NodeMaterialObserver {
173
173
  geometry: {
174
174
  id: geometry.id,
175
175
  attributes: this.getAttributesData( geometry.attributes ),
176
+ indexId: geometry.index ? geometry.index.id : null,
176
177
  indexVersion: geometry.index ? geometry.index.version : null,
177
178
  drawRange: { start: geometry.drawRange.start, count: geometry.drawRange.count }
178
179
  },
@@ -232,7 +233,8 @@ class NodeMaterialObserver {
232
233
  const attribute = attributes[ name ];
233
234
 
234
235
  attributesData[ name ] = {
235
- version: attribute.version
236
+ id: attribute.id,
237
+ version: attribute.version,
236
238
  };
237
239
 
238
240
  }
@@ -423,8 +425,9 @@ class NodeMaterialObserver {
423
425
 
424
426
  }
425
427
 
426
- if ( storedAttributeData.version !== attribute.version ) {
428
+ if ( storedAttributeData.id !== attribute.id || storedAttributeData.version !== attribute.version ) {
427
429
 
430
+ storedAttributeData.id = attribute.id;
428
431
  storedAttributeData.version = attribute.version;
429
432
  return false;
430
433
 
@@ -435,11 +438,14 @@ class NodeMaterialObserver {
435
438
  // check index
436
439
 
437
440
  const index = geometry.index;
441
+ const storedIndexId = storedGeometryData.indexId;
438
442
  const storedIndexVersion = storedGeometryData.indexVersion;
443
+ const currentIndexId = index ? index.id : null;
439
444
  const currentIndexVersion = index ? index.version : null;
440
445
 
441
- if ( storedIndexVersion !== currentIndexVersion ) {
446
+ if ( storedIndexId !== currentIndexId || storedIndexVersion !== currentIndexVersion ) {
442
447
 
448
+ storedGeometryData.indexId = currentIndexId;
443
449
  storedGeometryData.indexVersion = currentIndexVersion;
444
450
  return false;
445
451
 
package/src/math/Line3.js CHANGED
@@ -284,12 +284,10 @@ class Line3 {
284
284
 
285
285
  }
286
286
 
287
- c1.copy( p1 ).add( _d1.multiplyScalar( s ) );
288
- c2.copy( p2 ).add( _d2.multiplyScalar( t ) );
287
+ c1.copy( p1 ).addScaledVector( _d1, s );
288
+ c2.copy( p2 ).addScaledVector( _d2, t );
289
289
 
290
- c1.sub( c2 );
291
-
292
- return c1.dot( c1 );
290
+ return c1.distanceToSquared( c2 );
293
291
 
294
292
  }
295
293
 
@@ -64,7 +64,7 @@ function euclideanModulo( n, m ) {
64
64
 
65
65
  /**
66
66
  * Performs a linear mapping from range `<a1, a2>` to range `<b1, b2>`
67
- * for the given value.
67
+ * for the given value. `a2` must be greater than `a1`.
68
68
  *
69
69
  * @param {number} x - The value to be mapped.
70
70
  * @param {number} a1 - Minimum value for range A.
@@ -159,9 +159,9 @@ function pingpong( x, length = 1 ) {
159
159
  *
160
160
  * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details.
161
161
  *
162
- * @param {number} x - The value to evaluate based on its position between min and max.
163
- * @param {number} min - The min value. Any x value below min will be `0`.
164
- * @param {number} max - The max value. Any x value above max will be `1`.
162
+ * @param {number} x - The value to evaluate based on its position between `min` and `max`.
163
+ * @param {number} min - The min value. Any `x` value below `min` will be `0`. `min` must be lower than `max`.
164
+ * @param {number} max - The max value. Any `x` value above `max` will be `1`. `max` must be greater than `min`.
165
165
  * @return {number} The alternated value.
166
166
  */
167
167
  function smoothstep( x, min, max ) {
@@ -177,11 +177,11 @@ function smoothstep( x, min, max ) {
177
177
 
178
178
  /**
179
179
  * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations)
180
- * that has zero 1st and 2nd order derivatives at x=0 and x=1.
180
+ * that has zero 1st and 2nd order derivatives at `x=0` and `x=1`.
181
181
  *
182
- * @param {number} x - The value to evaluate based on its position between min and max.
183
- * @param {number} min - The min value. Any x value below min will be `0`.
184
- * @param {number} max - The max value. Any x value above max will be `1`.
182
+ * @param {number} x - The value to evaluate based on its position between `min` and `max`.
183
+ * @param {number} min - The min value. Any `x` value below `min` will be `0`. `min` must be lower than `max`.
184
+ * @param {number} max - The max value. Any `x` value above `max` will be `1`. `max` must be greater than `min`.
185
185
  * @return {number} The alternated value.
186
186
  */
187
187
  function smootherstep( x, min, max ) {
@@ -294,7 +294,7 @@ function isPowerOfTwo( value ) {
294
294
  /**
295
295
  * Returns the smallest power of two that is greater than or equal to the given number.
296
296
  *
297
- * @param {number} value - The value to find a POT for.
297
+ * @param {number} value - The value to find a POT for. Must be greater than `0`.
298
298
  * @return {number} The smallest power of two that is greater than or equal to the given number.
299
299
  */
300
300
  function ceilPowerOfTwo( value ) {
@@ -306,7 +306,7 @@ function ceilPowerOfTwo( value ) {
306
306
  /**
307
307
  * Returns the largest power of two that is less than or equal to the given number.
308
308
  *
309
- * @param {number} value - The value to find a POT for.
309
+ * @param {number} value - The value to find a POT for. Must be greater than `0`.
310
310
  * @return {number} The largest power of two that is less than or equal to the given number.
311
311
  */
312
312
  function floorPowerOfTwo( value ) {
@@ -707,7 +707,7 @@ class Matrix4 {
707
707
  */
708
708
  invert() {
709
709
 
710
- // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
710
+ // based on https://github.com/toji/gl-matrix
711
711
  const te = this.elements,
712
712
 
713
713
  n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], n41 = te[ 3 ],
@@ -715,36 +715,44 @@ class Matrix4 {
715
715
  n13 = te[ 8 ], n23 = te[ 9 ], n33 = te[ 10 ], n43 = te[ 11 ],
716
716
  n14 = te[ 12 ], n24 = te[ 13 ], n34 = te[ 14 ], n44 = te[ 15 ],
717
717
 
718
- t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
719
- t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
720
- t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
721
- t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
722
-
723
- const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
718
+ t1 = n11 * n22 - n21 * n12,
719
+ t2 = n11 * n32 - n31 * n12,
720
+ t3 = n11 * n42 - n41 * n12,
721
+ t4 = n21 * n32 - n31 * n22,
722
+ t5 = n21 * n42 - n41 * n22,
723
+ t6 = n31 * n42 - n41 * n32,
724
+ t7 = n13 * n24 - n23 * n14,
725
+ t8 = n13 * n34 - n33 * n14,
726
+ t9 = n13 * n44 - n43 * n14,
727
+ t10 = n23 * n34 - n33 * n24,
728
+ t11 = n23 * n44 - n43 * n24,
729
+ t12 = n33 * n44 - n43 * n34;
730
+
731
+ const det = t1 * t12 - t2 * t11 + t3 * t10 + t4 * t9 - t5 * t8 + t6 * t7;
724
732
 
725
733
  if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
726
734
 
727
735
  const detInv = 1 / det;
728
736
 
729
- te[ 0 ] = t11 * detInv;
730
- te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;
731
- te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;
732
- te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;
737
+ te[ 0 ] = ( n22 * t12 - n32 * t11 + n42 * t10 ) * detInv;
738
+ te[ 1 ] = ( n31 * t11 - n21 * t12 - n41 * t10 ) * detInv;
739
+ te[ 2 ] = ( n24 * t6 - n34 * t5 + n44 * t4 ) * detInv;
740
+ te[ 3 ] = ( n33 * t5 - n23 * t6 - n43 * t4 ) * detInv;
733
741
 
734
- te[ 4 ] = t12 * detInv;
735
- te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;
736
- te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;
737
- te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;
742
+ te[ 4 ] = ( n32 * t9 - n12 * t12 - n42 * t8 ) * detInv;
743
+ te[ 5 ] = ( n11 * t12 - n31 * t9 + n41 * t8 ) * detInv;
744
+ te[ 6 ] = ( n34 * t3 - n14 * t6 - n44 * t2 ) * detInv;
745
+ te[ 7 ] = ( n13 * t6 - n33 * t3 + n43 * t2 ) * detInv;
738
746
 
739
- te[ 8 ] = t13 * detInv;
740
- te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;
741
- te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;
742
- te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;
747
+ te[ 8 ] = ( n12 * t11 - n22 * t9 + n42 * t7 ) * detInv;
748
+ te[ 9 ] = ( n21 * t9 - n11 * t11 - n41 * t7 ) * detInv;
749
+ te[ 10 ] = ( n14 * t5 - n24 * t3 + n44 * t1 ) * detInv;
750
+ te[ 11 ] = ( n23 * t3 - n13 * t5 - n43 * t1 ) * detInv;
743
751
 
744
- te[ 12 ] = t14 * detInv;
745
- te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;
746
- te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;
747
- te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;
752
+ te[ 12 ] = ( n22 * t8 - n12 * t10 - n32 * t7 ) * detInv;
753
+ te[ 13 ] = ( n11 * t10 - n21 * t8 + n31 * t7 ) * detInv;
754
+ te[ 14 ] = ( n24 * t2 - n14 * t4 - n34 * t1 ) * detInv;
755
+ te[ 15 ] = ( n13 * t4 - n23 * t2 + n33 * t1 ) * detInv;
748
756
 
749
757
  return this;
750
758
 
@@ -1046,7 +1054,9 @@ class Matrix4 {
1046
1054
  position.y = te[ 13 ];
1047
1055
  position.z = te[ 14 ];
1048
1056
 
1049
- if ( this.determinant() === 0 ) {
1057
+ const det = this.determinant();
1058
+
1059
+ if ( det === 0 ) {
1050
1060
 
1051
1061
  scale.set( 1, 1, 1 );
1052
1062
  quaternion.identity();
@@ -1059,8 +1069,7 @@ class Matrix4 {
1059
1069
  const sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
1060
1070
  const sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
1061
1071
 
1062
- // if determine is negative, we need to invert one scale
1063
- const det = this.determinant();
1072
+ // if determinant is negative, we need to invert one scale
1064
1073
  if ( det < 0 ) sx = - sx;
1065
1074
 
1066
1075
  // scale the rotation part
@@ -54,7 +54,7 @@ class Quaternion {
54
54
  * @param {number} srcOffset0 - An offset into the first source array.
55
55
  * @param {Array<number>} src1 - The source array of the second quaternion.
56
56
  * @param {number} srcOffset1 - An offset into the second source array.
57
- * @param {number} t - The interpolation factor in the range `[0,1]`.
57
+ * @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.
58
58
  * @see {@link Quaternion#slerp}
59
59
  */
60
60
  static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
@@ -69,28 +69,6 @@ class Quaternion {
69
69
  z1 = src1[ srcOffset1 + 2 ],
70
70
  w1 = src1[ srcOffset1 + 3 ];
71
71
 
72
- if ( t <= 0 ) {
73
-
74
- dst[ dstOffset + 0 ] = x0;
75
- dst[ dstOffset + 1 ] = y0;
76
- dst[ dstOffset + 2 ] = z0;
77
- dst[ dstOffset + 3 ] = w0;
78
-
79
- return;
80
-
81
- }
82
-
83
- if ( t >= 1 ) {
84
-
85
- dst[ dstOffset + 0 ] = x1;
86
- dst[ dstOffset + 1 ] = y1;
87
- dst[ dstOffset + 2 ] = z1;
88
- dst[ dstOffset + 3 ] = w1;
89
-
90
- return;
91
-
92
- }
93
-
94
72
  if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
95
73
 
96
74
  let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
@@ -732,18 +710,14 @@ class Quaternion {
732
710
  }
733
711
 
734
712
  /**
735
- * Performs a spherical linear interpolation between quaternions.
713
+ * Performs a spherical linear interpolation between this quaternion and the target quaternion.
736
714
  *
737
715
  * @param {Quaternion} qb - The target quaternion.
738
- * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
716
+ * @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.
739
717
  * @return {Quaternion} A reference to this quaternion.
740
718
  */
741
719
  slerp( qb, t ) {
742
720
 
743
- if ( t <= 0 ) return this;
744
-
745
- if ( t >= 1 ) return this.copy( qb ); // copy calls _onChangeCallback()
746
-
747
721
  let x = qb._x, y = qb._y, z = qb._z, w = qb._w;
748
722
 
749
723
  let dot = this.dot( qb );
@@ -106,7 +106,7 @@ class Vector3 {
106
106
  }
107
107
 
108
108
  /**
109
- * Sets the vector's x component to the given value
109
+ * Sets the vector's x component to the given value.
110
110
  *
111
111
  * @param {number} x - The value to set.
112
112
  * @return {Vector3} A reference to this vector.
@@ -120,7 +120,7 @@ class Vector3 {
120
120
  }
121
121
 
122
122
  /**
123
- * Sets the vector's y component to the given value
123
+ * Sets the vector's y component to the given value.
124
124
  *
125
125
  * @param {number} y - The value to set.
126
126
  * @return {Vector3} A reference to this vector.
@@ -134,7 +134,7 @@ class Vector3 {
134
134
  }
135
135
 
136
136
  /**
137
- * Sets the vector's z component to the given value
137
+ * Sets the vector's z component to the given value.
138
138
  *
139
139
  * @param {number} z - The value to set.
140
140
  * @return {Vector3} A reference to this vector.
@@ -0,0 +1,108 @@
1
+ import { Interpolant } from '../Interpolant.js';
2
+
3
+ /**
4
+ * A Bezier interpolant using cubic Bezier curves with 2D control points.
5
+ *
6
+ * This interpolant supports the COLLADA/Maya style of Bezier animation where
7
+ * each keyframe has explicit in/out tangent control points specified as
8
+ * 2D coordinates (time, value).
9
+ *
10
+ * The tangent data must be provided via the `settings` object:
11
+ * - `settings.inTangents`: Float32Array with [time, value] pairs per keyframe per component
12
+ * - `settings.outTangents`: Float32Array with [time, value] pairs per keyframe per component
13
+ *
14
+ * For a track with N keyframes and stride S:
15
+ * - Each tangent array has N * S * 2 values
16
+ * - Layout: [k0_c0_time, k0_c0_value, k0_c1_time, k0_c1_value, ..., k0_cS_time, k0_cS_value,
17
+ * k1_c0_time, k1_c0_value, ...]
18
+ *
19
+ * @augments Interpolant
20
+ */
21
+ class BezierInterpolant extends Interpolant {
22
+
23
+ interpolate_( i1, t0, t, t1 ) {
24
+
25
+ const result = this.resultBuffer;
26
+ const values = this.sampleValues;
27
+ const stride = this.valueSize;
28
+
29
+ const offset1 = i1 * stride;
30
+ const offset0 = offset1 - stride;
31
+
32
+ const settings = this.settings || this.DefaultSettings_;
33
+ const inTangents = settings.inTangents;
34
+ const outTangents = settings.outTangents;
35
+
36
+ // If no tangent data, fall back to linear interpolation
37
+ if ( ! inTangents || ! outTangents ) {
38
+
39
+ const weight1 = ( t - t0 ) / ( t1 - t0 );
40
+ const weight0 = 1 - weight1;
41
+
42
+ for ( let i = 0; i !== stride; ++ i ) {
43
+
44
+ result[ i ] = values[ offset0 + i ] * weight0 + values[ offset1 + i ] * weight1;
45
+
46
+ }
47
+
48
+ return result;
49
+
50
+ }
51
+
52
+ const tangentStride = stride * 2;
53
+ const i0 = i1 - 1;
54
+
55
+ for ( let i = 0; i !== stride; ++ i ) {
56
+
57
+ const v0 = values[ offset0 + i ];
58
+ const v1 = values[ offset1 + i ];
59
+
60
+ // outTangent of previous keyframe (C0)
61
+ const outTangentOffset = i0 * tangentStride + i * 2;
62
+ const c0x = outTangents[ outTangentOffset ];
63
+ const c0y = outTangents[ outTangentOffset + 1 ];
64
+
65
+ // inTangent of current keyframe (C1)
66
+ const inTangentOffset = i1 * tangentStride + i * 2;
67
+ const c1x = inTangents[ inTangentOffset ];
68
+ const c1y = inTangents[ inTangentOffset + 1 ];
69
+
70
+ // Solve for Bezier parameter s where Bx(s) = t using Newton-Raphson
71
+ let s = ( t - t0 ) / ( t1 - t0 );
72
+ let s2, s3, oneMinusS, oneMinusS2, oneMinusS3;
73
+
74
+ for ( let iter = 0; iter < 8; iter ++ ) {
75
+
76
+ s2 = s * s;
77
+ s3 = s2 * s;
78
+ oneMinusS = 1 - s;
79
+ oneMinusS2 = oneMinusS * oneMinusS;
80
+ oneMinusS3 = oneMinusS2 * oneMinusS;
81
+
82
+ // Bezier X(s) = (1-s)³·t0 + 3(1-s)²s·c0x + 3(1-s)s²·c1x + s³·t1
83
+ const bx = oneMinusS3 * t0 + 3 * oneMinusS2 * s * c0x + 3 * oneMinusS * s2 * c1x + s3 * t1;
84
+
85
+ const error = bx - t;
86
+ if ( Math.abs( error ) < 1e-10 ) break;
87
+
88
+ // Derivative dX/ds
89
+ const dbx = 3 * oneMinusS2 * ( c0x - t0 ) + 6 * oneMinusS * s * ( c1x - c0x ) + 3 * s2 * ( t1 - c1x );
90
+ if ( Math.abs( dbx ) < 1e-10 ) break;
91
+
92
+ s = s - error / dbx;
93
+ s = Math.max( 0, Math.min( 1, s ) );
94
+
95
+ }
96
+
97
+ // Evaluate Bezier Y(s)
98
+ result[ i ] = oneMinusS3 * v0 + 3 * oneMinusS2 * s * c0y + 3 * oneMinusS * s2 * c1y + s3 * v1;
99
+
100
+ }
101
+
102
+ return result;
103
+
104
+ }
105
+
106
+ }
107
+
108
+ export { BezierInterpolant };