@needle-tools/three 0.146.10 → 0.153.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 (865) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +39486 -20286
  3. package/build/three.js +39471 -20270
  4. package/build/three.min.js +3 -2
  5. package/build/three.module.js +6717 -5427
  6. package/build/three.module.min.js +6 -0
  7. package/examples/jsm/animation/AnimationClipCreator.js +5 -3
  8. package/examples/jsm/cameras/CinematicCamera.js +1 -2
  9. package/examples/jsm/capabilities/WebGPU.js +17 -5
  10. package/examples/jsm/controls/ArcballControls.js +1828 -1821
  11. package/examples/jsm/controls/MapControls.js +28 -0
  12. package/examples/jsm/controls/OrbitControls.js +26 -53
  13. package/examples/jsm/controls/PointerLockControls.js +70 -65
  14. package/examples/jsm/controls/TrackballControls.js +18 -4
  15. package/examples/jsm/controls/TransformControls.js +0 -1
  16. package/examples/jsm/csm/CSM.js +11 -5
  17. package/examples/jsm/csm/CSMShader.js +7 -6
  18. package/examples/jsm/effects/AnaglyphEffect.js +6 -20
  19. package/examples/jsm/effects/AsciiEffect.js +3 -6
  20. package/examples/jsm/effects/OutlineEffect.js +1 -15
  21. package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
  22. package/examples/jsm/exporters/DRACOExporter.js +53 -11
  23. package/examples/jsm/exporters/EXRExporter.js +3 -9
  24. package/examples/jsm/exporters/GLTFExporter.js +561 -154
  25. package/examples/jsm/exporters/KTX2Exporter.js +34 -23
  26. package/examples/jsm/exporters/MMDExporter.js +1 -1
  27. package/examples/jsm/exporters/PLYExporter.js +8 -1
  28. package/examples/jsm/exporters/STLExporter.js +8 -4
  29. package/examples/jsm/exporters/USDZExporter.js +305 -792
  30. package/examples/jsm/geometries/ConvexGeometry.js +0 -6
  31. package/examples/jsm/geometries/ParametricGeometry.js +10 -0
  32. package/examples/jsm/helpers/OctreeHelper.js +1 -0
  33. package/examples/jsm/helpers/ViewHelper.js +71 -57
  34. package/examples/jsm/interactive/HTMLMesh.js +16 -3
  35. package/examples/jsm/interactive/InteractiveGroup.js +1 -1
  36. package/examples/{js → jsm}/libs/basis/README.md +4 -4
  37. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  38. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  39. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  40. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  41. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  42. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  43. package/examples/jsm/libs/lil-gui.module.min.js +2 -2
  44. package/examples/jsm/libs/tween.module.js +803 -0
  45. package/examples/jsm/lights/IESSpotLight.js +25 -0
  46. package/examples/jsm/lights/LightProbeGenerator.js +11 -9
  47. package/examples/jsm/lines/LineSegments2.js +16 -10
  48. package/examples/jsm/loaders/3DMLoader.js +8 -5
  49. package/examples/jsm/loaders/3MFLoader.js +12 -11
  50. package/examples/jsm/loaders/AMFLoader.js +2 -3
  51. package/examples/jsm/loaders/BVHLoader.js +2 -2
  52. package/examples/jsm/loaders/ColladaLoader.js +15 -16
  53. package/examples/jsm/loaders/DRACOLoader.js +69 -18
  54. package/examples/jsm/loaders/EXRLoader.js +23 -24
  55. package/examples/jsm/loaders/FBXLoader.js +34 -50
  56. package/examples/jsm/loaders/GCodeLoader.js +1 -2
  57. package/examples/jsm/loaders/GLTFLoader.js +417 -895
  58. package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +684 -0
  59. package/examples/jsm/loaders/HDRCubeTextureLoader.js +4 -4
  60. package/examples/jsm/loaders/IESLoader.js +337 -0
  61. package/examples/jsm/loaders/KMZLoader.js +4 -4
  62. package/examples/jsm/loaders/KTX2Loader.js +145 -69
  63. package/examples/jsm/loaders/LDrawLoader.js +20 -18
  64. package/examples/jsm/loaders/LWOLoader.js +12 -29
  65. package/examples/jsm/loaders/LottieLoader.js +3 -1
  66. package/examples/jsm/loaders/MMDLoader.js +49 -18
  67. package/examples/jsm/loaders/MTLLoader.js +2 -2
  68. package/examples/jsm/loaders/MaterialXLoader.js +9 -3
  69. package/examples/jsm/loaders/NRRDLoader.js +33 -5
  70. package/examples/jsm/loaders/OBJLoader.js +1 -1
  71. package/examples/jsm/loaders/PCDLoader.js +26 -12
  72. package/examples/jsm/loaders/PDBLoader.js +7 -2
  73. package/examples/jsm/loaders/PLYLoader.js +254 -109
  74. package/examples/jsm/loaders/RGBELoader.js +3 -3
  75. package/examples/jsm/loaders/STLLoader.js +9 -5
  76. package/examples/jsm/loaders/SVGLoader.js +36 -27
  77. package/examples/jsm/loaders/TTFLoader.js +1 -8
  78. package/examples/jsm/loaders/TiltLoader.js +13 -7
  79. package/examples/jsm/loaders/USDZLoader.js +6 -6
  80. package/examples/jsm/loaders/VOXLoader.js +8 -2
  81. package/examples/jsm/loaders/VRMLLoader.js +44 -16
  82. package/examples/jsm/loaders/VTKLoader.js +19 -10
  83. package/examples/jsm/loaders/XYZLoader.js +9 -3
  84. package/examples/jsm/loaders/lwo/IFFParser.js +19 -19
  85. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -3
  86. package/examples/jsm/math/ConvexHull.js +3 -3
  87. package/examples/jsm/math/Lut.js +5 -4
  88. package/examples/jsm/math/MeshSurfaceSampler.js +7 -9
  89. package/examples/jsm/math/Octree.js +1 -1
  90. package/examples/jsm/misc/ConvexObjectBreaker.js +2 -8
  91. package/examples/jsm/misc/GPUComputationRenderer.js +6 -5
  92. package/examples/jsm/misc/MD2Character.js +2 -2
  93. package/examples/jsm/misc/MD2CharacterComplex.js +2 -2
  94. package/examples/jsm/misc/ProgressiveLightMap.js +12 -10
  95. package/examples/jsm/misc/RollerCoaster.js +7 -1
  96. package/examples/jsm/misc/Volume.js +20 -5
  97. package/examples/jsm/misc/VolumeSlice.js +3 -1
  98. package/examples/jsm/modifiers/CurveModifier.js +1 -0
  99. package/examples/jsm/modifiers/TessellateModifier.js +19 -19
  100. package/examples/jsm/nodes/Nodes.js +144 -335
  101. package/examples/jsm/nodes/accessors/BitangentNode.js +43 -16
  102. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +86 -0
  103. package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
  104. package/examples/jsm/nodes/accessors/CameraNode.js +12 -2
  105. package/examples/jsm/nodes/accessors/CubeTextureNode.js +27 -33
  106. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +58 -0
  107. package/examples/jsm/nodes/accessors/InstanceNode.js +41 -26
  108. package/examples/jsm/nodes/accessors/MaterialNode.js +155 -38
  109. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +16 -0
  110. package/examples/jsm/nodes/accessors/ModelNode.js +11 -0
  111. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +13 -14
  112. package/examples/jsm/nodes/accessors/NormalNode.js +35 -19
  113. package/examples/jsm/nodes/accessors/Object3DNode.js +32 -12
  114. package/examples/jsm/nodes/accessors/PointUVNode.js +6 -1
  115. package/examples/jsm/nodes/accessors/PositionNode.js +38 -23
  116. package/examples/jsm/nodes/accessors/ReferenceNode.js +21 -14
  117. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +11 -7
  118. package/examples/jsm/nodes/accessors/SkinningNode.js +43 -40
  119. package/examples/jsm/nodes/accessors/StorageBufferNode.js +6 -0
  120. package/examples/jsm/nodes/accessors/TangentNode.js +28 -20
  121. package/examples/jsm/nodes/accessors/TextureNode.js +80 -12
  122. package/examples/jsm/nodes/accessors/UVNode.js +6 -0
  123. package/examples/jsm/nodes/accessors/UserDataNode.js +6 -0
  124. package/examples/jsm/nodes/code/CodeNode.js +75 -0
  125. package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
  126. package/examples/jsm/nodes/{core → code}/FunctionCallNode.js +15 -1
  127. package/examples/jsm/nodes/{core → code}/FunctionNode.js +8 -7
  128. package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
  129. package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
  130. package/examples/jsm/nodes/core/ArrayUniformNode.js +3 -0
  131. package/examples/jsm/nodes/core/AttributeNode.js +17 -9
  132. package/examples/jsm/nodes/core/BypassNode.js +9 -2
  133. package/examples/jsm/nodes/core/CacheNode.js +46 -0
  134. package/examples/jsm/nodes/core/ConstNode.js +3 -0
  135. package/examples/jsm/nodes/core/ContextNode.js +8 -1
  136. package/examples/jsm/nodes/core/InputNode.js +26 -5
  137. package/examples/jsm/nodes/core/InstanceIndexNode.js +26 -2
  138. package/examples/jsm/nodes/core/LightingModel.js +16 -0
  139. package/examples/jsm/nodes/core/Node.js +129 -35
  140. package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
  141. package/examples/jsm/nodes/core/NodeBuilder.js +271 -121
  142. package/examples/jsm/nodes/core/NodeCache.js +26 -0
  143. package/examples/jsm/nodes/core/NodeFrame.js +56 -5
  144. package/examples/jsm/nodes/core/NodeUtils.js +115 -28
  145. package/examples/jsm/nodes/core/PropertyNode.js +19 -2
  146. package/examples/jsm/nodes/core/StackNode.js +99 -0
  147. package/examples/jsm/nodes/core/TempNode.js +11 -3
  148. package/examples/jsm/nodes/core/UniformNode.js +16 -1
  149. package/examples/jsm/nodes/core/VarNode.js +21 -29
  150. package/examples/jsm/nodes/core/VaryingNode.js +15 -2
  151. package/examples/jsm/nodes/core/constants.js +6 -0
  152. package/examples/jsm/nodes/display/BlendModeNode.js +25 -11
  153. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +30 -14
  154. package/examples/jsm/nodes/display/ColorSpaceNode.js +39 -27
  155. package/examples/jsm/nodes/display/FrontFacingNode.js +7 -1
  156. package/examples/jsm/nodes/display/NormalMapNode.js +31 -18
  157. package/examples/jsm/nodes/display/PosterizeNode.js +10 -3
  158. package/examples/jsm/nodes/display/ToneMappingNode.js +101 -11
  159. package/examples/jsm/nodes/display/ViewportNode.js +27 -18
  160. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +30 -0
  161. package/examples/jsm/nodes/display/ViewportTextureNode.js +67 -0
  162. package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
  163. package/examples/jsm/nodes/fog/FogNode.js +12 -6
  164. package/examples/jsm/nodes/fog/FogRangeNode.js +12 -5
  165. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +30 -0
  166. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -13
  167. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  168. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -6
  169. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +4 -4
  170. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +3 -3
  171. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +7 -5
  172. package/examples/jsm/nodes/functions/PhongLightingModel.js +28 -0
  173. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +35 -36
  174. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +4 -3
  175. package/examples/jsm/nodes/functions/material/getRoughness.js +4 -4
  176. package/examples/jsm/nodes/geometry/RangeNode.js +50 -55
  177. package/examples/jsm/nodes/gpgpu/ComputeNode.js +9 -2
  178. package/examples/jsm/nodes/lighting/AONode.js +5 -3
  179. package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
  180. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +114 -5
  181. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +43 -0
  182. package/examples/jsm/nodes/lighting/EnvironmentNode.js +121 -35
  183. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +15 -10
  184. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
  185. package/examples/jsm/nodes/lighting/LightNode.js +57 -0
  186. package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
  187. package/examples/jsm/nodes/lighting/LightingContextNode.js +30 -8
  188. package/examples/jsm/nodes/lighting/LightingNode.js +3 -1
  189. package/examples/jsm/nodes/lighting/LightsNode.js +18 -10
  190. package/examples/jsm/nodes/lighting/PointLightNode.js +71 -0
  191. package/examples/jsm/nodes/lighting/SpotLightNode.js +92 -0
  192. package/examples/jsm/nodes/loaders/NodeLoader.js +5 -4
  193. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +4 -20
  194. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +6 -9
  195. package/examples/jsm/nodes/materials/Materials.js +11 -55
  196. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +5 -11
  197. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +48 -0
  198. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +74 -0
  199. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  200. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +21 -96
  201. package/examples/jsm/nodes/materials/NodeMaterial.js +284 -62
  202. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +7 -1
  203. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +29 -25
  204. package/examples/jsm/nodes/materialx/MaterialXNodes.js +31 -22
  205. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +1 -1
  206. package/examples/jsm/nodes/materialx/lib/mx_noise.js +2 -1
  207. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +2 -1
  208. package/examples/jsm/nodes/math/CondNode.js +43 -17
  209. package/examples/jsm/nodes/math/MathNode.js +178 -73
  210. package/examples/jsm/nodes/math/OperatorNode.js +52 -2
  211. package/examples/jsm/nodes/procedural/CheckerNode.js +14 -6
  212. package/examples/jsm/nodes/shadernode/ShaderNode.js +186 -63
  213. package/examples/jsm/nodes/utils/ArrayElementNode.js +4 -2
  214. package/examples/jsm/nodes/utils/ConvertNode.js +19 -1
  215. package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
  216. package/examples/jsm/nodes/utils/EquirectUVNode.js +10 -4
  217. package/examples/jsm/nodes/utils/JoinNode.js +4 -1
  218. package/examples/jsm/nodes/utils/LoopNode.js +186 -0
  219. package/examples/jsm/nodes/utils/MatcapUVNode.js +11 -4
  220. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +18 -5
  221. package/examples/jsm/nodes/utils/OscNode.js +21 -14
  222. package/examples/jsm/nodes/utils/PackingNode.js +55 -0
  223. package/examples/jsm/nodes/utils/RemapNode.js +13 -5
  224. package/examples/jsm/nodes/utils/RotateUVNode.js +18 -7
  225. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
  226. package/examples/jsm/nodes/utils/SplitNode.js +7 -5
  227. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +15 -30
  228. package/examples/jsm/nodes/utils/TimerNode.js +16 -6
  229. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +21 -10
  230. package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
  231. package/examples/jsm/objects/Lensflare.js +3 -4
  232. package/examples/jsm/objects/MarchingCubes.js +5 -1
  233. package/examples/jsm/objects/Reflector.js +7 -4
  234. package/examples/jsm/objects/Refractor.js +4 -4
  235. package/examples/jsm/objects/ShadowMesh.js +3 -3
  236. package/examples/jsm/objects/Water.js +2 -1
  237. package/examples/jsm/physics/AmmoPhysics.js +27 -28
  238. package/examples/jsm/physics/RapierPhysics.js +199 -0
  239. package/examples/jsm/postprocessing/AfterimagePass.js +3 -2
  240. package/examples/jsm/postprocessing/BloomPass.js +7 -4
  241. package/examples/jsm/postprocessing/BokehPass.js +3 -8
  242. package/examples/jsm/postprocessing/DotScreenPass.js +1 -2
  243. package/examples/jsm/postprocessing/EffectComposer.js +5 -95
  244. package/examples/jsm/postprocessing/FilmPass.js +1 -2
  245. package/examples/jsm/postprocessing/GlitchPass.js +0 -2
  246. package/examples/jsm/postprocessing/HalftonePass.js +0 -6
  247. package/examples/jsm/postprocessing/OutlinePass.js +7 -7
  248. package/examples/jsm/postprocessing/OutputPass.js +72 -0
  249. package/examples/jsm/postprocessing/Pass.js +2 -0
  250. package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
  251. package/examples/jsm/postprocessing/SAOPass.js +4 -26
  252. package/examples/jsm/postprocessing/SMAAPass.js +5 -8
  253. package/examples/jsm/postprocessing/SSAARenderPass.js +15 -6
  254. package/examples/jsm/postprocessing/SSAOPass.js +4 -14
  255. package/examples/jsm/postprocessing/SSRPass.js +3 -7
  256. package/examples/jsm/postprocessing/SavePass.js +2 -3
  257. package/examples/jsm/postprocessing/ShaderPass.js +1 -0
  258. package/examples/jsm/postprocessing/TAARenderPass.js +3 -2
  259. package/examples/jsm/postprocessing/TexturePass.js +0 -2
  260. package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -11
  261. package/examples/jsm/renderers/CSS2DRenderer.js +6 -1
  262. package/examples/jsm/renderers/CSS3DRenderer.js +27 -5
  263. package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +4 -4
  264. package/examples/jsm/renderers/common/Attributes.js +75 -0
  265. package/examples/jsm/renderers/common/Backend.js +160 -0
  266. package/examples/jsm/renderers/common/Background.js +133 -0
  267. package/examples/jsm/renderers/common/Binding.js +11 -0
  268. package/examples/jsm/renderers/common/Bindings.js +169 -0
  269. package/examples/jsm/renderers/common/Buffer.js +38 -0
  270. package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
  271. package/examples/jsm/renderers/common/ChainMap.js +89 -0
  272. package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
  273. package/examples/jsm/renderers/common/Constants.js +14 -0
  274. package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
  275. package/examples/jsm/renderers/common/DataMap.js +54 -0
  276. package/examples/jsm/renderers/common/Geometries.js +215 -0
  277. package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
  278. package/examples/jsm/renderers/common/Pipeline.js +13 -0
  279. package/examples/jsm/renderers/common/Pipelines.js +309 -0
  280. package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
  281. package/examples/jsm/renderers/common/RenderContext.js +37 -0
  282. package/examples/jsm/renderers/common/RenderContexts.js +38 -0
  283. package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +26 -47
  284. package/examples/jsm/renderers/common/RenderLists.js +38 -0
  285. package/examples/jsm/renderers/common/RenderObject.js +95 -0
  286. package/examples/jsm/renderers/common/RenderObjects.js +92 -0
  287. package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
  288. package/examples/jsm/renderers/common/RenderTarget.js +15 -0
  289. package/examples/jsm/renderers/common/Renderer.js +822 -0
  290. package/examples/jsm/renderers/common/SampledTexture.js +80 -0
  291. package/examples/jsm/renderers/common/Sampler.js +18 -0
  292. package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
  293. package/examples/jsm/renderers/common/Textures.js +206 -0
  294. package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
  295. package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
  296. package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
  297. package/examples/jsm/renderers/common/nodes/NodeRender.js +302 -0
  298. package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
  299. package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
  300. package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
  301. package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
  302. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +35 -31
  303. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +765 -0
  304. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -987
  305. package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +117 -90
  306. package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
  307. package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
  308. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +251 -0
  309. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
  310. package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +73 -12
  311. package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +135 -285
  312. package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +5 -25
  313. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +855 -0
  314. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +88 -0
  315. package/examples/jsm/shaders/BleachBypassShader.js +2 -0
  316. package/examples/jsm/shaders/BokehShader2.js +3 -0
  317. package/examples/jsm/shaders/ColorifyShader.js +2 -0
  318. package/examples/jsm/shaders/ConvolutionShader.js +2 -0
  319. package/examples/jsm/shaders/CopyShader.js +2 -0
  320. package/examples/jsm/shaders/DotScreenShader.js +2 -0
  321. package/examples/jsm/shaders/ExposureShader.js +44 -0
  322. package/examples/jsm/shaders/FilmShader.js +2 -0
  323. package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
  324. package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
  325. package/examples/jsm/shaders/MMDToonShader.js +15 -4
  326. package/examples/jsm/shaders/OutputShader.js +61 -0
  327. package/examples/jsm/shaders/RGBShiftShader.js +4 -2
  328. package/examples/jsm/shaders/SepiaShader.js +2 -0
  329. package/examples/jsm/shaders/ToonShader.js +13 -5
  330. package/examples/jsm/shaders/VelocityShader.js +1 -1
  331. package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
  332. package/examples/jsm/shaders/VignetteShader.js +2 -0
  333. package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
  334. package/examples/jsm/utils/BufferGeometryUtils.js +54 -36
  335. package/examples/jsm/utils/LDrawUtils.js +4 -4
  336. package/examples/jsm/utils/PackedPhongMaterial.js +5 -78
  337. package/examples/jsm/utils/SceneUtils.js +8 -4
  338. package/examples/jsm/utils/SkeletonUtils.js +27 -210
  339. package/examples/jsm/utils/TextureUtils.js +41 -40
  340. package/examples/jsm/webxr/VRButton.js +1 -2
  341. package/examples/jsm/webxr/XRButton.js +198 -0
  342. package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
  343. package/examples/jsm/webxr/XRPlanes.js +100 -0
  344. package/package.json +34 -87
  345. package/src/Three.Legacy.js +19 -110
  346. package/src/Three.js +4 -3
  347. package/src/animation/AnimationUtils.js +13 -1
  348. package/src/audio/Audio.js +7 -2
  349. package/src/audio/PositionalAudio.js +8 -0
  350. package/src/cameras/Camera.js +5 -0
  351. package/src/cameras/CubeCamera.js +76 -13
  352. package/src/cameras/OrthographicCamera.js +1 -1
  353. package/src/cameras/PerspectiveCamera.js +1 -1
  354. package/src/constants.js +22 -2
  355. package/src/core/BufferAttribute.js +150 -9
  356. package/src/core/BufferGeometry.js +4 -10
  357. package/src/core/GLBufferAttribute.js +2 -0
  358. package/src/core/InterleavedBufferAttribute.js +5 -5
  359. package/src/core/Object3D.js +37 -8
  360. package/src/extras/DataUtils.js +7 -1
  361. package/src/extras/ImageUtils.js +2 -2
  362. package/src/extras/PMREMGenerator.js +5 -5
  363. package/src/extras/core/Curve.js +1 -1
  364. package/src/extras/curves/LineCurve.js +6 -4
  365. package/src/extras/curves/LineCurve3.js +13 -0
  366. package/src/geometries/BoxGeometry.js +10 -0
  367. package/src/geometries/CircleGeometry.js +11 -1
  368. package/src/geometries/ConeGeometry.js +1 -1
  369. package/src/geometries/CylinderGeometry.js +11 -1
  370. package/src/geometries/EdgesGeometry.js +10 -0
  371. package/src/geometries/ExtrudeGeometry.js +11 -1
  372. package/src/geometries/LatheGeometry.js +10 -0
  373. package/src/geometries/PlaneGeometry.js +10 -0
  374. package/src/geometries/PolyhedronGeometry.js +11 -1
  375. package/src/geometries/RingGeometry.js +11 -1
  376. package/src/geometries/ShapeGeometry.js +11 -1
  377. package/src/geometries/SphereGeometry.js +12 -2
  378. package/src/geometries/TorusGeometry.js +11 -1
  379. package/src/geometries/TorusKnotGeometry.js +10 -0
  380. package/src/geometries/TubeGeometry.js +10 -0
  381. package/src/geometries/WireframeGeometry.js +10 -0
  382. package/src/helpers/Box3Helper.js +1 -2
  383. package/src/lights/DirectionalLight.js +1 -1
  384. package/src/lights/HemisphereLight.js +1 -1
  385. package/src/lights/SpotLight.js +1 -1
  386. package/src/loaders/AudioLoader.js +14 -8
  387. package/src/loaders/CubeTextureLoader.js +2 -0
  388. package/src/loaders/DataTextureLoader.js +5 -1
  389. package/src/loaders/MaterialLoader.js +8 -0
  390. package/src/loaders/ObjectLoader.js +10 -2
  391. package/src/materials/LineBasicMaterial.js +4 -0
  392. package/src/materials/Material.js +16 -4
  393. package/src/materials/MeshDistanceMaterial.js +0 -9
  394. package/src/materials/MeshPhysicalMaterial.js +32 -6
  395. package/src/materials/ShaderMaterial.js +6 -1
  396. package/src/math/Box2.js +3 -2
  397. package/src/math/Box3.js +49 -64
  398. package/src/math/Color.js +88 -66
  399. package/src/math/ColorManagement.js +75 -16
  400. package/src/math/Euler.js +2 -11
  401. package/src/math/Frustum.js +29 -5
  402. package/src/math/MathUtils.js +43 -1
  403. package/src/math/Matrix3.js +26 -6
  404. package/src/math/Matrix4.js +74 -19
  405. package/src/math/Plane.js +2 -2
  406. package/src/math/Quaternion.js +6 -0
  407. package/src/math/Ray.js +7 -7
  408. package/src/math/Triangle.js +37 -7
  409. package/src/math/Vector2.js +16 -0
  410. package/src/math/Vector3.js +10 -0
  411. package/src/math/interpolants/CubicInterpolant.js +1 -2
  412. package/src/objects/InstancedMesh.js +82 -1
  413. package/src/objects/Mesh.js +108 -76
  414. package/src/objects/Skeleton.js +1 -1
  415. package/src/objects/SkinnedMesh.js +123 -8
  416. package/src/objects/Sprite.js +1 -1
  417. package/src/renderers/WebGLCubeRenderTarget.js +12 -3
  418. package/src/renderers/WebGLMultipleRenderTargets.js +4 -2
  419. package/src/renderers/WebGLRenderTarget.js +14 -2
  420. package/src/renderers/WebGLRenderer.js +1433 -1236
  421. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +1 -1
  422. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  423. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +0 -271
  424. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +5 -5
  425. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +2 -10
  426. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +5 -5
  427. package/src/renderers/shaders/ShaderChunk/common.glsl.js +32 -0
  428. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +1 -1
  429. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +1 -1
  430. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +1 -1
  431. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
  432. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
  433. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
  434. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +10 -2
  435. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -11
  436. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +39 -13
  437. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +306 -10
  438. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -10
  439. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +9 -1
  440. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +10 -2
  441. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +1 -1
  442. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +32 -10
  443. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -13
  444. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +7 -7
  445. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -2
  446. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +11 -5
  447. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +1 -1
  448. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +4 -11
  449. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +2 -2
  450. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +39 -34
  451. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +1 -1
  452. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  453. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +5 -5
  454. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +101 -16
  455. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +113 -1
  456. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +134 -6
  457. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +116 -1
  458. package/src/renderers/shaders/ShaderChunk.js +0 -6
  459. package/src/renderers/shaders/ShaderLib/background.glsl.js +0 -8
  460. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +5 -0
  461. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -4
  462. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -3
  463. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -3
  464. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -3
  465. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +16 -12
  466. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -3
  467. package/src/renderers/shaders/ShaderLib/points.glsl.js +13 -0
  468. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +5 -0
  469. package/src/renderers/shaders/ShaderLib.js +18 -4
  470. package/src/renderers/shaders/UniformsLib.js +27 -15
  471. package/src/renderers/shaders/UniformsUtils.js +12 -3
  472. package/src/renderers/webgl/WebGLBackground.js +23 -12
  473. package/src/renderers/webgl/WebGLBindingStates.js +13 -5
  474. package/src/renderers/webgl/WebGLCapabilities.js +1 -2
  475. package/src/renderers/webgl/WebGLClipping.js +7 -3
  476. package/src/renderers/webgl/WebGLGeometries.js +12 -0
  477. package/src/renderers/webgl/WebGLInfo.js +0 -1
  478. package/src/renderers/webgl/WebGLLights.js +2 -2
  479. package/src/renderers/webgl/WebGLMaterials.js +123 -234
  480. package/src/renderers/webgl/WebGLMorphtargets.js +1 -1
  481. package/src/renderers/webgl/WebGLProgram.js +130 -48
  482. package/src/renderers/webgl/WebGLPrograms.js +210 -130
  483. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  484. package/src/renderers/webgl/WebGLShadowMap.js +40 -27
  485. package/src/renderers/webgl/WebGLState.js +23 -9
  486. package/src/renderers/webgl/WebGLTextures.js +39 -19
  487. package/src/renderers/webgl/WebGLUniformsGroups.js +74 -33
  488. package/src/renderers/webgl/WebGLUtils.js +41 -29
  489. package/src/renderers/webxr/WebXRController.js +3 -0
  490. package/src/renderers/webxr/WebXRManager.js +85 -141
  491. package/src/scenes/Scene.js +4 -6
  492. package/src/textures/CompressedTexture.js +2 -2
  493. package/src/textures/CubeTexture.js +2 -2
  494. package/src/textures/DataTexture.js +2 -2
  495. package/src/textures/DepthTexture.js +22 -0
  496. package/src/textures/FramebufferTexture.js +1 -3
  497. package/src/textures/Source.js +4 -0
  498. package/src/textures/Texture.js +43 -13
  499. package/src/utils.js +13 -1
  500. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  501. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  502. package/examples/fonts/open-sans/open-sans.css +0 -9
  503. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  504. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +0 -3966
  505. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  506. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  507. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  508. package/examples/fonts/tabler-icons/tabler-icons.min.css +0 -4
  509. package/examples/js/animation/AnimationClipCreator.js +0 -89
  510. package/examples/js/animation/CCDIKSolver.js +0 -416
  511. package/examples/js/animation/MMDAnimationHelper.js +0 -1046
  512. package/examples/js/animation/MMDPhysics.js +0 -1174
  513. package/examples/js/cameras/CinematicCamera.js +0 -168
  514. package/examples/js/controls/ArcballControls.js +0 -2770
  515. package/examples/js/controls/DragControls.js +0 -205
  516. package/examples/js/controls/FirstPersonControls.js +0 -312
  517. package/examples/js/controls/FlyControls.js +0 -321
  518. package/examples/js/controls/OrbitControls.js +0 -1065
  519. package/examples/js/controls/PointerLockControls.js +0 -144
  520. package/examples/js/controls/TrackballControls.js +0 -729
  521. package/examples/js/controls/TransformControls.js +0 -1301
  522. package/examples/js/csm/CSM.js +0 -347
  523. package/examples/js/csm/CSMFrustum.js +0 -127
  524. package/examples/js/csm/CSMHelper.js +0 -165
  525. package/examples/js/csm/CSMShader.js +0 -253
  526. package/examples/js/curves/CurveExtras.js +0 -348
  527. package/examples/js/curves/NURBSCurve.js +0 -63
  528. package/examples/js/curves/NURBSSurface.js +0 -48
  529. package/examples/js/curves/NURBSUtils.js +0 -439
  530. package/examples/js/effects/AnaglyphEffect.js +0 -86
  531. package/examples/js/effects/AsciiEffect.js +0 -260
  532. package/examples/js/effects/OutlineEffect.js +0 -450
  533. package/examples/js/effects/ParallaxBarrierEffect.js +0 -62
  534. package/examples/js/effects/PeppersGhostEffect.js +0 -139
  535. package/examples/js/effects/StereoEffect.js +0 -46
  536. package/examples/js/environments/DebugEnvironment.js +0 -53
  537. package/examples/js/environments/RoomEnvironment.js +0 -124
  538. package/examples/js/exporters/ColladaExporter.js +0 -487
  539. package/examples/js/exporters/DRACOExporter.js +0 -212
  540. package/examples/js/exporters/EXRExporter.js +0 -455
  541. package/examples/js/exporters/GLTFExporter.js +0 -2425
  542. package/examples/js/exporters/MMDExporter.js +0 -187
  543. package/examples/js/exporters/OBJExporter.js +0 -260
  544. package/examples/js/exporters/PLYExporter.js +0 -427
  545. package/examples/js/exporters/STLExporter.js +0 -188
  546. package/examples/js/exporters/USDZExporter.js +0 -608
  547. package/examples/js/geometries/BoxLineGeometry.js +0 -59
  548. package/examples/js/geometries/ConvexGeometry.js +0 -53
  549. package/examples/js/geometries/DecalGeometry.js +0 -324
  550. package/examples/js/geometries/LightningStrike.js +0 -861
  551. package/examples/js/geometries/ParametricGeometries.js +0 -216
  552. package/examples/js/geometries/ParametricGeometry.js +0 -121
  553. package/examples/js/geometries/RoundedBoxGeometry.js +0 -142
  554. package/examples/js/geometries/TeapotGeometry.js +0 -335
  555. package/examples/js/geometries/TextGeometry.js +0 -53
  556. package/examples/js/helpers/LightProbeHelper.js +0 -48
  557. package/examples/js/helpers/OctreeHelper.js +0 -76
  558. package/examples/js/helpers/PositionalAudioHelper.js +0 -91
  559. package/examples/js/helpers/RectAreaLightHelper.js +0 -73
  560. package/examples/js/helpers/VertexNormalsHelper.js +0 -74
  561. package/examples/js/helpers/VertexTangentsHelper.js +0 -68
  562. package/examples/js/helpers/ViewHelper.js +0 -281
  563. package/examples/js/interactive/HTMLMesh.js +0 -497
  564. package/examples/js/interactive/InteractiveGroup.js +0 -95
  565. package/examples/js/interactive/SelectionBox.js +0 -195
  566. package/examples/js/interactive/SelectionHelper.js +0 -83
  567. package/examples/js/libs/chevrotain.min.js +0 -3
  568. package/examples/js/libs/draco/draco_decoder.js +0 -52
  569. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  570. package/examples/js/libs/draco/draco_wasm_wrapper.js +0 -104
  571. package/examples/js/libs/draco/gltf/draco_decoder.js +0 -48
  572. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  573. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +0 -104
  574. package/examples/js/libs/fflate.min.js +0 -7
  575. package/examples/js/libs/ktx-parse.umd.js +0 -1
  576. package/examples/js/libs/meshopt_decoder.js +0 -188
  577. package/examples/js/libs/opentype.min.js +0 -1
  578. package/examples/js/libs/stats.min.js +0 -5
  579. package/examples/js/lights/LightProbeGenerator.js +0 -221
  580. package/examples/js/lights/RectAreaLightUniformsLib.js +0 -60
  581. package/examples/js/lines/Line2.js +0 -19
  582. package/examples/js/lines/LineGeometry.js +0 -69
  583. package/examples/js/lines/LineMaterial.js +0 -635
  584. package/examples/js/lines/LineSegments2.js +0 -311
  585. package/examples/js/lines/LineSegmentsGeometry.js +0 -198
  586. package/examples/js/lines/Wireframe.js +0 -47
  587. package/examples/js/lines/WireframeGeometry2.js +0 -20
  588. package/examples/js/loaders/3DMLoader.js +0 -1273
  589. package/examples/js/loaders/3MFLoader.js +0 -1306
  590. package/examples/js/loaders/AMFLoader.js +0 -504
  591. package/examples/js/loaders/BVHLoader.js +0 -395
  592. package/examples/js/loaders/BasisTextureLoader.js +0 -706
  593. package/examples/js/loaders/ColladaLoader.js +0 -3663
  594. package/examples/js/loaders/DDSLoader.js +0 -244
  595. package/examples/js/loaders/DRACOLoader.js +0 -511
  596. package/examples/js/loaders/EXRLoader.js +0 -2039
  597. package/examples/js/loaders/FBXLoader.js +0 -3680
  598. package/examples/js/loaders/FontLoader.js +0 -160
  599. package/examples/js/loaders/GCodeLoader.js +0 -255
  600. package/examples/js/loaders/GLTFLoader.js +0 -4108
  601. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -87
  602. package/examples/js/loaders/KMZLoader.js +0 -121
  603. package/examples/js/loaders/KTXLoader.js +0 -159
  604. package/examples/js/loaders/LDrawLoader.js +0 -2263
  605. package/examples/js/loaders/LUT3dlLoader.js +0 -135
  606. package/examples/js/loaders/LUTCubeLoader.js +0 -132
  607. package/examples/js/loaders/LWOLoader.js +0 -901
  608. package/examples/js/loaders/LogLuvLoader.js +0 -715
  609. package/examples/js/loaders/LottieLoader.js +0 -62
  610. package/examples/js/loaders/MD2Loader.js +0 -248
  611. package/examples/js/loaders/MDDLoader.js +0 -91
  612. package/examples/js/loaders/MMDLoader.js +0 -1915
  613. package/examples/js/loaders/MTLLoader.js +0 -472
  614. package/examples/js/loaders/MaterialXLoader.js +0 -392
  615. package/examples/js/loaders/NRRDLoader.js +0 -609
  616. package/examples/js/loaders/OBJLoader.js +0 -789
  617. package/examples/js/loaders/PCDLoader.js +0 -413
  618. package/examples/js/loaders/PDBLoader.js +0 -317
  619. package/examples/js/loaders/PLYLoader.js +0 -532
  620. package/examples/js/loaders/PRWMLoader.js +0 -249
  621. package/examples/js/loaders/PVRLoader.js +0 -218
  622. package/examples/js/loaders/RGBELoader.js +0 -442
  623. package/examples/js/loaders/RGBMLoader.js +0 -1354
  624. package/examples/js/loaders/STLLoader.js +0 -364
  625. package/examples/js/loaders/SVGLoader.js +0 -2783
  626. package/examples/js/loaders/TDSLoader.js +0 -992
  627. package/examples/js/loaders/TGALoader.js +0 -484
  628. package/examples/js/loaders/TIFFLoader.js +0 -30
  629. package/examples/js/loaders/TTFLoader.js +0 -203
  630. package/examples/js/loaders/TiltLoader.js +0 -459
  631. package/examples/js/loaders/VOXLoader.js +0 -240
  632. package/examples/js/loaders/VRMLLoader.js +0 -3140
  633. package/examples/js/loaders/VTKLoader.js +0 -1078
  634. package/examples/js/loaders/XYZLoader.js +0 -89
  635. package/examples/js/loaders/lwo/IFFParser.js +0 -1067
  636. package/examples/js/loaders/lwo/LWO2Parser.js +0 -397
  637. package/examples/js/loaders/lwo/LWO3Parser.js +0 -360
  638. package/examples/js/materials/MeshGouraudMaterial.js +0 -387
  639. package/examples/js/math/Capsule.js +0 -103
  640. package/examples/js/math/ColorConverter.js +0 -33
  641. package/examples/js/math/ConvexHull.js +0 -1154
  642. package/examples/js/math/ImprovedNoise.js +0 -66
  643. package/examples/js/math/Lut.js +0 -164
  644. package/examples/js/math/MeshSurfaceSampler.js +0 -171
  645. package/examples/js/math/OBB.js +0 -382
  646. package/examples/js/math/Octree.js +0 -410
  647. package/examples/js/math/SimplexNoise.js +0 -445
  648. package/examples/js/misc/ConvexObjectBreaker.js +0 -474
  649. package/examples/js/misc/GPUComputationRenderer.js +0 -393
  650. package/examples/js/misc/Gyroscope.js +0 -56
  651. package/examples/js/misc/MD2Character.js +0 -235
  652. package/examples/js/misc/MD2CharacterComplex.js +0 -513
  653. package/examples/js/misc/MorphAnimMesh.js +0 -63
  654. package/examples/js/misc/MorphBlendMesh.js +0 -265
  655. package/examples/js/misc/ProgressiveLightMap.js +0 -335
  656. package/examples/js/misc/RollerCoaster.js +0 -430
  657. package/examples/js/misc/TubePainter.js +0 -167
  658. package/examples/js/misc/Volume.js +0 -437
  659. package/examples/js/misc/VolumeSlice.js +0 -214
  660. package/examples/js/modifiers/CurveModifier.js +0 -309
  661. package/examples/js/modifiers/EdgeSplitModifier.js +0 -228
  662. package/examples/js/modifiers/SimplifyModifier.js +0 -465
  663. package/examples/js/modifiers/TessellateModifier.js +0 -276
  664. package/examples/js/objects/GroundProjectedEnv.js +0 -181
  665. package/examples/js/objects/Lensflare.js +0 -356
  666. package/examples/js/objects/LightningStorm.js +0 -206
  667. package/examples/js/objects/MarchingCubes.js +0 -759
  668. package/examples/js/objects/Reflector.js +0 -216
  669. package/examples/js/objects/ReflectorForSSRPass.js +0 -315
  670. package/examples/js/objects/Refractor.js +0 -283
  671. package/examples/js/objects/ShadowMesh.js +0 -59
  672. package/examples/js/objects/Sky.js +0 -218
  673. package/examples/js/objects/Water.js +0 -292
  674. package/examples/js/objects/Water2.js +0 -307
  675. package/examples/js/physics/AmmoPhysics.js +0 -259
  676. package/examples/js/physics/OimoPhysics.js +0 -217
  677. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +0 -335
  678. package/examples/js/postprocessing/AfterimagePass.js +0 -77
  679. package/examples/js/postprocessing/BloomPass.js +0 -135
  680. package/examples/js/postprocessing/BokehPass.js +0 -120
  681. package/examples/js/postprocessing/ClearPass.js +0 -39
  682. package/examples/js/postprocessing/CubeTexturePass.js +0 -60
  683. package/examples/js/postprocessing/DotScreenPass.js +0 -51
  684. package/examples/js/postprocessing/EffectComposer.js +0 -272
  685. package/examples/js/postprocessing/FilmPass.js +0 -52
  686. package/examples/js/postprocessing/GlitchPass.js +0 -104
  687. package/examples/js/postprocessing/HalftonePass.js +0 -75
  688. package/examples/js/postprocessing/LUTPass.js +0 -171
  689. package/examples/js/postprocessing/MaskPass.js +0 -95
  690. package/examples/js/postprocessing/OutlinePass.js +0 -598
  691. package/examples/js/postprocessing/Pass.js +0 -72
  692. package/examples/js/postprocessing/RenderPass.js +0 -70
  693. package/examples/js/postprocessing/SAOPass.js +0 -374
  694. package/examples/js/postprocessing/SMAAPass.js +0 -170
  695. package/examples/js/postprocessing/SSAARenderPass.js +0 -156
  696. package/examples/js/postprocessing/SSAOPass.js +0 -365
  697. package/examples/js/postprocessing/SSRPass.js +0 -567
  698. package/examples/js/postprocessing/SavePass.js +0 -59
  699. package/examples/js/postprocessing/ShaderPass.js +0 -64
  700. package/examples/js/postprocessing/TAARenderPass.js +0 -130
  701. package/examples/js/postprocessing/TexturePass.js +0 -49
  702. package/examples/js/postprocessing/UnrealBloomPass.js +0 -375
  703. package/examples/js/renderers/CSS2DRenderer.js +0 -178
  704. package/examples/js/renderers/CSS3DRenderer.js +0 -237
  705. package/examples/js/renderers/Projector.js +0 -818
  706. package/examples/js/renderers/SVGRenderer.js +0 -491
  707. package/examples/js/shaders/ACESFilmicToneMappingShader.js +0 -89
  708. package/examples/js/shaders/AfterimageShader.js +0 -60
  709. package/examples/js/shaders/BasicShader.js +0 -27
  710. package/examples/js/shaders/BleachBypassShader.js +0 -62
  711. package/examples/js/shaders/BlendShader.js +0 -54
  712. package/examples/js/shaders/BokehShader.js +0 -156
  713. package/examples/js/shaders/BokehShader2.js +0 -419
  714. package/examples/js/shaders/BrightnessContrastShader.js +0 -58
  715. package/examples/js/shaders/ColorCorrectionShader.js +0 -52
  716. package/examples/js/shaders/ColorifyShader.js +0 -47
  717. package/examples/js/shaders/ConvolutionShader.js +0 -92
  718. package/examples/js/shaders/CopyShader.js +0 -45
  719. package/examples/js/shaders/DOFMipMapShader.js +0 -60
  720. package/examples/js/shaders/DepthLimitedBlurShader.js +0 -173
  721. package/examples/js/shaders/DigitalGlitch.js +0 -127
  722. package/examples/js/shaders/DotScreenShader.js +0 -72
  723. package/examples/js/shaders/FXAAShader.js +0 -284
  724. package/examples/js/shaders/FilmShader.js +0 -110
  725. package/examples/js/shaders/FocusShader.js +0 -95
  726. package/examples/js/shaders/FreiChenShader.js +0 -93
  727. package/examples/js/shaders/GammaCorrectionShader.js +0 -41
  728. package/examples/js/shaders/GodRaysShader.js +0 -284
  729. package/examples/js/shaders/HalftoneShader.js +0 -336
  730. package/examples/js/shaders/HorizontalBlurShader.js +0 -59
  731. package/examples/js/shaders/HorizontalTiltShiftShader.js +0 -65
  732. package/examples/js/shaders/HueSaturationShader.js +0 -69
  733. package/examples/js/shaders/KaleidoShader.js +0 -60
  734. package/examples/js/shaders/LuminosityHighPassShader.js +0 -67
  735. package/examples/js/shaders/LuminosityShader.js +0 -46
  736. package/examples/js/shaders/MMDToonShader.js +0 -96
  737. package/examples/js/shaders/MirrorShader.js +0 -56
  738. package/examples/js/shaders/NormalMapShader.js +0 -55
  739. package/examples/js/shaders/RGBShiftShader.js +0 -56
  740. package/examples/js/shaders/SAOShader.js +0 -209
  741. package/examples/js/shaders/SMAAShader.js +0 -454
  742. package/examples/js/shaders/SSAOShader.js +0 -295
  743. package/examples/js/shaders/SSRShader.js +0 -381
  744. package/examples/js/shaders/SepiaShader.js +0 -52
  745. package/examples/js/shaders/SobelOperatorShader.js +0 -88
  746. package/examples/js/shaders/SubsurfaceScatteringShader.js +0 -49
  747. package/examples/js/shaders/TechnicolorShader.js +0 -43
  748. package/examples/js/shaders/ToneMapShader.js +0 -84
  749. package/examples/js/shaders/ToonShader.js +0 -335
  750. package/examples/js/shaders/TriangleBlurShader.js +0 -70
  751. package/examples/js/shaders/UnpackDepthRGBAShader.js +0 -47
  752. package/examples/js/shaders/VelocityShader.js +0 -126
  753. package/examples/js/shaders/VerticalBlurShader.js +0 -59
  754. package/examples/js/shaders/VerticalTiltShiftShader.js +0 -65
  755. package/examples/js/shaders/VignetteShader.js +0 -53
  756. package/examples/js/shaders/VolumeShader.js +0 -296
  757. package/examples/js/shaders/WaterRefractionShader.js +0 -84
  758. package/examples/js/textures/FlakesTexture.js +0 -40
  759. package/examples/js/utils/BufferGeometryUtils.js +0 -1160
  760. package/examples/js/utils/CameraUtils.js +0 -71
  761. package/examples/js/utils/GPUStatsPanel.js +0 -125
  762. package/examples/js/utils/GeometryCompressionUtils.js +0 -549
  763. package/examples/js/utils/GeometryUtils.js +0 -168
  764. package/examples/js/utils/LDrawUtils.js +0 -179
  765. package/examples/js/utils/PackedPhongMaterial.js +0 -109
  766. package/examples/js/utils/SceneUtils.js +0 -214
  767. package/examples/js/utils/ShadowMapViewer.js +0 -183
  768. package/examples/js/utils/SkeletonUtils.js +0 -493
  769. package/examples/js/utils/UVsDebug.js +0 -143
  770. package/examples/js/utils/WorkerPool.js +0 -105
  771. package/examples/jsm/exporters/ColladaExporter.js +0 -713
  772. package/examples/jsm/geometries/LightningStrike.js +0 -1017
  773. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +0 -37071
  774. package/examples/jsm/libs/OimoPhysics/index.js +0 -43
  775. package/examples/jsm/libs/flow.module.js +0 -4552
  776. package/examples/jsm/libs/tween.module.min.js +0 -3
  777. package/examples/jsm/loaders/BasisTextureLoader.js +0 -790
  778. package/examples/jsm/loaders/IFCLoader.js +0 -2431
  779. package/examples/jsm/loaders/PRWMLoader.js +0 -299
  780. package/examples/jsm/loaders/ifc/web-ifc-api.js +0 -47504
  781. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  782. package/examples/jsm/node-editor/NodeEditor.js +0 -857
  783. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +0 -14
  784. package/examples/jsm/node-editor/accessors/NormalEditor.js +0 -30
  785. package/examples/jsm/node-editor/accessors/PositionEditor.js +0 -30
  786. package/examples/jsm/node-editor/accessors/UVEditor.js +0 -25
  787. package/examples/jsm/node-editor/core/BaseNode.js +0 -96
  788. package/examples/jsm/node-editor/core/DataFile.js +0 -59
  789. package/examples/jsm/node-editor/core/FileEditor.js +0 -20
  790. package/examples/jsm/node-editor/core/FileURLEditor.js +0 -29
  791. package/examples/jsm/node-editor/display/BlendEditor.js +0 -44
  792. package/examples/jsm/node-editor/display/NormalMapEditor.js +0 -49
  793. package/examples/jsm/node-editor/examples/animate-uv.json +0 -1
  794. package/examples/jsm/node-editor/examples/fake-top-light.json +0 -1
  795. package/examples/jsm/node-editor/examples/matcap.json +0 -1
  796. package/examples/jsm/node-editor/examples/oscillator-color.json +0 -1
  797. package/examples/jsm/node-editor/examples/rim.json +0 -1
  798. package/examples/jsm/node-editor/inputs/ColorEditor.js +0 -96
  799. package/examples/jsm/node-editor/inputs/FloatEditor.js +0 -23
  800. package/examples/jsm/node-editor/inputs/SliderEditor.js +0 -67
  801. package/examples/jsm/node-editor/inputs/TextureEditor.js +0 -155
  802. package/examples/jsm/node-editor/inputs/Vector2Editor.js +0 -28
  803. package/examples/jsm/node-editor/inputs/Vector3Editor.js +0 -30
  804. package/examples/jsm/node-editor/inputs/Vector4Editor.js +0 -37
  805. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +0 -84
  806. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +0 -102
  807. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +0 -118
  808. package/examples/jsm/node-editor/math/AngleEditor.js +0 -40
  809. package/examples/jsm/node-editor/math/DotEditor.js +0 -35
  810. package/examples/jsm/node-editor/math/InvertEditor.js +0 -39
  811. package/examples/jsm/node-editor/math/LimiterEditor.js +0 -62
  812. package/examples/jsm/node-editor/math/NormalizeEditor.js +0 -28
  813. package/examples/jsm/node-editor/math/OperatorEditor.js +0 -63
  814. package/examples/jsm/node-editor/math/PowerEditor.js +0 -44
  815. package/examples/jsm/node-editor/math/TrigonometryEditor.js +0 -45
  816. package/examples/jsm/node-editor/procedural/CheckerEditor.js +0 -27
  817. package/examples/jsm/node-editor/scene/MeshEditor.js +0 -102
  818. package/examples/jsm/node-editor/scene/Object3DEditor.js +0 -160
  819. package/examples/jsm/node-editor/scene/PointsEditor.js +0 -99
  820. package/examples/jsm/node-editor/utils/JoinEditor.js +0 -58
  821. package/examples/jsm/node-editor/utils/OscillatorEditor.js +0 -43
  822. package/examples/jsm/node-editor/utils/PreviewEditor.js +0 -170
  823. package/examples/jsm/node-editor/utils/SplitEditor.js +0 -39
  824. package/examples/jsm/node-editor/utils/TimerEditor.js +0 -58
  825. package/examples/jsm/nodes/core/CodeNode.js +0 -50
  826. package/examples/jsm/nodes/core/ExpressionNode.js +0 -32
  827. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +0 -22
  828. package/examples/jsm/nodes/lighting/PunctualLightNode.js +0 -68
  829. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +0 -301
  830. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +0 -149
  831. package/examples/jsm/objects/GroundProjectedEnv.js +0 -186
  832. package/examples/jsm/objects/LightningStorm.js +0 -245
  833. package/examples/jsm/physics/OimoPhysics.js +0 -231
  834. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -369
  835. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -187
  836. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -173
  837. package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
  838. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -255
  839. package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
  840. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
  841. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +0 -82
  842. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -36
  843. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
  844. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -38
  845. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -296
  846. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -66
  847. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -73
  848. package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
  849. package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
  850. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -40
  851. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +0 -794
  852. package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
  853. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -81
  854. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +0 -83
  855. package/examples/jsm/shaders/ToneMapShader.js +0 -73
  856. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +0 -7
  857. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +0 -10
  858. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +0 -7
  859. /package/examples/{js → jsm}/libs/ammo.wasm.js +0 -0
  860. /package/examples/{js → jsm}/libs/ammo.wasm.wasm +0 -0
  861. /package/examples/{js → jsm}/libs/basis/basis_transcoder.js +0 -0
  862. /package/examples/{js → jsm}/libs/basis/basis_transcoder.wasm +0 -0
  863. /package/examples/{js → jsm}/libs/draco/README.md +0 -0
  864. /package/examples/{js → jsm}/libs/draco/draco_encoder.js +0 -0
  865. /package/examples/{js → jsm}/libs/draco/gltf/draco_encoder.js +0 -0
