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