@needle-tools/three 0.169.20-experimental.0 → 0.183.2-canary.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 (1051) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -6
  3. package/build/three.cjs +54184 -56703
  4. package/build/three.core.js +59506 -0
  5. package/build/three.core.min.js +6 -0
  6. package/build/three.module.js +11645 -73000
  7. package/build/three.module.min.js +2 -2
  8. package/build/three.tsl.js +648 -0
  9. package/build/three.tsl.min.js +6 -0
  10. package/build/three.webgpu.js +53912 -51652
  11. package/build/three.webgpu.min.js +2 -2
  12. package/build/three.webgpu.nodes.js +53888 -51806
  13. package/build/three.webgpu.nodes.min.js +2 -2
  14. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  15. package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
  16. package/examples/jsm/Addons.js +5 -15
  17. package/examples/jsm/animation/AnimationClipCreator.js +58 -6
  18. package/examples/jsm/animation/CCDIKSolver.js +152 -45
  19. package/examples/jsm/capabilities/WebGL.js +28 -29
  20. package/examples/jsm/capabilities/WebGPU.js +19 -17
  21. package/examples/jsm/controls/ArcballControls.js +474 -178
  22. package/examples/jsm/controls/DragControls.js +100 -58
  23. package/examples/jsm/controls/FirstPersonControls.js +116 -6
  24. package/examples/jsm/controls/FlyControls.js +50 -2
  25. package/examples/jsm/controls/MapControls.js +96 -8
  26. package/examples/jsm/controls/OrbitControls.js +496 -57
  27. package/examples/jsm/controls/PointerLockControls.js +115 -22
  28. package/examples/jsm/controls/TrackballControls.js +166 -14
  29. package/examples/jsm/controls/TransformControls.js +336 -26
  30. package/examples/jsm/csm/CSM.js +232 -18
  31. package/examples/jsm/csm/CSMFrustum.js +61 -4
  32. package/examples/jsm/csm/CSMHelper.js +50 -0
  33. package/examples/jsm/csm/CSMShader.js +13 -1
  34. package/examples/jsm/csm/CSMShadowNode.js +599 -0
  35. package/examples/jsm/curves/CurveExtras.js +303 -31
  36. package/examples/jsm/curves/NURBSCurve.js +91 -16
  37. package/examples/jsm/curves/NURBSSurface.js +52 -6
  38. package/examples/jsm/curves/NURBSUtils.js +102 -112
  39. package/examples/jsm/curves/NURBSVolume.js +24 -4
  40. package/examples/jsm/effects/AnaglyphEffect.js +134 -7
  41. package/examples/jsm/effects/AsciiEffect.js +69 -22
  42. package/examples/jsm/effects/OutlineEffect.js +61 -111
  43. package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
  44. package/examples/jsm/effects/StereoEffect.js +31 -0
  45. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  46. package/examples/jsm/environments/DebugEnvironment.js +50 -0
  47. package/examples/jsm/environments/RoomEnvironment.js +83 -42
  48. package/examples/jsm/exporters/DRACOExporter.js +56 -14
  49. package/examples/jsm/exporters/EXRExporter.js +40 -9
  50. package/examples/jsm/exporters/GLTFExporter.js +502 -169
  51. package/examples/jsm/exporters/OBJExporter.js +21 -1
  52. package/examples/jsm/exporters/PLYExporter.js +44 -12
  53. package/examples/jsm/exporters/STLExporter.js +27 -5
  54. package/examples/jsm/exporters/USDZExporter.js +781 -291
  55. package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
  56. package/examples/jsm/geometries/ConvexGeometry.js +19 -0
  57. package/examples/jsm/geometries/DecalGeometry.js +91 -30
  58. package/examples/jsm/geometries/ParametricFunctions.js +100 -0
  59. package/examples/jsm/geometries/ParametricGeometry.js +38 -5
  60. package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
  61. package/examples/jsm/geometries/TeapotGeometry.js +23 -38
  62. package/examples/jsm/geometries/TextGeometry.js +48 -29
  63. package/examples/jsm/gpgpu/BitonicSort.js +715 -0
  64. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  65. package/examples/jsm/helpers/LightProbeHelper.js +36 -0
  66. package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
  67. package/examples/jsm/helpers/OctreeHelper.js +36 -0
  68. package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
  69. package/examples/jsm/helpers/RapierHelper.js +59 -0
  70. package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
  71. package/examples/jsm/helpers/TextureHelper.js +28 -0
  72. package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
  73. package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
  74. package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
  75. package/examples/jsm/helpers/ViewHelper.js +181 -9
  76. package/examples/jsm/inspector/Inspector.js +487 -0
  77. package/examples/jsm/inspector/RendererInspector.js +425 -0
  78. package/examples/jsm/inspector/tabs/Console.js +238 -0
  79. package/examples/jsm/inspector/tabs/Parameters.js +348 -0
  80. package/examples/jsm/inspector/tabs/Performance.js +268 -0
  81. package/examples/jsm/inspector/tabs/Viewer.js +166 -0
  82. package/examples/jsm/inspector/ui/Graph.js +95 -0
  83. package/examples/jsm/inspector/ui/Item.js +170 -0
  84. package/examples/jsm/inspector/ui/List.js +75 -0
  85. package/examples/jsm/inspector/ui/Profiler.js +1975 -0
  86. package/examples/jsm/inspector/ui/Style.js +1613 -0
  87. package/examples/jsm/inspector/ui/Tab.js +233 -0
  88. package/examples/jsm/inspector/ui/Values.js +439 -0
  89. package/examples/jsm/inspector/ui/utils.js +56 -0
  90. package/examples/jsm/interactive/HTMLMesh.js +43 -12
  91. package/examples/jsm/interactive/InteractiveGroup.js +170 -52
  92. package/examples/jsm/interactive/SelectionBox.js +106 -9
  93. package/examples/jsm/interactive/SelectionHelper.js +76 -30
  94. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  95. package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
  96. package/examples/jsm/libs/motion-controllers.module.js +1 -1
  97. package/examples/jsm/lighting/TiledLighting.js +42 -0
  98. package/examples/jsm/lights/LightProbeGenerator.js +44 -7
  99. package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
  100. package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
  101. package/examples/jsm/lines/Line2.js +41 -4
  102. package/examples/jsm/lines/LineGeometry.js +80 -2
  103. package/examples/jsm/lines/LineMaterial.js +105 -5
  104. package/examples/jsm/lines/LineSegments2.js +54 -4
  105. package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
  106. package/examples/jsm/lines/Wireframe.js +41 -4
  107. package/examples/jsm/lines/WireframeGeometry2.js +27 -2
  108. package/examples/jsm/lines/webgpu/Line2.js +28 -2
  109. package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
  110. package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
  111. package/examples/jsm/loaders/3DMLoader.js +78 -6
  112. package/examples/jsm/loaders/3MFLoader.js +148 -7
  113. package/examples/jsm/loaders/AMFLoader.js +34 -14
  114. package/examples/jsm/loaders/BVHLoader.js +59 -12
  115. package/examples/jsm/loaders/ColladaLoader.js +61 -4027
  116. package/examples/jsm/loaders/DDSLoader.js +68 -1
  117. package/examples/jsm/loaders/DRACOLoader.js +146 -22
  118. package/examples/jsm/loaders/EXRLoader.js +255 -34
  119. package/examples/jsm/loaders/FBXLoader.js +80 -42
  120. package/examples/jsm/loaders/FontLoader.js +83 -6
  121. package/examples/jsm/loaders/GCodeLoader.js +71 -14
  122. package/examples/jsm/loaders/GLTFLoader.js +381 -263
  123. package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
  124. package/examples/jsm/loaders/HDRLoader.js +485 -0
  125. package/examples/jsm/loaders/IESLoader.js +42 -0
  126. package/examples/jsm/loaders/KMZLoader.js +39 -6
  127. package/examples/jsm/loaders/KTX2Loader.js +124 -48
  128. package/examples/jsm/loaders/KTXLoader.js +31 -10
  129. package/examples/jsm/loaders/LDrawLoader.js +192 -145
  130. package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
  131. package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
  132. package/examples/jsm/loaders/LUTImageLoader.js +79 -38
  133. package/examples/jsm/loaders/LWOLoader.js +54 -59
  134. package/examples/jsm/loaders/LottieLoader.js +54 -1
  135. package/examples/jsm/loaders/MD2Loader.js +37 -1
  136. package/examples/jsm/loaders/MDDLoader.js +57 -12
  137. package/examples/jsm/loaders/MTLLoader.js +60 -35
  138. package/examples/jsm/loaders/MaterialXLoader.js +268 -34
  139. package/examples/jsm/loaders/NRRDLoader.js +40 -8
  140. package/examples/jsm/loaders/OBJLoader.js +51 -2
  141. package/examples/jsm/loaders/PCDLoader.js +173 -21
  142. package/examples/jsm/loaders/PDBLoader.js +41 -2
  143. package/examples/jsm/loaders/PLYLoader.js +70 -39
  144. package/examples/jsm/loaders/PVRLoader.js +25 -6
  145. package/examples/jsm/loaders/RGBELoader.js +6 -438
  146. package/examples/jsm/loaders/STLLoader.js +48 -38
  147. package/examples/jsm/loaders/SVGLoader.js +119 -25
  148. package/examples/jsm/loaders/TDSLoader.js +92 -74
  149. package/examples/jsm/loaders/TGALoader.js +23 -2
  150. package/examples/jsm/loaders/TIFFLoader.js +23 -0
  151. package/examples/jsm/loaders/TTFLoader.js +50 -3
  152. package/examples/jsm/loaders/USDLoader.js +279 -0
  153. package/examples/jsm/loaders/USDZLoader.js +4 -858
  154. package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
  155. package/examples/jsm/loaders/VOXLoader.js +688 -87
  156. package/examples/jsm/loaders/VRMLLoader.js +121 -12
  157. package/examples/jsm/loaders/VTKLoader.js +77 -25
  158. package/examples/jsm/loaders/XYZLoader.js +36 -0
  159. package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
  160. package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
  161. package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
  162. package/examples/jsm/loaders/usd/USDAParser.js +822 -0
  163. package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
  164. package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
  165. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
  166. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
  167. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  168. package/examples/jsm/math/Capsule.js +91 -14
  169. package/examples/jsm/math/ColorConverter.js +22 -0
  170. package/examples/jsm/math/ColorSpaces.js +74 -2
  171. package/examples/jsm/math/ConvexHull.js +517 -93
  172. package/examples/jsm/math/ImprovedNoise.js +32 -15
  173. package/examples/jsm/math/Lut.js +113 -0
  174. package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
  175. package/examples/jsm/math/OBB.js +141 -29
  176. package/examples/jsm/math/Octree.js +283 -7
  177. package/examples/jsm/math/SimplexNoise.js +68 -42
  178. package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
  179. package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
  180. package/examples/jsm/misc/Gyroscope.js +12 -0
  181. package/examples/jsm/misc/MD2Character.js +117 -2
  182. package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
  183. package/examples/jsm/misc/MorphAnimMesh.js +44 -0
  184. package/examples/jsm/misc/MorphBlendMesh.js +103 -0
  185. package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
  186. package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
  187. package/examples/jsm/misc/RollerCoaster.js +57 -0
  188. package/examples/jsm/misc/TubePainter.js +437 -40
  189. package/examples/jsm/misc/Volume.js +123 -76
  190. package/examples/jsm/misc/VolumeSlice.js +95 -49
  191. package/examples/jsm/modifiers/CurveModifier.js +66 -38
  192. package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
  193. package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
  194. package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
  195. package/examples/jsm/modifiers/TessellateModifier.js +35 -2
  196. package/examples/jsm/objects/GroundedSkybox.js +25 -6
  197. package/examples/jsm/objects/Lensflare.js +94 -2
  198. package/examples/jsm/objects/LensflareMesh.js +64 -10
  199. package/examples/jsm/objects/MarchingCubes.js +90 -5
  200. package/examples/jsm/objects/Reflector.js +76 -2
  201. package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
  202. package/examples/jsm/objects/Refractor.js +62 -0
  203. package/examples/jsm/objects/ShadowMesh.js +54 -4
  204. package/examples/jsm/objects/Sky.js +106 -16
  205. package/examples/jsm/objects/SkyMesh.js +211 -38
  206. package/examples/jsm/objects/Water.js +49 -8
  207. package/examples/jsm/objects/Water2.js +49 -7
  208. package/examples/jsm/objects/Water2Mesh.js +50 -9
  209. package/examples/jsm/objects/WaterMesh.js +136 -43
  210. package/examples/jsm/physics/AmmoPhysics.js +60 -7
  211. package/examples/jsm/physics/JoltPhysics.js +65 -12
  212. package/examples/jsm/physics/RapierPhysics.js +217 -21
  213. package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
  214. package/examples/jsm/postprocessing/BloomPass.js +128 -26
  215. package/examples/jsm/postprocessing/BokehPass.js +99 -22
  216. package/examples/jsm/postprocessing/ClearPass.js +54 -3
  217. package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
  218. package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
  219. package/examples/jsm/postprocessing/EffectComposer.js +140 -6
  220. package/examples/jsm/postprocessing/FXAAPass.js +40 -0
  221. package/examples/jsm/postprocessing/FilmPass.js +54 -5
  222. package/examples/jsm/postprocessing/GTAOPass.js +202 -57
  223. package/examples/jsm/postprocessing/GlitchPass.js +86 -34
  224. package/examples/jsm/postprocessing/HalftonePass.js +65 -10
  225. package/examples/jsm/postprocessing/LUTPass.js +38 -8
  226. package/examples/jsm/postprocessing/MaskPass.js +91 -0
  227. package/examples/jsm/postprocessing/OutlinePass.js +272 -135
  228. package/examples/jsm/postprocessing/OutputPass.js +65 -14
  229. package/examples/jsm/postprocessing/Pass.js +100 -4
  230. package/examples/jsm/postprocessing/RenderPass.js +94 -0
  231. package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
  232. package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
  233. package/examples/jsm/postprocessing/SAOPass.js +128 -55
  234. package/examples/jsm/postprocessing/SMAAPass.js +106 -75
  235. package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
  236. package/examples/jsm/postprocessing/SSAOPass.js +173 -60
  237. package/examples/jsm/postprocessing/SSRPass.js +268 -53
  238. package/examples/jsm/postprocessing/SavePass.js +69 -16
  239. package/examples/jsm/postprocessing/ShaderPass.js +65 -7
  240. package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
  241. package/examples/jsm/postprocessing/TexturePass.js +72 -8
  242. package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
  243. package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
  244. package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
  245. package/examples/jsm/renderers/Projector.js +288 -32
  246. package/examples/jsm/renderers/SVGRenderer.js +323 -61
  247. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
  248. package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
  249. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
  250. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
  251. package/examples/jsm/shaders/AfterimageShader.js +8 -3
  252. package/examples/jsm/shaders/BasicShader.js +8 -1
  253. package/examples/jsm/shaders/BleachBypassShader.js +10 -3
  254. package/examples/jsm/shaders/BlendShader.js +8 -1
  255. package/examples/jsm/shaders/BokehShader.js +9 -3
  256. package/examples/jsm/shaders/BokehShader2.js +11 -4
  257. package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
  258. package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
  259. package/examples/jsm/shaders/ColorifyShader.js +8 -1
  260. package/examples/jsm/shaders/ConvolutionShader.js +9 -38
  261. package/examples/jsm/shaders/CopyShader.js +8 -1
  262. package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
  263. package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
  264. package/examples/jsm/shaders/DigitalGlitch.js +10 -7
  265. package/examples/jsm/shaders/DotScreenShader.js +8 -3
  266. package/examples/jsm/shaders/ExposureShader.js +8 -1
  267. package/examples/jsm/shaders/FXAAShader.js +233 -221
  268. package/examples/jsm/shaders/FilmShader.js +13 -0
  269. package/examples/jsm/shaders/FocusShader.js +8 -3
  270. package/examples/jsm/shaders/FreiChenShader.js +10 -3
  271. package/examples/jsm/shaders/GTAOShader.js +55 -45
  272. package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
  273. package/examples/jsm/shaders/HalftoneShader.js +24 -4
  274. package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
  275. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
  276. package/examples/jsm/shaders/HueSaturationShader.js +10 -3
  277. package/examples/jsm/shaders/KaleidoShader.js +11 -4
  278. package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
  279. package/examples/jsm/shaders/LuminosityShader.js +8 -2
  280. package/examples/jsm/shaders/MirrorShader.js +10 -4
  281. package/examples/jsm/shaders/NormalMapShader.js +7 -2
  282. package/examples/jsm/shaders/OutputShader.js +19 -1
  283. package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
  284. package/examples/jsm/shaders/RGBShiftShader.js +8 -1
  285. package/examples/jsm/shaders/SAOShader.js +27 -5
  286. package/examples/jsm/shaders/SMAAShader.js +24 -1
  287. package/examples/jsm/shaders/SSAOShader.js +37 -6
  288. package/examples/jsm/shaders/SSRShader.js +32 -6
  289. package/examples/jsm/shaders/SepiaShader.js +8 -3
  290. package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
  291. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
  292. package/examples/jsm/shaders/TechnicolorShader.js +10 -4
  293. package/examples/jsm/shaders/ToonShader.js +29 -6
  294. package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
  295. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
  296. package/examples/jsm/shaders/VelocityShader.js +8 -1
  297. package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
  298. package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
  299. package/examples/jsm/shaders/VignetteShader.js +8 -3
  300. package/examples/jsm/shaders/VolumeShader.js +11 -2
  301. package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
  302. package/examples/jsm/textures/FlakesTexture.js +14 -0
  303. package/examples/jsm/transpiler/AST.js +436 -31
  304. package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
  305. package/examples/jsm/transpiler/Linker.js +327 -0
  306. package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
  307. package/examples/jsm/transpiler/TSLEncoder.js +363 -97
  308. package/examples/jsm/transpiler/Transpiler.js +50 -1
  309. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  310. package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
  311. package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
  312. package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
  313. package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
  314. package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
  315. package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
  316. package/examples/jsm/tsl/display/BloomNode.js +534 -0
  317. package/examples/jsm/tsl/display/CRT.js +150 -0
  318. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
  319. package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
  320. package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
  321. package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
  322. package/examples/jsm/tsl/display/FXAANode.js +365 -0
  323. package/examples/jsm/tsl/display/FilmNode.js +101 -0
  324. package/examples/jsm/tsl/display/GTAONode.js +571 -0
  325. package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
  326. package/examples/jsm/tsl/display/GodraysNode.js +624 -0
  327. package/examples/jsm/tsl/display/LensflareNode.js +279 -0
  328. package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
  329. package/examples/jsm/tsl/display/MotionBlur.js +33 -0
  330. package/examples/jsm/tsl/display/OutlineNode.js +762 -0
  331. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
  332. package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
  333. package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
  334. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  335. package/examples/jsm/tsl/display/SMAANode.js +768 -0
  336. package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
  337. package/examples/jsm/tsl/display/SSGINode.js +642 -0
  338. package/examples/jsm/tsl/display/SSRNode.js +656 -0
  339. package/examples/jsm/tsl/display/SSSNode.js +490 -0
  340. package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
  341. package/examples/jsm/tsl/display/Shape.js +29 -0
  342. package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
  343. package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
  344. package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
  345. package/examples/jsm/tsl/display/TRAANode.js +726 -0
  346. package/examples/jsm/tsl/display/TransitionNode.js +141 -0
  347. package/examples/jsm/tsl/display/boxBlur.js +65 -0
  348. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  349. package/examples/jsm/tsl/display/hashBlur.js +54 -0
  350. package/examples/jsm/tsl/display/radialBlur.js +68 -0
  351. package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
  352. package/examples/jsm/tsl/math/Bayer.js +73 -0
  353. package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
  354. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
  355. package/examples/jsm/tsl/utils/Raymarching.js +70 -0
  356. package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
  357. package/examples/jsm/utils/CameraUtils.js +15 -6
  358. package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
  359. package/examples/jsm/utils/GeometryUtils.js +32 -27
  360. package/examples/jsm/utils/LDrawUtils.js +14 -5
  361. package/examples/jsm/utils/SceneOptimizer.js +458 -0
  362. package/examples/jsm/utils/SceneUtils.js +53 -3
  363. package/examples/jsm/utils/ShadowMapViewer.js +72 -33
  364. package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
  365. package/examples/jsm/utils/SkeletonUtils.js +48 -0
  366. package/examples/jsm/utils/SortUtils.js +17 -5
  367. package/examples/jsm/utils/UVsDebug.js +12 -4
  368. package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
  369. package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
  370. package/examples/jsm/utils/WorkerPool.js +67 -2
  371. package/examples/jsm/webxr/ARButton.js +19 -0
  372. package/examples/jsm/webxr/OculusHandModel.js +84 -0
  373. package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
  374. package/examples/jsm/webxr/Text2D.js +20 -6
  375. package/examples/jsm/webxr/VRButton.js +31 -0
  376. package/examples/jsm/webxr/XRButton.js +23 -0
  377. package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
  378. package/examples/jsm/webxr/XREstimatedLight.js +35 -4
  379. package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
  380. package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
  381. package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
  382. package/examples/jsm/webxr/XRPlanes.js +18 -0
  383. package/package.json +29 -37
  384. package/src/Three.Core.js +198 -0
  385. package/src/Three.Legacy.js +0 -21
  386. package/src/Three.TSL.js +641 -0
  387. package/src/Three.WebGPU.Nodes.js +14 -186
  388. package/src/Three.WebGPU.js +16 -186
  389. package/src/Three.js +2 -197
  390. package/src/animation/AnimationAction.js +263 -31
  391. package/src/animation/AnimationClip.js +162 -7
  392. package/src/animation/AnimationMixer.js +105 -15
  393. package/src/animation/AnimationObjectGroup.js +45 -21
  394. package/src/animation/AnimationUtils.js +163 -24
  395. package/src/animation/KeyframeTrack.js +191 -17
  396. package/src/animation/PropertyBinding.js +91 -16
  397. package/src/animation/PropertyMixer.js +72 -5
  398. package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
  399. package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
  400. package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
  401. package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
  402. package/src/animation/tracks/StringKeyframeTrack.js +33 -2
  403. package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
  404. package/src/audio/Audio.js +386 -8
  405. package/src/audio/AudioAnalyser.js +58 -1
  406. package/src/audio/AudioContext.js +15 -0
  407. package/src/audio/AudioListener.js +94 -13
  408. package/src/audio/PositionalAudio.js +107 -0
  409. package/src/cameras/ArrayCamera.js +37 -0
  410. package/src/cameras/Camera.js +61 -0
  411. package/src/cameras/CubeCamera.js +86 -0
  412. package/src/cameras/OrthographicCamera.js +110 -1
  413. package/src/cameras/PerspectiveCamera.js +174 -35
  414. package/src/cameras/StereoCamera.js +48 -2
  415. package/src/constants.js +1546 -11
  416. package/src/core/BufferAttribute.js +417 -3
  417. package/src/core/BufferGeometry.js +407 -22
  418. package/src/core/Clock.js +69 -8
  419. package/src/core/EventDispatcher.js +52 -8
  420. package/src/core/GLBufferAttribute.js +113 -2
  421. package/src/core/InstancedBufferAttribute.js +29 -0
  422. package/src/core/InstancedBufferGeometry.js +20 -0
  423. package/src/core/InstancedInterleavedBuffer.js +26 -0
  424. package/src/core/InterleavedBuffer.js +141 -7
  425. package/src/core/InterleavedBufferAttribute.js +200 -2
  426. package/src/core/Layers.js +71 -10
  427. package/src/core/Object3D.js +673 -26
  428. package/src/core/Raycaster.js +136 -2
  429. package/src/core/RenderTarget.js +256 -27
  430. package/src/core/RenderTarget3D.js +48 -0
  431. package/src/core/Timer.js +184 -0
  432. package/src/core/Uniform.js +29 -0
  433. package/src/core/UniformsGroup.js +84 -2
  434. package/src/extras/Controls.js +89 -1
  435. package/src/extras/DataUtils.js +50 -9
  436. package/src/extras/Earcut.js +18 -779
  437. package/src/extras/ImageUtils.js +22 -14
  438. package/src/extras/PMREMGenerator.js +316 -67
  439. package/src/extras/ShapeUtils.js +24 -2
  440. package/src/extras/TextureUtils.js +101 -15
  441. package/src/extras/core/Curve.js +156 -55
  442. package/src/extras/core/CurvePath.js +63 -22
  443. package/src/extras/core/Interpolations.js +34 -2
  444. package/src/extras/core/Path.js +134 -1
  445. package/src/extras/core/Shape.js +66 -3
  446. package/src/extras/core/ShapePath.js +80 -4
  447. package/src/extras/curves/ArcCurve.js +22 -0
  448. package/src/extras/curves/CatmullRomCurve3.js +89 -18
  449. package/src/extras/curves/CubicBezierCurve.js +67 -0
  450. package/src/extras/curves/CubicBezierCurve3.js +50 -0
  451. package/src/extras/curves/EllipseCurve.js +102 -0
  452. package/src/extras/curves/LineCurve.js +36 -0
  453. package/src/extras/curves/LineCurve3.js +36 -0
  454. package/src/extras/curves/QuadraticBezierCurve.js +59 -0
  455. package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
  456. package/src/extras/curves/SplineCurve.js +48 -0
  457. package/src/extras/lib/earcut.js +685 -0
  458. package/src/geometries/BoxGeometry.js +39 -0
  459. package/src/geometries/CapsuleGeometry.js +196 -11
  460. package/src/geometries/CircleGeometry.js +41 -0
  461. package/src/geometries/ConeGeometry.js +39 -0
  462. package/src/geometries/CylinderGeometry.js +42 -2
  463. package/src/geometries/DodecahedronGeometry.js +33 -0
  464. package/src/geometries/EdgesGeometry.js +30 -2
  465. package/src/geometries/ExtrudeGeometry.js +148 -52
  466. package/src/geometries/IcosahedronGeometry.js +33 -0
  467. package/src/geometries/LatheGeometry.js +44 -3
  468. package/src/geometries/OctahedronGeometry.js +33 -0
  469. package/src/geometries/PlaneGeometry.js +35 -0
  470. package/src/geometries/PolyhedronGeometry.js +30 -1
  471. package/src/geometries/RingGeometry.js +37 -0
  472. package/src/geometries/ShapeGeometry.js +38 -0
  473. package/src/geometries/SphereGeometry.js +38 -0
  474. package/src/geometries/TetrahedronGeometry.js +33 -0
  475. package/src/geometries/TorusGeometry.js +44 -3
  476. package/src/geometries/TorusKnotGeometry.js +39 -0
  477. package/src/geometries/TubeGeometry.js +50 -0
  478. package/src/geometries/WireframeGeometry.js +32 -0
  479. package/src/helpers/ArrowHelper.js +62 -5
  480. package/src/helpers/AxesHelper.js +28 -0
  481. package/src/helpers/Box3Helper.js +28 -0
  482. package/src/helpers/BoxHelper.js +43 -7
  483. package/src/helpers/CameraHelper.js +103 -27
  484. package/src/helpers/DirectionalLightHelper.js +55 -0
  485. package/src/helpers/GridHelper.js +26 -0
  486. package/src/helpers/HemisphereLightHelper.js +42 -0
  487. package/src/helpers/PlaneHelper.js +33 -0
  488. package/src/helpers/PointLightHelper.js +43 -24
  489. package/src/helpers/PolarGridHelper.js +30 -0
  490. package/src/helpers/SkeletonHelper.js +73 -7
  491. package/src/helpers/SpotLightHelper.js +43 -0
  492. package/src/lights/AmbientLight.js +25 -0
  493. package/src/lights/DirectionalLight.js +70 -0
  494. package/src/lights/DirectionalLightShadow.js +15 -0
  495. package/src/lights/HemisphereLight.js +42 -0
  496. package/src/lights/Light.js +37 -11
  497. package/src/lights/LightProbe.js +37 -9
  498. package/src/lights/LightShadow.js +202 -7
  499. package/src/lights/PointLight.js +74 -0
  500. package/src/lights/PointLightShadow.js +15 -80
  501. package/src/lights/RectAreaLight.js +59 -0
  502. package/src/lights/SpotLight.js +124 -1
  503. package/src/lights/SpotLightShadow.js +33 -3
  504. package/src/lights/webgpu/IESSpotLight.js +22 -0
  505. package/src/lights/webgpu/ProjectorLight.js +46 -0
  506. package/src/loaders/AnimationLoader.js +34 -2
  507. package/src/loaders/AudioLoader.js +34 -2
  508. package/src/loaders/BufferGeometryLoader.js +38 -13
  509. package/src/loaders/Cache.js +75 -2
  510. package/src/loaders/CompressedTextureLoader.js +36 -3
  511. package/src/loaders/CubeTextureLoader.js +45 -0
  512. package/src/loaders/DataTextureLoader.js +45 -4
  513. package/src/loaders/FileLoader.js +85 -5
  514. package/src/loaders/ImageBitmapLoader.js +113 -11
  515. package/src/loaders/ImageLoader.js +85 -8
  516. package/src/loaders/Loader.js +150 -0
  517. package/src/loaders/LoaderUtils.js +18 -36
  518. package/src/loaders/LoadingManager.js +187 -0
  519. package/src/loaders/MaterialLoader.js +62 -3
  520. package/src/loaders/ObjectLoader.js +131 -31
  521. package/src/loaders/TextureLoader.js +33 -0
  522. package/src/loaders/nodes/NodeLoader.js +68 -4
  523. package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
  524. package/src/loaders/nodes/NodeObjectLoader.js +61 -0
  525. package/src/materials/LineBasicMaterial.js +74 -1
  526. package/src/materials/LineDashedMaterial.js +52 -1
  527. package/src/materials/Material.js +502 -8
  528. package/src/materials/MeshBasicMaterial.js +168 -2
  529. package/src/materials/MeshDepthMaterial.js +94 -0
  530. package/src/materials/MeshDistanceMaterial.js +76 -0
  531. package/src/materials/MeshLambertMaterial.js +283 -0
  532. package/src/materials/MeshMatcapMaterial.js +164 -0
  533. package/src/materials/MeshNormalMaterial.js +114 -0
  534. package/src/materials/MeshPhongMaterial.js +298 -0
  535. package/src/materials/MeshPhysicalMaterial.js +296 -4
  536. package/src/materials/MeshStandardMaterial.js +300 -2
  537. package/src/materials/MeshToonMaterial.js +219 -0
  538. package/src/materials/PointsMaterial.js +89 -0
  539. package/src/materials/RawShaderMaterial.js +25 -0
  540. package/src/materials/ShaderMaterial.js +234 -6
  541. package/src/materials/ShadowMaterial.js +54 -0
  542. package/src/materials/SpriteMaterial.js +82 -0
  543. package/src/materials/nodes/Line2NodeMaterial.js +158 -53
  544. package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
  545. package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
  546. package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
  547. package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
  548. package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
  549. package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
  550. package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
  551. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
  552. package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
  553. package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
  554. package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
  555. package/src/materials/nodes/NodeMaterial.js +789 -74
  556. package/src/materials/nodes/NodeMaterials.js +0 -1
  557. package/src/materials/nodes/PointsNodeMaterial.js +180 -11
  558. package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
  559. package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
  560. package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
  561. package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
  562. package/src/math/Box2.js +177 -0
  563. package/src/math/Box3.js +271 -0
  564. package/src/math/Color.js +355 -11
  565. package/src/math/ColorManagement.js +158 -92
  566. package/src/math/Cylindrical.js +65 -6
  567. package/src/math/Euler.js +139 -5
  568. package/src/math/Frustum.js +108 -9
  569. package/src/math/FrustumArray.js +258 -0
  570. package/src/math/Interpolant.js +87 -8
  571. package/src/math/Line3.js +221 -2
  572. package/src/math/MathUtils.js +408 -20
  573. package/src/math/Matrix2.js +70 -0
  574. package/src/math/Matrix3.js +229 -4
  575. package/src/math/Matrix4.js +489 -94
  576. package/src/math/Plane.js +164 -2
  577. package/src/math/Quaternion.js +322 -90
  578. package/src/math/Ray.js +162 -0
  579. package/src/math/Sphere.js +175 -0
  580. package/src/math/Spherical.js +73 -11
  581. package/src/math/SphericalHarmonics3.js +112 -14
  582. package/src/math/Triangle.js +206 -2
  583. package/src/math/Vector2.js +396 -10
  584. package/src/math/Vector3.js +550 -15
  585. package/src/math/Vector4.js +415 -9
  586. package/src/math/interpolants/BezierInterpolant.js +108 -0
  587. package/src/math/interpolants/CubicInterpolant.js +10 -1
  588. package/src/math/interpolants/DiscreteInterpolant.js +10 -2
  589. package/src/math/interpolants/LinearInterpolant.js +13 -0
  590. package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
  591. package/src/nodes/Nodes.js +91 -88
  592. package/src/nodes/TSL.js +32 -38
  593. package/src/nodes/accessors/AccessorsUtils.js +37 -9
  594. package/src/nodes/accessors/Arrays.js +68 -0
  595. package/src/nodes/accessors/BatchNode.js +49 -14
  596. package/src/nodes/accessors/Bitangent.js +82 -13
  597. package/src/nodes/accessors/BufferAttributeNode.js +269 -8
  598. package/src/nodes/accessors/BufferNode.js +91 -2
  599. package/src/nodes/accessors/BuiltinNode.js +63 -0
  600. package/src/nodes/accessors/Camera.js +400 -10
  601. package/src/nodes/accessors/ClippingNode.js +149 -45
  602. package/src/nodes/accessors/CubeTextureNode.js +137 -7
  603. package/src/nodes/accessors/InstanceNode.js +245 -40
  604. package/src/nodes/accessors/InstancedMeshNode.js +50 -0
  605. package/src/nodes/accessors/Lights.js +88 -0
  606. package/src/nodes/accessors/MaterialNode.js +355 -13
  607. package/src/nodes/accessors/MaterialProperties.js +57 -1
  608. package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
  609. package/src/nodes/accessors/ModelNode.js +117 -5
  610. package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
  611. package/src/nodes/accessors/MorphNode.js +73 -26
  612. package/src/nodes/accessors/Normal.js +174 -19
  613. package/src/nodes/accessors/Object3DNode.js +146 -12
  614. package/src/nodes/accessors/PointUVNode.js +25 -0
  615. package/src/nodes/accessors/Position.js +119 -7
  616. package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
  617. package/src/nodes/accessors/ReferenceNode.js +223 -8
  618. package/src/nodes/accessors/ReflectVector.js +29 -3
  619. package/src/nodes/accessors/RendererReferenceNode.js +45 -2
  620. package/src/nodes/accessors/SceneProperties.js +53 -0
  621. package/src/nodes/accessors/SkinningNode.js +180 -43
  622. package/src/nodes/accessors/StorageBufferNode.js +278 -26
  623. package/src/nodes/accessors/StorageTextureNode.js +205 -12
  624. package/src/nodes/accessors/Tangent.js +48 -10
  625. package/src/nodes/accessors/TangentUtils.js +46 -0
  626. package/src/nodes/accessors/Texture3DNode.js +104 -11
  627. package/src/nodes/accessors/TextureBicubic.js +31 -4
  628. package/src/nodes/accessors/TextureNode.js +564 -52
  629. package/src/nodes/accessors/TextureSizeNode.js +42 -1
  630. package/src/nodes/accessors/UV.js +9 -1
  631. package/src/nodes/accessors/UniformArrayNode.js +226 -34
  632. package/src/nodes/accessors/UserDataNode.js +46 -2
  633. package/src/nodes/accessors/VelocityNode.js +93 -3
  634. package/src/nodes/accessors/VertexColorNode.js +39 -4
  635. package/src/nodes/code/CodeNode.js +101 -8
  636. package/src/nodes/code/ExpressionNode.js +29 -2
  637. package/src/nodes/code/FunctionCallNode.js +98 -10
  638. package/src/nodes/code/FunctionNode.js +69 -2
  639. package/src/nodes/core/ArrayNode.js +174 -0
  640. package/src/nodes/core/AssignNode.js +80 -9
  641. package/src/nodes/core/AttributeNode.js +47 -4
  642. package/src/nodes/core/BypassNode.js +47 -3
  643. package/src/nodes/core/ConstNode.js +32 -0
  644. package/src/nodes/core/ContextNode.js +220 -14
  645. package/src/nodes/core/IndexNode.js +72 -7
  646. package/src/nodes/core/InputNode.js +50 -1
  647. package/src/nodes/core/InspectorNode.js +128 -0
  648. package/src/nodes/core/IsolateNode.js +133 -0
  649. package/src/nodes/core/LightingModel.js +65 -5
  650. package/src/nodes/core/MRTNode.js +113 -2
  651. package/src/nodes/core/Node.js +595 -36
  652. package/src/nodes/core/NodeAttribute.js +38 -0
  653. package/src/nodes/core/NodeBuilder.js +1840 -121
  654. package/src/nodes/core/NodeCache.js +41 -2
  655. package/src/nodes/core/NodeCode.js +31 -0
  656. package/src/nodes/core/NodeError.js +28 -0
  657. package/src/nodes/core/NodeFrame.js +153 -24
  658. package/src/nodes/core/NodeFunction.js +48 -1
  659. package/src/nodes/core/NodeFunctionInput.js +44 -0
  660. package/src/nodes/core/NodeParser.js +13 -1
  661. package/src/nodes/core/NodeUniform.js +53 -1
  662. package/src/nodes/core/NodeUtils.js +201 -51
  663. package/src/nodes/core/NodeVar.js +47 -1
  664. package/src/nodes/core/NodeVarying.js +47 -1
  665. package/src/nodes/core/OutputStructNode.js +54 -12
  666. package/src/nodes/core/ParameterNode.js +60 -2
  667. package/src/nodes/core/PropertyNode.js +286 -7
  668. package/src/nodes/core/StackNode.js +337 -20
  669. package/src/nodes/core/StackTrace.js +139 -0
  670. package/src/nodes/core/StructNode.js +134 -0
  671. package/src/nodes/core/StructType.js +13 -0
  672. package/src/nodes/core/StructTypeNode.js +126 -6
  673. package/src/nodes/core/SubBuildNode.js +89 -0
  674. package/src/nodes/core/TempNode.js +31 -5
  675. package/src/nodes/core/UniformGroupNode.js +85 -7
  676. package/src/nodes/core/UniformNode.js +163 -16
  677. package/src/nodes/core/VarNode.js +317 -10
  678. package/src/nodes/core/VaryingNode.js +115 -13
  679. package/src/nodes/core/constants.js +40 -0
  680. package/src/nodes/display/BlendModes.js +171 -0
  681. package/src/nodes/display/BumpMapNode.js +38 -2
  682. package/src/nodes/display/ColorAdjustment.js +118 -6
  683. package/src/nodes/display/ColorSpaceFunctions.js +22 -6
  684. package/src/nodes/display/ColorSpaceNode.js +97 -47
  685. package/src/nodes/display/FrontFacingNode.js +64 -7
  686. package/src/nodes/display/NormalMapNode.js +101 -54
  687. package/src/nodes/display/PassNode.js +690 -33
  688. package/src/nodes/display/RenderOutputNode.js +94 -4
  689. package/src/nodes/display/ScreenNode.js +138 -27
  690. package/src/nodes/display/ToneMappingFunctions.js +62 -10
  691. package/src/nodes/display/ToneMappingNode.js +88 -8
  692. package/src/nodes/display/ToonOutlinePassNode.js +84 -4
  693. package/src/nodes/display/ViewportDepthNode.js +227 -10
  694. package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
  695. package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
  696. package/src/nodes/display/ViewportTextureNode.js +171 -7
  697. package/src/nodes/fog/Fog.js +97 -0
  698. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  699. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
  700. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  701. package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
  702. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  703. package/src/nodes/functions/BSDF/LTC.js +45 -1
  704. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
  705. package/src/nodes/functions/BasicLightingModel.js +28 -6
  706. package/src/nodes/functions/PhongLightingModel.js +36 -6
  707. package/src/nodes/functions/PhysicalLightingModel.js +336 -91
  708. package/src/nodes/functions/ShadowMaskModel.js +30 -3
  709. package/src/nodes/functions/ToonLightingModel.js +21 -2
  710. package/src/nodes/functions/VolumetricLightingModel.js +183 -0
  711. package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
  712. package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
  713. package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
  714. package/src/nodes/geometry/RangeNode.js +97 -8
  715. package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
  716. package/src/nodes/gpgpu/BarrierNode.js +52 -3
  717. package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
  718. package/src/nodes/gpgpu/ComputeNode.js +212 -16
  719. package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
  720. package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
  721. package/src/nodes/lighting/AONode.js +18 -0
  722. package/src/nodes/lighting/AmbientLightNode.js +10 -0
  723. package/src/nodes/lighting/AnalyticLightNode.js +186 -399
  724. package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
  725. package/src/nodes/lighting/BasicLightMapNode.js +17 -0
  726. package/src/nodes/lighting/DirectionalLightNode.js +12 -11
  727. package/src/nodes/lighting/EnvironmentNode.js +59 -19
  728. package/src/nodes/lighting/HemisphereLightNode.js +33 -2
  729. package/src/nodes/lighting/IESSpotLightNode.js +13 -1
  730. package/src/nodes/lighting/IrradianceNode.js +17 -0
  731. package/src/nodes/lighting/LightProbeNode.js +20 -0
  732. package/src/nodes/lighting/LightUtils.js +11 -3
  733. package/src/nodes/lighting/LightingContextNode.js +52 -4
  734. package/src/nodes/lighting/LightingNode.js +15 -6
  735. package/src/nodes/lighting/LightsNode.js +238 -35
  736. package/src/nodes/lighting/PointLightNode.js +60 -25
  737. package/src/nodes/lighting/PointShadowNode.js +325 -0
  738. package/src/nodes/lighting/ProjectorLightNode.js +91 -0
  739. package/src/nodes/lighting/RectAreaLightNode.js +50 -14
  740. package/src/nodes/lighting/ShadowBaseNode.js +81 -0
  741. package/src/nodes/lighting/ShadowFilterNode.js +264 -0
  742. package/src/nodes/lighting/ShadowNode.js +867 -0
  743. package/src/nodes/lighting/SpotLightNode.js +99 -18
  744. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  745. package/src/nodes/materialx/lib/mx_noise.js +166 -2
  746. package/src/nodes/math/BitcastNode.js +156 -0
  747. package/src/nodes/math/BitcountNode.js +433 -0
  748. package/src/nodes/math/ConditionalNode.js +110 -21
  749. package/src/nodes/math/Hash.js +8 -0
  750. package/src/nodes/math/MathNode.js +820 -97
  751. package/src/nodes/math/MathUtils.js +47 -1
  752. package/src/nodes/math/OperatorNode.js +517 -84
  753. package/src/nodes/math/PackFloatNode.js +98 -0
  754. package/src/nodes/math/TriNoise3D.js +17 -7
  755. package/src/nodes/math/UnpackFloatNode.js +96 -0
  756. package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
  757. package/src/nodes/parsers/GLSLNodeParser.js +11 -0
  758. package/src/nodes/pmrem/PMREMNode.js +180 -23
  759. package/src/nodes/pmrem/PMREMUtils.js +114 -5
  760. package/src/nodes/procedural/Checker.js +8 -0
  761. package/src/nodes/shapes/Shapes.js +33 -0
  762. package/src/nodes/tsl/TSLBase.js +10 -4
  763. package/src/nodes/tsl/TSLCore.js +732 -160
  764. package/src/nodes/utils/ArrayElementNode.js +55 -4
  765. package/src/nodes/utils/ConvertNode.js +31 -0
  766. package/src/nodes/utils/CubeMapNode.js +79 -2
  767. package/src/nodes/utils/DebugNode.js +83 -0
  768. package/src/nodes/utils/Discard.js +18 -2
  769. package/src/nodes/utils/EquirectUV.js +27 -0
  770. package/src/nodes/utils/EventNode.js +118 -0
  771. package/src/nodes/utils/FlipNode.js +38 -0
  772. package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
  773. package/src/nodes/utils/JoinNode.js +57 -4
  774. package/src/nodes/utils/LoopNode.js +193 -55
  775. package/src/nodes/utils/MatcapUV.js +22 -0
  776. package/src/nodes/utils/MaxMipLevelNode.js +49 -1
  777. package/src/nodes/utils/MemberNode.js +120 -0
  778. package/src/nodes/utils/Oscillators.js +41 -0
  779. package/src/nodes/utils/Packing.js +30 -1
  780. package/src/nodes/utils/PostProcessingUtils.js +154 -0
  781. package/src/nodes/utils/RTTNode.js +165 -9
  782. package/src/nodes/utils/ReflectorNode.js +407 -21
  783. package/src/nodes/utils/RemapNode.js +81 -2
  784. package/src/nodes/utils/RotateNode.js +41 -1
  785. package/src/nodes/utils/SampleNode.js +91 -0
  786. package/src/nodes/utils/SetNode.js +44 -1
  787. package/src/nodes/utils/SplitNode.js +66 -3
  788. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  789. package/src/nodes/utils/SpriteUtils.js +16 -0
  790. package/src/nodes/utils/StorageArrayElementNode.js +56 -3
  791. package/src/nodes/utils/Timer.js +26 -0
  792. package/src/nodes/utils/TriplanarTextures.js +65 -0
  793. package/src/nodes/utils/UVUtils.js +48 -0
  794. package/src/nodes/utils/ViewportUtils.js +12 -0
  795. package/src/objects/BatchedMesh.js +798 -309
  796. package/src/objects/Bone.js +24 -0
  797. package/src/objects/ClippingGroup.js +68 -0
  798. package/src/objects/Group.js +24 -0
  799. package/src/objects/InstancedMesh.js +131 -2
  800. package/src/objects/LOD.js +99 -5
  801. package/src/objects/Line.js +90 -7
  802. package/src/objects/LineLoop.js +20 -0
  803. package/src/objects/LineSegments.js +20 -1
  804. package/src/objects/Mesh.js +84 -0
  805. package/src/objects/Points.js +60 -0
  806. package/src/objects/Skeleton.js +120 -5
  807. package/src/objects/SkinnedMesh.js +102 -6
  808. package/src/objects/Sprite.js +65 -1
  809. package/src/renderers/WebGL3DRenderTarget.js +26 -0
  810. package/src/renderers/WebGLArrayRenderTarget.js +26 -0
  811. package/src/renderers/WebGLCubeRenderTarget.js +41 -5
  812. package/src/renderers/WebGLRenderTarget.js +19 -0
  813. package/src/renderers/WebGLRenderer.js +1016 -278
  814. package/src/renderers/common/Animation.js +123 -14
  815. package/src/renderers/common/Attributes.js +41 -1
  816. package/src/renderers/common/Backend.js +623 -44
  817. package/src/renderers/common/Background.js +99 -16
  818. package/src/renderers/common/BindGroup.js +37 -2
  819. package/src/renderers/common/Binding.js +46 -0
  820. package/src/renderers/common/Bindings.js +211 -20
  821. package/src/renderers/common/BlendMode.js +143 -0
  822. package/src/renderers/common/Buffer.js +89 -0
  823. package/src/renderers/common/BufferUtils.js +25 -0
  824. package/src/renderers/common/BundleGroup.js +57 -0
  825. package/src/renderers/common/CanvasTarget.js +341 -0
  826. package/src/renderers/common/ChainMap.js +73 -10
  827. package/src/renderers/common/ClippingContext.js +172 -87
  828. package/src/renderers/common/Color4.js +40 -0
  829. package/src/renderers/common/ComputePipeline.js +24 -0
  830. package/src/renderers/common/Constants.js +2 -1
  831. package/src/renderers/common/CubeRenderTarget.js +77 -7
  832. package/src/renderers/common/DataMap.js +37 -1
  833. package/src/renderers/common/Geometries.js +163 -14
  834. package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
  835. package/src/renderers/common/Info.js +81 -36
  836. package/src/renderers/common/InspectorBase.js +146 -0
  837. package/src/renderers/common/Lighting.js +57 -0
  838. package/src/renderers/common/Pipeline.js +22 -0
  839. package/src/renderers/common/Pipelines.js +150 -7
  840. package/src/renderers/common/PostProcessing.js +22 -84
  841. package/src/renderers/common/ProgrammableStage.js +60 -2
  842. package/src/renderers/common/QuadMesh.js +63 -6
  843. package/src/renderers/common/RenderBundle.js +14 -8
  844. package/src/renderers/common/RenderBundles.js +40 -10
  845. package/src/renderers/common/RenderContext.js +219 -4
  846. package/src/renderers/common/RenderContexts.js +54 -17
  847. package/src/renderers/common/RenderList.js +233 -24
  848. package/src/renderers/common/RenderLists.js +46 -6
  849. package/src/renderers/common/RenderObject.js +548 -46
  850. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  851. package/src/renderers/common/RenderObjects.js +133 -15
  852. package/src/renderers/common/RenderPipeline.js +216 -6
  853. package/src/renderers/common/Renderer.js +2155 -332
  854. package/src/renderers/common/RendererUtils.js +200 -0
  855. package/src/renderers/common/SampledTexture.js +99 -39
  856. package/src/renderers/common/Sampler.js +148 -1
  857. package/src/renderers/common/Storage3DTexture.js +100 -0
  858. package/src/renderers/common/StorageArrayTexture.js +84 -0
  859. package/src/renderers/common/StorageBuffer.js +38 -2
  860. package/src/renderers/common/StorageBufferAttribute.js +31 -2
  861. package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
  862. package/src/renderers/common/StorageTexture.js +65 -0
  863. package/src/renderers/common/Textures.js +273 -57
  864. package/src/renderers/common/TimestampQueryPool.js +163 -0
  865. package/src/renderers/common/Uniform.js +233 -3
  866. package/src/renderers/common/UniformBuffer.js +19 -0
  867. package/src/renderers/common/UniformsGroup.js +235 -26
  868. package/src/renderers/common/XRManager.js +1677 -0
  869. package/src/renderers/common/XRRenderTarget.js +91 -0
  870. package/src/renderers/common/extras/PMREMGenerator.js +371 -108
  871. package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
  872. package/src/renderers/common/nodes/NodeLibrary.js +95 -17
  873. package/src/renderers/common/nodes/NodeManager.js +852 -0
  874. package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
  875. package/src/renderers/common/nodes/NodeSampler.js +41 -1
  876. package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
  877. package/src/renderers/common/nodes/NodeUniform.js +285 -2
  878. package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
  879. package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
  880. package/src/renderers/shaders/DFGLUTData.js +49 -0
  881. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
  882. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
  883. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
  884. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
  885. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
  886. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
  887. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
  888. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
  889. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
  890. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
  891. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
  892. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
  893. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
  894. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
  895. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
  896. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
  897. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  898. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  899. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  900. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  901. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
  902. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
  903. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
  904. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
  905. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
  906. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  907. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
  908. package/src/renderers/shaders/ShaderChunk.js +3 -3
  909. package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
  910. package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
  911. package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
  912. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
  913. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
  914. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
  915. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
  916. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
  917. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
  918. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
  919. package/src/renderers/shaders/ShaderLib.js +7 -5
  920. package/src/renderers/shaders/UniformsLib.js +2 -7
  921. package/src/renderers/shaders/UniformsUtils.js +21 -2
  922. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  923. package/src/renderers/webgl/WebGLBackground.js +30 -5
  924. package/src/renderers/webgl/WebGLBindingStates.js +99 -27
  925. package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
  926. package/src/renderers/webgl/WebGLCapabilities.js +7 -14
  927. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  928. package/src/renderers/webgl/WebGLExtensions.js +2 -25
  929. package/src/renderers/webgl/WebGLGeometries.js +10 -35
  930. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
  931. package/src/renderers/webgl/WebGLInfo.js +3 -1
  932. package/src/renderers/webgl/WebGLLights.js +18 -1
  933. package/src/renderers/webgl/WebGLMaterials.js +12 -0
  934. package/src/renderers/webgl/WebGLObjects.js +3 -1
  935. package/src/renderers/webgl/WebGLOutput.js +267 -0
  936. package/src/renderers/webgl/WebGLProgram.js +87 -148
  937. package/src/renderers/webgl/WebGLPrograms.js +53 -51
  938. package/src/renderers/webgl/WebGLRenderLists.js +15 -0
  939. package/src/renderers/webgl/WebGLShadowMap.js +204 -28
  940. package/src/renderers/webgl/WebGLState.js +88 -56
  941. package/src/renderers/webgl/WebGLTextures.js +293 -59
  942. package/src/renderers/webgl/WebGLUniforms.js +40 -3
  943. package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
  944. package/src/renderers/webgl/WebGLUtils.js +7 -5
  945. package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
  946. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
  947. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
  948. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
  949. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
  950. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
  951. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
  952. package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
  953. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
  954. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
  955. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
  956. package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
  957. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
  958. package/src/renderers/webgpu/WebGPURenderer.js +55 -4
  959. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
  960. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
  961. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
  962. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
  963. package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
  964. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
  965. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
  966. package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
  967. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
  968. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
  969. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
  970. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
  971. package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
  972. package/src/renderers/webxr/WebXRController.js +87 -2
  973. package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
  974. package/src/renderers/webxr/WebXRManager.js +275 -15
  975. package/src/scenes/Fog.js +60 -0
  976. package/src/scenes/FogExp2.js +51 -0
  977. package/src/scenes/Scene.js +88 -0
  978. package/src/textures/CanvasTexture.js +28 -0
  979. package/src/textures/CompressedArrayTexture.js +57 -0
  980. package/src/textures/CompressedCubeTexture.js +29 -0
  981. package/src/textures/CompressedTexture.js +64 -6
  982. package/src/textures/CubeDepthTexture.js +76 -0
  983. package/src/textures/CubeTexture.js +52 -4
  984. package/src/textures/Data3DTexture.js +79 -2
  985. package/src/textures/DataArrayTexture.js +93 -0
  986. package/src/textures/DataTexture.js +65 -0
  987. package/src/textures/DepthTexture.js +59 -11
  988. package/src/textures/ExternalTexture.js +56 -0
  989. package/src/textures/FramebufferTexture.js +62 -0
  990. package/src/textures/Source.js +106 -4
  991. package/src/textures/Texture.js +488 -6
  992. package/src/textures/VideoFrameTexture.js +72 -0
  993. package/src/textures/VideoTexture.js +78 -6
  994. package/src/utils.js +322 -3
  995. package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
  996. package/examples/jsm/animation/MMDPhysics.js +0 -1406
  997. package/examples/jsm/cameras/CinematicCamera.js +0 -208
  998. package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
  999. package/examples/jsm/exporters/MMDExporter.js +0 -217
  1000. package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
  1001. package/examples/jsm/geometries/ParametricGeometries.js +0 -254
  1002. package/examples/jsm/libs/mmdparser.module.js +0 -11530
  1003. package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
  1004. package/examples/jsm/loaders/MMDLoader.js +0 -2295
  1005. package/examples/jsm/loaders/RGBMLoader.js +0 -1081
  1006. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
  1007. package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
  1008. package/examples/jsm/misc/Timer.js +0 -128
  1009. package/examples/jsm/objects/InstancedPoints.js +0 -21
  1010. package/examples/jsm/shaders/GodRaysShader.js +0 -321
  1011. package/examples/jsm/shaders/MMDToonShader.js +0 -134
  1012. package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
  1013. package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
  1014. package/src/nodes/accessors/SceneNode.js +0 -55
  1015. package/src/nodes/code/ScriptableNode.js +0 -505
  1016. package/src/nodes/code/ScriptableValueNode.js +0 -170
  1017. package/src/nodes/core/CacheNode.js +0 -50
  1018. package/src/nodes/core/UniformGroup.js +0 -13
  1019. package/src/nodes/display/AfterImageNode.js +0 -158
  1020. package/src/nodes/display/AnaglyphPassNode.js +0 -67
  1021. package/src/nodes/display/AnamorphicNode.js +0 -151
  1022. package/src/nodes/display/BlendMode.js +0 -54
  1023. package/src/nodes/display/BloomNode.js +0 -341
  1024. package/src/nodes/display/DenoiseNode.js +0 -204
  1025. package/src/nodes/display/DepthOfFieldNode.js +0 -124
  1026. package/src/nodes/display/DotScreenNode.js +0 -66
  1027. package/src/nodes/display/FXAANode.js +0 -332
  1028. package/src/nodes/display/FilmNode.js +0 -56
  1029. package/src/nodes/display/GTAONode.js +0 -331
  1030. package/src/nodes/display/GaussianBlurNode.js +0 -213
  1031. package/src/nodes/display/Lut3DNode.js +0 -57
  1032. package/src/nodes/display/MotionBlur.js +0 -25
  1033. package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
  1034. package/src/nodes/display/PixelationPassNode.js +0 -213
  1035. package/src/nodes/display/PosterizeNode.js +0 -33
  1036. package/src/nodes/display/RGBShiftNode.js +0 -53
  1037. package/src/nodes/display/StereoCompositePassNode.js +0 -110
  1038. package/src/nodes/display/TransitionNode.js +0 -80
  1039. package/src/nodes/fog/FogExp2Node.js +0 -35
  1040. package/src/nodes/fog/FogNode.js +0 -50
  1041. package/src/nodes/fog/FogRangeNode.js +0 -36
  1042. package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
  1043. package/src/nodes/utils/EquirectUVNode.js +0 -36
  1044. package/src/nodes/utils/MatcapUVNode.js +0 -33
  1045. package/src/nodes/utils/OscNode.js +0 -85
  1046. package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
  1047. package/src/nodes/utils/TimerNode.js +0 -97
  1048. package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
  1049. package/src/renderers/common/nodes/Nodes.js +0 -534
  1050. package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
  1051. package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