@@ -6,7 +6,6 @@ import {
6
6
  BufferGeometry,
7
7
  ClampToEdgeWrapping,
8
8
  Color,
9
- ColorKeyframeTrack,
10
9
  DirectionalLight,
11
10
  DoubleSide,
12
11
  FileLoader,
@@ -61,8 +60,9 @@ import {
61
60
  Vector2,
62
61
  Vector3,
63
62
  VectorKeyframeTrack,
64
- sRGBEncoding
63
+ SRGBColorSpace
65
64
  } from 'three';
65
+ import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
66
66
 
67
67
  class GLTFLoader extends Loader {
68
68
 
@@ -73,7 +73,6 @@ class GLTFLoader extends Loader {
73
73
  this.dracoLoader = null;
74
74
  this.ktx2Loader = null;
75
75
  this.meshoptDecoder = null;
76
- this.animationPointerResolver = null;
77
76
 
78
77
  this.pluginCallbacks = [];
79
78
 
@@ -95,6 +94,12 @@ class GLTFLoader extends Loader {
95
94
 
96
95
  } );
97
96
 
97
+ this.register( function ( parser ) {
98
+
99
+ return new GLTFTextureAVIFExtension( parser );
100
+
101
+ } );
102
+
98
103
  this.register( function ( parser ) {
99
104
 
100
105
  return new GLTFMaterialsSheenExtension( parser );
@@ -139,25 +144,25 @@ class GLTFLoader extends Loader {
139
144
 
140
145
  this.register( function ( parser ) {
141
146
 
142
- return new GLTFLightsExtension( parser );
147
+ return new GLTFMaterialsAnisotropyExtension( parser );
143
148
 
144
149
  } );
145
150
 
146
151
  this.register( function ( parser ) {
147
152
 
148
- return new GLTFMeshoptCompression( parser );
153
+ return new GLTFLightsExtension( parser );
149
154
 
150
155
  } );
151
156
 
152
157
  this.register( function ( parser ) {
153
158
 
154
- return new GLTFMeshGpuInstancing( parser );
159
+ return new GLTFMeshoptCompression( parser );
155
160
 
156
161
  } );
157
162
 
158
163
  this.register( function ( parser ) {
159
164
 
160
- return new GLTFAnimationPointerExtension( parser );
165
+ return new GLTFMeshGpuInstancing( parser );
161
166
 
162
167
  } );
163
168
 
@@ -265,13 +270,6 @@ class GLTFLoader extends Loader {
265
270
 
266
271
  }
267
272
 
268
- setAnimationPointerResolver( animationPointerResolver ) {
269
-
270
- this.animationPointerResolver = animationPointerResolver;
271
- return this;
272
-
273
- }
274
-
275
273
  register( callback ) {
276
274
 
277
275
  if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
@@ -301,6 +299,7 @@ class GLTFLoader extends Loader {
301
299
  let json;
302
300
  const extensions = {};
303
301
  const plugins = {};
302
+ const textDecoder = new TextDecoder();
304
303
 
305
304
  if ( typeof data === 'string' ) {
306
305
 
@@ -308,7 +307,7 @@ class GLTFLoader extends Loader {
308
307
 
309
308
  } else if ( data instanceof ArrayBuffer ) {
310
309
 
311
- const magic = LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
310
+ const magic = textDecoder.decode( new Uint8Array( data, 0, 4 ) );
312
311
 
313
312
  if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
314
313
 
@@ -327,7 +326,7 @@ class GLTFLoader extends Loader {
327
326
 
328
327
  } else {
329
328
 
330
- json = JSON.parse( LoaderUtils.decodeText( new Uint8Array( data ) ) );
329
+ json = JSON.parse( textDecoder.decode( data ) );
331
330
 
332
331
  }
333
332
 
@@ -351,8 +350,7 @@ class GLTFLoader extends Loader {
351
350
  requestHeader: this.requestHeader,
352
351
  manager: this.manager,
353
352
  ktx2Loader: this.ktx2Loader,
354
- meshoptDecoder: this.meshoptDecoder,
355
- animationPointerResolver: this.animationPointerResolver,
353
+ meshoptDecoder: this.meshoptDecoder
356
354
 
357
355
  } );
358
356
 
@@ -480,14 +478,15 @@ const EXTENSIONS = {
480
478
  KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
481
479
  KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
482
480
  KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
481
+ KHR_MATERIALS_ANISOTROPY: 'KHR_materials_anisotropy',
483
482
  KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
484
483
  KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
485
484
  KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
486
485
  KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
487
486
  KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
488
487
  KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
489
- KHR_ANIMATION_POINTER: 'KHR_animation_pointer',
490
488
  EXT_TEXTURE_WEBP: 'EXT_texture_webp',
489
+ EXT_TEXTURE_AVIF: 'EXT_texture_avif',
491
490
  EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
492
491
  EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
493
492
  };
@@ -671,7 +670,7 @@ class GLTFMaterialsUnlitExtension {
671
670
 
672
671
  if ( metallicRoughness.baseColorTexture !== undefined ) {
673
672
 
674
- pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, sRGBEncoding ) );
673
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
675
674
 
676
675
  }
677
676
 
@@ -806,556 +805,6 @@ class GLTFMaterialsClearcoatExtension {
806
805
 
807
806
  }
808
807
 
809
- /**
810
- * Animation Pointer Extension
811
- *
812
- * Draft Specification: https://github.com/ux3d/glTF/tree/extensions/KHR_animation_pointer/extensions/2.0/Khronos/KHR_animation_pointer
813
- */
814
-
815
-
816
- // HACK monkey patching findNode to ensure we can map to other types required by KHR_animation_pointer.
817
- const find = PropertyBinding.findNode;
818
- const _animationPointerDebug = false;
819
-
820
- class GLTFAnimationPointerExtension {
821
-
822
- ANIMATION_TARGET_TYPE = {
823
- node: 'node',
824
- material: 'material',
825
- camera: 'camera',
826
- light: 'light',
827
- };
828
-
829
- constructor( parser ) {
830
-
831
- this.parser = parser;
832
- this.name = EXTENSIONS.KHR_ANIMATION_POINTER;
833
-
834
- }
835
-
836
- _havePatchedPropertyBindings = false;
837
- _patchPropertyBindingFindNode() {
838
-
839
- if ( this._havePatchedPropertyBindings ) return;
840
- this._havePatchedPropertyBindings = true;
841
-
842
- // "node" is the Animator component in our case
843
- // "path" is the animated property path, just with translated material names.
844
- PropertyBinding.findNode = function ( node, path ) {
845
-
846
- if ( path.startsWith( '.materials.' ) ) {
847
-
848
- if ( _animationPointerDebug ) console.log( 'FIND', path );
849
-
850
- const remainingPath = path.substring( '.materials.'.length ).substring( path.indexOf( '.' ) );
851
- const nextIndex = remainingPath.indexOf( '.' );
852
- const uuid = nextIndex < 0 ? remainingPath : remainingPath.substring( 0, nextIndex );
853
- let res = null;
854
- node.traverse( x => {
855
-
856
- if ( res !== null || x.type !== 'Mesh' ) return;
857
- if ( x[ 'material' ]?.uuid === uuid || x[ 'material' ]?.name === uuid ) {
858
-
859
- res = x[ 'material' ];
860
- if ( _animationPointerDebug ) console.log( res, remainingPath );
861
- if ( res !== null ) {
862
-
863
- if ( remainingPath.endsWith( '.map' ) )
864
- res = res[ 'map' ];
865
- else if ( remainingPath.endsWith( '.emissiveMap' ) )
866
- res = res[ 'emissiveMap' ];
867
-
868
- // TODO other texture slots only make sense if three.js actually supports them
869
- // (currently only .map can have repeat/offset)
870
-
871
- }
872
-
873
- }
874
-
875
- } );
876
-
877
- return res;
878
-
879
- } else if ( path.startsWith( '.nodes.' ) || path.startsWith( '.lights.' ) || path.startsWith( '.cameras.' ) ) {
880
-
881
- const sections = path.split( '.' );
882
- let currentTarget = undefined;
883
- for ( let i = 1; i < sections.length; i ++ ) {
884
-
885
- const val = sections[ i ];
886
- const isUUID = val.length == 36;
887
- if ( isUUID ) {
888
-
889
- // access by UUID
890
- currentTarget = node.getObjectByProperty( 'uuid', val );
891
-
892
- } else if ( currentTarget && currentTarget[ val ] ) {
893
-
894
- // access by index
895
- const index = Number.parseInt( val );
896
- let key = val;
897
- if ( index >= 0 ) key = index;
898
- currentTarget = currentTarget[ key ];
899
- if ( _animationPointerDebug )
900
- console.log( currentTarget );
901
-
902
- } else {
903
-
904
- // access by node name
905
- const foundNode = node.getObjectByName( val );
906
- if ( foundNode )
907
- currentTarget = foundNode;
908
-
909
- }
910
-
911
- }
912
-
913
- if ( ! currentTarget ) {
914
-
915
- const originalFindResult = find( node, sections[ 2 ] );
916
-
917
- if ( ! originalFindResult )
918
- console.warn( EXTENSIONS.KHR_ANIMATION_POINTER + ': Property binding not found', path, node, node.name, sections );
919
-
920
- return originalFindResult;
921
-
922
- }
923
-
924
- if ( _animationPointerDebug )
925
- console.log( 'NODE', path, currentTarget );
926
-
927
- return currentTarget;
928
-
929
- }
930
-
931
- return find( node, path );
932
-
933
- };
934
-
935
- }
936
-
937
- loadAnimationTargetFromChannel( animationChannel ) {
938
-
939
- if ( ! this._havePatchedPropertyBindings )
940
- this._patchPropertyBindingFindNode();
941
-
942
- const target = animationChannel.target;
943
- const useExtension = target.extensions && target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ] && target.path && target.path === 'pointer';
944
- if ( ! useExtension ) return null;
945
-
946
- let targetProperty = undefined;
947
-
948
- // check if this is a extension animation
949
- let type = this.ANIMATION_TARGET_TYPE.node;
950
- let targetId = undefined;
951
-
952
- if ( useExtension ) {
953
-
954
- const ext = target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ];
955
- let path = ext.pointer;
956
- if ( this._animationPointerDebug )
957
- console.log( 'Original path: ' + path, target );
958
-
959
- if ( ! path ) {
960
-
961
- console.warn( 'Invalid path', ext, target );
962
- return;
963
-
964
- }
965
-
966
- if ( path.startsWith( '/materials/' ) )
967
- type = this.ANIMATION_TARGET_TYPE.material;
968
- else if ( path.startsWith( '/extensions/KHR_lights_punctual/lights/' ) )
969
- type = this.ANIMATION_TARGET_TYPE.light;
970
- else if ( path.startsWith( '/cameras/' ) )
971
- type = this.ANIMATION_TARGET_TYPE.camera;
972
-
973
- targetId = this._tryResolveTargetId( path, type );
974
- if ( targetId === null || isNaN( targetId ) ) {
975
-
976
- console.warn( 'Failed resolving animation node id: ' + targetId, path );
977
- return;
978
-
979
- } else {
980
-
981
- if ( this._animationPointerDebug ) console.log( 'Resolved node ID for ' + type, targetId );
982
-
983
- }
984
-
985
- // TODO could be parsed better
986
- switch ( type ) {
987
-
988
- case this.ANIMATION_TARGET_TYPE.material:
989
- const pathIndex = ( '/materials/' + targetId.toString() + '/' ).length;
990
- const pathStart = path.substring( 0, pathIndex );
991
- targetProperty = path.substring( pathIndex );
992
-
993
- switch ( targetProperty ) {
994
-
995
- // Core Spec PBR Properties
996
- case 'pbrMetallicRoughness/baseColorFactor':
997
- targetProperty = 'color';
998
- break;
999
- case 'pbrMetallicRoughness/roughnessFactor':
1000
- targetProperty = 'roughness';
1001
- break;
1002
- case 'pbrMetallicRoughness/metallicFactor':
1003
- targetProperty = 'metalness';
1004
- break;
1005
- case 'emissiveFactor':
1006
- targetProperty = 'emissive';
1007
- break;
1008
- case 'alphaCutoff':
1009
- targetProperty = 'alphaTest';
1010
- break;
1011
- case 'occlusionTexture/strength':
1012
- targetProperty = 'aoMapIntensity';
1013
- break;
1014
- case 'normalTexture/scale':
1015
- targetProperty = 'normalScale';
1016
- break;
1017
-
1018
- // Core Spec + KHR_texture_transform
1019
- case 'pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale':
1020
- targetProperty = 'map/repeat';
1021
- break;
1022
- case 'pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset':
1023
- targetProperty = 'map/offset';
1024
- break;
1025
-
1026
- // UV transforms for anything but map doesn't seem to currently be supported in three.js
1027
- case 'emissiveTexture/extensions/KHR_texture_transform/scale':
1028
- targetProperty = 'emissiveMap/repeat';
1029
- break;
1030
- case 'emissiveTexture/extensions/KHR_texture_transform/offset':
1031
- targetProperty = 'emissiveMap/offset';
1032
- break;
1033
-
1034
- // KHR_materials_emissive_strength
1035
- case 'extensions/KHR_materials_emissive_strength/emissiveStrength':
1036
- targetProperty = 'emissiveIntensity';
1037
- break;
1038
-
1039
- // KHR_materials_transmission
1040
- case 'extensions/KHR_materials_transmission/transmissionFactor':
1041
- targetProperty = 'transmission';
1042
- break;
1043
-
1044
- // KHR_materials_ior
1045
- case 'extensions/KHR_materials_ior/ior':
1046
- targetProperty = 'ior';
1047
- break;
1048
-
1049
- // KHR_materials_volume
1050
- case 'extensions/KHR_materials_volume/thicknessFactor':
1051
- targetProperty = 'thickness';
1052
- break;
1053
- case 'extensions/KHR_materials_volume/attenuationColor':
1054
- targetProperty = 'attenuationColor';
1055
- break;
1056
- case 'extensions/KHR_materials_volume/attenuationDistance':
1057
- targetProperty = 'attenuationDistance';
1058
- break;
1059
-
1060
- // KHR_materials_iridescence
1061
- case 'extensions/KHR_materials_iridescence/iridescenceFactor':
1062
- targetProperty = 'iridescence';
1063
- break;
1064
- case 'extensions/KHR_materials_iridescence/iridescenceIor':
1065
- targetProperty = 'iridescenceIOR';
1066
- break;
1067
- case 'extensions/KHR_materials_iridescence/iridescenceThicknessMinimum':
1068
- targetProperty = 'iridescenceThicknessRange[0]';
1069
- break;
1070
- case 'extensions/KHR_materials_iridescence/iridescenceThicknessMaximum':
1071
- targetProperty = 'iridescenceThicknessRange[1]';
1072
- break;
1073
-
1074
- // KHR_materials_clearcoat
1075
- case 'extensions/KHR_materials_clearcoat/clearcoatFactor':
1076
- targetProperty = 'clearcoat';
1077
- break;
1078
- case 'extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor':
1079
- targetProperty = 'clearcoatRoughness';
1080
- break;
1081
-
1082
- // KHR_materials_sheen
1083
- case 'extensions/KHR_materials_sheen/sheenColorFactor':
1084
- targetProperty = 'sheenColor';
1085
- break;
1086
- case 'extensions/KHR_materials_sheen/sheenRoughnessFactor':
1087
- targetProperty = 'sheenRoughness';
1088
- break;
1089
-
1090
- // KHR_materials_specular
1091
- case 'extensions/KHR_materials_specular/specularFactor':
1092
- targetProperty = 'specularIntensity';
1093
- break;
1094
- case 'extensions/KHR_materials_specular/specularColorFactor':
1095
- targetProperty = 'specularColor';
1096
- break;
1097
-
1098
- }
1099
-
1100
- path = pathStart + targetProperty;
1101
- if ( this._animationPointerDebug ) console.log( 'PROPERTY PATH', pathStart, targetProperty, path );
1102
- break;
1103
-
1104
- case this.ANIMATION_TARGET_TYPE.node:
1105
- const pathIndexNode = ( '/nodes/' + targetId.toString() + '/' ).length;
1106
- const pathStartNode = path.substring( 0, pathIndexNode );
1107
- targetProperty = path.substring( pathIndexNode );
1108
-
1109
- switch ( targetProperty ) {
1110
-
1111
- case 'translation':
1112
- targetProperty = 'position';
1113
- break;
1114
- case 'rotation':
1115
- targetProperty = 'quaternion';
1116
- break;
1117
- case 'scale':
1118
- targetProperty = 'scale';
1119
- break;
1120
- case 'weights':
1121
- targetProperty = 'morphTargetInfluences';
1122
- break;
1123
-
1124
- }
1125
-
1126
- path = pathStartNode + targetProperty;
1127
- break;
1128
-
1129
- case this.ANIMATION_TARGET_TYPE.light:
1130
- const pathIndexLight = ( '/extensions/KHR_lights_punctual/lights/' + targetId.toString() + '/' ).length;
1131
- targetProperty = path.substring( pathIndexLight );
1132
-
1133
- switch ( targetProperty ) {
1134
-
1135
- case 'color':
1136
- break;
1137
- case 'intensity':
1138
- break;
1139
- case 'spot/innerConeAngle':
1140
- // TODO would need to set .penumbra, but requires calculations on every animation change (?)
1141
- targetProperty = 'penumbra';
1142
- break;
1143
- case 'spot/outerConeAngle':
1144
- targetProperty = 'angle';
1145
- break;
1146
- case 'range':
1147
- targetProperty = 'distance';
1148
- break;
1149
-
1150
- }
1151
-
1152
- path = '/lights/' + targetId.toString() + '/' + targetProperty;
1153
- break;
1154
-
1155
- case this.ANIMATION_TARGET_TYPE.camera:
1156
- const pathIndexCamera = ( '/cameras/' + targetId.toString() + '/' ).length;
1157
- const pathStartCamera = path.substring( 0, pathIndexCamera );
1158
- targetProperty = path.substring( pathIndexCamera );
1159
-
1160
- switch ( targetProperty ) {
1161
-
1162
- case 'perspective/yfov':
1163
- targetProperty = 'fov';
1164
- break;
1165
- case 'perspective/znear':
1166
- case 'orthographic/znear':
1167
- targetProperty = 'near';
1168
- break;
1169
- case 'perspective/zfar':
1170
- case 'orthographic/zfar':
1171
- targetProperty = 'far';
1172
- break;
1173
- case 'perspective/aspect':
1174
- targetProperty = 'aspect';
1175
- break;
1176
- // these two write to the same target property since three.js orthographic camera only supports 'zoom'.
1177
- // TODO should there be a warning for either of them? E.g. a warning for "xmag" so that "yfov" + "ymag" work by default?
1178
- case 'orthographic/xmag':
1179
- targetProperty = 'zoom';
1180
- break;
1181
- case 'orthographic/ymag':
1182
- targetProperty = 'zoom';
1183
- break;
1184
-
1185
- }
1186
-
1187
- path = pathStartCamera + targetProperty;
1188
- break;
1189
-
1190
- }
1191
-
1192
- const pointerResolver = this.parser.options.animationPointerResolver;
1193
- if ( pointerResolver && pointerResolver.resolvePath ) {
1194
-
1195
- path = pointerResolver.resolvePath( path );
1196
-
1197
- }
1198
-
1199
- target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ].pointer = path;
1200
-
1201
- }
1202
-
1203
- if ( targetId === null || isNaN( targetId ) ) {
1204
-
1205
- console.warn( 'Failed resolving animation node id: ' + targetId, target );
1206
- return;
1207
-
1208
- }
1209
-
1210
- let depPromise;
1211
-
1212
- if ( type === this.ANIMATION_TARGET_TYPE.node )
1213
- depPromise = this.parser.getDependency( 'node', targetId );
1214
- else if ( type === this.ANIMATION_TARGET_TYPE.material )
1215
- depPromise = this.parser.getDependency( 'material', targetId );
1216
- else if ( type === this.ANIMATION_TARGET_TYPE.light )
1217
- depPromise = this.parser.getDependency( 'light', targetId );
1218
- else if ( type === this.ANIMATION_TARGET_TYPE.camera )
1219
- depPromise = this.parser.getDependency( 'camera', targetId );
1220
- else
1221
- console.error( 'Unhandled type', type );
1222
-
1223
- return depPromise;
1224
-
1225
- }
1226
-
1227
- createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
1228
-
1229
- const useExtension = target.extensions && target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ] && target.path && target.path === 'pointer';
1230
- if ( ! useExtension ) return null;
1231
-
1232
- let animationPointerPropertyPath = target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ].pointer;
1233
- if ( ! animationPointerPropertyPath ) return null;
1234
-
1235
- const tracks = [];
1236
-
1237
- animationPointerPropertyPath = animationPointerPropertyPath.replaceAll( '/', '.' );
1238
- // replace node/material/camera/light ID by UUID
1239
- const parts = animationPointerPropertyPath.split( '.' );
1240
- parts[ 2 ] = node.name ?? node.uuid;
1241
- animationPointerPropertyPath = parts.join( '.' );
1242
- if ( this._animationPointerDebug )
1243
- console.log( node, inputAccessor, outputAccessor, target, animationPointerPropertyPath );
1244
-
1245
- let TypedKeyframeTrack;
1246
-
1247
- switch ( outputAccessor.itemSize ) {
1248
-
1249
- case 1:
1250
- TypedKeyframeTrack = NumberKeyframeTrack;
1251
- break;
1252
- case 2:
1253
- case 3:
1254
- TypedKeyframeTrack = VectorKeyframeTrack;
1255
- break;
1256
- case 4:
1257
-
1258
- if ( animationPointerPropertyPath.endsWith( '.quaternion' ) )
1259
- TypedKeyframeTrack = QuaternionKeyframeTrack;
1260
- else
1261
- TypedKeyframeTrack = ColorKeyframeTrack;
1262
-
1263
- break;
1264
-
1265
- }
1266
-
1267
- const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;
1268
-
1269
- let outputArray = getArrayFromAccessor( outputAccessor );
1270
-
1271
- // convert fov values from radians to degrees
1272
- if ( animationPointerPropertyPath.endsWith( '.fov' ) ) {
1273
-
1274
- outputArray = outputArray.map( value => value / Math.PI * 180 );
1275
-
1276
- }
1277
-
1278
- const track = new TypedKeyframeTrack(
1279
- animationPointerPropertyPath,
1280
- inputAccessor.array,
1281
- outputArray,
1282
- interpolation
1283
- );
1284
-
1285
- // Override interpolation with custom factory method.
1286
- if ( interpolation === 'CUBICSPLINE' ) {
1287
-
1288
- createCubicSplineTrackInterpolant( track );
1289
-
1290
- }
1291
-
1292
- tracks.push( track );
1293
-
1294
- // glTF has opacity animation as last component of baseColorFactor,
1295
- // so we need to split that up here and create a separate opacity track if that is animated.
1296
- if ( animationPointerPropertyPath && outputAccessor.itemSize === 4 &&
1297
- animationPointerPropertyPath.startsWith( '.materials.' ) && animationPointerPropertyPath.endsWith( '.color' ) ) {
1298
-
1299
- const opacityArray = new Float32Array( outputArray.length / 4 );
1300
-
1301
- for ( let j = 0, jl = outputArray.length / 4; j < jl; j += 1 ) {
1302
-
1303
- opacityArray[ j ] = outputArray[ j * 4 + 3 ];
1304
-
1305
- }
1306
-
1307
- const opacityTrack = new TypedKeyframeTrack(
1308
- animationPointerPropertyPath.replace( '.color', '.opacity' ),
1309
- inputAccessor.array,
1310
- opacityArray,
1311
- interpolation
1312
- );
1313
-
1314
- // Override interpolation with custom factory method.
1315
- if ( interpolation === 'CUBICSPLINE' ) {
1316
-
1317
- createCubicSplineTrackInterpolant( track );
1318
-
1319
- }
1320
-
1321
- tracks.push( opacityTrack );
1322
-
1323
- }
1324
-
1325
- return tracks;
1326
-
1327
- }
1328
-
1329
-
1330
- _tryResolveTargetId( path, type ) {
1331
-
1332
- let name = '';
1333
- if ( type === 'node' ) {
1334
-
1335
- name = path.substring( '/nodes/'.length );
1336
-
1337
- } else if ( type === 'material' ) {
1338
-
1339
- name = path.substring( '/materials/'.length );
1340
-
1341
- } else if ( type === 'light' ) {
1342
-
1343
- name = path.substring( '/extensions/KHR_lights_punctual/lights/'.length );
1344
-
1345
- } else if ( type === 'camera' ) {
1346
-
1347
- name = path.substring( '/cameras/'.length );
1348
-
1349
- }
1350
-
1351
- name = name.substring( 0, name.indexOf( '/' ) );
1352
- const index = Number.parseInt( name );
1353
- return index;
1354
-
1355
- }
1356
-
1357
- }
1358
-
1359
808
  /**
1360
809
  * Iridescence Materials Extension
1361
810
  *
@@ -1502,7 +951,7 @@ class GLTFMaterialsSheenExtension {
1502
951
 
1503
952
  if ( extension.sheenColorTexture !== undefined ) {
1504
953
 
1505
- pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, sRGBEncoding ) );
954
+ pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
1506
955
 
1507
956
  }
1508
957
 
@@ -1735,7 +1184,71 @@ class GLTFMaterialsSpecularExtension {
1735
1184
 
1736
1185
  if ( extension.specularColorTexture !== undefined ) {
1737
1186
 
1738
- pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, sRGBEncoding ) );
1187
+ pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
1188
+
1189
+ }
1190
+
1191
+ return Promise.all( pending );
1192
+
1193
+ }
1194
+
1195
+ }
1196
+
1197
+ /**
1198
+ * Materials anisotropy Extension
1199
+ *
1200
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
1201
+ */
1202
+ class GLTFMaterialsAnisotropyExtension {
1203
+
1204
+ constructor( parser ) {
1205
+
1206
+ this.parser = parser;
1207
+ this.name = EXTENSIONS.KHR_MATERIALS_ANISOTROPY;
1208
+
1209
+ }
1210
+
1211
+ getMaterialType( materialIndex ) {
1212
+
1213
+ const parser = this.parser;
1214
+ const materialDef = parser.json.materials[ materialIndex ];
1215
+
1216
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1217
+
1218
+ return MeshPhysicalMaterial;
1219
+
1220
+ }
1221
+
1222
+ extendMaterialParams( materialIndex, materialParams ) {
1223
+
1224
+ const parser = this.parser;
1225
+ const materialDef = parser.json.materials[ materialIndex ];
1226
+
1227
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1228
+
1229
+ return Promise.resolve();
1230
+
1231
+ }
1232
+
1233
+ const pending = [];
1234
+
1235
+ const extension = materialDef.extensions[ this.name ];
1236
+
1237
+ if ( extension.anisotropyStrength !== undefined ) {
1238
+
1239
+ materialParams.anisotropy = extension.anisotropyStrength;
1240
+
1241
+ }
1242
+
1243
+ if ( extension.anisotropyRotation !== undefined ) {
1244
+
1245
+ materialParams.anisotropyRotation = extension.anisotropyRotation;
1246
+
1247
+ }
1248
+
1249
+ if ( extension.anisotropyTexture !== undefined ) {
1250
+
1251
+ pending.push( parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
1739
1252
 
1740
1253
  }
1741
1254
 
@@ -1881,6 +1394,89 @@ class GLTFTextureWebPExtension {
1881
1394
 
1882
1395
  }
1883
1396
 
1397
+ /**
1398
+ * AVIF Texture Extension
1399
+ *
1400
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
1401
+ */
1402
+ class GLTFTextureAVIFExtension {
1403
+
1404
+ constructor( parser ) {
1405
+
1406
+ this.parser = parser;
1407
+ this.name = EXTENSIONS.EXT_TEXTURE_AVIF;
1408
+ this.isSupported = null;
1409
+
1410
+ }
1411
+
1412
+ loadTexture( textureIndex ) {
1413
+
1414
+ const name = this.name;
1415
+ const parser = this.parser;
1416
+ const json = parser.json;
1417
+
1418
+ const textureDef = json.textures[ textureIndex ];
1419
+
1420
+ if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
1421
+
1422
+ return null;
1423
+
1424
+ }
1425
+
1426
+ const extension = textureDef.extensions[ name ];
1427
+ const source = json.images[ extension.source ];
1428
+
1429
+ let loader = parser.textureLoader;
1430
+ if ( source.uri ) {
1431
+
1432
+ const handler = parser.options.manager.getHandler( source.uri );
1433
+ if ( handler !== null ) loader = handler;
1434
+
1435
+ }
1436
+
1437
+ return this.detectSupport().then( function ( isSupported ) {
1438
+
1439
+ if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );
1440
+
1441
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
1442
+
1443
+ throw new Error( 'THREE.GLTFLoader: AVIF required by asset but unsupported.' );
1444
+
1445
+ }
1446
+
1447
+ // Fall back to PNG or JPEG.
1448
+ return parser.loadTexture( textureIndex );
1449
+
1450
+ } );
1451
+
1452
+ }
1453
+
1454
+ detectSupport() {
1455
+
1456
+ if ( ! this.isSupported ) {
1457
+
1458
+ this.isSupported = new Promise( function ( resolve ) {
1459
+
1460
+ const image = new Image();
1461
+
1462
+ // Lossy test image.
1463
+ image.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=';
1464
+ image.onload = image.onerror = function () {
1465
+
1466
+ resolve( image.height === 1 );
1467
+
1468
+ };
1469
+
1470
+ } );
1471
+
1472
+ }
1473
+
1474
+ return this.isSupported;
1475
+
1476
+ }
1477
+
1478
+ }
1479
+
1884
1480
  /**
1885
1481
  * meshopt BufferView Compression Extension
1886
1482
  *
@@ -2093,8 +1689,6 @@ class GLTFMeshGpuInstancing {
2093
1689
  // Just in case
2094
1690
  Object3D.prototype.copy.call( instancedMesh, mesh );
2095
1691
 
2096
- // https://github.com/mrdoob/three.js/issues/18334
2097
- instancedMesh.frustumCulled = false;
2098
1692
  this.parser.assignFinalMaterial( instancedMesh );
2099
1693
 
2100
1694
  instancedMeshes.push( instancedMesh );
@@ -2133,9 +1727,10 @@ class GLTFBinaryExtension {
2133
1727
  this.body = null;
2134
1728
 
2135
1729
  const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
1730
+ const textDecoder = new TextDecoder();
2136
1731
 
2137
1732
  this.header = {
2138
- magic: LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ),
1733
+ magic: textDecoder.decode( new Uint8Array( data.slice( 0, 4 ) ) ),
2139
1734
  version: headerView.getUint32( 4, true ),
2140
1735
  length: headerView.getUint32( 8, true )
2141
1736
  };
@@ -2165,7 +1760,7 @@ class GLTFBinaryExtension {
2165
1760
  if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
2166
1761
 
2167
1762
  const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
2168
- this.content = LoaderUtils.decodeText( contentArray );
1763
+ this.content = textDecoder.decode( contentArray );
2169
1764
 
2170
1765
  } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
2171
1766
 
@@ -2288,13 +1883,10 @@ class GLTFTextureTransformExtension {
2288
1883
 
2289
1884
  extendTexture( texture, transform ) {
2290
1885
 
2291
- if ( transform.texCoord !== undefined ) {
2292
-
2293
- console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
2294
-
2295
- }
2296
-
2297
- if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) {
1886
+ if ( ( transform.texCoord === undefined || transform.texCoord === texture.channel )
1887
+ && transform.offset === undefined
1888
+ && transform.rotation === undefined
1889
+ && transform.scale === undefined ) {
2298
1890
 
2299
1891
  // See https://github.com/mrdoob/three.js/issues/21819.
2300
1892
  return texture;
@@ -2303,6 +1895,12 @@ class GLTFTextureTransformExtension {
2303
1895
 
2304
1896
  texture = texture.clone();
2305
1897
 
1898
+ if ( transform.texCoord !== undefined ) {
1899
+
1900
+ texture.channel = transform.texCoord;
1901
+
1902
+ }
1903
+
2306
1904
  if ( transform.offset !== undefined ) {
2307
1905
 
2308
1906
  texture.offset.fromArray( transform.offset );
@@ -2504,7 +2102,9 @@ const ATTRIBUTES = {
2504
2102
  NORMAL: 'normal',
2505
2103
  TANGENT: 'tangent',
2506
2104
  TEXCOORD_0: 'uv',
2507
- TEXCOORD_1: 'uv2',
2105
+ TEXCOORD_1: 'uv1',
2106
+ TEXCOORD_2: 'uv2',
2107
+ TEXCOORD_3: 'uv3',
2508
2108
  COLOR_0: 'color',
2509
2109
  WEIGHTS_0: 'skinWeight',
2510
2110
  JOINTS_0: 'skinIndex',
@@ -2726,18 +2326,29 @@ function updateMorphTargets( mesh, meshDef ) {
2726
2326
 
2727
2327
  function createPrimitiveKey( primitiveDef ) {
2728
2328
 
2729
- const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
2730
2329
  let geometryKey;
2731
2330
 
2331
+ const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
2332
+
2732
2333
  if ( dracoExtension ) {
2733
2334
 
2734
2335
  geometryKey = 'draco:' + dracoExtension.bufferView
2735
2336
  + ':' + dracoExtension.indices
2736
2337
  + ':' + createAttributesKey( dracoExtension.attributes );
2737
2338
 
2738
- } else {
2339
+ } else {
2340
+
2341
+ geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
2342
+
2343
+ }
2344
+
2345
+ if ( primitiveDef.targets !== undefined ) {
2739
2346
 
2740
- geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
2347
+ for ( let i = 0, il = primitiveDef.targets.length; i < il; i ++ ) {
2348
+
2349
+ geometryKey += ':' + createAttributesKey( primitiveDef.targets[ i ] );
2350
+
2351
+ }
2741
2352
 
2742
2353
  }
2743
2354
 
@@ -2787,48 +2398,6 @@ function getNormalizedComponentScale( constructor ) {
2787
2398
 
2788
2399
  }
2789
2400
 
2790
- function getArrayFromAccessor( accessor ) {
2791
-
2792
- let outputArray = accessor.array;
2793
-
2794
- if ( accessor.normalized ) {
2795
-
2796
- const scale = getNormalizedComponentScale( outputArray.constructor );
2797
- const scaled = new Float32Array( outputArray.length );
2798
-
2799
- for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
2800
-
2801
- scaled[ j ] = outputArray[ j ] * scale;
2802
-
2803
- }
2804
-
2805
- outputArray = scaled;
2806
-
2807
- }
2808
-
2809
- return outputArray;
2810
-
2811
- }
2812
-
2813
- function createCubicSplineTrackInterpolant( track ) {
2814
-
2815
- track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
2816
-
2817
- // A CUBICSPLINE keyframe in glTF has three output values for each input value,
2818
- // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
2819
- // must be divided by three to get the interpolant's sampleSize argument.
2820
-
2821
- const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
2822
-
2823
- return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
2824
-
2825
- };
2826
-
2827
- // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
2828
- track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
2829
-
2830
- }
2831
-
2832
2401
  function getImageURIMimeType( uri ) {
2833
2402
 
2834
2403
  if ( uri.search( /\.jpe?g($|\?)/i ) > 0 || uri.search( /^data\:image\/jpeg/ ) === 0 ) return 'image/jpeg';
@@ -2838,6 +2407,8 @@ function getImageURIMimeType( uri ) {
2838
2407
 
2839
2408
  }
2840
2409
 
2410
+ const _identityMatrix = new Matrix4();
2411
+
2841
2412
  /* GLTF PARSER */
2842
2413
 
2843
2414
  class GLTFParser {
@@ -2858,6 +2429,9 @@ class GLTFParser {
2858
2429
  // BufferGeometry caching
2859
2430
  this.primitiveCache = {};
2860
2431
 
2432
+ // Node cache
2433
+ this.nodeCache = {};
2434
+
2861
2435
  // Object3D instance caches
2862
2436
  this.meshCache = { refs: {}, uses: {} };
2863
2437
  this.cameraCache = { refs: {}, uses: {} };
@@ -2928,6 +2502,7 @@ class GLTFParser {
2928
2502
 
2929
2503
  // Clear the loader cache
2930
2504
  this.cache.removeAll();
2505
+ this.nodeCache = {};
2931
2506
 
2932
2507
  // Mark the special nodes/meshes in json for efficient parse
2933
2508
  this._invokeAll( function ( ext ) {
@@ -3147,7 +2722,11 @@ class GLTFParser {
3147
2722
  break;
3148
2723
 
3149
2724
  case 'node':
3150
- dependency = this.loadNode( index );
2725
+ dependency = this._invokeOne( function ( ext ) {
2726
+
2727
+ return ext.loadNode && ext.loadNode( index );
2728
+
2729
+ } );
3151
2730
  break;
3152
2731
 
3153
2732
  case 'mesh':
@@ -3206,14 +2785,6 @@ class GLTFParser {
3206
2785
  dependency = this.loadCamera( index );
3207
2786
  break;
3208
2787
 
3209
- case 'light':
3210
- dependency = this._invokeOne( function ( ext ) {
3211
-
3212
- return ext._loadLight && ext._loadLight( index );
3213
-
3214
- } );
3215
- break;
3216
-
3217
2788
  default:
3218
2789
  dependency = this._invokeOne( function ( ext ) {
3219
2790
 
@@ -3460,7 +3031,7 @@ class GLTFParser {
3460
3031
  /**
3461
3032
  * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
3462
3033
  * @param {number} textureIndex
3463
- * @return {Promise<THREE.Texture>}
3034
+ * @return {Promise<THREE.Texture|null>}
3464
3035
  */
3465
3036
  loadTexture( textureIndex ) {
3466
3037
 
@@ -3506,6 +3077,12 @@ class GLTFParser {
3506
3077
 
3507
3078
  texture.name = textureDef.name || sourceDef.name || '';
3508
3079
 
3080
+ if ( texture.name === '' && typeof sourceDef.uri === 'string' && sourceDef.uri.startsWith( 'data:image/' ) === false ) {
3081
+
3082
+ texture.name = sourceDef.uri;
3083
+
3084
+ }
3085
+
3509
3086
  const samplers = json.samplers || {};
3510
3087
  const sampler = samplers[ textureDef.sampler ] || {};
3511
3088
 
@@ -3625,17 +3202,18 @@ class GLTFParser {
3625
3202
  * @param {Object} mapDef
3626
3203
  * @return {Promise<Texture>}
3627
3204
  */
3628
- assignTexture( materialParams, mapName, mapDef, encoding ) {
3205
+ assignTexture( materialParams, mapName, mapDef, colorSpace ) {
3629
3206
 
3630
3207
  const parser = this;
3631
3208
 
3632
3209
  return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
3633
3210
 
3634
- // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
3635
- // However, we will copy UV set 0 to UV set 1 on demand for aoMap
3636
- if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
3211
+ if ( ! texture ) return null;
3212
+
3213
+ if ( mapDef.texCoord !== undefined && mapDef.texCoord > 0 ) {
3637
3214
 
3638
- console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' );
3215
+ texture = texture.clone();
3216
+ texture.channel = mapDef.texCoord;
3639
3217
 
3640
3218
  }
3641
3219
 
@@ -3653,9 +3231,9 @@ class GLTFParser {
3653
3231
 
3654
3232
  }
3655
3233
 
3656
- if ( encoding !== undefined && texture ) {
3234
+ if ( colorSpace !== undefined ) {
3657
3235
 
3658
- texture.encoding = encoding;
3236
+ texture.colorSpace = colorSpace;
3659
3237
 
3660
3238
  }
3661
3239
 
@@ -3715,6 +3293,7 @@ class GLTFParser {
3715
3293
  lineMaterial = new LineBasicMaterial();
3716
3294
  Material.prototype.copy.call( lineMaterial, material );
3717
3295
  lineMaterial.color.copy( material.color );
3296
+ lineMaterial.map = material.map;
3718
3297
 
3719
3298
  this.cache.add( cacheKey, lineMaterial );
3720
3299
 
@@ -3760,14 +3339,6 @@ class GLTFParser {
3760
3339
 
3761
3340
  }
3762
3341
 
3763
- // workarounds for mesh and geometry
3764
-
3765
- if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {
3766
-
3767
- geometry.setAttribute( 'uv2', geometry.attributes.uv );
3768
-
3769
- }
3770
-
3771
3342
  mesh.material = material;
3772
3343
 
3773
3344
  }
@@ -3823,7 +3394,7 @@ class GLTFParser {
3823
3394
 
3824
3395
  if ( metallicRoughness.baseColorTexture !== undefined ) {
3825
3396
 
3826
- pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, sRGBEncoding ) );
3397
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
3827
3398
 
3828
3399
  }
3829
3400
 
@@ -3914,7 +3485,7 @@ class GLTFParser {
3914
3485
 
3915
3486
  if ( materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial ) {
3916
3487
 
3917
- pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, sRGBEncoding ) );
3488
+ pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, SRGBColorSpace ) );
3918
3489
 
3919
3490
  }
3920
3491
 
@@ -3941,17 +3512,17 @@ class GLTFParser {
3941
3512
 
3942
3513
  const sanitizedName = PropertyBinding.sanitizeNodeName( originalName || '' );
3943
3514
 
3944
- let name = sanitizedName;
3515
+ if ( sanitizedName in this.nodeNamesUsed ) {
3945
3516
 
3946
- for ( let i = 1; this.nodeNamesUsed[ name ]; ++ i ) {
3517
+ return sanitizedName + '_' + ( ++ this.nodeNamesUsed[ sanitizedName ] );
3947
3518
 
3948
- name = sanitizedName + '_' + i;
3519
+ } else {
3949
3520
 
3950
- }
3521
+ this.nodeNamesUsed[ sanitizedName ] = 0;
3951
3522
 
3952
- this.nodeNamesUsed[ name ] = true;
3523
+ return sanitizedName;
3953
3524
 
3954
- return name;
3525
+ }
3955
3526
 
3956
3527
  }
3957
3528
 
@@ -4081,10 +3652,9 @@ class GLTFParser {
4081
3652
  ? new SkinnedMesh( geometry, material )
4082
3653
  : new Mesh( geometry, material );
4083
3654
 
4084
- if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
3655
+ if ( mesh.isSkinnedMesh === true ) {
4085
3656
 
4086
- // we normalize floating point skin weight array to fix malformed assets (see #15319)
4087
- // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
3657
+ // normalize skin weights to fix malformed assets (see #15319)
4088
3658
  mesh.normalizeSkinWeights();
4089
3659
 
4090
3660
  }
@@ -4150,12 +3720,16 @@ class GLTFParser {
4150
3720
 
4151
3721
  if ( meshes.length === 1 ) {
4152
3722
 
3723
+ if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, meshes[ 0 ], meshDef );
3724
+
4153
3725
  return meshes[ 0 ];
4154
3726
 
4155
3727
  }
4156
3728
 
4157
3729
  const group = new Group();
4158
3730
 
3731
+ if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, group, meshDef );
3732
+
4159
3733
  parser.associations.set( group, { meshes: meshIndex } );
4160
3734
 
4161
3735
  for ( let i = 0, il = meshes.length; i < il; i ++ ) {
@@ -4209,25 +3783,68 @@ class GLTFParser {
4209
3783
  /**
4210
3784
  * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
4211
3785
  * @param {number} skinIndex
4212
- * @return {Promise<Object>}
3786
+ * @return {Promise<Skeleton>}
4213
3787
  */
4214
3788
  loadSkin( skinIndex ) {
4215
3789
 
4216
3790
  const skinDef = this.json.skins[ skinIndex ];
4217
3791
 
4218
- const skinEntry = { joints: skinDef.joints };
3792
+ const pending = [];
3793
+
3794
+ for ( let i = 0, il = skinDef.joints.length; i < il; i ++ ) {
3795
+
3796
+ pending.push( this._loadNodeShallow( skinDef.joints[ i ] ) );
3797
+
3798
+ }
3799
+
3800
+ if ( skinDef.inverseBindMatrices !== undefined ) {
4219
3801
 
4220
- if ( skinDef.inverseBindMatrices === undefined ) {
3802
+ pending.push( this.getDependency( 'accessor', skinDef.inverseBindMatrices ) );
3803
+
3804
+ } else {
4221
3805
 
4222
- return Promise.resolve( skinEntry );
3806
+ pending.push( null );
4223
3807
 
4224
3808
  }
4225
3809
 
4226
- return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) {
3810
+ return Promise.all( pending ).then( function ( results ) {
3811
+
3812
+ const inverseBindMatrices = results.pop();
3813
+ const jointNodes = results;
3814
+
3815
+ // Note that bones (joint nodes) may or may not be in the
3816
+ // scene graph at this time.
3817
+
3818
+ const bones = [];
3819
+ const boneInverses = [];
3820
+
3821
+ for ( let i = 0, il = jointNodes.length; i < il; i ++ ) {
3822
+
3823
+ const jointNode = jointNodes[ i ];
3824
+
3825
+ if ( jointNode ) {
3826
+
3827
+ bones.push( jointNode );
3828
+
3829
+ const mat = new Matrix4();
3830
+
3831
+ if ( inverseBindMatrices !== null ) {
3832
+
3833
+ mat.fromArray( inverseBindMatrices.array, i * 16 );
3834
+
3835
+ }
3836
+
3837
+ boneInverses.push( mat );
3838
+
3839
+ } else {
4227
3840
 
4228
- skinEntry.inverseBindMatrices = accessor;
3841
+ console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[ i ] );
4229
3842
 
4230
- return skinEntry;
3843
+ }
3844
+
3845
+ }
3846
+
3847
+ return new Skeleton( bones, boneInverses );
4231
3848
 
4232
3849
  } );
4233
3850
 
@@ -4244,6 +3861,7 @@ class GLTFParser {
4244
3861
  const parser = this;
4245
3862
 
4246
3863
  const animationDef = json.animations[ animationIndex ];
3864
+ const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
4247
3865
 
4248
3866
  const pendingNodes = [];
4249
3867
  const pendingInputAccessors = [];
@@ -4257,16 +3875,13 @@ class GLTFParser {
4257
3875
  const channel = animationDef.channels[ i ];
4258
3876
  const sampler = animationDef.samplers[ channel.sampler ];
4259
3877
  const target = channel.target;
3878
+ const name = target.node;
4260
3879
  const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
4261
3880
  const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
4262
3881
 
4263
- const nodeDependency = parser._invokeOne( function ( ext ) {
3882
+ if ( target.node === undefined ) continue;
4264
3883
 
4265
- return ext.loadAnimationTargetFromChannel && ext.loadAnimationTargetFromChannel( channel );
4266
-
4267
- } );
4268
-
4269
- pendingNodes.push( nodeDependency );
3884
+ pendingNodes.push( this.getDependency( 'node', name ) );
4270
3885
  pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
4271
3886
  pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
4272
3887
  pendingSamplers.push( sampler );
@@ -4309,11 +3924,7 @@ class GLTFParser {
4309
3924
 
4310
3925
  }
4311
3926
 
4312
- const createdTracks = parser._invokeOne( function ( ext ) {
4313
-
4314
- return ext.createAnimationTracks && ext.createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target );
4315
-
4316
- } );
3927
+ const createdTracks = parser._createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target );
4317
3928
 
4318
3929
  if ( createdTracks ) {
4319
3930
 
@@ -4327,9 +3938,7 @@ class GLTFParser {
4327
3938
 
4328
3939
  }
4329
3940
 
4330
- const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
4331
-
4332
- return new AnimationClip( name, undefined, tracks );
3941
+ return new AnimationClip( animationName, undefined, tracks );
4333
3942
 
4334
3943
  } );
4335
3944
 
@@ -4378,53 +3987,118 @@ class GLTFParser {
4378
3987
  loadNode( nodeIndex ) {
4379
3988
 
4380
3989
  const json = this.json;
4381
- const extensions = this.extensions;
4382
3990
  const parser = this;
4383
3991
 
4384
3992
  const nodeDef = json.nodes[ nodeIndex ];
4385
3993
 
4386
- // reserve node's name before its dependencies, so the root has the intended name.
4387
- const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
3994
+ const nodePending = parser._loadNodeShallow( nodeIndex );
4388
3995
 
4389
- return ( function () {
3996
+ const childPending = [];
3997
+ const childrenDef = nodeDef.children || [];
4390
3998
 
4391
- const pending = [];
3999
+ for ( let i = 0, il = childrenDef.length; i < il; i ++ ) {
4392
4000
 
4393
- const meshPromise = parser._invokeOne( function ( ext ) {
4001
+ childPending.push( parser.getDependency( 'node', childrenDef[ i ] ) );
4394
4002
 
4395
- return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
4003
+ }
4396
4004
 
4397
- } );
4005
+ const skeletonPending = nodeDef.skin === undefined
4006
+ ? Promise.resolve( null )
4007
+ : parser.getDependency( 'skin', nodeDef.skin );
4398
4008
 
4399
- if ( meshPromise ) {
4009
+ return Promise.all( [
4010
+ nodePending,
4011
+ Promise.all( childPending ),
4012
+ skeletonPending
4013
+ ] ).then( function ( results ) {
4400
4014
 
4401
- pending.push( meshPromise );
4015
+ const node = results[ 0 ];
4016
+ const children = results[ 1 ];
4017
+ const skeleton = results[ 2 ];
4402
4018
 
4403
- }
4019
+ if ( skeleton !== null ) {
4404
4020
 
4405
- if ( nodeDef.camera !== undefined ) {
4021
+ // This full traverse should be fine because
4022
+ // child glTF nodes have not been added to this node yet.
4023
+ node.traverse( function ( mesh ) {
4406
4024
 
4407
- pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
4025
+ if ( ! mesh.isSkinnedMesh ) return;
4408
4026
 
4409
- return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
4027
+ mesh.bind( skeleton, _identityMatrix );
4410
4028
 
4411
- } ) );
4029
+ } );
4412
4030
 
4413
4031
  }
4414
4032
 
4415
- parser._invokeAll( function ( ext ) {
4033
+ for ( let i = 0, il = children.length; i < il; i ++ ) {
4416
4034
 
4417
- return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
4035
+ node.add( children[ i ] );
4418
4036
 
4419
- } ).forEach( function ( promise ) {
4037
+ }
4420
4038
 
4421
- pending.push( promise );
4039
+ return node;
4422
4040
 
4423
- } );
4041
+ } );
4042
+
4043
+ }
4044
+
4045
+ // ._loadNodeShallow() parses a single node.
4046
+ // skin and child nodes are created and added in .loadNode() (no '_' prefix).
4047
+ _loadNodeShallow( nodeIndex ) {
4048
+
4049
+ const json = this.json;
4050
+ const extensions = this.extensions;
4051
+ const parser = this;
4052
+
4053
+ // This method is called from .loadNode() and .loadSkin().
4054
+ // Cache a node to avoid duplication.
4055
+
4056
+ if ( this.nodeCache[ nodeIndex ] !== undefined ) {
4057
+
4058
+ return this.nodeCache[ nodeIndex ];
4059
+
4060
+ }
4061
+
4062
+ const nodeDef = json.nodes[ nodeIndex ];
4063
+
4064
+ // reserve node's name before its dependencies, so the root has the intended name.
4065
+ const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
4066
+
4067
+ const pending = [];
4068
+
4069
+ const meshPromise = parser._invokeOne( function ( ext ) {
4070
+
4071
+ return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
4072
+
4073
+ } );
4424
4074
 
4425
- return Promise.all( pending );
4075
+ if ( meshPromise ) {
4426
4076
 
4427
- }() ).then( function ( objects ) {
4077
+ pending.push( meshPromise );
4078
+
4079
+ }
4080
+
4081
+ if ( nodeDef.camera !== undefined ) {
4082
+
4083
+ pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
4084
+
4085
+ return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
4086
+
4087
+ } ) );
4088
+
4089
+ }
4090
+
4091
+ parser._invokeAll( function ( ext ) {
4092
+
4093
+ return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
4094
+
4095
+ } ).forEach( function ( promise ) {
4096
+
4097
+ pending.push( promise );
4098
+
4099
+ } );
4100
+
4101
+ this.nodeCache[ nodeIndex ] = Promise.all( pending ).then( function ( objects ) {
4428
4102
 
4429
4103
  let node;
4430
4104
 
@@ -4508,6 +4182,8 @@ class GLTFParser {
4508
4182
 
4509
4183
  } );
4510
4184
 
4185
+ return this.nodeCache[ nodeIndex ];
4186
+
4511
4187
  }
4512
4188
 
4513
4189
  /**
@@ -4517,7 +4193,6 @@ class GLTFParser {
4517
4193
  */
4518
4194
  loadScene( sceneIndex ) {
4519
4195
 
4520
- const json = this.json;
4521
4196
  const extensions = this.extensions;
4522
4197
  const sceneDef = this.json.scenes[ sceneIndex ];
4523
4198
  const parser = this;
@@ -4537,11 +4212,17 @@ class GLTFParser {
4537
4212
 
4538
4213
  for ( let i = 0, il = nodeIds.length; i < il; i ++ ) {
4539
4214
 
4540
- pending.push( buildNodeHierarchy( nodeIds[ i ], scene, json, parser ) );
4215
+ pending.push( parser.getDependency( 'node', nodeIds[ i ] ) );
4541
4216
 
4542
4217
  }
4543
4218
 
4544
- return Promise.all( pending ).then( function () {
4219
+ return Promise.all( pending ).then( function ( nodes ) {
4220
+
4221
+ for ( let i = 0, il = nodes.length; i < il; i ++ ) {
4222
+
4223
+ scene.add( nodes[ i ] );
4224
+
4225
+ }
4545
4226
 
4546
4227
  // Removes dangling associations, associations that reference a node that
4547
4228
  // didn't make it into the scene.
@@ -4583,15 +4264,7 @@ class GLTFParser {
4583
4264
 
4584
4265
  }
4585
4266
 
4586
- loadAnimationTargetFromChannel( animationChannel ) {
4587
-
4588
- const target = animationChannel.target;
4589
- const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.
4590
- return this.getDependency( 'node', name );
4591
-
4592
- }
4593
-
4594
- createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
4267
+ _createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
4595
4268
 
4596
4269
  const tracks = [];
4597
4270
 
@@ -4643,9 +4316,6 @@ class GLTFParser {
4643
4316
  case 3:
4644
4317
  TypedKeyframeTrack = VectorKeyframeTrack;
4645
4318
  break;
4646
- case 4:
4647
- TypedKeyframeTrack = ColorKeyframeTrack;
4648
- break;
4649
4319
 
4650
4320
  }
4651
4321
 
@@ -4655,7 +4325,7 @@ class GLTFParser {
4655
4325
 
4656
4326
  const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;
4657
4327
 
4658
- const outputArray = getArrayFromAccessor( outputAccessor );
4328
+ const outputArray = this._getArrayFromAccessor( outputAccessor );
4659
4329
 
4660
4330
  for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) {
4661
4331
 
@@ -4669,7 +4339,7 @@ class GLTFParser {
4669
4339
  // Override interpolation with custom factory method.
4670
4340
  if ( interpolation === 'CUBICSPLINE' ) {
4671
4341
 
4672
- createCubicSplineTrackInterpolant( track );
4342
+ this._createCubicSplineTrackInterpolant( track );
4673
4343
 
4674
4344
  }
4675
4345
 
@@ -4681,101 +4351,47 @@ class GLTFParser {
4681
4351
 
4682
4352
  }
4683
4353
 
4684
- }
4685
-
4686
- function buildNodeHierarchy( nodeId, parentObject, json, parser ) {
4687
-
4688
- const nodeDef = json.nodes[ nodeId ];
4689
-
4690
- return parser.getDependency( 'node', nodeId ).then( function ( node ) {
4354
+ _getArrayFromAccessor( accessor ) {
4691
4355
 
4692
- if ( nodeDef.skin === undefined ) return node;
4356
+ let outputArray = accessor.array;
4693
4357
 
4694
- // build skeleton here as well
4358
+ if ( accessor.normalized ) {
4695
4359
 
4696
- let skinEntry;
4360
+ const scale = getNormalizedComponentScale( outputArray.constructor );
4361
+ const scaled = new Float32Array( outputArray.length );
4697
4362
 
4698
- return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) {
4363
+ for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
4699
4364
 
4700
- skinEntry = skin;
4701
-
4702
- const pendingJoints = [];
4703
-
4704
- for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) {
4705
-
4706
- pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) );
4365
+ scaled[ j ] = outputArray[ j ] * scale;
4707
4366
 
4708
4367
  }
4709
4368
 
4710
- return Promise.all( pendingJoints );
4711
-
4712
- } ).then( function ( jointNodes ) {
4713
-
4714
- node.traverse( function ( mesh ) {
4715
-
4716
- if ( ! mesh.isMesh ) return;
4717
-
4718
- const bones = [];
4719
- const boneInverses = [];
4720
-
4721
- for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) {
4722
-
4723
- const jointNode = jointNodes[ j ];
4724
-
4725
- if ( jointNode ) {
4726
-
4727
- bones.push( jointNode );
4728
-
4729
- const mat = new Matrix4();
4730
-
4731
- if ( skinEntry.inverseBindMatrices !== undefined ) {
4732
-
4733
- mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 );
4734
-
4735
- }
4736
-
4737
- boneInverses.push( mat );
4738
-
4739
- } else {
4740
-
4741
- console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] );
4742
-
4743
- }
4744
-
4745
- }
4746
-
4747
- mesh.bind( new Skeleton( bones, boneInverses ), mesh.matrixWorld );
4369
+ outputArray = scaled;
4748
4370
 
4749
- } );
4750
-
4751
- return node;
4752
-
4753
- } );
4754
-
4755
- } ).then( function ( node ) {
4756
-
4757
- // build node hierachy
4371
+ }
4758
4372
 
4759
- parentObject.add( node );
4373
+ return outputArray;
4760
4374
 
4761
- const pending = [];
4375
+ }
4762
4376
 
4763
- if ( nodeDef.children ) {
4377
+ _createCubicSplineTrackInterpolant( track ) {
4764
4378
 
4765
- const children = nodeDef.children;
4379
+ track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
4766
4380
 
4767
- for ( let i = 0, il = children.length; i < il; i ++ ) {
4381
+ // A CUBICSPLINE keyframe in glTF has three output values for each input value,
4382
+ // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
4383
+ // must be divided by three to get the interpolant's sampleSize argument.
4768
4384
 
4769
- const child = children[ i ];
4770
- pending.push( buildNodeHierarchy( child, node, json, parser ) );
4385
+ const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
4771
4386
 
4772
- }
4387
+ return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
4773
4388
 
4774
- }
4389
+ };
4775
4390
 
4776
- return Promise.all( pending );
4391
+ // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
4392
+ track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
4777
4393
 
4778
- } );
4394
+ }
4779
4395
 
4780
4396
  }
4781
4397
 
@@ -4954,98 +4570,4 @@ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
4954
4570
 
4955
4571
  }
4956
4572
 
4957
- /**
4958
- * @param {BufferGeometry} geometry
4959
- * @param {Number} drawMode
4960
- * @return {BufferGeometry}
4961
- */
4962
- function toTrianglesDrawMode( geometry, drawMode ) {
4963
-
4964
- let index = geometry.getIndex();
4965
-
4966
- // generate index if not present
4967
-
4968
- if ( index === null ) {
4969
-
4970
- const indices = [];
4971
-
4972
- const position = geometry.getAttribute( 'position' );
4973
-
4974
- if ( position !== undefined ) {
4975
-
4976
- for ( let i = 0; i < position.count; i ++ ) {
4977
-
4978
- indices.push( i );
4979
-
4980
- }
4981
-
4982
- geometry.setIndex( indices );
4983
- index = geometry.getIndex();
4984
-
4985
- } else {
4986
-
4987
- console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
4988
- return geometry;
4989
-
4990
- }
4991
-
4992
- }
4993
-
4994
- //
4995
-
4996
- const numberOfTriangles = index.count - 2;
4997
- const newIndices = [];
4998
-
4999
- if ( drawMode === TriangleFanDrawMode ) {
5000
-
5001
- // gl.TRIANGLE_FAN
5002
-
5003
- for ( let i = 1; i <= numberOfTriangles; i ++ ) {
5004
-
5005
- newIndices.push( index.getX( 0 ) );
5006
- newIndices.push( index.getX( i ) );
5007
- newIndices.push( index.getX( i + 1 ) );
5008
-
5009
- }
5010
-
5011
- } else {
5012
-
5013
- // gl.TRIANGLE_STRIP
5014
-
5015
- for ( let i = 0; i < numberOfTriangles; i ++ ) {
5016
-
5017
- if ( i % 2 === 0 ) {
5018
-
5019
- newIndices.push( index.getX( i ) );
5020
- newIndices.push( index.getX( i + 1 ) );
5021
- newIndices.push( index.getX( i + 2 ) );
5022
-
5023
-
5024
- } else {
5025
-
5026
- newIndices.push( index.getX( i + 2 ) );
5027
- newIndices.push( index.getX( i + 1 ) );
5028
- newIndices.push( index.getX( i ) );
5029
-
5030
- }
5031
-
5032
- }
5033
-
5034
- }
5035
-
5036
- if ( ( newIndices.length / 3 ) !== numberOfTriangles ) {
5037
-
5038
- console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
5039
-
5040
- }
5041
-
5042
- // build final geometry
5043
-
5044
- const newGeometry = geometry.clone();
5045
- newGeometry.setIndex( newIndices );
5046
-
5047
- return newGeometry;
5048
-
5049
- }
5050
-
5051
4573
  export { GLTFLoader };