@@ -0,0 +1,2950 @@
1
+ import {
2
+ AmbientLight,
3
+ AnimationClip,
4
+ Bone,
5
+ BufferGeometry,
6
+ ClampToEdgeWrapping,
7
+ Color,
8
+ ColorManagement,
9
+ DirectionalLight,
10
+ DoubleSide,
11
+ Float32BufferAttribute,
12
+ FrontSide,
13
+ Group,
14
+ InterpolateBezier,
15
+ InterpolateDiscrete,
16
+ Line,
17
+ LineBasicMaterial,
18
+ LineSegments,
19
+ Loader,
20
+ MathUtils,
21
+ Matrix4,
22
+ Mesh,
23
+ MeshBasicMaterial,
24
+ MeshLambertMaterial,
25
+ MeshPhongMaterial,
26
+ OrthographicCamera,
27
+ PerspectiveCamera,
28
+ PointLight,
29
+ Quaternion,
30
+ QuaternionKeyframeTrack,
31
+ RepeatWrapping,
32
+ Skeleton,
33
+ SkinnedMesh,
34
+ SpotLight,
35
+ Vector2,
36
+ Vector3,
37
+ VectorKeyframeTrack,
38
+ SRGBColorSpace
39
+ } from 'three';
40
+
41
+ import { getElementsByTagName, parseFloats } from './ColladaParser.js';
42
+
43
+ /**
44
+ * ColladaComposer converts parsed library data into Three.js objects.
45
+ */
46
+ class ColladaComposer {
47
+
48
+ constructor( library, collada, textureLoader, tgaLoader ) {
49
+
50
+ this.library = library;
51
+ this.collada = collada;
52
+ this.textureLoader = textureLoader;
53
+ this.tgaLoader = tgaLoader;
54
+
55
+ this.tempColor = new Color();
56
+ this.animations = [];
57
+ this.kinematics = {};
58
+
59
+ // Reusable objects for animation
60
+ this.position = new Vector3();
61
+ this.scale = new Vector3();
62
+ this.quaternion = new Quaternion();
63
+ this.matrix = new Matrix4();
64
+
65
+ // Storage for deferred pivot animation data
66
+ // Nodes with pivot transforms need all their animation channels collected
67
+ // before building tracks, as channels may be split across animation elements
68
+ this.deferredPivotAnimations = {};
69
+
70
+ // Storage for transform node hierarchy
71
+ // Maps nodeId -> transformSid -> Object3D for animation targeting
72
+ this.transformNodes = {};
73
+
74
+ }
75
+
76
+ compose() {
77
+
78
+ const library = this.library;
79
+
80
+ this.buildLibrary( library.animations, this.buildAnimation.bind( this ) );
81
+ this.buildLibrary( library.clips, this.buildAnimationClip.bind( this ) );
82
+ this.buildLibrary( library.controllers, this.buildController.bind( this ) );
83
+ this.buildLibrary( library.images, this.buildImage.bind( this ) );
84
+ this.buildLibrary( library.effects, this.buildEffect.bind( this ) );
85
+ this.buildLibrary( library.materials, this.buildMaterial.bind( this ) );
86
+ this.buildLibrary( library.cameras, this.buildCamera.bind( this ) );
87
+ this.buildLibrary( library.lights, this.buildLight.bind( this ) );
88
+ this.buildLibrary( library.geometries, this.buildGeometry.bind( this ) );
89
+ this.buildLibrary( library.visualScenes, this.buildVisualScene.bind( this ) );
90
+
91
+ this.setupAnimations();
92
+ this.setupKinematics();
93
+
94
+ const scene = this.parseScene( getElementsByTagName( this.collada, 'scene' )[ 0 ] );
95
+ scene.animations = this.animations;
96
+
97
+ return {
98
+ scene: scene,
99
+ animations: this.animations,
100
+ kinematics: this.kinematics
101
+ };
102
+
103
+ }
104
+
105
+ buildLibrary( data, builder ) {
106
+
107
+ for ( const name in data ) {
108
+
109
+ const object = data[ name ];
110
+ object.build = builder( data[ name ] );
111
+
112
+ }
113
+
114
+ }
115
+
116
+ getBuild( data, builder ) {
117
+
118
+ if ( data.build !== undefined ) return data.build;
119
+
120
+ data.build = builder( data );
121
+
122
+ return data.build;
123
+
124
+ }
125
+
126
+ isEmpty( object ) {
127
+
128
+ return Object.keys( object ).length === 0;
129
+
130
+ }
131
+
132
+ buildAnimation( data ) {
133
+
134
+ const tracks = [];
135
+
136
+ const channels = data.channels;
137
+ const samplers = data.samplers;
138
+ const sources = data.sources;
139
+
140
+ const aggregated = this.aggregateAnimationChannels( channels, samplers, sources );
141
+
142
+ for ( const nodeId in aggregated ) {
143
+
144
+ const nodeData = this.library.nodes[ nodeId ];
145
+ if ( ! nodeData ) continue;
146
+
147
+ const nodeChannels = aggregated[ nodeId ];
148
+
149
+ if ( this.hasPivotTransforms( nodeData ) ) {
150
+
151
+ // Defer - nodes haven't been built yet
152
+ this.collectDeferredPivotAnimation( nodeId, nodeChannels );
153
+
154
+ } else {
155
+
156
+ const object3D = this.getNode( nodeId );
157
+ let rotationTrackBuilt = false;
158
+
159
+ for ( const sid in nodeChannels ) {
160
+
161
+ const transformType = nodeData.transforms[ sid ];
162
+ const transformInfo = nodeData.transformData[ sid ];
163
+ const channelData = nodeChannels[ sid ];
164
+
165
+ switch ( transformType ) {
166
+
167
+ case 'matrix':
168
+ this.buildMatrixTracks( object3D, channelData, nodeData, tracks );
169
+ break;
170
+
171
+ case 'translate':
172
+ this.buildTranslateTrack( object3D, channelData, transformInfo, tracks );
173
+ break;
174
+
175
+ case 'rotate':
176
+ if ( ! rotationTrackBuilt ) {
177
+
178
+ this.buildRotateTrack( object3D, sid, channelData, transformInfo, nodeData, tracks );
179
+ rotationTrackBuilt = true;
180
+
181
+ }
182
+
183
+ break;
184
+
185
+ case 'scale':
186
+ this.buildScaleTrack( object3D, channelData, transformInfo, tracks );
187
+ break;
188
+
189
+ }
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ return tracks;
198
+
199
+ }
200
+
201
+ collectDeferredPivotAnimation( nodeId, nodeChannels ) {
202
+
203
+ if ( ! this.deferredPivotAnimations[ nodeId ] ) {
204
+
205
+ this.deferredPivotAnimations[ nodeId ] = {};
206
+
207
+ }
208
+
209
+ const deferred = this.deferredPivotAnimations[ nodeId ];
210
+
211
+ for ( const sid in nodeChannels ) {
212
+
213
+ if ( ! deferred[ sid ] ) {
214
+
215
+ deferred[ sid ] = {};
216
+
217
+ }
218
+
219
+ for ( const member in nodeChannels[ sid ] ) {
220
+
221
+ deferred[ sid ][ member ] = nodeChannels[ sid ][ member ];
222
+
223
+ }
224
+
225
+ }
226
+
227
+ }
228
+
229
+ hasPivotTransforms( nodeData ) {
230
+
231
+ const pivotSids = [
232
+ 'rotatePivot', 'rotatePivotInverse', 'rotatePivotTranslation',
233
+ 'scalePivot', 'scalePivotInverse', 'scalePivotTranslation'
234
+ ];
235
+
236
+ for ( const sid of pivotSids ) {
237
+
238
+ if ( nodeData.transforms[ sid ] !== undefined ) {
239
+
240
+ return true;
241
+
242
+ }
243
+
244
+ }
245
+
246
+ return false;
247
+
248
+ }
249
+
250
+ getAnimation( id ) {
251
+
252
+ return this.getBuild( this.library.animations[ id ], this.buildAnimation.bind( this ) );
253
+
254
+ }
255
+
256
+ aggregateAnimationChannels( channels, samplers, sources ) {
257
+
258
+ const aggregated = {};
259
+
260
+ for ( const target in channels ) {
261
+
262
+ if ( ! channels.hasOwnProperty( target ) ) continue;
263
+
264
+ const channel = channels[ target ];
265
+ const sampler = samplers[ channel.sampler ];
266
+
267
+ const inputId = sampler.inputs.INPUT;
268
+ const outputId = sampler.inputs.OUTPUT;
269
+
270
+ const inputSource = sources[ inputId ];
271
+ const outputSource = sources[ outputId ];
272
+
273
+ const interpolationId = sampler.inputs.INTERPOLATION;
274
+ const inTangentId = sampler.inputs.IN_TANGENT;
275
+ const outTangentId = sampler.inputs.OUT_TANGENT;
276
+
277
+ const interpolationSource = interpolationId ? sources[ interpolationId ] : null;
278
+ const inTangentSource = inTangentId ? sources[ inTangentId ] : null;
279
+ const outTangentSource = outTangentId ? sources[ outTangentId ] : null;
280
+
281
+ const nodeId = channel.id;
282
+ const sid = channel.sid;
283
+ const member = channel.member || 'default';
284
+
285
+ if ( ! aggregated[ nodeId ] ) aggregated[ nodeId ] = {};
286
+ if ( ! aggregated[ nodeId ][ sid ] ) aggregated[ nodeId ][ sid ] = {};
287
+
288
+ aggregated[ nodeId ][ sid ][ member ] = {
289
+ times: inputSource.array,
290
+ values: outputSource.array,
291
+ stride: outputSource.stride,
292
+ arraySyntax: channel.arraySyntax,
293
+ indices: channel.indices,
294
+ interpolation: interpolationSource ? interpolationSource.array : null,
295
+ inTangent: inTangentSource ? inTangentSource.array : null,
296
+ outTangent: outTangentSource ? outTangentSource.array : null,
297
+ inTangentStride: inTangentSource ? inTangentSource.stride : 0,
298
+ outTangentStride: outTangentSource ? outTangentSource.stride : 0
299
+ };
300
+
301
+ }
302
+
303
+ return aggregated;
304
+
305
+ }
306
+
307
+ buildMatrixTracks( object3D, channelData, nodeData, tracks ) {
308
+
309
+ const defaultMatrix = nodeData.matrix.clone().transpose();
310
+ const data = {};
311
+
312
+ for ( const member in channelData ) {
313
+
314
+ const component = channelData[ member ];
315
+ const times = component.times;
316
+ const values = component.values;
317
+ const stride = component.stride;
318
+
319
+ for ( let i = 0, il = times.length; i < il; i ++ ) {
320
+
321
+ const time = times[ i ];
322
+ const valueOffset = i * stride;
323
+
324
+ if ( data[ time ] === undefined ) data[ time ] = {};
325
+
326
+ if ( component.arraySyntax === true ) {
327
+
328
+ const value = values[ valueOffset ];
329
+ const index = component.indices[ 0 ] + 4 * component.indices[ 1 ];
330
+ data[ time ][ index ] = value;
331
+
332
+ } else {
333
+
334
+ for ( let j = 0; j < stride; j ++ ) {
335
+
336
+ data[ time ][ j ] = values[ valueOffset + j ];
337
+
338
+ }
339
+
340
+ }
341
+
342
+ }
343
+
344
+ }
345
+
346
+ const keyframes = this.prepareAnimationData( data, defaultMatrix );
347
+ const animation = { name: object3D.uuid, keyframes: keyframes };
348
+ this.createKeyframeTracks( animation, tracks );
349
+
350
+ }
351
+
352
+ buildTranslateTrack( object3D, channelData, transformInfo, tracks ) {
353
+
354
+ if ( channelData.default && channelData.default.stride === 3 ) {
355
+
356
+ const data = channelData.default;
357
+ const times = Array.from( data.times );
358
+ const values = Array.from( data.values );
359
+
360
+ const track = new VectorKeyframeTrack(
361
+ object3D.uuid + '.position',
362
+ times,
363
+ values
364
+ );
365
+
366
+ const interpolationInfo = this.getInterpolationInfo( channelData );
367
+ this.applyInterpolation( track, interpolationInfo, channelData );
368
+ tracks.push( track );
369
+ return;
370
+
371
+ }
372
+
373
+ const times = this.getTimesForAllAxes( channelData );
374
+ if ( times.length === 0 ) return;
375
+
376
+ const values = [];
377
+ const interpolationInfo = this.getInterpolationInfo( channelData );
378
+
379
+ for ( let i = 0; i < times.length; i ++ ) {
380
+
381
+ const time = times[ i ];
382
+
383
+ const x = this.getValueAtTime( channelData.X, time, transformInfo.x );
384
+ const y = this.getValueAtTime( channelData.Y, time, transformInfo.y );
385
+ const z = this.getValueAtTime( channelData.Z, time, transformInfo.z );
386
+
387
+ values.push( x, y, z );
388
+
389
+ }
390
+
391
+ const track = new VectorKeyframeTrack(
392
+ object3D.uuid + '.position',
393
+ times,
394
+ values
395
+ );
396
+
397
+ this.applyInterpolation( track, interpolationInfo );
398
+ tracks.push( track );
399
+
400
+ }
401
+
402
+ buildRotateTrack( object3D, sid, channelData, transformInfo, nodeData, tracks ) {
403
+
404
+ const angleData = channelData.ANGLE || channelData.default;
405
+ if ( ! angleData ) return;
406
+
407
+ const times = Array.from( angleData.times );
408
+ if ( times.length === 0 ) return;
409
+
410
+ // Collect all rotations to compose them in order
411
+ const rotations = [];
412
+
413
+ for ( const transformSid of nodeData.transformOrder ) {
414
+
415
+ const transformType = nodeData.transforms[ transformSid ];
416
+
417
+ if ( transformType === 'rotate' ) {
418
+
419
+ const info = nodeData.transformData[ transformSid ];
420
+ rotations.push( {
421
+ sid: transformSid,
422
+ axis: new Vector3( info.axis[ 0 ], info.axis[ 1 ], info.axis[ 2 ] ),
423
+ defaultAngle: info.angle
424
+ } );
425
+
426
+ }
427
+
428
+ }
429
+
430
+ const quaternion = new Quaternion();
431
+ const prevQuaternion = new Quaternion();
432
+ const tempQuat = new Quaternion();
433
+ const values = [];
434
+ const interpolationInfo = this.getInterpolationInfo( channelData );
435
+
436
+ for ( let i = 0; i < times.length; i ++ ) {
437
+
438
+ const time = times[ i ];
439
+ quaternion.identity();
440
+
441
+ for ( const rotation of rotations ) {
442
+
443
+ let angleDegrees;
444
+
445
+ if ( rotation.sid === sid ) {
446
+
447
+ angleDegrees = this.getValueAtTime( angleData, time, rotation.defaultAngle );
448
+
449
+ } else {
450
+
451
+ angleDegrees = rotation.defaultAngle;
452
+
453
+ }
454
+
455
+ const angleRadians = MathUtils.degToRad( angleDegrees );
456
+ tempQuat.setFromAxisAngle( rotation.axis, angleRadians );
457
+ quaternion.multiply( tempQuat );
458
+
459
+ }
460
+
461
+ // Ensure quaternion continuity
462
+ if ( i > 0 && prevQuaternion.dot( quaternion ) < 0 ) {
463
+
464
+ quaternion.x = - quaternion.x;
465
+ quaternion.y = - quaternion.y;
466
+ quaternion.z = - quaternion.z;
467
+ quaternion.w = - quaternion.w;
468
+
469
+ }
470
+
471
+ prevQuaternion.copy( quaternion );
472
+
473
+ values.push( quaternion.x, quaternion.y, quaternion.z, quaternion.w );
474
+
475
+ }
476
+
477
+ const track = new QuaternionKeyframeTrack(
478
+ object3D.uuid + '.quaternion',
479
+ times,
480
+ values
481
+ );
482
+
483
+ this.applyInterpolation( track, interpolationInfo );
484
+ tracks.push( track );
485
+
486
+ }
487
+
488
+ buildScaleTrack( object3D, channelData, transformInfo, tracks ) {
489
+
490
+ if ( channelData.default && channelData.default.stride === 3 ) {
491
+
492
+ const data = channelData.default;
493
+ const times = Array.from( data.times );
494
+ const values = Array.from( data.values );
495
+
496
+ const track = new VectorKeyframeTrack(
497
+ object3D.uuid + '.scale',
498
+ times,
499
+ values
500
+ );
501
+
502
+ const interpolationInfo = this.getInterpolationInfo( channelData );
503
+ this.applyInterpolation( track, interpolationInfo, channelData );
504
+ tracks.push( track );
505
+ return;
506
+
507
+ }
508
+
509
+ const times = this.getTimesForAllAxes( channelData );
510
+ if ( times.length === 0 ) return;
511
+
512
+ const values = [];
513
+ const interpolationInfo = this.getInterpolationInfo( channelData );
514
+
515
+ for ( let i = 0; i < times.length; i ++ ) {
516
+
517
+ const time = times[ i ];
518
+
519
+ const x = this.getValueAtTime( channelData.X, time, transformInfo.x );
520
+ const y = this.getValueAtTime( channelData.Y, time, transformInfo.y );
521
+ const z = this.getValueAtTime( channelData.Z, time, transformInfo.z );
522
+
523
+ values.push( x, y, z );
524
+
525
+ }
526
+
527
+ const track = new VectorKeyframeTrack(
528
+ object3D.uuid + '.scale',
529
+ times,
530
+ values
531
+ );
532
+
533
+ this.applyInterpolation( track, interpolationInfo );
534
+ tracks.push( track );
535
+
536
+ }
537
+
538
+ getTimesForAllAxes( channelData ) {
539
+
540
+ let times = [];
541
+
542
+ if ( channelData.X ) times = times.concat( Array.from( channelData.X.times ) );
543
+ if ( channelData.Y ) times = times.concat( Array.from( channelData.Y.times ) );
544
+ if ( channelData.Z ) times = times.concat( Array.from( channelData.Z.times ) );
545
+ if ( channelData.ANGLE ) times = times.concat( Array.from( channelData.ANGLE.times ) );
546
+ if ( channelData.default ) times = times.concat( Array.from( channelData.default.times ) );
547
+
548
+ times = [ ...new Set( times ) ].sort( ( a, b ) => a - b );
549
+
550
+ return times;
551
+
552
+ }
553
+
554
+ getValueAtTime( componentData, time, defaultValue ) {
555
+
556
+ if ( ! componentData ) return defaultValue;
557
+
558
+ const times = componentData.times;
559
+ const values = componentData.values;
560
+ const interpolation = componentData.interpolation;
561
+
562
+ for ( let i = 0; i < times.length; i ++ ) {
563
+
564
+ if ( times[ i ] === time ) {
565
+
566
+ return values[ i ];
567
+
568
+ }
569
+
570
+ if ( times[ i ] > time ) {
571
+
572
+ if ( i === 0 ) {
573
+
574
+ return values[ 0 ];
575
+
576
+ }
577
+
578
+ const i0 = i - 1;
579
+ const i1 = i;
580
+ const t0 = times[ i0 ];
581
+ const t1 = times[ i1 ];
582
+ const v0 = values[ i0 ];
583
+ const v1 = values[ i1 ];
584
+
585
+ const interp = interpolation ? interpolation[ i0 ] : 'LINEAR';
586
+
587
+ if ( interp === 'STEP' ) {
588
+
589
+ return v0;
590
+
591
+ } else if ( interp === 'BEZIER' && componentData.inTangent && componentData.outTangent ) {
592
+
593
+ return this.evaluateBezierComponent( componentData, i0, i1, t0, t1, time );
594
+
595
+ } else {
596
+
597
+ const t = ( time - t0 ) / ( t1 - t0 );
598
+ return v0 + t * ( v1 - v0 );
599
+
600
+ }
601
+
602
+ }
603
+
604
+ }
605
+
606
+ return values[ values.length - 1 ];
607
+
608
+ }
609
+
610
+ evaluateBezierComponent( componentData, i0, i1, t0, t1, time ) {
611
+
612
+ const values = componentData.values;
613
+ const inTangent = componentData.inTangent;
614
+ const outTangent = componentData.outTangent;
615
+ const tangentStride = componentData.inTangentStride || 1;
616
+
617
+ const v0 = values[ i0 ];
618
+ const v1 = values[ i1 ];
619
+
620
+ let c0x, c0y, c1x, c1y;
621
+
622
+ if ( tangentStride === 2 ) {
623
+
624
+ c0x = outTangent[ i0 * 2 ];
625
+ c0y = outTangent[ i0 * 2 + 1 ];
626
+ c1x = inTangent[ i1 * 2 ];
627
+ c1y = inTangent[ i1 * 2 + 1 ];
628
+
629
+ } else {
630
+
631
+ c0x = t0 + ( t1 - t0 ) / 3;
632
+ c0y = outTangent[ i0 ];
633
+ c1x = t1 - ( t1 - t0 ) / 3;
634
+ c1y = inTangent[ i1 ];
635
+
636
+ }
637
+
638
+ // Newton-Raphson to solve Bx(s) = time
639
+ let s = ( time - t0 ) / ( t1 - t0 );
640
+
641
+ for ( let iter = 0; iter < 8; iter ++ ) {
642
+
643
+ const s2 = s * s;
644
+ const s3 = s2 * s;
645
+ const oneMinusS = 1 - s;
646
+ const oneMinusS2 = oneMinusS * oneMinusS;
647
+ const oneMinusS3 = oneMinusS2 * oneMinusS;
648
+
649
+ const bx = oneMinusS3 * t0 + 3 * oneMinusS2 * s * c0x + 3 * oneMinusS * s2 * c1x + s3 * t1;
650
+ const dbx = 3 * oneMinusS2 * ( c0x - t0 ) + 6 * oneMinusS * s * ( c1x - c0x ) + 3 * s2 * ( t1 - c1x );
651
+
652
+ if ( Math.abs( dbx ) < 1e-10 ) break;
653
+
654
+ const error = bx - time;
655
+ if ( Math.abs( error ) < 1e-10 ) break;
656
+
657
+ s = s - error / dbx;
658
+ s = Math.max( 0, Math.min( 1, s ) );
659
+
660
+ }
661
+
662
+ const s2 = s * s;
663
+ const s3 = s2 * s;
664
+ const oneMinusS = 1 - s;
665
+ const oneMinusS2 = oneMinusS * oneMinusS;
666
+ const oneMinusS3 = oneMinusS2 * oneMinusS;
667
+
668
+ return oneMinusS3 * v0 + 3 * oneMinusS2 * s * c0y + 3 * oneMinusS * s2 * c1y + s3 * v1;
669
+
670
+ }
671
+
672
+ getInterpolationInfo( channelData ) {
673
+
674
+ const components = [ 'X', 'Y', 'Z', 'ANGLE', 'default' ];
675
+ let interpolationType = null;
676
+ let isUniform = true;
677
+
678
+ for ( const comp of components ) {
679
+
680
+ const data = channelData[ comp ];
681
+ if ( ! data || ! data.interpolation ) continue;
682
+
683
+ const interpArray = data.interpolation;
684
+
685
+ for ( let i = 0; i < interpArray.length; i ++ ) {
686
+
687
+ const interp = interpArray[ i ];
688
+
689
+ if ( interpolationType === null ) {
690
+
691
+ interpolationType = interp;
692
+
693
+ } else if ( interp !== interpolationType ) {
694
+
695
+ isUniform = false;
696
+
697
+ }
698
+
699
+ }
700
+
701
+ }
702
+
703
+ return {
704
+ type: interpolationType || 'LINEAR',
705
+ uniform: isUniform
706
+ };
707
+
708
+ }
709
+
710
+ applyInterpolation( track, interpolationInfo, channelData = null ) {
711
+
712
+ if ( interpolationInfo.type === 'STEP' && interpolationInfo.uniform ) {
713
+
714
+ track.setInterpolation( InterpolateDiscrete );
715
+
716
+ } else if ( interpolationInfo.type === 'BEZIER' && interpolationInfo.uniform && channelData ) {
717
+
718
+ const data = channelData.default;
719
+
720
+ if ( data && data.inTangent && data.outTangent ) {
721
+
722
+ track.setInterpolation( InterpolateBezier );
723
+ track.settings = {
724
+ inTangents: new Float32Array( data.inTangent ),
725
+ outTangents: new Float32Array( data.outTangent )
726
+ };
727
+
728
+ }
729
+
730
+ }
731
+
732
+ }
733
+
734
+ prepareAnimationData( data, defaultMatrix ) {
735
+
736
+ const keyframes = [];
737
+
738
+ for ( const time in data ) {
739
+
740
+ keyframes.push( { time: parseFloat( time ), value: data[ time ] } );
741
+
742
+ }
743
+
744
+ keyframes.sort( ( a, b ) => a.time - b.time );
745
+
746
+ for ( let i = 0; i < 16; i ++ ) {
747
+
748
+ this.transformAnimationData( keyframes, i, defaultMatrix.elements[ i ] );
749
+
750
+ }
751
+
752
+ return keyframes;
753
+
754
+ }
755
+
756
+ createKeyframeTracks( animation, tracks ) {
757
+
758
+ const keyframes = animation.keyframes;
759
+ const name = animation.name;
760
+
761
+ const times = [];
762
+ const positionData = [];
763
+ const quaternionData = [];
764
+ const scaleData = [];
765
+
766
+ const position = this.position;
767
+ const quaternion = this.quaternion;
768
+ const scale = this.scale;
769
+ const matrix = this.matrix;
770
+
771
+ for ( let i = 0, l = keyframes.length; i < l; i ++ ) {
772
+
773
+ const keyframe = keyframes[ i ];
774
+
775
+ const time = keyframe.time;
776
+ const value = keyframe.value;
777
+
778
+ matrix.fromArray( value ).transpose();
779
+ matrix.decompose( position, quaternion, scale );
780
+
781
+ times.push( time );
782
+ positionData.push( position.x, position.y, position.z );
783
+ quaternionData.push( quaternion.x, quaternion.y, quaternion.z, quaternion.w );
784
+ scaleData.push( scale.x, scale.y, scale.z );
785
+
786
+ }
787
+
788
+ if ( positionData.length > 0 ) tracks.push( new VectorKeyframeTrack( name + '.position', times, positionData ) );
789
+ if ( quaternionData.length > 0 ) tracks.push( new QuaternionKeyframeTrack( name + '.quaternion', times, quaternionData ) );
790
+ if ( scaleData.length > 0 ) tracks.push( new VectorKeyframeTrack( name + '.scale', times, scaleData ) );
791
+
792
+ return tracks;
793
+
794
+ }
795
+
796
+ transformAnimationData( keyframes, property, defaultValue ) {
797
+
798
+ let keyframe;
799
+
800
+ let empty = true;
801
+ let i, l;
802
+
803
+ // check, if values of a property are missing in our keyframes
804
+
805
+ for ( i = 0, l = keyframes.length; i < l; i ++ ) {
806
+
807
+ keyframe = keyframes[ i ];
808
+
809
+ if ( keyframe.value[ property ] === undefined ) {
810
+
811
+ keyframe.value[ property ] = null; // mark as missing
812
+
813
+ } else {
814
+
815
+ empty = false;
816
+
817
+ }
818
+
819
+ }
820
+
821
+ if ( empty === true ) {
822
+
823
+ // no values at all, so we set a default value
824
+
825
+ for ( i = 0, l = keyframes.length; i < l; i ++ ) {
826
+
827
+ keyframe = keyframes[ i ];
828
+
829
+ keyframe.value[ property ] = defaultValue;
830
+
831
+ }
832
+
833
+ } else {
834
+
835
+ // filling gaps
836
+
837
+ this.createMissingKeyframes( keyframes, property );
838
+
839
+ }
840
+
841
+ }
842
+
843
+ createMissingKeyframes( keyframes, property ) {
844
+
845
+ let prev, next;
846
+
847
+ for ( let i = 0, l = keyframes.length; i < l; i ++ ) {
848
+
849
+ const keyframe = keyframes[ i ];
850
+
851
+ if ( keyframe.value[ property ] === null ) {
852
+
853
+ prev = this.getPrev( keyframes, i, property );
854
+ next = this.getNext( keyframes, i, property );
855
+
856
+ if ( prev === null ) {
857
+
858
+ keyframe.value[ property ] = next.value[ property ];
859
+ continue;
860
+
861
+ }
862
+
863
+ if ( next === null ) {
864
+
865
+ keyframe.value[ property ] = prev.value[ property ];
866
+ continue;
867
+
868
+ }
869
+
870
+ this.interpolate( keyframe, prev, next, property );
871
+
872
+ }
873
+
874
+ }
875
+
876
+ }
877
+
878
+ getPrev( keyframes, i, property ) {
879
+
880
+ while ( i >= 0 ) {
881
+
882
+ const keyframe = keyframes[ i ];
883
+
884
+ if ( keyframe.value[ property ] !== null ) return keyframe;
885
+
886
+ i --;
887
+
888
+ }
889
+
890
+ return null;
891
+
892
+ }
893
+
894
+ getNext( keyframes, i, property ) {
895
+
896
+ while ( i < keyframes.length ) {
897
+
898
+ const keyframe = keyframes[ i ];
899
+
900
+ if ( keyframe.value[ property ] !== null ) return keyframe;
901
+
902
+ i ++;
903
+
904
+ }
905
+
906
+ return null;
907
+
908
+ }
909
+
910
+ interpolate( key, prev, next, property ) {
911
+
912
+ if ( ( next.time - prev.time ) === 0 ) {
913
+
914
+ key.value[ property ] = prev.value[ property ];
915
+ return;
916
+
917
+ }
918
+
919
+ key.value[ property ] = ( ( key.time - prev.time ) * ( next.value[ property ] - prev.value[ property ] ) / ( next.time - prev.time ) ) + prev.value[ property ];
920
+
921
+ }
922
+
923
+
924
+ buildAnimationClip( data ) {
925
+
926
+ const tracks = [];
927
+
928
+ const name = data.name;
929
+ const duration = ( data.end - data.start ) || - 1;
930
+ const animations = data.animations;
931
+
932
+ for ( let i = 0, il = animations.length; i < il; i ++ ) {
933
+
934
+ const animationTracks = this.getAnimation( animations[ i ] );
935
+
936
+ for ( let j = 0, jl = animationTracks.length; j < jl; j ++ ) {
937
+
938
+ tracks.push( animationTracks[ j ] );
939
+
940
+ }
941
+
942
+ }
943
+
944
+ return new AnimationClip( name, duration, tracks );
945
+
946
+ }
947
+
948
+ getAnimationClip( id ) {
949
+
950
+ return this.getBuild( this.library.clips[ id ], this.buildAnimationClip.bind( this ) );
951
+
952
+ }
953
+
954
+
955
+ buildController( data ) {
956
+
957
+ const build = {
958
+ id: data.id
959
+ };
960
+
961
+ const geometry = this.library.geometries[ build.id ];
962
+
963
+ if ( data.skin !== undefined ) {
964
+
965
+ build.skin = this.buildSkin( data.skin );
966
+
967
+ // we enhance the 'sources' property of the corresponding geometry with our skin data
968
+
969
+ geometry.sources.skinIndices = build.skin.indices;
970
+ geometry.sources.skinWeights = build.skin.weights;
971
+
972
+ }
973
+
974
+ return build;
975
+
976
+ }
977
+
978
+ buildSkin( data ) {
979
+
980
+ const BONE_LIMIT = 4;
981
+
982
+ const build = {
983
+ joints: [], // this must be an array to preserve the joint order
984
+ indices: {
985
+ array: [],
986
+ stride: BONE_LIMIT
987
+ },
988
+ weights: {
989
+ array: [],
990
+ stride: BONE_LIMIT
991
+ }
992
+ };
993
+
994
+ const sources = data.sources;
995
+ const vertexWeights = data.vertexWeights;
996
+
997
+ const vcount = vertexWeights.vcount;
998
+ const v = vertexWeights.v;
999
+ const jointOffset = vertexWeights.inputs.JOINT.offset;
1000
+ const weightOffset = vertexWeights.inputs.WEIGHT.offset;
1001
+
1002
+ const jointSource = data.sources[ data.joints.inputs.JOINT ];
1003
+ const inverseSource = data.sources[ data.joints.inputs.INV_BIND_MATRIX ];
1004
+
1005
+ const weights = sources[ vertexWeights.inputs.WEIGHT.id ].array;
1006
+ let stride = 0;
1007
+
1008
+ let i, j, l;
1009
+
1010
+ // process skin data for each vertex
1011
+
1012
+ for ( i = 0, l = vcount.length; i < l; i ++ ) {
1013
+
1014
+ const jointCount = vcount[ i ]; // this is the amount of joints that affect a single vertex
1015
+ const vertexSkinData = [];
1016
+
1017
+ for ( j = 0; j < jointCount; j ++ ) {
1018
+
1019
+ const skinIndex = v[ stride + jointOffset ];
1020
+ const weightId = v[ stride + weightOffset ];
1021
+ const skinWeight = weights[ weightId ];
1022
+
1023
+ vertexSkinData.push( { index: skinIndex, weight: skinWeight } );
1024
+
1025
+ stride += 2;
1026
+
1027
+ }
1028
+
1029
+ // we sort the joints in descending order based on the weights.
1030
+ // this ensures, we only proceed the most important joints of the vertex
1031
+
1032
+ vertexSkinData.sort( descending );
1033
+
1034
+ // now we provide for each vertex a set of four index and weight values.
1035
+ // the order of the skin data matches the order of vertices
1036
+
1037
+ for ( j = 0; j < BONE_LIMIT; j ++ ) {
1038
+
1039
+ const d = vertexSkinData[ j ];
1040
+
1041
+ if ( d !== undefined ) {
1042
+
1043
+ build.indices.array.push( d.index );
1044
+ build.weights.array.push( d.weight );
1045
+
1046
+ } else {
1047
+
1048
+ build.indices.array.push( 0 );
1049
+ build.weights.array.push( 0 );
1050
+
1051
+ }
1052
+
1053
+ }
1054
+
1055
+ }
1056
+
1057
+ // setup bind matrix
1058
+
1059
+ if ( data.bindShapeMatrix ) {
1060
+
1061
+ build.bindMatrix = new Matrix4().fromArray( data.bindShapeMatrix ).transpose();
1062
+
1063
+ } else {
1064
+
1065
+ build.bindMatrix = new Matrix4().identity();
1066
+
1067
+ }
1068
+
1069
+ // process bones and inverse bind matrix data
1070
+
1071
+ for ( i = 0, l = jointSource.array.length; i < l; i ++ ) {
1072
+
1073
+ const name = jointSource.array[ i ];
1074
+ const boneInverse = new Matrix4().fromArray( inverseSource.array, i * inverseSource.stride ).transpose();
1075
+
1076
+ build.joints.push( { name: name, boneInverse: boneInverse } );
1077
+
1078
+ }
1079
+
1080
+ return build;
1081
+
1082
+ // array sort function
1083
+
1084
+ function descending( a, b ) {
1085
+
1086
+ return b.weight - a.weight;
1087
+
1088
+ }
1089
+
1090
+ }
1091
+
1092
+ getController( id ) {
1093
+
1094
+ return this.getBuild( this.library.controllers[ id ], this.buildController.bind( this ) );
1095
+
1096
+ }
1097
+
1098
+
1099
+ buildImage( data ) {
1100
+
1101
+ if ( data.build !== undefined ) return data.build;
1102
+
1103
+ return data.init_from;
1104
+
1105
+ }
1106
+
1107
+ getImage( id ) {
1108
+
1109
+ const data = this.library.images[ id ];
1110
+
1111
+ if ( data !== undefined ) {
1112
+
1113
+ return this.getBuild( data, this.buildImage.bind( this ) );
1114
+
1115
+ }
1116
+
1117
+ console.warn( 'THREE.ColladaLoader: Couldn\'t find image with ID:', id );
1118
+
1119
+ return null;
1120
+
1121
+ }
1122
+
1123
+
1124
+ buildEffect( data ) {
1125
+
1126
+ return data;
1127
+
1128
+ }
1129
+
1130
+ getEffect( id ) {
1131
+
1132
+ return this.getBuild( this.library.effects[ id ], this.buildEffect.bind( this ) );
1133
+
1134
+ }
1135
+
1136
+
1137
+ getTextureLoader( image ) {
1138
+
1139
+ let loader;
1140
+
1141
+ let extension = image.slice( ( image.lastIndexOf( '.' ) - 1 >>> 0 ) + 2 ); // http://www.jstips.co/en/javascript/get-file-extension/
1142
+ extension = extension.toLowerCase();
1143
+
1144
+ switch ( extension ) {
1145
+
1146
+ case 'tga':
1147
+ loader = this.tgaLoader;
1148
+ break;
1149
+
1150
+ default:
1151
+ loader = this.textureLoader;
1152
+
1153
+ }
1154
+
1155
+ return loader;
1156
+
1157
+ }
1158
+
1159
+ buildMaterial( data ) {
1160
+
1161
+ const effect = this.getEffect( data.url );
1162
+ const technique = effect.profile.technique;
1163
+
1164
+ let material;
1165
+
1166
+ switch ( technique.type ) {
1167
+
1168
+ case 'phong':
1169
+ case 'blinn':
1170
+ material = new MeshPhongMaterial();
1171
+ break;
1172
+
1173
+ case 'lambert':
1174
+ material = new MeshLambertMaterial();
1175
+ break;
1176
+
1177
+ default:
1178
+ material = new MeshBasicMaterial();
1179
+ break;
1180
+
1181
+ }
1182
+
1183
+ material.name = data.name || '';
1184
+
1185
+ const self = this;
1186
+
1187
+ function getTexture( textureObject, colorSpace = null ) {
1188
+
1189
+ const sampler = effect.profile.samplers[ textureObject.id ];
1190
+ let image = null;
1191
+
1192
+ // get image
1193
+
1194
+ if ( sampler !== undefined ) {
1195
+
1196
+ const surface = effect.profile.surfaces[ sampler.source ];
1197
+ image = self.getImage( surface.init_from );
1198
+
1199
+ } else {
1200
+
1201
+ console.warn( 'THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530).' );
1202
+ image = self.getImage( textureObject.id );
1203
+
1204
+ }
1205
+
1206
+ // create texture if image is available
1207
+
1208
+ if ( image !== null ) {
1209
+
1210
+ const loader = self.getTextureLoader( image );
1211
+
1212
+ if ( loader !== undefined ) {
1213
+
1214
+ const texture = loader.load( image );
1215
+
1216
+ const extra = textureObject.extra;
1217
+
1218
+ if ( extra !== undefined && extra.technique !== undefined && self.isEmpty( extra.technique ) === false ) {
1219
+
1220
+ const technique = extra.technique;
1221
+
1222
+ texture.wrapS = technique.wrapU ? RepeatWrapping : ClampToEdgeWrapping;
1223
+ texture.wrapT = technique.wrapV ? RepeatWrapping : ClampToEdgeWrapping;
1224
+
1225
+ texture.offset.set( technique.offsetU || 0, technique.offsetV || 0 );
1226
+ texture.repeat.set( technique.repeatU || 1, technique.repeatV || 1 );
1227
+
1228
+ } else {
1229
+
1230
+ texture.wrapS = RepeatWrapping;
1231
+ texture.wrapT = RepeatWrapping;
1232
+
1233
+ }
1234
+
1235
+ if ( colorSpace !== null ) {
1236
+
1237
+ texture.colorSpace = colorSpace;
1238
+
1239
+ }
1240
+
1241
+ return texture;
1242
+
1243
+ } else {
1244
+
1245
+ console.warn( 'THREE.ColladaLoader: Loader for texture %s not found.', image );
1246
+
1247
+ return null;
1248
+
1249
+ }
1250
+
1251
+ } else {
1252
+
1253
+ console.warn( 'THREE.ColladaLoader: Couldn\'t create texture with ID:', textureObject.id );
1254
+
1255
+ return null;
1256
+
1257
+ }
1258
+
1259
+ }
1260
+
1261
+ const parameters = technique.parameters;
1262
+
1263
+ for ( const key in parameters ) {
1264
+
1265
+ const parameter = parameters[ key ];
1266
+
1267
+ switch ( key ) {
1268
+
1269
+ case 'diffuse':
1270
+ if ( parameter.color ) material.color.fromArray( parameter.color );
1271
+ if ( parameter.texture ) material.map = getTexture( parameter.texture, SRGBColorSpace );
1272
+ break;
1273
+ case 'specular':
1274
+ if ( parameter.color && material.specular ) material.specular.fromArray( parameter.color );
1275
+ if ( parameter.texture ) material.specularMap = getTexture( parameter.texture );
1276
+ break;
1277
+ case 'bump':
1278
+ if ( parameter.texture ) material.normalMap = getTexture( parameter.texture );
1279
+ break;
1280
+ case 'ambient':
1281
+ if ( parameter.texture ) material.lightMap = getTexture( parameter.texture, SRGBColorSpace );
1282
+ break;
1283
+ case 'shininess':
1284
+ if ( parameter.float && material.shininess ) material.shininess = parameter.float;
1285
+ break;
1286
+ case 'emission':
1287
+ if ( parameter.color && material.emissive ) material.emissive.fromArray( parameter.color );
1288
+ if ( parameter.texture ) material.emissiveMap = getTexture( parameter.texture, SRGBColorSpace );
1289
+ break;
1290
+
1291
+ }
1292
+
1293
+ }
1294
+
1295
+ ColorManagement.colorSpaceToWorking( material.color, SRGBColorSpace );
1296
+ if ( material.specular ) ColorManagement.colorSpaceToWorking( material.specular, SRGBColorSpace );
1297
+ if ( material.emissive ) ColorManagement.colorSpaceToWorking( material.emissive, SRGBColorSpace );
1298
+
1299
+ //
1300
+
1301
+ let transparent = parameters[ 'transparent' ];
1302
+ let transparency = parameters[ 'transparency' ];
1303
+
1304
+ // <transparency> does not exist but <transparent>
1305
+
1306
+ if ( transparency === undefined && transparent ) {
1307
+
1308
+ transparency = {
1309
+ float: 1
1310
+ };
1311
+
1312
+ }
1313
+
1314
+ // <transparent> does not exist but <transparency>
1315
+
1316
+ if ( transparent === undefined && transparency ) {
1317
+
1318
+ transparent = {
1319
+ opaque: 'A_ONE',
1320
+ data: {
1321
+ color: [ 1, 1, 1, 1 ]
1322
+ } };
1323
+
1324
+ }
1325
+
1326
+ if ( transparent && transparency ) {
1327
+
1328
+ // handle case if a texture exists but no color
1329
+
1330
+ if ( transparent.data.texture ) {
1331
+
1332
+ // we do not set an alpha map (see #13792)
1333
+
1334
+ material.transparent = true;
1335
+
1336
+ } else {
1337
+
1338
+ const color = transparent.data.color;
1339
+
1340
+ switch ( transparent.opaque ) {
1341
+
1342
+ case 'A_ONE':
1343
+ material.opacity = color[ 3 ] * transparency.float;
1344
+ break;
1345
+ case 'RGB_ZERO':
1346
+ material.opacity = 1 - ( color[ 0 ] * transparency.float );
1347
+ break;
1348
+ case 'A_ZERO':
1349
+ material.opacity = 1 - ( color[ 3 ] * transparency.float );
1350
+ break;
1351
+ case 'RGB_ONE':
1352
+ material.opacity = color[ 0 ] * transparency.float;
1353
+ break;
1354
+ default:
1355
+ console.warn( 'THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.', transparent.opaque );
1356
+
1357
+ }
1358
+
1359
+ if ( material.opacity < 1 ) material.transparent = true;
1360
+
1361
+ }
1362
+
1363
+ }
1364
+
1365
+ //
1366
+
1367
+
1368
+ if ( technique.extra !== undefined && technique.extra.technique !== undefined ) {
1369
+
1370
+ const techniques = technique.extra.technique;
1371
+
1372
+ for ( const k in techniques ) {
1373
+
1374
+ const v = techniques[ k ];
1375
+
1376
+ switch ( k ) {
1377
+
1378
+ case 'double_sided':
1379
+ material.side = ( v === 1 ? DoubleSide : FrontSide );
1380
+ break;
1381
+
1382
+ case 'bump':
1383
+ material.normalMap = getTexture( v.texture );
1384
+ material.normalScale = new Vector2( 1, 1 );
1385
+ break;
1386
+
1387
+ }
1388
+
1389
+ }
1390
+
1391
+ }
1392
+
1393
+ return material;
1394
+
1395
+ }
1396
+
1397
+ getMaterial( id ) {
1398
+
1399
+ return this.getBuild( this.library.materials[ id ], this.buildMaterial.bind( this ) );
1400
+
1401
+ }
1402
+
1403
+
1404
+ buildCamera( data ) {
1405
+
1406
+ let camera;
1407
+
1408
+ switch ( data.optics.technique ) {
1409
+
1410
+ case 'perspective':
1411
+ camera = new PerspectiveCamera(
1412
+ data.optics.parameters.yfov,
1413
+ data.optics.parameters.aspect_ratio,
1414
+ data.optics.parameters.znear,
1415
+ data.optics.parameters.zfar
1416
+ );
1417
+ break;
1418
+
1419
+ case 'orthographic':
1420
+ let ymag = data.optics.parameters.ymag;
1421
+ let xmag = data.optics.parameters.xmag;
1422
+ const aspectRatio = data.optics.parameters.aspect_ratio;
1423
+
1424
+ xmag = ( xmag === undefined ) ? ( ymag * aspectRatio ) : xmag;
1425
+ ymag = ( ymag === undefined ) ? ( xmag / aspectRatio ) : ymag;
1426
+
1427
+ xmag *= 0.5;
1428
+ ymag *= 0.5;
1429
+
1430
+ camera = new OrthographicCamera(
1431
+ - xmag, xmag, ymag, - ymag, // left, right, top, bottom
1432
+ data.optics.parameters.znear,
1433
+ data.optics.parameters.zfar
1434
+ );
1435
+ break;
1436
+
1437
+ default:
1438
+ camera = new PerspectiveCamera();
1439
+ break;
1440
+
1441
+ }
1442
+
1443
+ camera.name = data.name || '';
1444
+
1445
+ return camera;
1446
+
1447
+ }
1448
+
1449
+ getCamera( id ) {
1450
+
1451
+ const data = this.library.cameras[ id ];
1452
+
1453
+ if ( data !== undefined ) {
1454
+
1455
+ return this.getBuild( data, this.buildCamera.bind( this ) );
1456
+
1457
+ }
1458
+
1459
+ console.warn( 'THREE.ColladaLoader: Couldn\'t find camera with ID:', id );
1460
+
1461
+ return null;
1462
+
1463
+ }
1464
+
1465
+
1466
+ buildLight( data ) {
1467
+
1468
+ let light;
1469
+
1470
+ switch ( data.technique ) {
1471
+
1472
+ case 'directional':
1473
+ light = new DirectionalLight();
1474
+ break;
1475
+
1476
+ case 'point':
1477
+ light = new PointLight();
1478
+ break;
1479
+
1480
+ case 'spot':
1481
+ light = new SpotLight();
1482
+ break;
1483
+
1484
+ case 'ambient':
1485
+ light = new AmbientLight();
1486
+ break;
1487
+
1488
+ }
1489
+
1490
+ if ( data.parameters.color ) light.color.copy( data.parameters.color );
1491
+ if ( data.parameters.distance ) light.distance = data.parameters.distance;
1492
+ if ( data.parameters.falloffAngle ) light.angle = MathUtils.degToRad( data.parameters.falloffAngle );
1493
+
1494
+ return light;
1495
+
1496
+ }
1497
+
1498
+ getLight( id ) {
1499
+
1500
+ const data = this.library.lights[ id ];
1501
+
1502
+ if ( data !== undefined ) {
1503
+
1504
+ return this.getBuild( data, this.buildLight.bind( this ) );
1505
+
1506
+ }
1507
+
1508
+ console.warn( 'THREE.ColladaLoader: Couldn\'t find light with ID:', id );
1509
+
1510
+ return null;
1511
+
1512
+ }
1513
+
1514
+
1515
+ groupPrimitives( primitives ) {
1516
+
1517
+ const build = {};
1518
+
1519
+ for ( let i = 0; i < primitives.length; i ++ ) {
1520
+
1521
+ const primitive = primitives[ i ];
1522
+
1523
+ if ( build[ primitive.type ] === undefined ) build[ primitive.type ] = [];
1524
+
1525
+ build[ primitive.type ].push( primitive );
1526
+
1527
+ }
1528
+
1529
+ return build;
1530
+
1531
+ }
1532
+
1533
+ checkUVCoordinates( primitives ) {
1534
+
1535
+ let count = 0;
1536
+
1537
+ for ( let i = 0, l = primitives.length; i < l; i ++ ) {
1538
+
1539
+ const primitive = primitives[ i ];
1540
+
1541
+ if ( primitive.hasUV === true ) {
1542
+
1543
+ count ++;
1544
+
1545
+ }
1546
+
1547
+ }
1548
+
1549
+ if ( count > 0 && count < primitives.length ) {
1550
+
1551
+ primitives.uvsNeedsFix = true;
1552
+
1553
+ }
1554
+
1555
+ }
1556
+
1557
+ buildGeometry( data ) {
1558
+
1559
+ const build = {};
1560
+
1561
+ const sources = data.sources;
1562
+ const vertices = data.vertices;
1563
+ const primitives = data.primitives;
1564
+
1565
+ if ( primitives.length === 0 ) return {};
1566
+
1567
+ // our goal is to create one buffer geometry for a single type of primitives
1568
+ // first, we group all primitives by their type
1569
+
1570
+ const groupedPrimitives = this.groupPrimitives( primitives );
1571
+
1572
+ for ( const type in groupedPrimitives ) {
1573
+
1574
+ const primitiveType = groupedPrimitives[ type ];
1575
+
1576
+ // second, ensure consistent uv coordinates for each type of primitives (polylist,triangles or lines)
1577
+
1578
+ this.checkUVCoordinates( primitiveType );
1579
+
1580
+ // third, create a buffer geometry for each type of primitives
1581
+
1582
+ build[ type ] = this.buildGeometryType( primitiveType, sources, vertices );
1583
+
1584
+ }
1585
+
1586
+ return build;
1587
+
1588
+ }
1589
+
1590
+ buildGeometryType( primitives, sources, vertices ) {
1591
+
1592
+ const build = {};
1593
+
1594
+ const position = { array: [], stride: 0 };
1595
+ const normal = { array: [], stride: 0 };
1596
+ const uv = { array: [], stride: 0 };
1597
+ const uv1 = { array: [], stride: 0 };
1598
+ const color = { array: [], stride: 0 };
1599
+
1600
+ const skinIndex = { array: [], stride: 4 };
1601
+ const skinWeight = { array: [], stride: 4 };
1602
+
1603
+ const geometry = new BufferGeometry();
1604
+
1605
+ const materialKeys = [];
1606
+
1607
+ let start = 0;
1608
+
1609
+ for ( let p = 0; p < primitives.length; p ++ ) {
1610
+
1611
+ const primitive = primitives[ p ];
1612
+ const inputs = primitive.inputs;
1613
+
1614
+ // groups
1615
+
1616
+ let count = 0;
1617
+
1618
+ switch ( primitive.type ) {
1619
+
1620
+ case 'lines':
1621
+ case 'linestrips':
1622
+ count = primitive.count * 2;
1623
+ break;
1624
+
1625
+ case 'triangles':
1626
+ count = primitive.count * 3;
1627
+ break;
1628
+
1629
+ case 'polylist':
1630
+
1631
+ for ( let g = 0; g < primitive.count; g ++ ) {
1632
+
1633
+ const vc = primitive.vcount[ g ];
1634
+
1635
+ switch ( vc ) {
1636
+
1637
+ case 3:
1638
+ count += 3; // single triangle
1639
+ break;
1640
+
1641
+ case 4:
1642
+ count += 6; // quad, subdivided into two triangles
1643
+ break;
1644
+
1645
+ default:
1646
+ count += ( vc - 2 ) * 3; // polylist with more than four vertices
1647
+ break;
1648
+
1649
+ }
1650
+
1651
+ }
1652
+
1653
+ break;
1654
+
1655
+ default:
1656
+ console.warn( 'THREE.ColladaLoader: Unknown primitive type:', primitive.type );
1657
+
1658
+ }
1659
+
1660
+ geometry.addGroup( start, count, p );
1661
+ start += count;
1662
+
1663
+ // material
1664
+
1665
+ if ( primitive.material ) {
1666
+
1667
+ materialKeys.push( primitive.material );
1668
+
1669
+ }
1670
+
1671
+ // geometry data
1672
+
1673
+ for ( const name in inputs ) {
1674
+
1675
+ const input = inputs[ name ];
1676
+
1677
+ switch ( name ) {
1678
+
1679
+ case 'VERTEX':
1680
+ for ( const key in vertices ) {
1681
+
1682
+ const id = vertices[ key ];
1683
+
1684
+ switch ( key ) {
1685
+
1686
+ case 'POSITION':
1687
+ const prevLength = position.array.length;
1688
+ this.buildGeometryData( primitive, sources[ id ], input.offset, position.array );
1689
+ position.stride = sources[ id ].stride;
1690
+
1691
+ if ( sources.skinWeights && sources.skinIndices ) {
1692
+
1693
+ this.buildGeometryData( primitive, sources.skinIndices, input.offset, skinIndex.array );
1694
+ this.buildGeometryData( primitive, sources.skinWeights, input.offset, skinWeight.array );
1695
+
1696
+ }
1697
+
1698
+ // see #3803
1699
+
1700
+ if ( primitive.hasUV === false && primitives.uvsNeedsFix === true ) {
1701
+
1702
+ const count = ( position.array.length - prevLength ) / position.stride;
1703
+
1704
+ for ( let i = 0; i < count; i ++ ) {
1705
+
1706
+ // fill missing uv coordinates
1707
+
1708
+ uv.array.push( 0, 0 );
1709
+
1710
+ }
1711
+
1712
+ }
1713
+
1714
+ break;
1715
+
1716
+ case 'NORMAL':
1717
+ this.buildGeometryData( primitive, sources[ id ], input.offset, normal.array );
1718
+ normal.stride = sources[ id ].stride;
1719
+ break;
1720
+
1721
+ case 'COLOR':
1722
+ this.buildGeometryData( primitive, sources[ id ], input.offset, color.array );
1723
+ color.stride = sources[ id ].stride;
1724
+ break;
1725
+
1726
+ case 'TEXCOORD':
1727
+ this.buildGeometryData( primitive, sources[ id ], input.offset, uv.array );
1728
+ uv.stride = sources[ id ].stride;
1729
+ break;
1730
+
1731
+ case 'TEXCOORD1':
1732
+ this.buildGeometryData( primitive, sources[ id ], input.offset, uv1.array );
1733
+ uv.stride = sources[ id ].stride;
1734
+ break;
1735
+
1736
+ default:
1737
+ console.warn( 'THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.', key );
1738
+
1739
+ }
1740
+
1741
+ }
1742
+
1743
+ break;
1744
+
1745
+ case 'NORMAL':
1746
+ this.buildGeometryData( primitive, sources[ input.id ], input.offset, normal.array );
1747
+ normal.stride = sources[ input.id ].stride;
1748
+ break;
1749
+
1750
+ case 'COLOR':
1751
+ this.buildGeometryData( primitive, sources[ input.id ], input.offset, color.array, true );
1752
+ color.stride = sources[ input.id ].stride;
1753
+ break;
1754
+
1755
+ case 'TEXCOORD':
1756
+ this.buildGeometryData( primitive, sources[ input.id ], input.offset, uv.array );
1757
+ uv.stride = sources[ input.id ].stride;
1758
+ break;
1759
+
1760
+ case 'TEXCOORD1':
1761
+ this.buildGeometryData( primitive, sources[ input.id ], input.offset, uv1.array );
1762
+ uv1.stride = sources[ input.id ].stride;
1763
+ break;
1764
+
1765
+ }
1766
+
1767
+ }
1768
+
1769
+ }
1770
+
1771
+ // build geometry
1772
+
1773
+ if ( position.array.length > 0 ) geometry.setAttribute( 'position', new Float32BufferAttribute( position.array, position.stride ) );
1774
+ if ( normal.array.length > 0 ) geometry.setAttribute( 'normal', new Float32BufferAttribute( normal.array, normal.stride ) );
1775
+ if ( color.array.length > 0 ) geometry.setAttribute( 'color', new Float32BufferAttribute( color.array, color.stride ) );
1776
+ if ( uv.array.length > 0 ) geometry.setAttribute( 'uv', new Float32BufferAttribute( uv.array, uv.stride ) );
1777
+ if ( uv1.array.length > 0 ) geometry.setAttribute( 'uv1', new Float32BufferAttribute( uv1.array, uv1.stride ) );
1778
+
1779
+ if ( skinIndex.array.length > 0 ) geometry.setAttribute( 'skinIndex', new Float32BufferAttribute( skinIndex.array, skinIndex.stride ) );
1780
+ if ( skinWeight.array.length > 0 ) geometry.setAttribute( 'skinWeight', new Float32BufferAttribute( skinWeight.array, skinWeight.stride ) );
1781
+
1782
+ build.data = geometry;
1783
+ build.type = primitives[ 0 ].type;
1784
+ build.materialKeys = materialKeys;
1785
+
1786
+ return build;
1787
+
1788
+ }
1789
+
1790
+ buildGeometryData( primitive, source, offset, array, isColor = false ) {
1791
+
1792
+ const indices = primitive.p;
1793
+ const stride = primitive.stride;
1794
+ const vcount = primitive.vcount;
1795
+
1796
+ const tempColor = this.tempColor;
1797
+
1798
+ function pushVector( i ) {
1799
+
1800
+ let index = indices[ i + offset ] * sourceStride;
1801
+ const length = index + sourceStride;
1802
+
1803
+ for ( ; index < length; index ++ ) {
1804
+
1805
+ array.push( sourceArray[ index ] );
1806
+
1807
+ }
1808
+
1809
+ if ( isColor ) {
1810
+
1811
+ // convert the vertex colors from srgb to linear if present
1812
+ const startIndex = array.length - sourceStride - 1;
1813
+ tempColor.setRGB(
1814
+ array[ startIndex + 0 ],
1815
+ array[ startIndex + 1 ],
1816
+ array[ startIndex + 2 ],
1817
+ SRGBColorSpace
1818
+ );
1819
+
1820
+ array[ startIndex + 0 ] = tempColor.r;
1821
+ array[ startIndex + 1 ] = tempColor.g;
1822
+ array[ startIndex + 2 ] = tempColor.b;
1823
+
1824
+ }
1825
+
1826
+ }
1827
+
1828
+ const sourceArray = source.array;
1829
+ const sourceStride = source.stride;
1830
+
1831
+ if ( primitive.vcount !== undefined ) {
1832
+
1833
+ let index = 0;
1834
+
1835
+ for ( let i = 0, l = vcount.length; i < l; i ++ ) {
1836
+
1837
+ const count = vcount[ i ];
1838
+
1839
+ if ( count === 4 ) {
1840
+
1841
+ const a = index + stride * 0;
1842
+ const b = index + stride * 1;
1843
+ const c = index + stride * 2;
1844
+ const d = index + stride * 3;
1845
+
1846
+ pushVector( a ); pushVector( b ); pushVector( d );
1847
+ pushVector( b ); pushVector( c ); pushVector( d );
1848
+
1849
+ } else if ( count === 3 ) {
1850
+
1851
+ const a = index + stride * 0;
1852
+ const b = index + stride * 1;
1853
+ const c = index + stride * 2;
1854
+
1855
+ pushVector( a ); pushVector( b ); pushVector( c );
1856
+
1857
+ } else if ( count > 4 ) {
1858
+
1859
+ for ( let k = 1, kl = ( count - 2 ); k <= kl; k ++ ) {
1860
+
1861
+ const a = index + stride * 0;
1862
+ const b = index + stride * k;
1863
+ const c = index + stride * ( k + 1 );
1864
+
1865
+ pushVector( a ); pushVector( b ); pushVector( c );
1866
+
1867
+ }
1868
+
1869
+ }
1870
+
1871
+ index += stride * count;
1872
+
1873
+ }
1874
+
1875
+ } else {
1876
+
1877
+ for ( let i = 0, l = indices.length; i < l; i += stride ) {
1878
+
1879
+ pushVector( i );
1880
+
1881
+ }
1882
+
1883
+ }
1884
+
1885
+ }
1886
+
1887
+ getGeometry( id ) {
1888
+
1889
+ return this.getBuild( this.library.geometries[ id ], this.buildGeometry.bind( this ) );
1890
+
1891
+ }
1892
+
1893
+
1894
+ buildKinematicsModel( data ) {
1895
+
1896
+ if ( data.build !== undefined ) return data.build;
1897
+
1898
+ return data;
1899
+
1900
+ }
1901
+
1902
+ getKinematicsModel( id ) {
1903
+
1904
+ return this.getBuild( this.library.kinematicsModels[ id ], this.buildKinematicsModel.bind( this ) );
1905
+
1906
+ }
1907
+
1908
+ buildKinematicsScene( data ) {
1909
+
1910
+ if ( data.build !== undefined ) return data.build;
1911
+
1912
+ return data;
1913
+
1914
+ }
1915
+
1916
+ getKinematicsScene( id ) {
1917
+
1918
+ return this.getBuild( this.library.kinematicsScenes[ id ], this.buildKinematicsScene.bind( this ) );
1919
+
1920
+ }
1921
+
1922
+ setupKinematics() {
1923
+
1924
+ const kinematicsModelId = Object.keys( this.library.kinematicsModels )[ 0 ];
1925
+ const kinematicsSceneId = Object.keys( this.library.kinematicsScenes )[ 0 ];
1926
+ const visualSceneId = Object.keys( this.library.visualScenes )[ 0 ];
1927
+
1928
+ if ( kinematicsModelId === undefined || kinematicsSceneId === undefined ) return;
1929
+
1930
+ const kinematicsModel = this.getKinematicsModel( kinematicsModelId );
1931
+ const kinematicsScene = this.getKinematicsScene( kinematicsSceneId );
1932
+ const visualScene = this.getVisualScene( visualSceneId );
1933
+
1934
+ const bindJointAxis = kinematicsScene.bindJointAxis;
1935
+ const jointMap = {};
1936
+
1937
+ const collada = this.collada;
1938
+ const self = this;
1939
+
1940
+ for ( let i = 0, l = bindJointAxis.length; i < l; i ++ ) {
1941
+
1942
+ const axis = bindJointAxis[ i ];
1943
+
1944
+ // the result of the following query is an element of type 'translate', 'rotate','scale' or 'matrix'
1945
+
1946
+ const targetElement = collada.querySelector( '[sid="' + axis.target + '"]' );
1947
+
1948
+ if ( targetElement ) {
1949
+
1950
+ // get the parent of the transform element
1951
+
1952
+ const parentVisualElement = targetElement.parentElement;
1953
+
1954
+ // connect the joint of the kinematics model with the element in the visual scene
1955
+
1956
+ connect( axis.jointIndex, parentVisualElement );
1957
+
1958
+ }
1959
+
1960
+ }
1961
+
1962
+ function connect( jointIndex, visualElement ) {
1963
+
1964
+ const visualElementName = visualElement.getAttribute( 'name' );
1965
+ const joint = kinematicsModel.joints[ jointIndex ];
1966
+ const transforms = self.buildTransformList( visualElement );
1967
+
1968
+ visualScene.traverse( function ( object ) {
1969
+
1970
+ if ( object.name === visualElementName ) {
1971
+
1972
+ jointMap[ jointIndex ] = {
1973
+ object: object,
1974
+ transforms: transforms,
1975
+ joint: joint,
1976
+ position: joint.zeroPosition
1977
+ };
1978
+
1979
+ }
1980
+
1981
+ } );
1982
+
1983
+ }
1984
+
1985
+ const m0 = new Matrix4();
1986
+ const matrix = this.matrix;
1987
+
1988
+ this.kinematics = {
1989
+
1990
+ joints: kinematicsModel && kinematicsModel.joints,
1991
+
1992
+ getJointValue: function ( jointIndex ) {
1993
+
1994
+ const jointData = jointMap[ jointIndex ];
1995
+
1996
+ if ( jointData ) {
1997
+
1998
+ return jointData.position;
1999
+
2000
+ } else {
2001
+
2002
+ console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' doesn\'t exist.' );
2003
+
2004
+ }
2005
+
2006
+ },
2007
+
2008
+ setJointValue: function ( jointIndex, value ) {
2009
+
2010
+ const jointData = jointMap[ jointIndex ];
2011
+
2012
+ if ( jointData ) {
2013
+
2014
+ const joint = jointData.joint;
2015
+
2016
+ if ( value > joint.limits.max || value < joint.limits.min ) {
2017
+
2018
+ console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' value ' + value + ' outside of limits (min: ' + joint.limits.min + ', max: ' + joint.limits.max + ').' );
2019
+
2020
+ } else if ( joint.static ) {
2021
+
2022
+ console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' is static.' );
2023
+
2024
+ } else {
2025
+
2026
+ const object = jointData.object;
2027
+ const axis = joint.axis;
2028
+ const transforms = jointData.transforms;
2029
+
2030
+ matrix.identity();
2031
+
2032
+ // each update, we have to apply all transforms in the correct order
2033
+
2034
+ for ( let i = 0; i < transforms.length; i ++ ) {
2035
+
2036
+ const transform = transforms[ i ];
2037
+
2038
+ // if there is a connection of the transform node with a joint, apply the joint value
2039
+
2040
+ if ( transform.sid && transform.sid.indexOf( jointIndex ) !== - 1 ) {
2041
+
2042
+ switch ( joint.type ) {
2043
+
2044
+ case 'revolute':
2045
+ matrix.multiply( m0.makeRotationAxis( axis, MathUtils.degToRad( value ) ) );
2046
+ break;
2047
+
2048
+ case 'prismatic':
2049
+ matrix.multiply( m0.makeTranslation( axis.x * value, axis.y * value, axis.z * value ) );
2050
+ break;
2051
+
2052
+ default:
2053
+ console.warn( 'THREE.ColladaLoader: Unknown joint type: ' + joint.type );
2054
+ break;
2055
+
2056
+ }
2057
+
2058
+ } else {
2059
+
2060
+ switch ( transform.type ) {
2061
+
2062
+ case 'matrix':
2063
+ matrix.multiply( transform.obj );
2064
+ break;
2065
+
2066
+ case 'translate':
2067
+ matrix.multiply( m0.makeTranslation( transform.obj.x, transform.obj.y, transform.obj.z ) );
2068
+ break;
2069
+
2070
+ case 'scale':
2071
+ matrix.scale( transform.obj );
2072
+ break;
2073
+
2074
+ case 'rotate':
2075
+ matrix.multiply( m0.makeRotationAxis( transform.obj, transform.angle ) );
2076
+ break;
2077
+
2078
+ }
2079
+
2080
+ }
2081
+
2082
+ }
2083
+
2084
+ object.matrix.copy( matrix );
2085
+ object.matrix.decompose( object.position, object.quaternion, object.scale );
2086
+
2087
+ jointMap[ jointIndex ].position = value;
2088
+
2089
+ }
2090
+
2091
+ } else {
2092
+
2093
+ console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' does not exist.' );
2094
+
2095
+ }
2096
+
2097
+ }
2098
+
2099
+ };
2100
+
2101
+ }
2102
+
2103
+ buildTransformList( node ) {
2104
+
2105
+ const transforms = [];
2106
+
2107
+ const xml = this.collada.querySelector( '[id="' + node.id + '"]' );
2108
+
2109
+ for ( let i = 0; i < xml.childNodes.length; i ++ ) {
2110
+
2111
+ const child = xml.childNodes[ i ];
2112
+
2113
+ if ( child.nodeType !== 1 ) continue;
2114
+
2115
+ let array, vector;
2116
+
2117
+ switch ( child.nodeName ) {
2118
+
2119
+ case 'matrix':
2120
+ array = parseFloats( child.textContent );
2121
+ const matrix = new Matrix4().fromArray( array ).transpose();
2122
+ transforms.push( {
2123
+ sid: child.getAttribute( 'sid' ),
2124
+ type: child.nodeName,
2125
+ obj: matrix
2126
+ } );
2127
+ break;
2128
+
2129
+ case 'translate':
2130
+ case 'scale':
2131
+ array = parseFloats( child.textContent );
2132
+ vector = new Vector3().fromArray( array );
2133
+ transforms.push( {
2134
+ sid: child.getAttribute( 'sid' ),
2135
+ type: child.nodeName,
2136
+ obj: vector
2137
+ } );
2138
+ break;
2139
+
2140
+ case 'rotate':
2141
+ array = parseFloats( child.textContent );
2142
+ vector = new Vector3().fromArray( array );
2143
+ const angle = MathUtils.degToRad( array[ 3 ] );
2144
+ transforms.push( {
2145
+ sid: child.getAttribute( 'sid' ),
2146
+ type: child.nodeName,
2147
+ obj: vector,
2148
+ angle: angle
2149
+ } );
2150
+ break;
2151
+
2152
+ }
2153
+
2154
+ }
2155
+
2156
+ return transforms;
2157
+
2158
+ }
2159
+
2160
+
2161
+ buildSkeleton( skeletons, joints ) {
2162
+
2163
+ const boneData = [];
2164
+ const sortedBoneData = [];
2165
+
2166
+ let i, j, data;
2167
+
2168
+ // a skeleton can have multiple root bones. collada expresses this
2169
+ // situation with multiple "skeleton" tags per controller instance
2170
+
2171
+ for ( i = 0; i < skeletons.length; i ++ ) {
2172
+
2173
+ const skeleton = skeletons[ i ];
2174
+
2175
+ let root;
2176
+
2177
+ if ( this.hasNode( skeleton ) ) {
2178
+
2179
+ root = this.getNode( skeleton );
2180
+ this.buildBoneHierarchy( root, joints, boneData );
2181
+
2182
+ } else if ( this.hasVisualScene( skeleton ) ) {
2183
+
2184
+ // handle case where the skeleton refers to the visual scene (#13335)
2185
+
2186
+ const visualScene = this.library.visualScenes[ skeleton ];
2187
+ const children = visualScene.children;
2188
+
2189
+ for ( let j = 0; j < children.length; j ++ ) {
2190
+
2191
+ const child = children[ j ];
2192
+
2193
+ if ( child.type === 'JOINT' ) {
2194
+
2195
+ const root = this.getNode( child.id );
2196
+ this.buildBoneHierarchy( root, joints, boneData );
2197
+
2198
+ }
2199
+
2200
+ }
2201
+
2202
+ } else {
2203
+
2204
+ console.error( 'THREE.ColladaLoader: Unable to find root bone of skeleton with ID:', skeleton );
2205
+
2206
+ }
2207
+
2208
+ }
2209
+
2210
+ // sort bone data (the order is defined in the corresponding controller)
2211
+
2212
+ for ( i = 0; i < joints.length; i ++ ) {
2213
+
2214
+ for ( j = 0; j < boneData.length; j ++ ) {
2215
+
2216
+ data = boneData[ j ];
2217
+
2218
+ if ( data.bone.name === joints[ i ].name ) {
2219
+
2220
+ sortedBoneData[ i ] = data;
2221
+ data.processed = true;
2222
+ break;
2223
+
2224
+ }
2225
+
2226
+ }
2227
+
2228
+ }
2229
+
2230
+ // add unprocessed bone data at the end of the list
2231
+
2232
+ for ( i = 0; i < boneData.length; i ++ ) {
2233
+
2234
+ data = boneData[ i ];
2235
+
2236
+ if ( data.processed === false ) {
2237
+
2238
+ sortedBoneData.push( data );
2239
+ data.processed = true;
2240
+
2241
+ }
2242
+
2243
+ }
2244
+
2245
+ // setup arrays for skeleton creation
2246
+
2247
+ const bones = [];
2248
+ const boneInverses = [];
2249
+
2250
+ for ( i = 0; i < sortedBoneData.length; i ++ ) {
2251
+
2252
+ data = sortedBoneData[ i ];
2253
+
2254
+ bones.push( data.bone );
2255
+ boneInverses.push( data.boneInverse );
2256
+
2257
+ }
2258
+
2259
+ return new Skeleton( bones, boneInverses );
2260
+
2261
+ }
2262
+
2263
+ buildBoneHierarchy( root, joints, boneData ) {
2264
+
2265
+ // setup bone data from visual scene
2266
+
2267
+ root.traverse( function ( object ) {
2268
+
2269
+ if ( object.isBone === true ) {
2270
+
2271
+ let boneInverse;
2272
+
2273
+ // retrieve the boneInverse from the controller data
2274
+
2275
+ for ( let i = 0; i < joints.length; i ++ ) {
2276
+
2277
+ const joint = joints[ i ];
2278
+
2279
+ if ( joint.name === object.name ) {
2280
+
2281
+ boneInverse = joint.boneInverse;
2282
+ break;
2283
+
2284
+ }
2285
+
2286
+ }
2287
+
2288
+ if ( boneInverse === undefined ) {
2289
+
2290
+ // Unfortunately, there can be joints in the visual scene that are not part of the
2291
+ // corresponding controller. In this case, we have to create a dummy boneInverse matrix
2292
+ // for the respective bone. This bone won't affect any vertices, because there are no skin indices
2293
+ // and weights defined for it. But we still have to add the bone to the sorted bone list in order to
2294
+ // ensure a correct animation of the model.
2295
+
2296
+ boneInverse = new Matrix4();
2297
+
2298
+ }
2299
+
2300
+ boneData.push( { bone: object, boneInverse: boneInverse, processed: false } );
2301
+
2302
+ }
2303
+
2304
+ } );
2305
+
2306
+ }
2307
+
2308
+ buildNode( data ) {
2309
+
2310
+ const objects = [];
2311
+
2312
+ const matrix = data.matrix;
2313
+ const nodes = data.nodes;
2314
+ const type = data.type;
2315
+ const instanceCameras = data.instanceCameras;
2316
+ const instanceControllers = data.instanceControllers;
2317
+ const instanceLights = data.instanceLights;
2318
+ const instanceGeometries = data.instanceGeometries;
2319
+ const instanceNodes = data.instanceNodes;
2320
+
2321
+ // nodes
2322
+
2323
+ for ( let i = 0, l = nodes.length; i < l; i ++ ) {
2324
+
2325
+ objects.push( this.getNode( nodes[ i ] ) );
2326
+
2327
+ }
2328
+
2329
+ // instance cameras
2330
+
2331
+ for ( let i = 0, l = instanceCameras.length; i < l; i ++ ) {
2332
+
2333
+ const instanceCamera = this.getCamera( instanceCameras[ i ] );
2334
+
2335
+ if ( instanceCamera !== null ) {
2336
+
2337
+ objects.push( instanceCamera.clone() );
2338
+
2339
+ }
2340
+
2341
+ }
2342
+
2343
+ // instance controllers
2344
+
2345
+ for ( let i = 0, l = instanceControllers.length; i < l; i ++ ) {
2346
+
2347
+ const instance = instanceControllers[ i ];
2348
+ const controller = this.getController( instance.id );
2349
+ const geometries = this.getGeometry( controller.id );
2350
+ const newObjects = this.buildObjects( geometries, instance.materials );
2351
+
2352
+ const skeletons = instance.skeletons;
2353
+ const joints = controller.skin.joints;
2354
+
2355
+ const skeleton = this.buildSkeleton( skeletons, joints );
2356
+
2357
+ for ( let j = 0, jl = newObjects.length; j < jl; j ++ ) {
2358
+
2359
+ const object = newObjects[ j ];
2360
+
2361
+ if ( object.isSkinnedMesh ) {
2362
+
2363
+ object.bind( skeleton, controller.skin.bindMatrix );
2364
+ object.normalizeSkinWeights();
2365
+
2366
+ }
2367
+
2368
+ objects.push( object );
2369
+
2370
+ }
2371
+
2372
+ }
2373
+
2374
+ // instance lights
2375
+
2376
+ for ( let i = 0, l = instanceLights.length; i < l; i ++ ) {
2377
+
2378
+ const instanceLight = this.getLight( instanceLights[ i ] );
2379
+
2380
+ if ( instanceLight !== null ) {
2381
+
2382
+ objects.push( instanceLight.clone() );
2383
+
2384
+ }
2385
+
2386
+ }
2387
+
2388
+ // instance geometries
2389
+
2390
+ for ( let i = 0, l = instanceGeometries.length; i < l; i ++ ) {
2391
+
2392
+ const instance = instanceGeometries[ i ];
2393
+
2394
+ // a single geometry instance in collada can lead to multiple object3Ds.
2395
+ // this is the case when primitives are combined like triangles and lines
2396
+
2397
+ const geometries = this.getGeometry( instance.id );
2398
+ const newObjects = this.buildObjects( geometries, instance.materials );
2399
+
2400
+ for ( let j = 0, jl = newObjects.length; j < jl; j ++ ) {
2401
+
2402
+ objects.push( newObjects[ j ] );
2403
+
2404
+ }
2405
+
2406
+ }
2407
+
2408
+ // instance nodes
2409
+
2410
+ for ( let i = 0, l = instanceNodes.length; i < l; i ++ ) {
2411
+
2412
+ objects.push( this.getNode( instanceNodes[ i ] ).clone() );
2413
+
2414
+ }
2415
+
2416
+ let object;
2417
+
2418
+ if ( nodes.length === 0 && objects.length === 1 ) {
2419
+
2420
+ object = objects[ 0 ];
2421
+
2422
+ } else {
2423
+
2424
+ object = ( type === 'JOINT' ) ? new Bone() : new Group();
2425
+
2426
+ for ( let i = 0; i < objects.length; i ++ ) {
2427
+
2428
+ object.add( objects[ i ] );
2429
+
2430
+ }
2431
+
2432
+ }
2433
+
2434
+ object.name = ( type === 'JOINT' ) ? data.sid : data.name;
2435
+
2436
+ if ( type !== 'JOINT' && this.hasPivotTransforms( data ) ) {
2437
+
2438
+ return this.wrapWithTransformHierarchy( object, data );
2439
+
2440
+ }
2441
+
2442
+ object.matrix.copy( matrix );
2443
+ object.matrix.decompose( object.position, object.quaternion, object.scale );
2444
+
2445
+ return object;
2446
+
2447
+ }
2448
+
2449
+ wrapWithTransformHierarchy( contentObject, nodeData ) {
2450
+
2451
+ const nodeId = nodeData.id;
2452
+ this.transformNodes[ nodeId ] = {};
2453
+
2454
+ const transformOrder = nodeData.transformOrder;
2455
+ const transformData = nodeData.transformData;
2456
+
2457
+ const rootNode = new Group();
2458
+ rootNode.name = nodeData.name;
2459
+
2460
+ let currentParent = rootNode;
2461
+
2462
+ for ( let i = 0; i < transformOrder.length; i ++ ) {
2463
+
2464
+ const sid = transformOrder[ i ];
2465
+ const info = transformData[ sid ];
2466
+
2467
+ const transformNode = new Group();
2468
+ transformNode.name = nodeData.name + '_' + sid;
2469
+
2470
+ switch ( info.type ) {
2471
+
2472
+ case 'translate':
2473
+ transformNode.position.set( info.x, info.y, info.z );
2474
+ break;
2475
+
2476
+ case 'rotate': {
2477
+
2478
+ const axis = new Vector3( info.axis[ 0 ], info.axis[ 1 ], info.axis[ 2 ] );
2479
+ const angle = MathUtils.degToRad( info.angle );
2480
+ transformNode.quaternion.setFromAxisAngle( axis, angle );
2481
+ transformNode.userData.rotationAxis = axis;
2482
+ break;
2483
+
2484
+ }
2485
+
2486
+ case 'scale':
2487
+ transformNode.scale.set( info.x, info.y, info.z );
2488
+ break;
2489
+
2490
+ case 'matrix': {
2491
+
2492
+ const matrix = new Matrix4().fromArray( info.array ).transpose();
2493
+ matrix.decompose( transformNode.position, transformNode.quaternion, transformNode.scale );
2494
+ break;
2495
+
2496
+ }
2497
+
2498
+ }
2499
+
2500
+ this.transformNodes[ nodeId ][ sid ] = transformNode;
2501
+
2502
+ currentParent.add( transformNode );
2503
+ currentParent = transformNode;
2504
+
2505
+ }
2506
+
2507
+ currentParent.add( contentObject );
2508
+
2509
+ return rootNode;
2510
+
2511
+ }
2512
+
2513
+ resolveMaterialBinding( keys, instanceMaterials ) {
2514
+
2515
+ const materials = [];
2516
+
2517
+ for ( let i = 0, l = keys.length; i < l; i ++ ) {
2518
+
2519
+ const id = instanceMaterials[ keys[ i ] ];
2520
+
2521
+ if ( id === undefined ) {
2522
+
2523
+ console.warn( 'THREE.ColladaLoader: Material with key %s not found. Apply fallback material.', keys[ i ] );
2524
+ materials.push( this.fallbackMaterial );
2525
+
2526
+ } else {
2527
+
2528
+ materials.push( this.getMaterial( id ) );
2529
+
2530
+ }
2531
+
2532
+ }
2533
+
2534
+ return materials;
2535
+
2536
+ }
2537
+
2538
+ get fallbackMaterial() {
2539
+
2540
+ if ( this._fallbackMaterial === undefined ) {
2541
+
2542
+ this._fallbackMaterial = new MeshBasicMaterial( {
2543
+ name: Loader.DEFAULT_MATERIAL_NAME,
2544
+ color: 0xff00ff
2545
+ } );
2546
+
2547
+ }
2548
+
2549
+ return this._fallbackMaterial;
2550
+
2551
+ }
2552
+
2553
+ buildObjects( geometries, instanceMaterials ) {
2554
+
2555
+ const objects = [];
2556
+
2557
+ for ( const type in geometries ) {
2558
+
2559
+ const geometry = geometries[ type ];
2560
+
2561
+ const materials = this.resolveMaterialBinding( geometry.materialKeys, instanceMaterials );
2562
+
2563
+ // handle case if no materials are defined
2564
+
2565
+ if ( materials.length === 0 ) {
2566
+
2567
+ if ( type === 'lines' || type === 'linestrips' ) {
2568
+
2569
+ materials.push( new LineBasicMaterial() );
2570
+
2571
+ } else {
2572
+
2573
+ materials.push( new MeshPhongMaterial() );
2574
+
2575
+ }
2576
+
2577
+ }
2578
+
2579
+ // Collada allows to use phong and lambert materials with lines. Replacing these cases with LineBasicMaterial.
2580
+
2581
+ if ( type === 'lines' || type === 'linestrips' ) {
2582
+
2583
+ for ( let i = 0, l = materials.length; i < l; i ++ ) {
2584
+
2585
+ const material = materials[ i ];
2586
+
2587
+ if ( material.isMeshPhongMaterial === true || material.isMeshLambertMaterial === true ) {
2588
+
2589
+ const lineMaterial = new LineBasicMaterial();
2590
+
2591
+ // copy compatible properties
2592
+
2593
+ lineMaterial.color.copy( material.color );
2594
+ lineMaterial.opacity = material.opacity;
2595
+ lineMaterial.transparent = material.transparent;
2596
+
2597
+ // replace material
2598
+
2599
+ materials[ i ] = lineMaterial;
2600
+
2601
+ }
2602
+
2603
+ }
2604
+
2605
+ }
2606
+
2607
+ // regard skinning
2608
+
2609
+ const skinning = ( geometry.data.attributes.skinIndex !== undefined );
2610
+
2611
+ // choose between a single or multi materials (material array)
2612
+
2613
+ const material = ( materials.length === 1 ) ? materials[ 0 ] : materials;
2614
+
2615
+ // now create a specific 3D object
2616
+
2617
+ let object;
2618
+
2619
+ switch ( type ) {
2620
+
2621
+ case 'lines':
2622
+ object = new LineSegments( geometry.data, material );
2623
+ break;
2624
+
2625
+ case 'linestrips':
2626
+ object = new Line( geometry.data, material );
2627
+ break;
2628
+
2629
+ case 'triangles':
2630
+ case 'polylist':
2631
+ if ( skinning ) {
2632
+
2633
+ object = new SkinnedMesh( geometry.data, material );
2634
+
2635
+ } else {
2636
+
2637
+ object = new Mesh( geometry.data, material );
2638
+
2639
+ }
2640
+
2641
+ break;
2642
+
2643
+ }
2644
+
2645
+ objects.push( object );
2646
+
2647
+ }
2648
+
2649
+ return objects;
2650
+
2651
+ }
2652
+
2653
+ hasNode( id ) {
2654
+
2655
+ return this.library.nodes[ id ] !== undefined;
2656
+
2657
+ }
2658
+
2659
+ getNode( id ) {
2660
+
2661
+ return this.getBuild( this.library.nodes[ id ], this.buildNode.bind( this ) );
2662
+
2663
+ }
2664
+
2665
+
2666
+ buildVisualScene( data ) {
2667
+
2668
+ const group = new Group();
2669
+ group.name = data.name;
2670
+
2671
+ const children = data.children;
2672
+
2673
+ for ( let i = 0; i < children.length; i ++ ) {
2674
+
2675
+ const child = children[ i ];
2676
+
2677
+ group.add( this.getNode( child.id ) );
2678
+
2679
+ }
2680
+
2681
+ return group;
2682
+
2683
+ }
2684
+
2685
+ hasVisualScene( id ) {
2686
+
2687
+ return this.library.visualScenes[ id ] !== undefined;
2688
+
2689
+ }
2690
+
2691
+ getVisualScene( id ) {
2692
+
2693
+ return this.getBuild( this.library.visualScenes[ id ], this.buildVisualScene.bind( this ) );
2694
+
2695
+ }
2696
+
2697
+
2698
+ parseScene( xml ) {
2699
+
2700
+ const instance = getElementsByTagName( xml, 'instance_visual_scene' )[ 0 ];
2701
+ return this.getVisualScene( this.parseId( instance.getAttribute( 'url' ) ) );
2702
+
2703
+ }
2704
+
2705
+ parseId( text ) {
2706
+
2707
+ return text.substring( 1 );
2708
+
2709
+ }
2710
+
2711
+ setupAnimations() {
2712
+
2713
+ const clips = this.library.clips;
2714
+
2715
+ if ( this.isEmpty( clips ) === true ) {
2716
+
2717
+ if ( this.isEmpty( this.library.animations ) === false ) {
2718
+
2719
+ // if there are animations but no clips, we create a default clip for playback
2720
+
2721
+ const tracks = [];
2722
+
2723
+ for ( const id in this.library.animations ) {
2724
+
2725
+ const animationTracks = this.getAnimation( id );
2726
+
2727
+ for ( let i = 0, l = animationTracks.length; i < l; i ++ ) {
2728
+
2729
+ tracks.push( animationTracks[ i ] );
2730
+
2731
+ }
2732
+
2733
+ }
2734
+
2735
+ this.buildDeferredPivotAnimationTracks( tracks );
2736
+
2737
+ this.animations.push( new AnimationClip( 'default', - 1, tracks ) );
2738
+
2739
+ }
2740
+
2741
+ } else {
2742
+
2743
+ for ( const id in clips ) {
2744
+
2745
+ this.animations.push( this.getAnimationClip( id ) );
2746
+
2747
+ }
2748
+
2749
+ }
2750
+
2751
+ }
2752
+
2753
+ buildDeferredPivotAnimationTracks( tracks ) {
2754
+
2755
+ for ( const nodeId in this.deferredPivotAnimations ) {
2756
+
2757
+ const nodeData = this.library.nodes[ nodeId ];
2758
+ if ( ! nodeData ) continue;
2759
+
2760
+ const mergedChannels = this.deferredPivotAnimations[ nodeId ];
2761
+ this.buildTransformHierarchyTracks( nodeId, mergedChannels, nodeData, tracks );
2762
+
2763
+ }
2764
+
2765
+ }
2766
+
2767
+ buildTransformHierarchyTracks( nodeId, nodeChannels, nodeData, tracks ) {
2768
+
2769
+ const transformNodes = this.transformNodes[ nodeId ];
2770
+
2771
+ if ( ! transformNodes ) {
2772
+
2773
+ console.warn( 'THREE.ColladaLoader: Transform hierarchy not found for node:', nodeId );
2774
+ return;
2775
+
2776
+ }
2777
+
2778
+ for ( const sid in nodeChannels ) {
2779
+
2780
+ const transformNode = transformNodes[ sid ];
2781
+ if ( ! transformNode ) continue;
2782
+
2783
+ const transformType = nodeData.transforms[ sid ];
2784
+ const transformInfo = nodeData.transformData[ sid ];
2785
+ const channelData = nodeChannels[ sid ];
2786
+
2787
+ switch ( transformType ) {
2788
+
2789
+ case 'translate':
2790
+ this.buildHierarchyTranslateTrack( transformNode, channelData, transformInfo, tracks );
2791
+ break;
2792
+
2793
+ case 'rotate':
2794
+ this.buildHierarchyRotateTrack( transformNode, channelData, transformInfo, tracks );
2795
+ break;
2796
+
2797
+ case 'scale':
2798
+ this.buildHierarchyScaleTrack( transformNode, channelData, transformInfo, tracks );
2799
+ break;
2800
+
2801
+ }
2802
+
2803
+ }
2804
+
2805
+ }
2806
+
2807
+ buildHierarchyTranslateTrack( transformNode, channelData, transformInfo, tracks ) {
2808
+
2809
+ if ( channelData.default && channelData.default.stride === 3 ) {
2810
+
2811
+ const data = channelData.default;
2812
+ const track = new VectorKeyframeTrack(
2813
+ transformNode.uuid + '.position',
2814
+ Array.from( data.times ),
2815
+ Array.from( data.values )
2816
+ );
2817
+
2818
+ const interpolationInfo = this.getInterpolationInfo( channelData );
2819
+ this.applyInterpolation( track, interpolationInfo, channelData );
2820
+ tracks.push( track );
2821
+ return;
2822
+
2823
+ }
2824
+
2825
+ const times = this.getTimesForAllAxes( channelData );
2826
+ if ( times.length === 0 ) return;
2827
+
2828
+ const values = [];
2829
+ const interpolationInfo = this.getInterpolationInfo( channelData );
2830
+
2831
+ for ( let i = 0; i < times.length; i ++ ) {
2832
+
2833
+ const time = times[ i ];
2834
+ const x = this.getValueAtTime( channelData.X, time, transformInfo.x );
2835
+ const y = this.getValueAtTime( channelData.Y, time, transformInfo.y );
2836
+ const z = this.getValueAtTime( channelData.Z, time, transformInfo.z );
2837
+ values.push( x, y, z );
2838
+
2839
+ }
2840
+
2841
+ const track = new VectorKeyframeTrack(
2842
+ transformNode.uuid + '.position',
2843
+ times,
2844
+ values
2845
+ );
2846
+
2847
+ this.applyInterpolation( track, interpolationInfo );
2848
+ tracks.push( track );
2849
+
2850
+ }
2851
+
2852
+ buildHierarchyRotateTrack( transformNode, channelData, transformInfo, tracks ) {
2853
+
2854
+ const angleData = channelData.ANGLE || channelData.default;
2855
+ if ( ! angleData ) return;
2856
+
2857
+ const times = Array.from( angleData.times );
2858
+ if ( times.length === 0 ) return;
2859
+
2860
+ const axis = transformNode.userData.rotationAxis ||
2861
+ new Vector3( transformInfo.axis[ 0 ], transformInfo.axis[ 1 ], transformInfo.axis[ 2 ] );
2862
+
2863
+ const quaternion = new Quaternion();
2864
+ const prevQuaternion = new Quaternion();
2865
+ const values = [];
2866
+
2867
+ const interpolationInfo = this.getInterpolationInfo( channelData );
2868
+
2869
+ for ( let i = 0; i < times.length; i ++ ) {
2870
+
2871
+ const time = times[ i ];
2872
+ const angleDegrees = this.getValueAtTime( angleData, time, transformInfo.angle );
2873
+ const angleRadians = MathUtils.degToRad( angleDegrees );
2874
+
2875
+ quaternion.setFromAxisAngle( axis, angleRadians );
2876
+
2877
+ // Ensure quaternion continuity
2878
+ if ( i > 0 && prevQuaternion.dot( quaternion ) < 0 ) {
2879
+
2880
+ quaternion.x = - quaternion.x;
2881
+ quaternion.y = - quaternion.y;
2882
+ quaternion.z = - quaternion.z;
2883
+ quaternion.w = - quaternion.w;
2884
+
2885
+ }
2886
+
2887
+ prevQuaternion.copy( quaternion );
2888
+ values.push( quaternion.x, quaternion.y, quaternion.z, quaternion.w );
2889
+
2890
+ }
2891
+
2892
+ const track = new QuaternionKeyframeTrack(
2893
+ transformNode.uuid + '.quaternion',
2894
+ times,
2895
+ values
2896
+ );
2897
+
2898
+ this.applyInterpolation( track, interpolationInfo );
2899
+ tracks.push( track );
2900
+
2901
+ }
2902
+
2903
+ buildHierarchyScaleTrack( transformNode, channelData, transformInfo, tracks ) {
2904
+
2905
+ if ( channelData.default && channelData.default.stride === 3 ) {
2906
+
2907
+ const data = channelData.default;
2908
+ const track = new VectorKeyframeTrack(
2909
+ transformNode.uuid + '.scale',
2910
+ Array.from( data.times ),
2911
+ Array.from( data.values )
2912
+ );
2913
+
2914
+ const interpolationInfo = this.getInterpolationInfo( channelData );
2915
+ this.applyInterpolation( track, interpolationInfo, channelData );
2916
+ tracks.push( track );
2917
+ return;
2918
+
2919
+ }
2920
+
2921
+ const times = this.getTimesForAllAxes( channelData );
2922
+ if ( times.length === 0 ) return;
2923
+
2924
+ const values = [];
2925
+ const interpolationInfo = this.getInterpolationInfo( channelData );
2926
+
2927
+ for ( let i = 0; i < times.length; i ++ ) {
2928
+
2929
+ const time = times[ i ];
2930
+ const x = this.getValueAtTime( channelData.X, time, transformInfo.x );
2931
+ const y = this.getValueAtTime( channelData.Y, time, transformInfo.y );
2932
+ const z = this.getValueAtTime( channelData.Z, time, transformInfo.z );
2933
+ values.push( x, y, z );
2934
+
2935
+ }
2936
+
2937
+ const track = new VectorKeyframeTrack(
2938
+ transformNode.uuid + '.scale',
2939
+ times,
2940
+ values
2941
+ );
2942
+
2943
+ this.applyInterpolation( track, interpolationInfo );
2944
+ tracks.push( track );
2945
+
2946
+ }
2947
+
2948
+ }
2949
+
2950
+ export { ColladaComposer };