three-stdlib 2.25.0 → 2.25.1

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 (539) hide show
  1. package/index.cjs +116401 -611
  2. package/index.js +116037 -263
  3. package/package.json +17 -4
  4. package/_polyfill/CapsuleGeometry.cjs +0 -22
  5. package/_polyfill/CapsuleGeometry.js +0 -22
  6. package/_polyfill/CompressedArrayTexture.cjs +0 -12
  7. package/_polyfill/CompressedArrayTexture.js +0 -12
  8. package/_polyfill/Data3DTexture.cjs +0 -17
  9. package/_polyfill/Data3DTexture.js +0 -17
  10. package/animation/AnimationClipCreator.cjs +0 -56
  11. package/animation/AnimationClipCreator.js +0 -56
  12. package/animation/CCDIKSolver.cjs +0 -269
  13. package/animation/CCDIKSolver.js +0 -269
  14. package/animation/MMDAnimationHelper.cjs +0 -688
  15. package/animation/MMDAnimationHelper.js +0 -688
  16. package/animation/MMDPhysics.cjs +0 -830
  17. package/animation/MMDPhysics.js +0 -830
  18. package/cameras/CinematicCamera.cjs +0 -131
  19. package/cameras/CinematicCamera.js +0 -131
  20. package/controls/ArcballControls.cjs +0 -2033
  21. package/controls/ArcballControls.js +0 -2033
  22. package/controls/DeviceOrientationControls.cjs +0 -85
  23. package/controls/DeviceOrientationControls.js +0 -85
  24. package/controls/DragControls.cjs +0 -182
  25. package/controls/DragControls.js +0 -182
  26. package/controls/FirstPersonControls.cjs +0 -229
  27. package/controls/FirstPersonControls.js +0 -229
  28. package/controls/FlyControls.cjs +0 -248
  29. package/controls/FlyControls.js +0 -248
  30. package/controls/OrbitControls.cjs +0 -791
  31. package/controls/OrbitControls.js +0 -791
  32. package/controls/PointerLockControls.cjs +0 -103
  33. package/controls/PointerLockControls.js +0 -103
  34. package/controls/TrackballControls.cjs +0 -502
  35. package/controls/TrackballControls.js +0 -502
  36. package/controls/TransformControls.cjs +0 -1089
  37. package/controls/TransformControls.js +0 -1089
  38. package/controls/experimental/CameraControls.cjs +0 -736
  39. package/controls/experimental/CameraControls.js +0 -736
  40. package/csm/CSM.cjs +0 -244
  41. package/csm/CSM.js +0 -244
  42. package/csm/CSMFrustum.cjs +0 -75
  43. package/csm/CSMFrustum.js +0 -75
  44. package/csm/CSMHelper.cjs +0 -114
  45. package/csm/CSMHelper.js +0 -114
  46. package/csm/CSMShader.cjs +0 -261
  47. package/csm/CSMShader.js +0 -261
  48. package/curves/CurveExtras.cjs +0 -214
  49. package/curves/CurveExtras.js +0 -214
  50. package/curves/NURBSCurve.cjs +0 -35
  51. package/curves/NURBSCurve.js +0 -35
  52. package/curves/NURBSSurface.cjs +0 -28
  53. package/curves/NURBSSurface.js +0 -28
  54. package/curves/NURBSUtils.cjs +0 -226
  55. package/curves/NURBSUtils.js +0 -226
  56. package/deprecated/Geometry.cjs +0 -971
  57. package/deprecated/Geometry.js +0 -971
  58. package/effects/AnaglyphEffect.cjs +0 -102
  59. package/effects/AnaglyphEffect.js +0 -102
  60. package/effects/AsciiEffect.cjs +0 -155
  61. package/effects/AsciiEffect.js +0 -155
  62. package/effects/OutlineEffect.cjs +0 -275
  63. package/effects/OutlineEffect.js +0 -275
  64. package/effects/ParallaxBarrierEffect.cjs +0 -65
  65. package/effects/ParallaxBarrierEffect.js +0 -65
  66. package/effects/PeppersGhostEffect.cjs +0 -88
  67. package/effects/PeppersGhostEffect.js +0 -88
  68. package/effects/StereoEffect.cjs +0 -35
  69. package/effects/StereoEffect.js +0 -35
  70. package/environments/RoomEnvironment.cjs +0 -95
  71. package/environments/RoomEnvironment.js +0 -78
  72. package/exporters/ColladaExporter.cjs +0 -331
  73. package/exporters/ColladaExporter.js +0 -331
  74. package/exporters/DRACOExporter.cjs +0 -141
  75. package/exporters/DRACOExporter.js +0 -141
  76. package/exporters/GLTFExporter.cjs +0 -1909
  77. package/exporters/GLTFExporter.js +0 -1909
  78. package/exporters/MMDExporter.cjs +0 -131
  79. package/exporters/MMDExporter.js +0 -131
  80. package/exporters/OBJExporter.cjs +0 -181
  81. package/exporters/OBJExporter.js +0 -181
  82. package/exporters/PLYExporter.cjs +0 -280
  83. package/exporters/PLYExporter.js +0 -280
  84. package/exporters/STLExporter.cjs +0 -146
  85. package/exporters/STLExporter.js +0 -146
  86. package/exporters/USDZExporter.cjs +0 -340
  87. package/exporters/USDZExporter.js +0 -340
  88. package/geometries/BoxLineGeometry.cjs +0 -45
  89. package/geometries/BoxLineGeometry.js +0 -45
  90. package/geometries/ConvexGeometry.cjs +0 -26
  91. package/geometries/ConvexGeometry.js +0 -26
  92. package/geometries/DecalGeometry.cjs +0 -184
  93. package/geometries/DecalGeometry.js +0 -184
  94. package/geometries/LightningStrike.cjs +0 -553
  95. package/geometries/LightningStrike.js +0 -553
  96. package/geometries/ParametricGeometries.cjs +0 -130
  97. package/geometries/ParametricGeometries.js +0 -130
  98. package/geometries/ParametricGeometry.cjs +0 -63
  99. package/geometries/ParametricGeometry.js +0 -63
  100. package/geometries/RoundedBoxGeometry.cjs +0 -91
  101. package/geometries/RoundedBoxGeometry.js +0 -91
  102. package/geometries/TeapotGeometry.cjs +0 -1563
  103. package/geometries/TeapotGeometry.js +0 -1563
  104. package/geometries/TextGeometry.cjs +0 -27
  105. package/geometries/TextGeometry.js +0 -27
  106. package/helpers/LightProbeHelper.cjs +0 -73
  107. package/helpers/LightProbeHelper.js +0 -73
  108. package/helpers/PositionalAudioHelper.cjs +0 -68
  109. package/helpers/PositionalAudioHelper.js +0 -68
  110. package/helpers/RectAreaLightHelper.cjs +0 -44
  111. package/helpers/RectAreaLightHelper.js +0 -44
  112. package/helpers/VertexNormalsHelper.cjs +0 -47
  113. package/helpers/VertexNormalsHelper.js +0 -47
  114. package/helpers/VertexTangentsHelper.cjs +0 -43
  115. package/helpers/VertexTangentsHelper.js +0 -43
  116. package/interactive/HTMLMesh.cjs +0 -325
  117. package/interactive/HTMLMesh.js +0 -325
  118. package/interactive/InteractiveGroup.cjs +0 -68
  119. package/interactive/InteractiveGroup.js +0 -68
  120. package/interactive/SelectionBox.cjs +0 -134
  121. package/interactive/SelectionBox.js +0 -134
  122. package/interactive/SelectionHelper.cjs +0 -51
  123. package/interactive/SelectionHelper.js +0 -51
  124. package/libs/MeshoptDecoder.cjs +0 -221
  125. package/libs/MeshoptDecoder.js +0 -221
  126. package/libs/MotionControllers.cjs +0 -325
  127. package/libs/MotionControllers.js +0 -325
  128. package/lights/LightProbeGenerator.cjs +0 -145
  129. package/lights/LightProbeGenerator.js +0 -145
  130. package/lights/RectAreaLightUniformsLib.cjs +0 -32846
  131. package/lights/RectAreaLightUniformsLib.js +0 -32846
  132. package/lines/Line2.cjs +0 -13
  133. package/lines/Line2.js +0 -13
  134. package/lines/LineGeometry.cjs +0 -44
  135. package/lines/LineGeometry.js +0 -44
  136. package/lines/LineMaterial.cjs +0 -547
  137. package/lines/LineMaterial.js +0 -547
  138. package/lines/LineSegments2.cjs +0 -203
  139. package/lines/LineSegments2.js +0 -203
  140. package/lines/LineSegmentsGeometry.cjs +0 -124
  141. package/lines/LineSegmentsGeometry.js +0 -124
  142. package/lines/Wireframe.cjs +0 -32
  143. package/lines/Wireframe.js +0 -32
  144. package/lines/WireframeGeometry2.cjs +0 -13
  145. package/lines/WireframeGeometry2.js +0 -13
  146. package/loaders/3DMLoader.cjs +0 -803
  147. package/loaders/3DMLoader.js +0 -803
  148. package/loaders/3MFLoader.cjs +0 -854
  149. package/loaders/3MFLoader.js +0 -854
  150. package/loaders/AMFLoader.cjs +0 -284
  151. package/loaders/AMFLoader.js +0 -284
  152. package/loaders/AssimpLoader.cjs +0 -1434
  153. package/loaders/AssimpLoader.js +0 -1434
  154. package/loaders/BVHLoader.cjs +0 -207
  155. package/loaders/BVHLoader.js +0 -207
  156. package/loaders/BasisTextureLoader.cjs +0 -489
  157. package/loaders/BasisTextureLoader.js +0 -489
  158. package/loaders/ColladaLoader.cjs +0 -2405
  159. package/loaders/ColladaLoader.js +0 -2405
  160. package/loaders/DDSLoader.cjs +0 -148
  161. package/loaders/DDSLoader.js +0 -148
  162. package/loaders/DRACOLoader.cjs +0 -341
  163. package/loaders/DRACOLoader.js +0 -341
  164. package/loaders/EXRLoader.cjs +0 -1356
  165. package/loaders/EXRLoader.js +0 -1356
  166. package/loaders/FBXLoader.cjs +0 -2457
  167. package/loaders/FBXLoader.js +0 -2457
  168. package/loaders/FontLoader.cjs +0 -123
  169. package/loaders/FontLoader.js +0 -123
  170. package/loaders/GCodeLoader.cjs +0 -141
  171. package/loaders/GCodeLoader.js +0 -141
  172. package/loaders/GLTFLoader.cjs +0 -2504
  173. package/loaders/GLTFLoader.js +0 -2504
  174. package/loaders/HDRCubeTextureLoader.cjs +0 -75
  175. package/loaders/HDRCubeTextureLoader.js +0 -75
  176. package/loaders/KMZLoader.cjs +0 -75
  177. package/loaders/KMZLoader.js +0 -75
  178. package/loaders/KTX2Loader.cjs +0 -480
  179. package/loaders/KTX2Loader.js +0 -480
  180. package/loaders/KTXLoader.cjs +0 -93
  181. package/loaders/KTXLoader.js +0 -93
  182. package/loaders/LDrawLoader.cjs +0 -1424
  183. package/loaders/LDrawLoader.js +0 -1424
  184. package/loaders/LUT3dlLoader.cjs +0 -103
  185. package/loaders/LUT3dlLoader.js +0 -103
  186. package/loaders/LUTCubeLoader.cjs +0 -107
  187. package/loaders/LUTCubeLoader.js +0 -107
  188. package/loaders/LWOLoader.cjs +0 -645
  189. package/loaders/LWOLoader.js +0 -645
  190. package/loaders/LottieLoader.cjs +0 -47
  191. package/loaders/LottieLoader.js +0 -47
  192. package/loaders/MD2Loader.cjs +0 -359
  193. package/loaders/MD2Loader.js +0 -359
  194. package/loaders/MDDLoader.cjs +0 -58
  195. package/loaders/MDDLoader.js +0 -58
  196. package/loaders/MMDLoader.cjs +0 -1121
  197. package/loaders/MMDLoader.js +0 -1121
  198. package/loaders/MTLLoader.cjs +0 -304
  199. package/loaders/MTLLoader.js +0 -304
  200. package/loaders/NRRDLoader.cjs +0 -401
  201. package/loaders/NRRDLoader.js +0 -401
  202. package/loaders/OBJLoader.cjs +0 -487
  203. package/loaders/OBJLoader.js +0 -487
  204. package/loaders/PCDLoader.cjs +0 -248
  205. package/loaders/PCDLoader.js +0 -248
  206. package/loaders/PDBLoader.cjs +0 -247
  207. package/loaders/PDBLoader.js +0 -247
  208. package/loaders/PLYLoader.cjs +0 -317
  209. package/loaders/PLYLoader.js +0 -317
  210. package/loaders/PRWMLoader.cjs +0 -160
  211. package/loaders/PRWMLoader.js +0 -160
  212. package/loaders/PVRLoader.cjs +0 -131
  213. package/loaders/PVRLoader.js +0 -131
  214. package/loaders/RGBELoader.cjs +0 -252
  215. package/loaders/RGBELoader.js +0 -252
  216. package/loaders/RGBMLoader.cjs +0 -1004
  217. package/loaders/RGBMLoader.js +0 -1004
  218. package/loaders/STLLoader.cjs +0 -190
  219. package/loaders/STLLoader.js +0 -190
  220. package/loaders/SVGLoader.cjs +0 -1712
  221. package/loaders/SVGLoader.js +0 -1712
  222. package/loaders/TDSLoader.cjs +0 -650
  223. package/loaders/TDSLoader.js +0 -650
  224. package/loaders/TGALoader.cjs +0 -285
  225. package/loaders/TGALoader.js +0 -285
  226. package/loaders/TTFLoader.cjs +0 -131
  227. package/loaders/TTFLoader.js +0 -131
  228. package/loaders/TiltLoader.cjs +0 -375
  229. package/loaders/TiltLoader.js +0 -375
  230. package/loaders/VOXLoader.cjs +0 -432
  231. package/loaders/VOXLoader.js +0 -432
  232. package/loaders/VRMLLoader.cjs +0 -2105
  233. package/loaders/VRMLLoader.js +0 -2105
  234. package/loaders/VRMLoader.cjs +0 -38
  235. package/loaders/VRMLoader.js +0 -38
  236. package/loaders/VTKLoader.cjs +0 -648
  237. package/loaders/VTKLoader.js +0 -648
  238. package/loaders/XLoader.cjs +0 -1258
  239. package/loaders/XLoader.js +0 -1258
  240. package/loaders/XYZLoader.cjs +0 -60
  241. package/loaders/XYZLoader.js +0 -60
  242. package/loaders/lwo/IFFParser.cjs +0 -743
  243. package/loaders/lwo/IFFParser.js +0 -743
  244. package/loaders/lwo/LWO2Parser.cjs +0 -312
  245. package/loaders/lwo/LWO2Parser.js +0 -312
  246. package/loaders/lwo/LWO3Parser.cjs +0 -282
  247. package/loaders/lwo/LWO3Parser.js +0 -282
  248. package/math/Capsule.cjs +0 -98
  249. package/math/Capsule.js +0 -98
  250. package/math/ColorConverter.cjs +0 -42
  251. package/math/ColorConverter.js +0 -42
  252. package/math/ConvexHull.cjs +0 -596
  253. package/math/ConvexHull.js +0 -596
  254. package/math/ImprovedNoise.cjs +0 -304
  255. package/math/ImprovedNoise.js +0 -304
  256. package/math/Lut.cjs +0 -137
  257. package/math/Lut.js +0 -137
  258. package/math/MeshSurfaceSampler.cjs +0 -103
  259. package/math/MeshSurfaceSampler.js +0 -103
  260. package/math/OBB.cjs +0 -242
  261. package/math/OBB.js +0 -242
  262. package/math/Octree.cjs +0 -273
  263. package/math/Octree.js +0 -273
  264. package/math/SimplexNoise.cjs +0 -440
  265. package/math/SimplexNoise.js +0 -440
  266. package/misc/ConvexObjectBreaker.cjs +0 -292
  267. package/misc/ConvexObjectBreaker.js +0 -292
  268. package/misc/GPUComputationRenderer.cjs +0 -205
  269. package/misc/GPUComputationRenderer.js +0 -205
  270. package/misc/Gyroscope.cjs +0 -33
  271. package/misc/Gyroscope.js +0 -33
  272. package/misc/MD2Character.cjs +0 -167
  273. package/misc/MD2Character.js +0 -167
  274. package/misc/MD2CharacterComplex.cjs +0 -332
  275. package/misc/MD2CharacterComplex.js +0 -332
  276. package/misc/MorphAnimMesh.cjs +0 -40
  277. package/misc/MorphAnimMesh.js +0 -40
  278. package/misc/MorphBlendMesh.cjs +0 -179
  279. package/misc/MorphBlendMesh.js +0 -179
  280. package/misc/ProgressiveLightmap.cjs +0 -186
  281. package/misc/ProgressiveLightmap.js +0 -186
  282. package/misc/RollerCoaster.cjs +0 -353
  283. package/misc/RollerCoaster.js +0 -353
  284. package/misc/Timer.cjs +0 -101
  285. package/misc/Timer.js +0 -101
  286. package/misc/TubePainter.cjs +0 -123
  287. package/misc/TubePainter.js +0 -123
  288. package/misc/Volume.cjs +0 -305
  289. package/misc/Volume.js +0 -305
  290. package/misc/VolumeSlice.cjs +0 -114
  291. package/misc/VolumeSlice.js +0 -114
  292. package/misc/WebGL.cjs +0 -74
  293. package/misc/WebGL.js +0 -74
  294. package/modifiers/CurveModifier.cjs +0 -232
  295. package/modifiers/CurveModifier.js +0 -232
  296. package/modifiers/EdgeSplitModifier.cjs +0 -167
  297. package/modifiers/EdgeSplitModifier.js +0 -168
  298. package/modifiers/SimplifyModifier.cjs +0 -301
  299. package/modifiers/SimplifyModifier.js +0 -301
  300. package/modifiers/TessellateModifier.cjs +0 -214
  301. package/modifiers/TessellateModifier.js +0 -214
  302. package/objects/GroundProjectedEnv.cjs +0 -134
  303. package/objects/GroundProjectedEnv.js +0 -134
  304. package/objects/Lensflare.cjs +0 -291
  305. package/objects/Lensflare.js +0 -291
  306. package/objects/LightningStorm.cjs +0 -110
  307. package/objects/LightningStorm.js +0 -110
  308. package/objects/MarchingCubes.cjs +0 -4809
  309. package/objects/MarchingCubes.js +0 -4809
  310. package/objects/Reflector.cjs +0 -202
  311. package/objects/Reflector.js +0 -202
  312. package/objects/ReflectorForSSRPass.cjs +0 -260
  313. package/objects/ReflectorForSSRPass.js +0 -260
  314. package/objects/ReflectorRTT.cjs +0 -10
  315. package/objects/ReflectorRTT.js +0 -10
  316. package/objects/Refractor.cjs +0 -215
  317. package/objects/Refractor.js +0 -215
  318. package/objects/ShadowMesh.cjs +0 -45
  319. package/objects/ShadowMesh.js +0 -45
  320. package/objects/Sky.cjs +0 -200
  321. package/objects/Sky.js +0 -200
  322. package/objects/Water.cjs +0 -242
  323. package/objects/Water.js +0 -242
  324. package/objects/Water2.cjs +0 -256
  325. package/objects/Water2.js +0 -256
  326. package/physics/AmmoPhysics.cjs +0 -166
  327. package/physics/AmmoPhysics.js +0 -166
  328. package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
  329. package/postprocessing/AdaptiveToneMappingPass.js +0 -218
  330. package/postprocessing/AfterimagePass.cjs +0 -68
  331. package/postprocessing/AfterimagePass.js +0 -68
  332. package/postprocessing/BloomPass.cjs +0 -109
  333. package/postprocessing/BloomPass.js +0 -109
  334. package/postprocessing/BokehPass.cjs +0 -90
  335. package/postprocessing/BokehPass.js +0 -90
  336. package/postprocessing/ClearPass.cjs +0 -36
  337. package/postprocessing/ClearPass.js +0 -36
  338. package/postprocessing/CubeTexturePass.cjs +0 -53
  339. package/postprocessing/CubeTexturePass.js +0 -53
  340. package/postprocessing/DotScreenPass.cjs +0 -49
  341. package/postprocessing/DotScreenPass.js +0 -49
  342. package/postprocessing/EffectComposer.cjs +0 -157
  343. package/postprocessing/EffectComposer.js +0 -157
  344. package/postprocessing/FilmPass.cjs +0 -51
  345. package/postprocessing/FilmPass.js +0 -51
  346. package/postprocessing/GlitchPass.cjs +0 -84
  347. package/postprocessing/GlitchPass.js +0 -84
  348. package/postprocessing/HalftonePass.cjs +0 -53
  349. package/postprocessing/HalftonePass.js +0 -53
  350. package/postprocessing/LUTPass.cjs +0 -142
  351. package/postprocessing/LUTPass.js +0 -142
  352. package/postprocessing/MaskPass.cjs +0 -69
  353. package/postprocessing/MaskPass.js +0 -69
  354. package/postprocessing/OutlinePass.cjs +0 -479
  355. package/postprocessing/OutlinePass.js +0 -479
  356. package/postprocessing/Pass.cjs +0 -48
  357. package/postprocessing/Pass.js +0 -48
  358. package/postprocessing/RenderPass.cjs +0 -59
  359. package/postprocessing/RenderPass.js +0 -59
  360. package/postprocessing/RenderPixelatedPass.cjs +0 -199
  361. package/postprocessing/RenderPixelatedPass.js +0 -199
  362. package/postprocessing/SAOPass.cjs +0 -288
  363. package/postprocessing/SAOPass.js +0 -288
  364. package/postprocessing/SMAAPass.cjs +0 -112
  365. package/postprocessing/SMAAPass.js +0 -112
  366. package/postprocessing/SSAARenderPass.cjs +0 -189
  367. package/postprocessing/SSAARenderPass.js +0 -189
  368. package/postprocessing/SSAOPass.cjs +0 -272
  369. package/postprocessing/SSAOPass.js +0 -272
  370. package/postprocessing/SSRPass.cjs +0 -411
  371. package/postprocessing/SSRPass.js +0 -411
  372. package/postprocessing/SavePass.cjs +0 -38
  373. package/postprocessing/SavePass.js +0 -38
  374. package/postprocessing/ShaderPass.cjs +0 -49
  375. package/postprocessing/ShaderPass.js +0 -49
  376. package/postprocessing/TAARenderPass.cjs +0 -174
  377. package/postprocessing/TAARenderPass.js +0 -174
  378. package/postprocessing/TexturePass.cjs +0 -42
  379. package/postprocessing/TexturePass.js +0 -42
  380. package/postprocessing/UnrealBloomPass.cjs +0 -277
  381. package/postprocessing/UnrealBloomPass.js +0 -277
  382. package/postprocessing/WaterPass.cjs +0 -72
  383. package/postprocessing/WaterPass.js +0 -72
  384. package/renderers/CSS2DRenderer.cjs +0 -122
  385. package/renderers/CSS2DRenderer.js +0 -122
  386. package/renderers/CSS3DRenderer.cjs +0 -167
  387. package/renderers/CSS3DRenderer.js +0 -167
  388. package/renderers/Projector.cjs +0 -499
  389. package/renderers/Projector.js +0 -499
  390. package/renderers/SVGRenderer.cjs +0 -311
  391. package/renderers/SVGRenderer.js +0 -311
  392. package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
  393. package/shaders/ACESFilmicToneMappingShader.js +0 -55
  394. package/shaders/AfterimageShader.cjs +0 -32
  395. package/shaders/AfterimageShader.js +0 -32
  396. package/shaders/BasicShader.cjs +0 -12
  397. package/shaders/BasicShader.js +0 -12
  398. package/shaders/BleachBypassShader.cjs +0 -35
  399. package/shaders/BleachBypassShader.js +0 -35
  400. package/shaders/BlendShader.cjs +0 -30
  401. package/shaders/BlendShader.js +0 -30
  402. package/shaders/BokehShader.cjs +0 -109
  403. package/shaders/BokehShader.js +0 -109
  404. package/shaders/BokehShader2.cjs +0 -269
  405. package/shaders/BokehShader2.js +0 -269
  406. package/shaders/BrightnessContrastShader.cjs +0 -32
  407. package/shaders/BrightnessContrastShader.js +0 -32
  408. package/shaders/ColorCorrectionShader.cjs +0 -30
  409. package/shaders/ColorCorrectionShader.js +0 -30
  410. package/shaders/ColorifyShader.cjs +0 -28
  411. package/shaders/ColorifyShader.js +0 -28
  412. package/shaders/ConvolutionShader.cjs +0 -55
  413. package/shaders/ConvolutionShader.js +0 -55
  414. package/shaders/CopyShader.cjs +0 -25
  415. package/shaders/CopyShader.js +0 -25
  416. package/shaders/DOFMipMapShader.cjs +0 -32
  417. package/shaders/DOFMipMapShader.js +0 -32
  418. package/shaders/DepthLimitedBlurShader.cjs +0 -114
  419. package/shaders/DepthLimitedBlurShader.js +0 -114
  420. package/shaders/DigitalGlitch.cjs +0 -85
  421. package/shaders/DigitalGlitch.js +0 -85
  422. package/shaders/DotScreenShader.cjs +0 -39
  423. package/shaders/DotScreenShader.js +0 -39
  424. package/shaders/FXAAShader.cjs +0 -1098
  425. package/shaders/FXAAShader.js +0 -1098
  426. package/shaders/FilmShader.cjs +0 -53
  427. package/shaders/FilmShader.js +0 -53
  428. package/shaders/FocusShader.cjs +0 -55
  429. package/shaders/FocusShader.js +0 -55
  430. package/shaders/FreiChenShader.cjs +0 -64
  431. package/shaders/FreiChenShader.js +0 -64
  432. package/shaders/FresnelShader.cjs +0 -47
  433. package/shaders/FresnelShader.js +0 -47
  434. package/shaders/GammaCorrectionShader.cjs +0 -23
  435. package/shaders/GammaCorrectionShader.js +0 -23
  436. package/shaders/GodRaysShader.cjs +0 -183
  437. package/shaders/GodRaysShader.js +0 -183
  438. package/shaders/HalftoneShader.cjs +0 -228
  439. package/shaders/HalftoneShader.js +0 -228
  440. package/shaders/HorizontalBlurShader.cjs +0 -49
  441. package/shaders/HorizontalBlurShader.js +0 -49
  442. package/shaders/HorizontalTiltShiftShader.cjs +0 -37
  443. package/shaders/HorizontalTiltShiftShader.js +0 -37
  444. package/shaders/HueSaturationShader.cjs +0 -43
  445. package/shaders/HueSaturationShader.js +0 -43
  446. package/shaders/KaleidoShader.cjs +0 -34
  447. package/shaders/KaleidoShader.js +0 -34
  448. package/shaders/LuminosityHighPassShader.cjs +0 -37
  449. package/shaders/LuminosityHighPassShader.js +0 -37
  450. package/shaders/LuminosityShader.cjs +0 -25
  451. package/shaders/LuminosityShader.js +0 -25
  452. package/shaders/MirrorShader.cjs +0 -35
  453. package/shaders/MirrorShader.js +0 -35
  454. package/shaders/NormalMapShader.cjs +0 -31
  455. package/shaders/NormalMapShader.js +0 -31
  456. package/shaders/ParallaxShader.cjs +0 -133
  457. package/shaders/ParallaxShader.js +0 -133
  458. package/shaders/PixelShader.cjs +0 -28
  459. package/shaders/PixelShader.js +0 -28
  460. package/shaders/RGBShiftShader.cjs +0 -30
  461. package/shaders/RGBShiftShader.js +0 -30
  462. package/shaders/SAOShader.cjs +0 -144
  463. package/shaders/SAOShader.js +0 -144
  464. package/shaders/SMAAShader.cjs +0 -358
  465. package/shaders/SMAAShader.js +0 -358
  466. package/shaders/SSAOShader.cjs +0 -182
  467. package/shaders/SSAOShader.js +0 -182
  468. package/shaders/SSRShader.cjs +0 -342
  469. package/shaders/SSRShader.js +0 -342
  470. package/shaders/SepiaShader.cjs +0 -29
  471. package/shaders/SepiaShader.js +0 -29
  472. package/shaders/SobelOperatorShader.cjs +0 -54
  473. package/shaders/SobelOperatorShader.js +0 -54
  474. package/shaders/SubsurfaceScatteringShader.cjs +0 -98
  475. package/shaders/SubsurfaceScatteringShader.js +0 -98
  476. package/shaders/TechnicolorShader.cjs +0 -24
  477. package/shaders/TechnicolorShader.js +0 -24
  478. package/shaders/ToneMapShader.cjs +0 -51
  479. package/shaders/ToneMapShader.js +0 -51
  480. package/shaders/ToonShader.cjs +0 -188
  481. package/shaders/ToonShader.js +0 -188
  482. package/shaders/TriangleBlurShader.cjs +0 -37
  483. package/shaders/TriangleBlurShader.js +0 -37
  484. package/shaders/UnpackDepthRGBAShader.cjs +0 -26
  485. package/shaders/UnpackDepthRGBAShader.js +0 -26
  486. package/shaders/VerticalBlurShader.cjs +0 -50
  487. package/shaders/VerticalBlurShader.js +0 -50
  488. package/shaders/VerticalTiltShiftShader.cjs +0 -37
  489. package/shaders/VerticalTiltShiftShader.js +0 -37
  490. package/shaders/VignetteShader.cjs +0 -38
  491. package/shaders/VignetteShader.js +0 -38
  492. package/shaders/VolumeShader.cjs +0 -225
  493. package/shaders/VolumeShader.js +0 -225
  494. package/shaders/WaterRefractionShader.cjs +0 -59
  495. package/shaders/WaterRefractionShader.js +0 -59
  496. package/shaders/types.cjs +0 -1
  497. package/shaders/types.js +0 -1
  498. package/textures/FlakesTexture.cjs +0 -30
  499. package/textures/FlakesTexture.js +0 -30
  500. package/types/helpers.cjs +0 -4
  501. package/types/helpers.js +0 -4
  502. package/utils/BufferGeometryUtils.cjs +0 -636
  503. package/utils/BufferGeometryUtils.js +0 -636
  504. package/utils/GeometryCompressionUtils.cjs +0 -573
  505. package/utils/GeometryCompressionUtils.js +0 -573
  506. package/utils/GeometryUtils.cjs +0 -109
  507. package/utils/GeometryUtils.js +0 -109
  508. package/utils/RoughnessMipmapper.cjs +0 -223
  509. package/utils/RoughnessMipmapper.js +0 -223
  510. package/utils/SceneUtils.cjs +0 -36
  511. package/utils/SceneUtils.js +0 -36
  512. package/utils/ShadowMapViewer.cjs +0 -111
  513. package/utils/ShadowMapViewer.js +0 -111
  514. package/utils/SkeletonUtils.cjs +0 -211
  515. package/utils/SkeletonUtils.js +0 -211
  516. package/utils/UVsDebug.cjs +0 -80
  517. package/utils/UVsDebug.js +0 -80
  518. package/utils/WorkerPool.cjs +0 -62
  519. package/utils/WorkerPool.js +0 -62
  520. package/webxr/ARButton.cjs +0 -119
  521. package/webxr/ARButton.js +0 -119
  522. package/webxr/OculusHandModel.cjs +0 -82
  523. package/webxr/OculusHandModel.js +0 -82
  524. package/webxr/OculusHandPointerModel.cjs +0 -241
  525. package/webxr/OculusHandPointerModel.js +0 -224
  526. package/webxr/Text2D.cjs +0 -48
  527. package/webxr/Text2D.js +0 -31
  528. package/webxr/VRButton.cjs +0 -111
  529. package/webxr/VRButton.js +0 -111
  530. package/webxr/XRControllerModelFactory.cjs +0 -174
  531. package/webxr/XRControllerModelFactory.js +0 -174
  532. package/webxr/XREstimatedLight.cjs +0 -126
  533. package/webxr/XREstimatedLight.js +0 -126
  534. package/webxr/XRHandMeshModel.cjs +0 -82
  535. package/webxr/XRHandMeshModel.js +0 -82
  536. package/webxr/XRHandModelFactory.cjs +0 -61
  537. package/webxr/XRHandModelFactory.js +0 -61
  538. package/webxr/XRHandPrimitiveModel.cjs +0 -68
  539. package/webxr/XRHandPrimitiveModel.js +0 -68
@@ -1,2405 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const THREE = require("three");
4
- const TGALoader = require("./TGALoader.cjs");
5
- class ColladaLoader extends THREE.Loader {
6
- constructor(manager) {
7
- super(manager);
8
- }
9
- load(url, onLoad, onProgress, onError) {
10
- const scope = this;
11
- const path = scope.path === "" ? THREE.LoaderUtils.extractUrlBase(url) : scope.path;
12
- const loader = new THREE.FileLoader(scope.manager);
13
- loader.setPath(scope.path);
14
- loader.setRequestHeader(scope.requestHeader);
15
- loader.setWithCredentials(scope.withCredentials);
16
- loader.load(
17
- url,
18
- function(text) {
19
- try {
20
- onLoad(scope.parse(text, path));
21
- } catch (e) {
22
- if (onError) {
23
- onError(e);
24
- } else {
25
- console.error(e);
26
- }
27
- scope.manager.itemError(url);
28
- }
29
- },
30
- onProgress,
31
- onError
32
- );
33
- }
34
- parse(text, path) {
35
- function getElementsByTagName(xml2, name) {
36
- const array = [];
37
- const childNodes = xml2.childNodes;
38
- for (let i = 0, l = childNodes.length; i < l; i++) {
39
- const child = childNodes[i];
40
- if (child.nodeName === name) {
41
- array.push(child);
42
- }
43
- }
44
- return array;
45
- }
46
- function parseStrings(text2) {
47
- if (text2.length === 0)
48
- return [];
49
- const parts = text2.trim().split(/\s+/);
50
- const array = new Array(parts.length);
51
- for (let i = 0, l = parts.length; i < l; i++) {
52
- array[i] = parts[i];
53
- }
54
- return array;
55
- }
56
- function parseFloats(text2) {
57
- if (text2.length === 0)
58
- return [];
59
- const parts = text2.trim().split(/\s+/);
60
- const array = new Array(parts.length);
61
- for (let i = 0, l = parts.length; i < l; i++) {
62
- array[i] = parseFloat(parts[i]);
63
- }
64
- return array;
65
- }
66
- function parseInts(text2) {
67
- if (text2.length === 0)
68
- return [];
69
- const parts = text2.trim().split(/\s+/);
70
- const array = new Array(parts.length);
71
- for (let i = 0, l = parts.length; i < l; i++) {
72
- array[i] = parseInt(parts[i]);
73
- }
74
- return array;
75
- }
76
- function parseId(text2) {
77
- return text2.substring(1);
78
- }
79
- function generateId() {
80
- return "three_default_" + count++;
81
- }
82
- function isEmpty(object) {
83
- return Object.keys(object).length === 0;
84
- }
85
- function parseAsset(xml2) {
86
- return {
87
- unit: parseAssetUnit(getElementsByTagName(xml2, "unit")[0]),
88
- upAxis: parseAssetUpAxis(getElementsByTagName(xml2, "up_axis")[0])
89
- };
90
- }
91
- function parseAssetUnit(xml2) {
92
- if (xml2 !== void 0 && xml2.hasAttribute("meter") === true) {
93
- return parseFloat(xml2.getAttribute("meter"));
94
- } else {
95
- return 1;
96
- }
97
- }
98
- function parseAssetUpAxis(xml2) {
99
- return xml2 !== void 0 ? xml2.textContent : "Y_UP";
100
- }
101
- function parseLibrary(xml2, libraryName, nodeName, parser) {
102
- const library2 = getElementsByTagName(xml2, libraryName)[0];
103
- if (library2 !== void 0) {
104
- const elements = getElementsByTagName(library2, nodeName);
105
- for (let i = 0; i < elements.length; i++) {
106
- parser(elements[i]);
107
- }
108
- }
109
- }
110
- function buildLibrary(data, builder) {
111
- for (const name in data) {
112
- const object = data[name];
113
- object.build = builder(data[name]);
114
- }
115
- }
116
- function getBuild(data, builder) {
117
- if (data.build !== void 0)
118
- return data.build;
119
- data.build = builder(data);
120
- return data.build;
121
- }
122
- function parseAnimation(xml2) {
123
- const data = {
124
- sources: {},
125
- samplers: {},
126
- channels: {}
127
- };
128
- let hasChildren = false;
129
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
130
- const child = xml2.childNodes[i];
131
- if (child.nodeType !== 1)
132
- continue;
133
- let id;
134
- switch (child.nodeName) {
135
- case "source":
136
- id = child.getAttribute("id");
137
- data.sources[id] = parseSource(child);
138
- break;
139
- case "sampler":
140
- id = child.getAttribute("id");
141
- data.samplers[id] = parseAnimationSampler(child);
142
- break;
143
- case "channel":
144
- id = child.getAttribute("target");
145
- data.channels[id] = parseAnimationChannel(child);
146
- break;
147
- case "animation":
148
- parseAnimation(child);
149
- hasChildren = true;
150
- break;
151
- default:
152
- console.log(child);
153
- }
154
- }
155
- if (hasChildren === false) {
156
- library.animations[xml2.getAttribute("id") || THREE.MathUtils.generateUUID()] = data;
157
- }
158
- }
159
- function parseAnimationSampler(xml2) {
160
- const data = {
161
- inputs: {}
162
- };
163
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
164
- const child = xml2.childNodes[i];
165
- if (child.nodeType !== 1)
166
- continue;
167
- switch (child.nodeName) {
168
- case "input":
169
- const id = parseId(child.getAttribute("source"));
170
- const semantic = child.getAttribute("semantic");
171
- data.inputs[semantic] = id;
172
- break;
173
- }
174
- }
175
- return data;
176
- }
177
- function parseAnimationChannel(xml2) {
178
- const data = {};
179
- const target = xml2.getAttribute("target");
180
- let parts = target.split("/");
181
- const id = parts.shift();
182
- let sid = parts.shift();
183
- const arraySyntax = sid.indexOf("(") !== -1;
184
- const memberSyntax = sid.indexOf(".") !== -1;
185
- if (memberSyntax) {
186
- parts = sid.split(".");
187
- sid = parts.shift();
188
- data.member = parts.shift();
189
- } else if (arraySyntax) {
190
- const indices = sid.split("(");
191
- sid = indices.shift();
192
- for (let i = 0; i < indices.length; i++) {
193
- indices[i] = parseInt(indices[i].replace(/\)/, ""));
194
- }
195
- data.indices = indices;
196
- }
197
- data.id = id;
198
- data.sid = sid;
199
- data.arraySyntax = arraySyntax;
200
- data.memberSyntax = memberSyntax;
201
- data.sampler = parseId(xml2.getAttribute("source"));
202
- return data;
203
- }
204
- function buildAnimation(data) {
205
- const tracks = [];
206
- const channels = data.channels;
207
- const samplers = data.samplers;
208
- const sources = data.sources;
209
- for (const target in channels) {
210
- if (channels.hasOwnProperty(target)) {
211
- const channel = channels[target];
212
- const sampler = samplers[channel.sampler];
213
- const inputId = sampler.inputs.INPUT;
214
- const outputId = sampler.inputs.OUTPUT;
215
- const inputSource = sources[inputId];
216
- const outputSource = sources[outputId];
217
- const animation = buildAnimationChannel(channel, inputSource, outputSource);
218
- createKeyframeTracks(animation, tracks);
219
- }
220
- }
221
- return tracks;
222
- }
223
- function getAnimation(id) {
224
- return getBuild(library.animations[id], buildAnimation);
225
- }
226
- function buildAnimationChannel(channel, inputSource, outputSource) {
227
- const node = library.nodes[channel.id];
228
- const object3D = getNode(node.id);
229
- const transform = node.transforms[channel.sid];
230
- const defaultMatrix = node.matrix.clone().transpose();
231
- let time, stride;
232
- let i, il, j, jl;
233
- const data = {};
234
- switch (transform) {
235
- case "matrix":
236
- for (i = 0, il = inputSource.array.length; i < il; i++) {
237
- time = inputSource.array[i];
238
- stride = i * outputSource.stride;
239
- if (data[time] === void 0)
240
- data[time] = {};
241
- if (channel.arraySyntax === true) {
242
- const value = outputSource.array[stride];
243
- const index = channel.indices[0] + 4 * channel.indices[1];
244
- data[time][index] = value;
245
- } else {
246
- for (j = 0, jl = outputSource.stride; j < jl; j++) {
247
- data[time][j] = outputSource.array[stride + j];
248
- }
249
- }
250
- }
251
- break;
252
- case "translate":
253
- console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform);
254
- break;
255
- case "rotate":
256
- console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform);
257
- break;
258
- case "scale":
259
- console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform);
260
- break;
261
- }
262
- const keyframes = prepareAnimationData(data, defaultMatrix);
263
- const animation = {
264
- name: object3D.uuid,
265
- keyframes
266
- };
267
- return animation;
268
- }
269
- function prepareAnimationData(data, defaultMatrix) {
270
- const keyframes = [];
271
- for (const time in data) {
272
- keyframes.push({ time: parseFloat(time), value: data[time] });
273
- }
274
- keyframes.sort(ascending);
275
- for (let i = 0; i < 16; i++) {
276
- transformAnimationData(keyframes, i, defaultMatrix.elements[i]);
277
- }
278
- return keyframes;
279
- function ascending(a, b) {
280
- return a.time - b.time;
281
- }
282
- }
283
- const position = new THREE.Vector3();
284
- const scale = new THREE.Vector3();
285
- const quaternion = new THREE.Quaternion();
286
- function createKeyframeTracks(animation, tracks) {
287
- const keyframes = animation.keyframes;
288
- const name = animation.name;
289
- const times = [];
290
- const positionData = [];
291
- const quaternionData = [];
292
- const scaleData = [];
293
- for (let i = 0, l = keyframes.length; i < l; i++) {
294
- const keyframe = keyframes[i];
295
- const time = keyframe.time;
296
- const value = keyframe.value;
297
- matrix.fromArray(value).transpose();
298
- matrix.decompose(position, quaternion, scale);
299
- times.push(time);
300
- positionData.push(position.x, position.y, position.z);
301
- quaternionData.push(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
302
- scaleData.push(scale.x, scale.y, scale.z);
303
- }
304
- if (positionData.length > 0)
305
- tracks.push(new THREE.VectorKeyframeTrack(name + ".position", times, positionData));
306
- if (quaternionData.length > 0) {
307
- tracks.push(new THREE.QuaternionKeyframeTrack(name + ".quaternion", times, quaternionData));
308
- }
309
- if (scaleData.length > 0)
310
- tracks.push(new THREE.VectorKeyframeTrack(name + ".scale", times, scaleData));
311
- return tracks;
312
- }
313
- function transformAnimationData(keyframes, property, defaultValue) {
314
- let keyframe;
315
- let empty = true;
316
- let i, l;
317
- for (i = 0, l = keyframes.length; i < l; i++) {
318
- keyframe = keyframes[i];
319
- if (keyframe.value[property] === void 0) {
320
- keyframe.value[property] = null;
321
- } else {
322
- empty = false;
323
- }
324
- }
325
- if (empty === true) {
326
- for (i = 0, l = keyframes.length; i < l; i++) {
327
- keyframe = keyframes[i];
328
- keyframe.value[property] = defaultValue;
329
- }
330
- } else {
331
- createMissingKeyframes(keyframes, property);
332
- }
333
- }
334
- function createMissingKeyframes(keyframes, property) {
335
- let prev, next;
336
- for (let i = 0, l = keyframes.length; i < l; i++) {
337
- const keyframe = keyframes[i];
338
- if (keyframe.value[property] === null) {
339
- prev = getPrev(keyframes, i, property);
340
- next = getNext(keyframes, i, property);
341
- if (prev === null) {
342
- keyframe.value[property] = next.value[property];
343
- continue;
344
- }
345
- if (next === null) {
346
- keyframe.value[property] = prev.value[property];
347
- continue;
348
- }
349
- interpolate(keyframe, prev, next, property);
350
- }
351
- }
352
- }
353
- function getPrev(keyframes, i, property) {
354
- while (i >= 0) {
355
- const keyframe = keyframes[i];
356
- if (keyframe.value[property] !== null)
357
- return keyframe;
358
- i--;
359
- }
360
- return null;
361
- }
362
- function getNext(keyframes, i, property) {
363
- while (i < keyframes.length) {
364
- const keyframe = keyframes[i];
365
- if (keyframe.value[property] !== null)
366
- return keyframe;
367
- i++;
368
- }
369
- return null;
370
- }
371
- function interpolate(key, prev, next, property) {
372
- if (next.time - prev.time === 0) {
373
- key.value[property] = prev.value[property];
374
- return;
375
- }
376
- key.value[property] = (key.time - prev.time) * (next.value[property] - prev.value[property]) / (next.time - prev.time) + prev.value[property];
377
- }
378
- function parseAnimationClip(xml2) {
379
- const data = {
380
- name: xml2.getAttribute("id") || "default",
381
- start: parseFloat(xml2.getAttribute("start") || 0),
382
- end: parseFloat(xml2.getAttribute("end") || 0),
383
- animations: []
384
- };
385
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
386
- const child = xml2.childNodes[i];
387
- if (child.nodeType !== 1)
388
- continue;
389
- switch (child.nodeName) {
390
- case "instance_animation":
391
- data.animations.push(parseId(child.getAttribute("url")));
392
- break;
393
- }
394
- }
395
- library.clips[xml2.getAttribute("id")] = data;
396
- }
397
- function buildAnimationClip(data) {
398
- const tracks = [];
399
- const name = data.name;
400
- const duration = data.end - data.start || -1;
401
- const animations2 = data.animations;
402
- for (let i = 0, il = animations2.length; i < il; i++) {
403
- const animationTracks = getAnimation(animations2[i]);
404
- for (let j = 0, jl = animationTracks.length; j < jl; j++) {
405
- tracks.push(animationTracks[j]);
406
- }
407
- }
408
- return new THREE.AnimationClip(name, duration, tracks);
409
- }
410
- function getAnimationClip(id) {
411
- return getBuild(library.clips[id], buildAnimationClip);
412
- }
413
- function parseController(xml2) {
414
- const data = {};
415
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
416
- const child = xml2.childNodes[i];
417
- if (child.nodeType !== 1)
418
- continue;
419
- switch (child.nodeName) {
420
- case "skin":
421
- data.id = parseId(child.getAttribute("source"));
422
- data.skin = parseSkin(child);
423
- break;
424
- case "morph":
425
- data.id = parseId(child.getAttribute("source"));
426
- console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");
427
- break;
428
- }
429
- }
430
- library.controllers[xml2.getAttribute("id")] = data;
431
- }
432
- function parseSkin(xml2) {
433
- const data = {
434
- sources: {}
435
- };
436
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
437
- const child = xml2.childNodes[i];
438
- if (child.nodeType !== 1)
439
- continue;
440
- switch (child.nodeName) {
441
- case "bind_shape_matrix":
442
- data.bindShapeMatrix = parseFloats(child.textContent);
443
- break;
444
- case "source":
445
- const id = child.getAttribute("id");
446
- data.sources[id] = parseSource(child);
447
- break;
448
- case "joints":
449
- data.joints = parseJoints(child);
450
- break;
451
- case "vertex_weights":
452
- data.vertexWeights = parseVertexWeights(child);
453
- break;
454
- }
455
- }
456
- return data;
457
- }
458
- function parseJoints(xml2) {
459
- const data = {
460
- inputs: {}
461
- };
462
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
463
- const child = xml2.childNodes[i];
464
- if (child.nodeType !== 1)
465
- continue;
466
- switch (child.nodeName) {
467
- case "input":
468
- const semantic = child.getAttribute("semantic");
469
- const id = parseId(child.getAttribute("source"));
470
- data.inputs[semantic] = id;
471
- break;
472
- }
473
- }
474
- return data;
475
- }
476
- function parseVertexWeights(xml2) {
477
- const data = {
478
- inputs: {}
479
- };
480
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
481
- const child = xml2.childNodes[i];
482
- if (child.nodeType !== 1)
483
- continue;
484
- switch (child.nodeName) {
485
- case "input":
486
- const semantic = child.getAttribute("semantic");
487
- const id = parseId(child.getAttribute("source"));
488
- const offset = parseInt(child.getAttribute("offset"));
489
- data.inputs[semantic] = { id, offset };
490
- break;
491
- case "vcount":
492
- data.vcount = parseInts(child.textContent);
493
- break;
494
- case "v":
495
- data.v = parseInts(child.textContent);
496
- break;
497
- }
498
- }
499
- return data;
500
- }
501
- function buildController(data) {
502
- const build = {
503
- id: data.id
504
- };
505
- const geometry = library.geometries[build.id];
506
- if (data.skin !== void 0) {
507
- build.skin = buildSkin(data.skin);
508
- geometry.sources.skinIndices = build.skin.indices;
509
- geometry.sources.skinWeights = build.skin.weights;
510
- }
511
- return build;
512
- }
513
- function buildSkin(data) {
514
- const BONE_LIMIT = 4;
515
- const build = {
516
- joints: [],
517
- // this must be an array to preserve the joint order
518
- indices: {
519
- array: [],
520
- stride: BONE_LIMIT
521
- },
522
- weights: {
523
- array: [],
524
- stride: BONE_LIMIT
525
- }
526
- };
527
- const sources = data.sources;
528
- const vertexWeights = data.vertexWeights;
529
- const vcount = vertexWeights.vcount;
530
- const v = vertexWeights.v;
531
- const jointOffset = vertexWeights.inputs.JOINT.offset;
532
- const weightOffset = vertexWeights.inputs.WEIGHT.offset;
533
- const jointSource = data.sources[data.joints.inputs.JOINT];
534
- const inverseSource = data.sources[data.joints.inputs.INV_BIND_MATRIX];
535
- const weights = sources[vertexWeights.inputs.WEIGHT.id].array;
536
- let stride = 0;
537
- let i, j, l;
538
- for (i = 0, l = vcount.length; i < l; i++) {
539
- const jointCount = vcount[i];
540
- const vertexSkinData = [];
541
- for (j = 0; j < jointCount; j++) {
542
- const skinIndex = v[stride + jointOffset];
543
- const weightId = v[stride + weightOffset];
544
- const skinWeight = weights[weightId];
545
- vertexSkinData.push({ index: skinIndex, weight: skinWeight });
546
- stride += 2;
547
- }
548
- vertexSkinData.sort(descending);
549
- for (j = 0; j < BONE_LIMIT; j++) {
550
- const d = vertexSkinData[j];
551
- if (d !== void 0) {
552
- build.indices.array.push(d.index);
553
- build.weights.array.push(d.weight);
554
- } else {
555
- build.indices.array.push(0);
556
- build.weights.array.push(0);
557
- }
558
- }
559
- }
560
- if (data.bindShapeMatrix) {
561
- build.bindMatrix = new THREE.Matrix4().fromArray(data.bindShapeMatrix).transpose();
562
- } else {
563
- build.bindMatrix = new THREE.Matrix4().identity();
564
- }
565
- for (i = 0, l = jointSource.array.length; i < l; i++) {
566
- const name = jointSource.array[i];
567
- const boneInverse = new THREE.Matrix4().fromArray(inverseSource.array, i * inverseSource.stride).transpose();
568
- build.joints.push({ name, boneInverse });
569
- }
570
- return build;
571
- function descending(a, b) {
572
- return b.weight - a.weight;
573
- }
574
- }
575
- function getController(id) {
576
- return getBuild(library.controllers[id], buildController);
577
- }
578
- function parseImage(xml2) {
579
- const data = {
580
- init_from: getElementsByTagName(xml2, "init_from")[0].textContent
581
- };
582
- library.images[xml2.getAttribute("id")] = data;
583
- }
584
- function buildImage(data) {
585
- if (data.build !== void 0)
586
- return data.build;
587
- return data.init_from;
588
- }
589
- function getImage(id) {
590
- const data = library.images[id];
591
- if (data !== void 0) {
592
- return getBuild(data, buildImage);
593
- }
594
- console.warn("THREE.ColladaLoader: Couldn't find image with ID:", id);
595
- return null;
596
- }
597
- function parseEffect(xml2) {
598
- const data = {};
599
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
600
- const child = xml2.childNodes[i];
601
- if (child.nodeType !== 1)
602
- continue;
603
- switch (child.nodeName) {
604
- case "profile_COMMON":
605
- data.profile = parseEffectProfileCOMMON(child);
606
- break;
607
- }
608
- }
609
- library.effects[xml2.getAttribute("id")] = data;
610
- }
611
- function parseEffectProfileCOMMON(xml2) {
612
- const data = {
613
- surfaces: {},
614
- samplers: {}
615
- };
616
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
617
- const child = xml2.childNodes[i];
618
- if (child.nodeType !== 1)
619
- continue;
620
- switch (child.nodeName) {
621
- case "newparam":
622
- parseEffectNewparam(child, data);
623
- break;
624
- case "technique":
625
- data.technique = parseEffectTechnique(child);
626
- break;
627
- case "extra":
628
- data.extra = parseEffectExtra(child);
629
- break;
630
- }
631
- }
632
- return data;
633
- }
634
- function parseEffectNewparam(xml2, data) {
635
- const sid = xml2.getAttribute("sid");
636
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
637
- const child = xml2.childNodes[i];
638
- if (child.nodeType !== 1)
639
- continue;
640
- switch (child.nodeName) {
641
- case "surface":
642
- data.surfaces[sid] = parseEffectSurface(child);
643
- break;
644
- case "sampler2D":
645
- data.samplers[sid] = parseEffectSampler(child);
646
- break;
647
- }
648
- }
649
- }
650
- function parseEffectSurface(xml2) {
651
- const data = {};
652
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
653
- const child = xml2.childNodes[i];
654
- if (child.nodeType !== 1)
655
- continue;
656
- switch (child.nodeName) {
657
- case "init_from":
658
- data.init_from = child.textContent;
659
- break;
660
- }
661
- }
662
- return data;
663
- }
664
- function parseEffectSampler(xml2) {
665
- const data = {};
666
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
667
- const child = xml2.childNodes[i];
668
- if (child.nodeType !== 1)
669
- continue;
670
- switch (child.nodeName) {
671
- case "source":
672
- data.source = child.textContent;
673
- break;
674
- }
675
- }
676
- return data;
677
- }
678
- function parseEffectTechnique(xml2) {
679
- const data = {};
680
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
681
- const child = xml2.childNodes[i];
682
- if (child.nodeType !== 1)
683
- continue;
684
- switch (child.nodeName) {
685
- case "constant":
686
- case "lambert":
687
- case "blinn":
688
- case "phong":
689
- data.type = child.nodeName;
690
- data.parameters = parseEffectParameters(child);
691
- break;
692
- case "extra":
693
- data.extra = parseEffectExtra(child);
694
- break;
695
- }
696
- }
697
- return data;
698
- }
699
- function parseEffectParameters(xml2) {
700
- const data = {};
701
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
702
- const child = xml2.childNodes[i];
703
- if (child.nodeType !== 1)
704
- continue;
705
- switch (child.nodeName) {
706
- case "emission":
707
- case "diffuse":
708
- case "specular":
709
- case "bump":
710
- case "ambient":
711
- case "shininess":
712
- case "transparency":
713
- data[child.nodeName] = parseEffectParameter(child);
714
- break;
715
- case "transparent":
716
- data[child.nodeName] = {
717
- opaque: child.hasAttribute("opaque") ? child.getAttribute("opaque") : "A_ONE",
718
- data: parseEffectParameter(child)
719
- };
720
- break;
721
- }
722
- }
723
- return data;
724
- }
725
- function parseEffectParameter(xml2) {
726
- const data = {};
727
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
728
- const child = xml2.childNodes[i];
729
- if (child.nodeType !== 1)
730
- continue;
731
- switch (child.nodeName) {
732
- case "color":
733
- data[child.nodeName] = parseFloats(child.textContent);
734
- break;
735
- case "float":
736
- data[child.nodeName] = parseFloat(child.textContent);
737
- break;
738
- case "texture":
739
- data[child.nodeName] = { id: child.getAttribute("texture"), extra: parseEffectParameterTexture(child) };
740
- break;
741
- }
742
- }
743
- return data;
744
- }
745
- function parseEffectParameterTexture(xml2) {
746
- const data = {
747
- technique: {}
748
- };
749
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
750
- const child = xml2.childNodes[i];
751
- if (child.nodeType !== 1)
752
- continue;
753
- switch (child.nodeName) {
754
- case "extra":
755
- parseEffectParameterTextureExtra(child, data);
756
- break;
757
- }
758
- }
759
- return data;
760
- }
761
- function parseEffectParameterTextureExtra(xml2, data) {
762
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
763
- const child = xml2.childNodes[i];
764
- if (child.nodeType !== 1)
765
- continue;
766
- switch (child.nodeName) {
767
- case "technique":
768
- parseEffectParameterTextureExtraTechnique(child, data);
769
- break;
770
- }
771
- }
772
- }
773
- function parseEffectParameterTextureExtraTechnique(xml2, data) {
774
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
775
- const child = xml2.childNodes[i];
776
- if (child.nodeType !== 1)
777
- continue;
778
- switch (child.nodeName) {
779
- case "repeatU":
780
- case "repeatV":
781
- case "offsetU":
782
- case "offsetV":
783
- data.technique[child.nodeName] = parseFloat(child.textContent);
784
- break;
785
- case "wrapU":
786
- case "wrapV":
787
- if (child.textContent.toUpperCase() === "TRUE") {
788
- data.technique[child.nodeName] = 1;
789
- } else if (child.textContent.toUpperCase() === "FALSE") {
790
- data.technique[child.nodeName] = 0;
791
- } else {
792
- data.technique[child.nodeName] = parseInt(child.textContent);
793
- }
794
- break;
795
- case "bump":
796
- data[child.nodeName] = parseEffectExtraTechniqueBump(child);
797
- break;
798
- }
799
- }
800
- }
801
- function parseEffectExtra(xml2) {
802
- const data = {};
803
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
804
- const child = xml2.childNodes[i];
805
- if (child.nodeType !== 1)
806
- continue;
807
- switch (child.nodeName) {
808
- case "technique":
809
- data.technique = parseEffectExtraTechnique(child);
810
- break;
811
- }
812
- }
813
- return data;
814
- }
815
- function parseEffectExtraTechnique(xml2) {
816
- const data = {};
817
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
818
- const child = xml2.childNodes[i];
819
- if (child.nodeType !== 1)
820
- continue;
821
- switch (child.nodeName) {
822
- case "double_sided":
823
- data[child.nodeName] = parseInt(child.textContent);
824
- break;
825
- case "bump":
826
- data[child.nodeName] = parseEffectExtraTechniqueBump(child);
827
- break;
828
- }
829
- }
830
- return data;
831
- }
832
- function parseEffectExtraTechniqueBump(xml2) {
833
- var data = {};
834
- for (var i = 0, l = xml2.childNodes.length; i < l; i++) {
835
- var child = xml2.childNodes[i];
836
- if (child.nodeType !== 1)
837
- continue;
838
- switch (child.nodeName) {
839
- case "texture":
840
- data[child.nodeName] = {
841
- id: child.getAttribute("texture"),
842
- texcoord: child.getAttribute("texcoord"),
843
- extra: parseEffectParameterTexture(child)
844
- };
845
- break;
846
- }
847
- }
848
- return data;
849
- }
850
- function buildEffect(data) {
851
- return data;
852
- }
853
- function getEffect(id) {
854
- return getBuild(library.effects[id], buildEffect);
855
- }
856
- function parseMaterial(xml2) {
857
- const data = {
858
- name: xml2.getAttribute("name")
859
- };
860
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
861
- const child = xml2.childNodes[i];
862
- if (child.nodeType !== 1)
863
- continue;
864
- switch (child.nodeName) {
865
- case "instance_effect":
866
- data.url = parseId(child.getAttribute("url"));
867
- break;
868
- }
869
- }
870
- library.materials[xml2.getAttribute("id")] = data;
871
- }
872
- function getTextureLoader(image) {
873
- let loader;
874
- let extension = image.slice((image.lastIndexOf(".") - 1 >>> 0) + 2);
875
- extension = extension.toLowerCase();
876
- switch (extension) {
877
- case "tga":
878
- loader = tgaLoader;
879
- break;
880
- default:
881
- loader = textureLoader;
882
- }
883
- return loader;
884
- }
885
- function buildMaterial(data) {
886
- const effect = getEffect(data.url);
887
- const technique = effect.profile.technique;
888
- let material;
889
- switch (technique.type) {
890
- case "phong":
891
- case "blinn":
892
- material = new THREE.MeshPhongMaterial();
893
- break;
894
- case "lambert":
895
- material = new THREE.MeshLambertMaterial();
896
- break;
897
- default:
898
- material = new THREE.MeshBasicMaterial();
899
- break;
900
- }
901
- material.name = data.name || "";
902
- function getTexture(textureObject) {
903
- const sampler = effect.profile.samplers[textureObject.id];
904
- let image = null;
905
- if (sampler !== void 0) {
906
- const surface = effect.profile.surfaces[sampler.source];
907
- image = getImage(surface.init_from);
908
- } else {
909
- console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530).");
910
- image = getImage(textureObject.id);
911
- }
912
- if (image !== null) {
913
- const loader = getTextureLoader(image);
914
- if (loader !== void 0) {
915
- const texture = loader.load(image);
916
- const extra = textureObject.extra;
917
- if (extra !== void 0 && extra.technique !== void 0 && isEmpty(extra.technique) === false) {
918
- const technique2 = extra.technique;
919
- texture.wrapS = technique2.wrapU ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
920
- texture.wrapT = technique2.wrapV ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
921
- texture.offset.set(technique2.offsetU || 0, technique2.offsetV || 0);
922
- texture.repeat.set(technique2.repeatU || 1, technique2.repeatV || 1);
923
- } else {
924
- texture.wrapS = THREE.RepeatWrapping;
925
- texture.wrapT = THREE.RepeatWrapping;
926
- }
927
- return texture;
928
- } else {
929
- console.warn("THREE.ColladaLoader: Loader for texture %s not found.", image);
930
- return null;
931
- }
932
- } else {
933
- console.warn("THREE.ColladaLoader: Couldn't create texture with ID:", textureObject.id);
934
- return null;
935
- }
936
- }
937
- const parameters = technique.parameters;
938
- for (const key in parameters) {
939
- const parameter = parameters[key];
940
- switch (key) {
941
- case "diffuse":
942
- if (parameter.color)
943
- material.color.fromArray(parameter.color);
944
- if (parameter.texture)
945
- material.map = getTexture(parameter.texture);
946
- break;
947
- case "specular":
948
- if (parameter.color && material.specular)
949
- material.specular.fromArray(parameter.color);
950
- if (parameter.texture)
951
- material.specularMap = getTexture(parameter.texture);
952
- break;
953
- case "bump":
954
- if (parameter.texture)
955
- material.normalMap = getTexture(parameter.texture);
956
- break;
957
- case "ambient":
958
- if (parameter.texture)
959
- material.lightMap = getTexture(parameter.texture);
960
- break;
961
- case "shininess":
962
- if (parameter.float && material.shininess)
963
- material.shininess = parameter.float;
964
- break;
965
- case "emission":
966
- if (parameter.color && material.emissive)
967
- material.emissive.fromArray(parameter.color);
968
- if (parameter.texture)
969
- material.emissiveMap = getTexture(parameter.texture);
970
- break;
971
- }
972
- }
973
- let transparent = parameters["transparent"];
974
- let transparency = parameters["transparency"];
975
- if (transparency === void 0 && transparent) {
976
- transparency = {
977
- float: 1
978
- };
979
- }
980
- if (transparent === void 0 && transparency) {
981
- transparent = {
982
- opaque: "A_ONE",
983
- data: {
984
- color: [1, 1, 1, 1]
985
- }
986
- };
987
- }
988
- if (transparent && transparency) {
989
- if (transparent.data.texture) {
990
- material.transparent = true;
991
- } else {
992
- const color = transparent.data.color;
993
- switch (transparent.opaque) {
994
- case "A_ONE":
995
- material.opacity = color[3] * transparency.float;
996
- break;
997
- case "RGB_ZERO":
998
- material.opacity = 1 - color[0] * transparency.float;
999
- break;
1000
- case "A_ZERO":
1001
- material.opacity = 1 - color[3] * transparency.float;
1002
- break;
1003
- case "RGB_ONE":
1004
- material.opacity = color[0] * transparency.float;
1005
- break;
1006
- default:
1007
- console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.', transparent.opaque);
1008
- }
1009
- if (material.opacity < 1)
1010
- material.transparent = true;
1011
- }
1012
- }
1013
- if (technique.extra !== void 0 && technique.extra.technique !== void 0) {
1014
- const techniques = technique.extra.technique;
1015
- for (const k in techniques) {
1016
- const v = techniques[k];
1017
- switch (k) {
1018
- case "double_sided":
1019
- material.side = v === 1 ? THREE.DoubleSide : THREE.FrontSide;
1020
- break;
1021
- case "bump":
1022
- material.normalMap = getTexture(v.texture);
1023
- material.normalScale = new THREE.Vector2(1, 1);
1024
- break;
1025
- }
1026
- }
1027
- }
1028
- return material;
1029
- }
1030
- function getMaterial(id) {
1031
- return getBuild(library.materials[id], buildMaterial);
1032
- }
1033
- function parseCamera(xml2) {
1034
- const data = {
1035
- name: xml2.getAttribute("name")
1036
- };
1037
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
1038
- const child = xml2.childNodes[i];
1039
- if (child.nodeType !== 1)
1040
- continue;
1041
- switch (child.nodeName) {
1042
- case "optics":
1043
- data.optics = parseCameraOptics(child);
1044
- break;
1045
- }
1046
- }
1047
- library.cameras[xml2.getAttribute("id")] = data;
1048
- }
1049
- function parseCameraOptics(xml2) {
1050
- for (let i = 0; i < xml2.childNodes.length; i++) {
1051
- const child = xml2.childNodes[i];
1052
- switch (child.nodeName) {
1053
- case "technique_common":
1054
- return parseCameraTechnique(child);
1055
- }
1056
- }
1057
- return {};
1058
- }
1059
- function parseCameraTechnique(xml2) {
1060
- const data = {};
1061
- for (let i = 0; i < xml2.childNodes.length; i++) {
1062
- const child = xml2.childNodes[i];
1063
- switch (child.nodeName) {
1064
- case "perspective":
1065
- case "orthographic":
1066
- data.technique = child.nodeName;
1067
- data.parameters = parseCameraParameters(child);
1068
- break;
1069
- }
1070
- }
1071
- return data;
1072
- }
1073
- function parseCameraParameters(xml2) {
1074
- const data = {};
1075
- for (let i = 0; i < xml2.childNodes.length; i++) {
1076
- const child = xml2.childNodes[i];
1077
- switch (child.nodeName) {
1078
- case "xfov":
1079
- case "yfov":
1080
- case "xmag":
1081
- case "ymag":
1082
- case "znear":
1083
- case "zfar":
1084
- case "aspect_ratio":
1085
- data[child.nodeName] = parseFloat(child.textContent);
1086
- break;
1087
- }
1088
- }
1089
- return data;
1090
- }
1091
- function buildCamera(data) {
1092
- let camera;
1093
- switch (data.optics.technique) {
1094
- case "perspective":
1095
- camera = new THREE.PerspectiveCamera(
1096
- data.optics.parameters.yfov,
1097
- data.optics.parameters.aspect_ratio,
1098
- data.optics.parameters.znear,
1099
- data.optics.parameters.zfar
1100
- );
1101
- break;
1102
- case "orthographic":
1103
- let ymag = data.optics.parameters.ymag;
1104
- let xmag = data.optics.parameters.xmag;
1105
- const aspectRatio = data.optics.parameters.aspect_ratio;
1106
- xmag = xmag === void 0 ? ymag * aspectRatio : xmag;
1107
- ymag = ymag === void 0 ? xmag / aspectRatio : ymag;
1108
- xmag *= 0.5;
1109
- ymag *= 0.5;
1110
- camera = new THREE.OrthographicCamera(
1111
- -xmag,
1112
- xmag,
1113
- ymag,
1114
- -ymag,
1115
- // left, right, top, bottom
1116
- data.optics.parameters.znear,
1117
- data.optics.parameters.zfar
1118
- );
1119
- break;
1120
- default:
1121
- camera = new THREE.PerspectiveCamera();
1122
- break;
1123
- }
1124
- camera.name = data.name || "";
1125
- return camera;
1126
- }
1127
- function getCamera(id) {
1128
- const data = library.cameras[id];
1129
- if (data !== void 0) {
1130
- return getBuild(data, buildCamera);
1131
- }
1132
- console.warn("THREE.ColladaLoader: Couldn't find camera with ID:", id);
1133
- return null;
1134
- }
1135
- function parseLight(xml2) {
1136
- let data = {};
1137
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
1138
- const child = xml2.childNodes[i];
1139
- if (child.nodeType !== 1)
1140
- continue;
1141
- switch (child.nodeName) {
1142
- case "technique_common":
1143
- data = parseLightTechnique(child);
1144
- break;
1145
- }
1146
- }
1147
- library.lights[xml2.getAttribute("id")] = data;
1148
- }
1149
- function parseLightTechnique(xml2) {
1150
- const data = {};
1151
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
1152
- const child = xml2.childNodes[i];
1153
- if (child.nodeType !== 1)
1154
- continue;
1155
- switch (child.nodeName) {
1156
- case "directional":
1157
- case "point":
1158
- case "spot":
1159
- case "ambient":
1160
- data.technique = child.nodeName;
1161
- data.parameters = parseLightParameters(child);
1162
- }
1163
- }
1164
- return data;
1165
- }
1166
- function parseLightParameters(xml2) {
1167
- const data = {};
1168
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
1169
- const child = xml2.childNodes[i];
1170
- if (child.nodeType !== 1)
1171
- continue;
1172
- switch (child.nodeName) {
1173
- case "color":
1174
- const array = parseFloats(child.textContent);
1175
- data.color = new THREE.Color().fromArray(array);
1176
- break;
1177
- case "falloff_angle":
1178
- data.falloffAngle = parseFloat(child.textContent);
1179
- break;
1180
- case "quadratic_attenuation":
1181
- const f = parseFloat(child.textContent);
1182
- data.distance = f ? Math.sqrt(1 / f) : 0;
1183
- break;
1184
- }
1185
- }
1186
- return data;
1187
- }
1188
- function buildLight(data) {
1189
- let light;
1190
- switch (data.technique) {
1191
- case "directional":
1192
- light = new THREE.DirectionalLight();
1193
- break;
1194
- case "point":
1195
- light = new THREE.PointLight();
1196
- break;
1197
- case "spot":
1198
- light = new THREE.SpotLight();
1199
- break;
1200
- case "ambient":
1201
- light = new THREE.AmbientLight();
1202
- break;
1203
- }
1204
- if (data.parameters.color)
1205
- light.color.copy(data.parameters.color);
1206
- if (data.parameters.distance)
1207
- light.distance = data.parameters.distance;
1208
- return light;
1209
- }
1210
- function getLight(id) {
1211
- const data = library.lights[id];
1212
- if (data !== void 0) {
1213
- return getBuild(data, buildLight);
1214
- }
1215
- console.warn("THREE.ColladaLoader: Couldn't find light with ID:", id);
1216
- return null;
1217
- }
1218
- function parseGeometry(xml2) {
1219
- const data = {
1220
- name: xml2.getAttribute("name"),
1221
- sources: {},
1222
- vertices: {},
1223
- primitives: []
1224
- };
1225
- const mesh = getElementsByTagName(xml2, "mesh")[0];
1226
- if (mesh === void 0)
1227
- return;
1228
- for (let i = 0; i < mesh.childNodes.length; i++) {
1229
- const child = mesh.childNodes[i];
1230
- if (child.nodeType !== 1)
1231
- continue;
1232
- const id = child.getAttribute("id");
1233
- switch (child.nodeName) {
1234
- case "source":
1235
- data.sources[id] = parseSource(child);
1236
- break;
1237
- case "vertices":
1238
- data.vertices = parseGeometryVertices(child);
1239
- break;
1240
- case "polygons":
1241
- console.warn("THREE.ColladaLoader: Unsupported primitive type: ", child.nodeName);
1242
- break;
1243
- case "lines":
1244
- case "linestrips":
1245
- case "polylist":
1246
- case "triangles":
1247
- data.primitives.push(parseGeometryPrimitive(child));
1248
- break;
1249
- default:
1250
- console.log(child);
1251
- }
1252
- }
1253
- library.geometries[xml2.getAttribute("id")] = data;
1254
- }
1255
- function parseSource(xml2) {
1256
- const data = {
1257
- array: [],
1258
- stride: 3
1259
- };
1260
- for (let i = 0; i < xml2.childNodes.length; i++) {
1261
- const child = xml2.childNodes[i];
1262
- if (child.nodeType !== 1)
1263
- continue;
1264
- switch (child.nodeName) {
1265
- case "float_array":
1266
- data.array = parseFloats(child.textContent);
1267
- break;
1268
- case "Name_array":
1269
- data.array = parseStrings(child.textContent);
1270
- break;
1271
- case "technique_common":
1272
- const accessor = getElementsByTagName(child, "accessor")[0];
1273
- if (accessor !== void 0) {
1274
- data.stride = parseInt(accessor.getAttribute("stride"));
1275
- }
1276
- break;
1277
- }
1278
- }
1279
- return data;
1280
- }
1281
- function parseGeometryVertices(xml2) {
1282
- const data = {};
1283
- for (let i = 0; i < xml2.childNodes.length; i++) {
1284
- const child = xml2.childNodes[i];
1285
- if (child.nodeType !== 1)
1286
- continue;
1287
- data[child.getAttribute("semantic")] = parseId(child.getAttribute("source"));
1288
- }
1289
- return data;
1290
- }
1291
- function parseGeometryPrimitive(xml2) {
1292
- const primitive = {
1293
- type: xml2.nodeName,
1294
- material: xml2.getAttribute("material"),
1295
- count: parseInt(xml2.getAttribute("count")),
1296
- inputs: {},
1297
- stride: 0,
1298
- hasUV: false
1299
- };
1300
- for (let i = 0, l = xml2.childNodes.length; i < l; i++) {
1301
- const child = xml2.childNodes[i];
1302
- if (child.nodeType !== 1)
1303
- continue;
1304
- switch (child.nodeName) {
1305
- case "input":
1306
- const id = parseId(child.getAttribute("source"));
1307
- const semantic = child.getAttribute("semantic");
1308
- const offset = parseInt(child.getAttribute("offset"));
1309
- const set = parseInt(child.getAttribute("set"));
1310
- const inputname = set > 0 ? semantic + set : semantic;
1311
- primitive.inputs[inputname] = { id, offset };
1312
- primitive.stride = Math.max(primitive.stride, offset + 1);
1313
- if (semantic === "TEXCOORD")
1314
- primitive.hasUV = true;
1315
- break;
1316
- case "vcount":
1317
- primitive.vcount = parseInts(child.textContent);
1318
- break;
1319
- case "p":
1320
- primitive.p = parseInts(child.textContent);
1321
- break;
1322
- }
1323
- }
1324
- return primitive;
1325
- }
1326
- function groupPrimitives(primitives) {
1327
- const build = {};
1328
- for (let i = 0; i < primitives.length; i++) {
1329
- const primitive = primitives[i];
1330
- if (build[primitive.type] === void 0)
1331
- build[primitive.type] = [];
1332
- build[primitive.type].push(primitive);
1333
- }
1334
- return build;
1335
- }
1336
- function checkUVCoordinates(primitives) {
1337
- let count2 = 0;
1338
- for (let i = 0, l = primitives.length; i < l; i++) {
1339
- const primitive = primitives[i];
1340
- if (primitive.hasUV === true) {
1341
- count2++;
1342
- }
1343
- }
1344
- if (count2 > 0 && count2 < primitives.length) {
1345
- primitives.uvsNeedsFix = true;
1346
- }
1347
- }
1348
- function buildGeometry(data) {
1349
- const build = {};
1350
- const sources = data.sources;
1351
- const vertices = data.vertices;
1352
- const primitives = data.primitives;
1353
- if (primitives.length === 0)
1354
- return {};
1355
- const groupedPrimitives = groupPrimitives(primitives);
1356
- for (const type in groupedPrimitives) {
1357
- const primitiveType = groupedPrimitives[type];
1358
- checkUVCoordinates(primitiveType);
1359
- build[type] = buildGeometryType(primitiveType, sources, vertices);
1360
- }
1361
- return build;
1362
- }
1363
- function buildGeometryType(primitives, sources, vertices) {
1364
- const build = {};
1365
- const position2 = { array: [], stride: 0 };
1366
- const normal = { array: [], stride: 0 };
1367
- const uv = { array: [], stride: 0 };
1368
- const uv2 = { array: [], stride: 0 };
1369
- const color = { array: [], stride: 0 };
1370
- const skinIndex = { array: [], stride: 4 };
1371
- const skinWeight = { array: [], stride: 4 };
1372
- const geometry = new THREE.BufferGeometry();
1373
- const materialKeys = [];
1374
- let start = 0;
1375
- for (let p = 0; p < primitives.length; p++) {
1376
- const primitive = primitives[p];
1377
- const inputs = primitive.inputs;
1378
- let count2 = 0;
1379
- switch (primitive.type) {
1380
- case "lines":
1381
- case "linestrips":
1382
- count2 = primitive.count * 2;
1383
- break;
1384
- case "triangles":
1385
- count2 = primitive.count * 3;
1386
- break;
1387
- case "polylist":
1388
- for (let g = 0; g < primitive.count; g++) {
1389
- const vc = primitive.vcount[g];
1390
- switch (vc) {
1391
- case 3:
1392
- count2 += 3;
1393
- break;
1394
- case 4:
1395
- count2 += 6;
1396
- break;
1397
- default:
1398
- count2 += (vc - 2) * 3;
1399
- break;
1400
- }
1401
- }
1402
- break;
1403
- default:
1404
- console.warn("THREE.ColladaLoader: Unknow primitive type:", primitive.type);
1405
- }
1406
- geometry.addGroup(start, count2, p);
1407
- start += count2;
1408
- if (primitive.material) {
1409
- materialKeys.push(primitive.material);
1410
- }
1411
- for (const name in inputs) {
1412
- const input = inputs[name];
1413
- switch (name) {
1414
- case "VERTEX":
1415
- for (const key in vertices) {
1416
- const id = vertices[key];
1417
- switch (key) {
1418
- case "POSITION":
1419
- const prevLength = position2.array.length;
1420
- buildGeometryData(primitive, sources[id], input.offset, position2.array);
1421
- position2.stride = sources[id].stride;
1422
- if (sources.skinWeights && sources.skinIndices) {
1423
- buildGeometryData(primitive, sources.skinIndices, input.offset, skinIndex.array);
1424
- buildGeometryData(primitive, sources.skinWeights, input.offset, skinWeight.array);
1425
- }
1426
- if (primitive.hasUV === false && primitives.uvsNeedsFix === true) {
1427
- const count3 = (position2.array.length - prevLength) / position2.stride;
1428
- for (let i = 0; i < count3; i++) {
1429
- uv.array.push(0, 0);
1430
- }
1431
- }
1432
- break;
1433
- case "NORMAL":
1434
- buildGeometryData(primitive, sources[id], input.offset, normal.array);
1435
- normal.stride = sources[id].stride;
1436
- break;
1437
- case "COLOR":
1438
- buildGeometryData(primitive, sources[id], input.offset, color.array);
1439
- color.stride = sources[id].stride;
1440
- break;
1441
- case "TEXCOORD":
1442
- buildGeometryData(primitive, sources[id], input.offset, uv.array);
1443
- uv.stride = sources[id].stride;
1444
- break;
1445
- case "TEXCOORD1":
1446
- buildGeometryData(primitive, sources[id], input.offset, uv2.array);
1447
- uv.stride = sources[id].stride;
1448
- break;
1449
- default:
1450
- console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.', key);
1451
- }
1452
- }
1453
- break;
1454
- case "NORMAL":
1455
- buildGeometryData(primitive, sources[input.id], input.offset, normal.array);
1456
- normal.stride = sources[input.id].stride;
1457
- break;
1458
- case "COLOR":
1459
- buildGeometryData(primitive, sources[input.id], input.offset, color.array);
1460
- color.stride = sources[input.id].stride;
1461
- break;
1462
- case "TEXCOORD":
1463
- buildGeometryData(primitive, sources[input.id], input.offset, uv.array);
1464
- uv.stride = sources[input.id].stride;
1465
- break;
1466
- case "TEXCOORD1":
1467
- buildGeometryData(primitive, sources[input.id], input.offset, uv2.array);
1468
- uv2.stride = sources[input.id].stride;
1469
- break;
1470
- }
1471
- }
1472
- }
1473
- if (position2.array.length > 0) {
1474
- geometry.setAttribute("position", new THREE.Float32BufferAttribute(position2.array, position2.stride));
1475
- }
1476
- if (normal.array.length > 0) {
1477
- geometry.setAttribute("normal", new THREE.Float32BufferAttribute(normal.array, normal.stride));
1478
- }
1479
- if (color.array.length > 0)
1480
- geometry.setAttribute("color", new THREE.Float32BufferAttribute(color.array, color.stride));
1481
- if (uv.array.length > 0)
1482
- geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uv.array, uv.stride));
1483
- if (uv2.array.length > 0)
1484
- geometry.setAttribute("uv2", new THREE.Float32BufferAttribute(uv2.array, uv2.stride));
1485
- if (skinIndex.array.length > 0) {
1486
- geometry.setAttribute("skinIndex", new THREE.Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1487
- }
1488
- if (skinWeight.array.length > 0) {
1489
- geometry.setAttribute("skinWeight", new THREE.Float32BufferAttribute(skinWeight.array, skinWeight.stride));
1490
- }
1491
- build.data = geometry;
1492
- build.type = primitives[0].type;
1493
- build.materialKeys = materialKeys;
1494
- return build;
1495
- }
1496
- function buildGeometryData(primitive, source, offset, array) {
1497
- const indices = primitive.p;
1498
- const stride = primitive.stride;
1499
- const vcount = primitive.vcount;
1500
- function pushVector(i) {
1501
- let index = indices[i + offset] * sourceStride;
1502
- const length = index + sourceStride;
1503
- for (; index < length; index++) {
1504
- array.push(sourceArray[index]);
1505
- }
1506
- }
1507
- const sourceArray = source.array;
1508
- const sourceStride = source.stride;
1509
- if (primitive.vcount !== void 0) {
1510
- let index = 0;
1511
- for (let i = 0, l = vcount.length; i < l; i++) {
1512
- const count2 = vcount[i];
1513
- if (count2 === 4) {
1514
- const a = index + stride * 0;
1515
- const b = index + stride * 1;
1516
- const c = index + stride * 2;
1517
- const d = index + stride * 3;
1518
- pushVector(a);
1519
- pushVector(b);
1520
- pushVector(d);
1521
- pushVector(b);
1522
- pushVector(c);
1523
- pushVector(d);
1524
- } else if (count2 === 3) {
1525
- const a = index + stride * 0;
1526
- const b = index + stride * 1;
1527
- const c = index + stride * 2;
1528
- pushVector(a);
1529
- pushVector(b);
1530
- pushVector(c);
1531
- } else if (count2 > 4) {
1532
- for (let k = 1, kl = count2 - 2; k <= kl; k++) {
1533
- const a = index + stride * 0;
1534
- const b = index + stride * k;
1535
- const c = index + stride * (k + 1);
1536
- pushVector(a);
1537
- pushVector(b);
1538
- pushVector(c);
1539
- }
1540
- }
1541
- index += stride * count2;
1542
- }
1543
- } else {
1544
- for (let i = 0, l = indices.length; i < l; i += stride) {
1545
- pushVector(i);
1546
- }
1547
- }
1548
- }
1549
- function getGeometry(id) {
1550
- return getBuild(library.geometries[id], buildGeometry);
1551
- }
1552
- function parseKinematicsModel(xml2) {
1553
- const data = {
1554
- name: xml2.getAttribute("name") || "",
1555
- joints: {},
1556
- links: []
1557
- };
1558
- for (let i = 0; i < xml2.childNodes.length; i++) {
1559
- const child = xml2.childNodes[i];
1560
- if (child.nodeType !== 1)
1561
- continue;
1562
- switch (child.nodeName) {
1563
- case "technique_common":
1564
- parseKinematicsTechniqueCommon(child, data);
1565
- break;
1566
- }
1567
- }
1568
- library.kinematicsModels[xml2.getAttribute("id")] = data;
1569
- }
1570
- function buildKinematicsModel(data) {
1571
- if (data.build !== void 0)
1572
- return data.build;
1573
- return data;
1574
- }
1575
- function getKinematicsModel(id) {
1576
- return getBuild(library.kinematicsModels[id], buildKinematicsModel);
1577
- }
1578
- function parseKinematicsTechniqueCommon(xml2, data) {
1579
- for (let i = 0; i < xml2.childNodes.length; i++) {
1580
- const child = xml2.childNodes[i];
1581
- if (child.nodeType !== 1)
1582
- continue;
1583
- switch (child.nodeName) {
1584
- case "joint":
1585
- data.joints[child.getAttribute("sid")] = parseKinematicsJoint(child);
1586
- break;
1587
- case "link":
1588
- data.links.push(parseKinematicsLink(child));
1589
- break;
1590
- }
1591
- }
1592
- }
1593
- function parseKinematicsJoint(xml2) {
1594
- let data;
1595
- for (let i = 0; i < xml2.childNodes.length; i++) {
1596
- const child = xml2.childNodes[i];
1597
- if (child.nodeType !== 1)
1598
- continue;
1599
- switch (child.nodeName) {
1600
- case "prismatic":
1601
- case "revolute":
1602
- data = parseKinematicsJointParameter(child);
1603
- break;
1604
- }
1605
- }
1606
- return data;
1607
- }
1608
- function parseKinematicsJointParameter(xml2) {
1609
- const data = {
1610
- sid: xml2.getAttribute("sid"),
1611
- name: xml2.getAttribute("name") || "",
1612
- axis: new THREE.Vector3(),
1613
- limits: {
1614
- min: 0,
1615
- max: 0
1616
- },
1617
- type: xml2.nodeName,
1618
- static: false,
1619
- zeroPosition: 0,
1620
- middlePosition: 0
1621
- };
1622
- for (let i = 0; i < xml2.childNodes.length; i++) {
1623
- const child = xml2.childNodes[i];
1624
- if (child.nodeType !== 1)
1625
- continue;
1626
- switch (child.nodeName) {
1627
- case "axis":
1628
- const array = parseFloats(child.textContent);
1629
- data.axis.fromArray(array);
1630
- break;
1631
- case "limits":
1632
- const max = child.getElementsByTagName("max")[0];
1633
- const min = child.getElementsByTagName("min")[0];
1634
- data.limits.max = parseFloat(max.textContent);
1635
- data.limits.min = parseFloat(min.textContent);
1636
- break;
1637
- }
1638
- }
1639
- if (data.limits.min >= data.limits.max) {
1640
- data.static = true;
1641
- }
1642
- data.middlePosition = (data.limits.min + data.limits.max) / 2;
1643
- return data;
1644
- }
1645
- function parseKinematicsLink(xml2) {
1646
- const data = {
1647
- sid: xml2.getAttribute("sid"),
1648
- name: xml2.getAttribute("name") || "",
1649
- attachments: [],
1650
- transforms: []
1651
- };
1652
- for (let i = 0; i < xml2.childNodes.length; i++) {
1653
- const child = xml2.childNodes[i];
1654
- if (child.nodeType !== 1)
1655
- continue;
1656
- switch (child.nodeName) {
1657
- case "attachment_full":
1658
- data.attachments.push(parseKinematicsAttachment(child));
1659
- break;
1660
- case "matrix":
1661
- case "translate":
1662
- case "rotate":
1663
- data.transforms.push(parseKinematicsTransform(child));
1664
- break;
1665
- }
1666
- }
1667
- return data;
1668
- }
1669
- function parseKinematicsAttachment(xml2) {
1670
- const data = {
1671
- joint: xml2.getAttribute("joint").split("/").pop(),
1672
- transforms: [],
1673
- links: []
1674
- };
1675
- for (let i = 0; i < xml2.childNodes.length; i++) {
1676
- const child = xml2.childNodes[i];
1677
- if (child.nodeType !== 1)
1678
- continue;
1679
- switch (child.nodeName) {
1680
- case "link":
1681
- data.links.push(parseKinematicsLink(child));
1682
- break;
1683
- case "matrix":
1684
- case "translate":
1685
- case "rotate":
1686
- data.transforms.push(parseKinematicsTransform(child));
1687
- break;
1688
- }
1689
- }
1690
- return data;
1691
- }
1692
- function parseKinematicsTransform(xml2) {
1693
- const data = {
1694
- type: xml2.nodeName
1695
- };
1696
- const array = parseFloats(xml2.textContent);
1697
- switch (data.type) {
1698
- case "matrix":
1699
- data.obj = new THREE.Matrix4();
1700
- data.obj.fromArray(array).transpose();
1701
- break;
1702
- case "translate":
1703
- data.obj = new THREE.Vector3();
1704
- data.obj.fromArray(array);
1705
- break;
1706
- case "rotate":
1707
- data.obj = new THREE.Vector3();
1708
- data.obj.fromArray(array);
1709
- data.angle = THREE.MathUtils.degToRad(array[3]);
1710
- break;
1711
- }
1712
- return data;
1713
- }
1714
- function parsePhysicsModel(xml2) {
1715
- const data = {
1716
- name: xml2.getAttribute("name") || "",
1717
- rigidBodies: {}
1718
- };
1719
- for (let i = 0; i < xml2.childNodes.length; i++) {
1720
- const child = xml2.childNodes[i];
1721
- if (child.nodeType !== 1)
1722
- continue;
1723
- switch (child.nodeName) {
1724
- case "rigid_body":
1725
- data.rigidBodies[child.getAttribute("name")] = {};
1726
- parsePhysicsRigidBody(child, data.rigidBodies[child.getAttribute("name")]);
1727
- break;
1728
- }
1729
- }
1730
- library.physicsModels[xml2.getAttribute("id")] = data;
1731
- }
1732
- function parsePhysicsRigidBody(xml2, data) {
1733
- for (let i = 0; i < xml2.childNodes.length; i++) {
1734
- const child = xml2.childNodes[i];
1735
- if (child.nodeType !== 1)
1736
- continue;
1737
- switch (child.nodeName) {
1738
- case "technique_common":
1739
- parsePhysicsTechniqueCommon(child, data);
1740
- break;
1741
- }
1742
- }
1743
- }
1744
- function parsePhysicsTechniqueCommon(xml2, data) {
1745
- for (let i = 0; i < xml2.childNodes.length; i++) {
1746
- const child = xml2.childNodes[i];
1747
- if (child.nodeType !== 1)
1748
- continue;
1749
- switch (child.nodeName) {
1750
- case "inertia":
1751
- data.inertia = parseFloats(child.textContent);
1752
- break;
1753
- case "mass":
1754
- data.mass = parseFloats(child.textContent)[0];
1755
- break;
1756
- }
1757
- }
1758
- }
1759
- function parseKinematicsScene(xml2) {
1760
- const data = {
1761
- bindJointAxis: []
1762
- };
1763
- for (let i = 0; i < xml2.childNodes.length; i++) {
1764
- const child = xml2.childNodes[i];
1765
- if (child.nodeType !== 1)
1766
- continue;
1767
- switch (child.nodeName) {
1768
- case "bind_joint_axis":
1769
- data.bindJointAxis.push(parseKinematicsBindJointAxis(child));
1770
- break;
1771
- }
1772
- }
1773
- library.kinematicsScenes[parseId(xml2.getAttribute("url"))] = data;
1774
- }
1775
- function parseKinematicsBindJointAxis(xml2) {
1776
- const data = {
1777
- target: xml2.getAttribute("target").split("/").pop()
1778
- };
1779
- for (let i = 0; i < xml2.childNodes.length; i++) {
1780
- const child = xml2.childNodes[i];
1781
- if (child.nodeType !== 1)
1782
- continue;
1783
- switch (child.nodeName) {
1784
- case "axis":
1785
- const param = child.getElementsByTagName("param")[0];
1786
- data.axis = param.textContent;
1787
- const tmpJointIndex = data.axis.split("inst_").pop().split("axis")[0];
1788
- data.jointIndex = tmpJointIndex.substr(0, tmpJointIndex.length - 1);
1789
- break;
1790
- }
1791
- }
1792
- return data;
1793
- }
1794
- function buildKinematicsScene(data) {
1795
- if (data.build !== void 0)
1796
- return data.build;
1797
- return data;
1798
- }
1799
- function getKinematicsScene(id) {
1800
- return getBuild(library.kinematicsScenes[id], buildKinematicsScene);
1801
- }
1802
- function setupKinematics() {
1803
- const kinematicsModelId = Object.keys(library.kinematicsModels)[0];
1804
- const kinematicsSceneId = Object.keys(library.kinematicsScenes)[0];
1805
- const visualSceneId = Object.keys(library.visualScenes)[0];
1806
- if (kinematicsModelId === void 0 || kinematicsSceneId === void 0)
1807
- return;
1808
- const kinematicsModel = getKinematicsModel(kinematicsModelId);
1809
- const kinematicsScene = getKinematicsScene(kinematicsSceneId);
1810
- const visualScene = getVisualScene(visualSceneId);
1811
- const bindJointAxis = kinematicsScene.bindJointAxis;
1812
- const jointMap = {};
1813
- for (let i = 0, l = bindJointAxis.length; i < l; i++) {
1814
- const axis = bindJointAxis[i];
1815
- const targetElement = collada.querySelector('[sid="' + axis.target + '"]');
1816
- if (targetElement) {
1817
- const parentVisualElement = targetElement.parentElement;
1818
- connect(axis.jointIndex, parentVisualElement);
1819
- }
1820
- }
1821
- function connect(jointIndex, visualElement) {
1822
- const visualElementName = visualElement.getAttribute("name");
1823
- const joint = kinematicsModel.joints[jointIndex];
1824
- visualScene.traverse(function(object) {
1825
- if (object.name === visualElementName) {
1826
- jointMap[jointIndex] = {
1827
- object,
1828
- transforms: buildTransformList(visualElement),
1829
- joint,
1830
- position: joint.zeroPosition
1831
- };
1832
- }
1833
- });
1834
- }
1835
- const m0 = new THREE.Matrix4();
1836
- kinematics = {
1837
- joints: kinematicsModel && kinematicsModel.joints,
1838
- getJointValue: function(jointIndex) {
1839
- const jointData = jointMap[jointIndex];
1840
- if (jointData) {
1841
- return jointData.position;
1842
- } else {
1843
- console.warn("THREE.ColladaLoader: Joint " + jointIndex + " doesn't exist.");
1844
- }
1845
- },
1846
- setJointValue: function(jointIndex, value) {
1847
- const jointData = jointMap[jointIndex];
1848
- if (jointData) {
1849
- const joint = jointData.joint;
1850
- if (value > joint.limits.max || value < joint.limits.min) {
1851
- console.warn(
1852
- "THREE.ColladaLoader: Joint " + jointIndex + " value " + value + " outside of limits (min: " + joint.limits.min + ", max: " + joint.limits.max + ")."
1853
- );
1854
- } else if (joint.static) {
1855
- console.warn("THREE.ColladaLoader: Joint " + jointIndex + " is static.");
1856
- } else {
1857
- const object = jointData.object;
1858
- const axis = joint.axis;
1859
- const transforms = jointData.transforms;
1860
- matrix.identity();
1861
- for (let i = 0; i < transforms.length; i++) {
1862
- const transform = transforms[i];
1863
- if (transform.sid && transform.sid.indexOf(jointIndex) !== -1) {
1864
- switch (joint.type) {
1865
- case "revolute":
1866
- matrix.multiply(m0.makeRotationAxis(axis, THREE.MathUtils.degToRad(value)));
1867
- break;
1868
- case "prismatic":
1869
- matrix.multiply(m0.makeTranslation(axis.x * value, axis.y * value, axis.z * value));
1870
- break;
1871
- default:
1872
- console.warn("THREE.ColladaLoader: Unknown joint type: " + joint.type);
1873
- break;
1874
- }
1875
- } else {
1876
- switch (transform.type) {
1877
- case "matrix":
1878
- matrix.multiply(transform.obj);
1879
- break;
1880
- case "translate":
1881
- matrix.multiply(m0.makeTranslation(transform.obj.x, transform.obj.y, transform.obj.z));
1882
- break;
1883
- case "scale":
1884
- matrix.scale(transform.obj);
1885
- break;
1886
- case "rotate":
1887
- matrix.multiply(m0.makeRotationAxis(transform.obj, transform.angle));
1888
- break;
1889
- }
1890
- }
1891
- }
1892
- object.matrix.copy(matrix);
1893
- object.matrix.decompose(object.position, object.quaternion, object.scale);
1894
- jointMap[jointIndex].position = value;
1895
- }
1896
- } else {
1897
- console.log("THREE.ColladaLoader: " + jointIndex + " does not exist.");
1898
- }
1899
- }
1900
- };
1901
- }
1902
- function buildTransformList(node) {
1903
- const transforms = [];
1904
- const xml2 = collada.querySelector('[id="' + node.id + '"]');
1905
- for (let i = 0; i < xml2.childNodes.length; i++) {
1906
- const child = xml2.childNodes[i];
1907
- if (child.nodeType !== 1)
1908
- continue;
1909
- let array, vector2;
1910
- switch (child.nodeName) {
1911
- case "matrix":
1912
- array = parseFloats(child.textContent);
1913
- const matrix2 = new THREE.Matrix4().fromArray(array).transpose();
1914
- transforms.push({
1915
- sid: child.getAttribute("sid"),
1916
- type: child.nodeName,
1917
- obj: matrix2
1918
- });
1919
- break;
1920
- case "translate":
1921
- case "scale":
1922
- array = parseFloats(child.textContent);
1923
- vector2 = new THREE.Vector3().fromArray(array);
1924
- transforms.push({
1925
- sid: child.getAttribute("sid"),
1926
- type: child.nodeName,
1927
- obj: vector2
1928
- });
1929
- break;
1930
- case "rotate":
1931
- array = parseFloats(child.textContent);
1932
- vector2 = new THREE.Vector3().fromArray(array);
1933
- const angle = THREE.MathUtils.degToRad(array[3]);
1934
- transforms.push({
1935
- sid: child.getAttribute("sid"),
1936
- type: child.nodeName,
1937
- obj: vector2,
1938
- angle
1939
- });
1940
- break;
1941
- }
1942
- }
1943
- return transforms;
1944
- }
1945
- function prepareNodes(xml2) {
1946
- const elements = xml2.getElementsByTagName("node");
1947
- for (let i = 0; i < elements.length; i++) {
1948
- const element = elements[i];
1949
- if (element.hasAttribute("id") === false) {
1950
- element.setAttribute("id", generateId());
1951
- }
1952
- }
1953
- }
1954
- const matrix = new THREE.Matrix4();
1955
- const vector = new THREE.Vector3();
1956
- function parseNode(xml2) {
1957
- const data = {
1958
- name: xml2.getAttribute("name") || "",
1959
- type: xml2.getAttribute("type"),
1960
- id: xml2.getAttribute("id"),
1961
- sid: xml2.getAttribute("sid"),
1962
- matrix: new THREE.Matrix4(),
1963
- nodes: [],
1964
- instanceCameras: [],
1965
- instanceControllers: [],
1966
- instanceLights: [],
1967
- instanceGeometries: [],
1968
- instanceNodes: [],
1969
- transforms: {}
1970
- };
1971
- for (let i = 0; i < xml2.childNodes.length; i++) {
1972
- const child = xml2.childNodes[i];
1973
- if (child.nodeType !== 1)
1974
- continue;
1975
- let array;
1976
- switch (child.nodeName) {
1977
- case "node":
1978
- data.nodes.push(child.getAttribute("id"));
1979
- parseNode(child);
1980
- break;
1981
- case "instance_camera":
1982
- data.instanceCameras.push(parseId(child.getAttribute("url")));
1983
- break;
1984
- case "instance_controller":
1985
- data.instanceControllers.push(parseNodeInstance(child));
1986
- break;
1987
- case "instance_light":
1988
- data.instanceLights.push(parseId(child.getAttribute("url")));
1989
- break;
1990
- case "instance_geometry":
1991
- data.instanceGeometries.push(parseNodeInstance(child));
1992
- break;
1993
- case "instance_node":
1994
- data.instanceNodes.push(parseId(child.getAttribute("url")));
1995
- break;
1996
- case "matrix":
1997
- array = parseFloats(child.textContent);
1998
- data.matrix.multiply(matrix.fromArray(array).transpose());
1999
- data.transforms[child.getAttribute("sid")] = child.nodeName;
2000
- break;
2001
- case "translate":
2002
- array = parseFloats(child.textContent);
2003
- vector.fromArray(array);
2004
- data.matrix.multiply(matrix.makeTranslation(vector.x, vector.y, vector.z));
2005
- data.transforms[child.getAttribute("sid")] = child.nodeName;
2006
- break;
2007
- case "rotate":
2008
- array = parseFloats(child.textContent);
2009
- const angle = THREE.MathUtils.degToRad(array[3]);
2010
- data.matrix.multiply(matrix.makeRotationAxis(vector.fromArray(array), angle));
2011
- data.transforms[child.getAttribute("sid")] = child.nodeName;
2012
- break;
2013
- case "scale":
2014
- array = parseFloats(child.textContent);
2015
- data.matrix.scale(vector.fromArray(array));
2016
- data.transforms[child.getAttribute("sid")] = child.nodeName;
2017
- break;
2018
- case "extra":
2019
- break;
2020
- default:
2021
- console.log(child);
2022
- }
2023
- }
2024
- if (hasNode(data.id)) {
2025
- console.warn(
2026
- "THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",
2027
- data.id
2028
- );
2029
- } else {
2030
- library.nodes[data.id] = data;
2031
- }
2032
- return data;
2033
- }
2034
- function parseNodeInstance(xml2) {
2035
- const data = {
2036
- id: parseId(xml2.getAttribute("url")),
2037
- materials: {},
2038
- skeletons: []
2039
- };
2040
- for (let i = 0; i < xml2.childNodes.length; i++) {
2041
- const child = xml2.childNodes[i];
2042
- switch (child.nodeName) {
2043
- case "bind_material":
2044
- const instances = child.getElementsByTagName("instance_material");
2045
- for (let j = 0; j < instances.length; j++) {
2046
- const instance = instances[j];
2047
- const symbol = instance.getAttribute("symbol");
2048
- const target = instance.getAttribute("target");
2049
- data.materials[symbol] = parseId(target);
2050
- }
2051
- break;
2052
- case "skeleton":
2053
- data.skeletons.push(parseId(child.textContent));
2054
- break;
2055
- default:
2056
- break;
2057
- }
2058
- }
2059
- return data;
2060
- }
2061
- function buildSkeleton(skeletons, joints) {
2062
- const boneData = [];
2063
- const sortedBoneData = [];
2064
- let i, j, data;
2065
- for (i = 0; i < skeletons.length; i++) {
2066
- const skeleton = skeletons[i];
2067
- let root;
2068
- if (hasNode(skeleton)) {
2069
- root = getNode(skeleton);
2070
- buildBoneHierarchy(root, joints, boneData);
2071
- } else if (hasVisualScene(skeleton)) {
2072
- const visualScene = library.visualScenes[skeleton];
2073
- const children = visualScene.children;
2074
- for (let j2 = 0; j2 < children.length; j2++) {
2075
- const child = children[j2];
2076
- if (child.type === "JOINT") {
2077
- const root2 = getNode(child.id);
2078
- buildBoneHierarchy(root2, joints, boneData);
2079
- }
2080
- }
2081
- } else {
2082
- console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:", skeleton);
2083
- }
2084
- }
2085
- for (i = 0; i < joints.length; i++) {
2086
- for (j = 0; j < boneData.length; j++) {
2087
- data = boneData[j];
2088
- if (data.bone.name === joints[i].name) {
2089
- sortedBoneData[i] = data;
2090
- data.processed = true;
2091
- break;
2092
- }
2093
- }
2094
- }
2095
- for (i = 0; i < boneData.length; i++) {
2096
- data = boneData[i];
2097
- if (data.processed === false) {
2098
- sortedBoneData.push(data);
2099
- data.processed = true;
2100
- }
2101
- }
2102
- const bones = [];
2103
- const boneInverses = [];
2104
- for (i = 0; i < sortedBoneData.length; i++) {
2105
- data = sortedBoneData[i];
2106
- bones.push(data.bone);
2107
- boneInverses.push(data.boneInverse);
2108
- }
2109
- return new THREE.Skeleton(bones, boneInverses);
2110
- }
2111
- function buildBoneHierarchy(root, joints, boneData) {
2112
- root.traverse(function(object) {
2113
- if (object.isBone === true) {
2114
- let boneInverse;
2115
- for (let i = 0; i < joints.length; i++) {
2116
- const joint = joints[i];
2117
- if (joint.name === object.name) {
2118
- boneInverse = joint.boneInverse;
2119
- break;
2120
- }
2121
- }
2122
- if (boneInverse === void 0) {
2123
- boneInverse = new THREE.Matrix4();
2124
- }
2125
- boneData.push({ bone: object, boneInverse, processed: false });
2126
- }
2127
- });
2128
- }
2129
- function buildNode(data) {
2130
- const objects = [];
2131
- const matrix2 = data.matrix;
2132
- const nodes = data.nodes;
2133
- const type = data.type;
2134
- const instanceCameras = data.instanceCameras;
2135
- const instanceControllers = data.instanceControllers;
2136
- const instanceLights = data.instanceLights;
2137
- const instanceGeometries = data.instanceGeometries;
2138
- const instanceNodes = data.instanceNodes;
2139
- for (let i = 0, l = nodes.length; i < l; i++) {
2140
- objects.push(getNode(nodes[i]));
2141
- }
2142
- for (let i = 0, l = instanceCameras.length; i < l; i++) {
2143
- const instanceCamera = getCamera(instanceCameras[i]);
2144
- if (instanceCamera !== null) {
2145
- objects.push(instanceCamera.clone());
2146
- }
2147
- }
2148
- for (let i = 0, l = instanceControllers.length; i < l; i++) {
2149
- const instance = instanceControllers[i];
2150
- const controller = getController(instance.id);
2151
- const geometries = getGeometry(controller.id);
2152
- const newObjects = buildObjects(geometries, instance.materials);
2153
- const skeletons = instance.skeletons;
2154
- const joints = controller.skin.joints;
2155
- const skeleton = buildSkeleton(skeletons, joints);
2156
- for (let j = 0, jl = newObjects.length; j < jl; j++) {
2157
- const object2 = newObjects[j];
2158
- if (object2.isSkinnedMesh) {
2159
- object2.bind(skeleton, controller.skin.bindMatrix);
2160
- object2.normalizeSkinWeights();
2161
- }
2162
- objects.push(object2);
2163
- }
2164
- }
2165
- for (let i = 0, l = instanceLights.length; i < l; i++) {
2166
- const instanceLight = getLight(instanceLights[i]);
2167
- if (instanceLight !== null) {
2168
- objects.push(instanceLight.clone());
2169
- }
2170
- }
2171
- for (let i = 0, l = instanceGeometries.length; i < l; i++) {
2172
- const instance = instanceGeometries[i];
2173
- const geometries = getGeometry(instance.id);
2174
- const newObjects = buildObjects(geometries, instance.materials);
2175
- for (let j = 0, jl = newObjects.length; j < jl; j++) {
2176
- objects.push(newObjects[j]);
2177
- }
2178
- }
2179
- for (let i = 0, l = instanceNodes.length; i < l; i++) {
2180
- objects.push(getNode(instanceNodes[i]).clone());
2181
- }
2182
- let object;
2183
- if (nodes.length === 0 && objects.length === 1) {
2184
- object = objects[0];
2185
- } else {
2186
- object = type === "JOINT" ? new THREE.Bone() : new THREE.Group();
2187
- for (let i = 0; i < objects.length; i++) {
2188
- object.add(objects[i]);
2189
- }
2190
- }
2191
- object.name = type === "JOINT" ? data.sid : data.name;
2192
- object.matrix.copy(matrix2);
2193
- object.matrix.decompose(object.position, object.quaternion, object.scale);
2194
- return object;
2195
- }
2196
- const fallbackMaterial = new THREE.MeshBasicMaterial({ color: 16711935 });
2197
- function resolveMaterialBinding(keys, instanceMaterials) {
2198
- const materials = [];
2199
- for (let i = 0, l = keys.length; i < l; i++) {
2200
- const id = instanceMaterials[keys[i]];
2201
- if (id === void 0) {
2202
- console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.", keys[i]);
2203
- materials.push(fallbackMaterial);
2204
- } else {
2205
- materials.push(getMaterial(id));
2206
- }
2207
- }
2208
- return materials;
2209
- }
2210
- function buildObjects(geometries, instanceMaterials) {
2211
- const objects = [];
2212
- for (const type in geometries) {
2213
- const geometry = geometries[type];
2214
- const materials = resolveMaterialBinding(geometry.materialKeys, instanceMaterials);
2215
- if (materials.length === 0) {
2216
- if (type === "lines" || type === "linestrips") {
2217
- materials.push(new THREE.LineBasicMaterial());
2218
- } else {
2219
- materials.push(new THREE.MeshPhongMaterial());
2220
- }
2221
- }
2222
- const skinning = geometry.data.attributes.skinIndex !== void 0;
2223
- const material = materials.length === 1 ? materials[0] : materials;
2224
- let object;
2225
- switch (type) {
2226
- case "lines":
2227
- object = new THREE.LineSegments(geometry.data, material);
2228
- break;
2229
- case "linestrips":
2230
- object = new THREE.Line(geometry.data, material);
2231
- break;
2232
- case "triangles":
2233
- case "polylist":
2234
- if (skinning) {
2235
- object = new THREE.SkinnedMesh(geometry.data, material);
2236
- } else {
2237
- object = new THREE.Mesh(geometry.data, material);
2238
- }
2239
- break;
2240
- }
2241
- objects.push(object);
2242
- }
2243
- return objects;
2244
- }
2245
- function hasNode(id) {
2246
- return library.nodes[id] !== void 0;
2247
- }
2248
- function getNode(id) {
2249
- return getBuild(library.nodes[id], buildNode);
2250
- }
2251
- function parseVisualScene(xml2) {
2252
- const data = {
2253
- name: xml2.getAttribute("name"),
2254
- children: []
2255
- };
2256
- prepareNodes(xml2);
2257
- const elements = getElementsByTagName(xml2, "node");
2258
- for (let i = 0; i < elements.length; i++) {
2259
- data.children.push(parseNode(elements[i]));
2260
- }
2261
- library.visualScenes[xml2.getAttribute("id")] = data;
2262
- }
2263
- function buildVisualScene(data) {
2264
- const group = new THREE.Group();
2265
- group.name = data.name;
2266
- const children = data.children;
2267
- for (let i = 0; i < children.length; i++) {
2268
- const child = children[i];
2269
- group.add(getNode(child.id));
2270
- }
2271
- return group;
2272
- }
2273
- function hasVisualScene(id) {
2274
- return library.visualScenes[id] !== void 0;
2275
- }
2276
- function getVisualScene(id) {
2277
- return getBuild(library.visualScenes[id], buildVisualScene);
2278
- }
2279
- function parseScene(xml2) {
2280
- const instance = getElementsByTagName(xml2, "instance_visual_scene")[0];
2281
- return getVisualScene(parseId(instance.getAttribute("url")));
2282
- }
2283
- function setupAnimations() {
2284
- const clips = library.clips;
2285
- if (isEmpty(clips) === true) {
2286
- if (isEmpty(library.animations) === false) {
2287
- const tracks = [];
2288
- for (const id in library.animations) {
2289
- const animationTracks = getAnimation(id);
2290
- for (let i = 0, l = animationTracks.length; i < l; i++) {
2291
- tracks.push(animationTracks[i]);
2292
- }
2293
- }
2294
- animations.push(new THREE.AnimationClip("default", -1, tracks));
2295
- }
2296
- } else {
2297
- for (const id in clips) {
2298
- animations.push(getAnimationClip(id));
2299
- }
2300
- }
2301
- }
2302
- function parserErrorToText(parserError2) {
2303
- let result = "";
2304
- const stack = [parserError2];
2305
- while (stack.length) {
2306
- const node = stack.shift();
2307
- if (node.nodeType === Node.TEXT_NODE) {
2308
- result += node.textContent;
2309
- } else {
2310
- result += "\n";
2311
- stack.push.apply(stack, node.childNodes);
2312
- }
2313
- }
2314
- return result.trim();
2315
- }
2316
- if (text.length === 0) {
2317
- return { scene: new THREE.Scene() };
2318
- }
2319
- const xml = new DOMParser().parseFromString(text, "application/xml");
2320
- const collada = getElementsByTagName(xml, "COLLADA")[0];
2321
- const parserError = xml.getElementsByTagName("parsererror")[0];
2322
- if (parserError !== void 0) {
2323
- const errorElement = getElementsByTagName(parserError, "div")[0];
2324
- let errorText;
2325
- if (errorElement) {
2326
- errorText = errorElement.textContent;
2327
- } else {
2328
- errorText = parserErrorToText(parserError);
2329
- }
2330
- console.error("THREE.ColladaLoader: Failed to parse collada file.\n", errorText);
2331
- return null;
2332
- }
2333
- const version = collada.getAttribute("version");
2334
- console.log("THREE.ColladaLoader: File version", version);
2335
- const asset = parseAsset(getElementsByTagName(collada, "asset")[0]);
2336
- const textureLoader = new THREE.TextureLoader(this.manager);
2337
- textureLoader.setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
2338
- let tgaLoader;
2339
- if (TGALoader.TGALoader) {
2340
- tgaLoader = new TGALoader.TGALoader(this.manager);
2341
- tgaLoader.setPath(this.resourcePath || path);
2342
- }
2343
- const animations = [];
2344
- let kinematics = {};
2345
- let count = 0;
2346
- const library = {
2347
- animations: {},
2348
- clips: {},
2349
- controllers: {},
2350
- images: {},
2351
- effects: {},
2352
- materials: {},
2353
- cameras: {},
2354
- lights: {},
2355
- geometries: {},
2356
- nodes: {},
2357
- visualScenes: {},
2358
- kinematicsModels: {},
2359
- physicsModels: {},
2360
- kinematicsScenes: {}
2361
- };
2362
- parseLibrary(collada, "library_animations", "animation", parseAnimation);
2363
- parseLibrary(collada, "library_animation_clips", "animation_clip", parseAnimationClip);
2364
- parseLibrary(collada, "library_controllers", "controller", parseController);
2365
- parseLibrary(collada, "library_images", "image", parseImage);
2366
- parseLibrary(collada, "library_effects", "effect", parseEffect);
2367
- parseLibrary(collada, "library_materials", "material", parseMaterial);
2368
- parseLibrary(collada, "library_cameras", "camera", parseCamera);
2369
- parseLibrary(collada, "library_lights", "light", parseLight);
2370
- parseLibrary(collada, "library_geometries", "geometry", parseGeometry);
2371
- parseLibrary(collada, "library_nodes", "node", parseNode);
2372
- parseLibrary(collada, "library_visual_scenes", "visual_scene", parseVisualScene);
2373
- parseLibrary(collada, "library_kinematics_models", "kinematics_model", parseKinematicsModel);
2374
- parseLibrary(collada, "library_physics_models", "physics_model", parsePhysicsModel);
2375
- parseLibrary(collada, "scene", "instance_kinematics_scene", parseKinematicsScene);
2376
- buildLibrary(library.animations, buildAnimation);
2377
- buildLibrary(library.clips, buildAnimationClip);
2378
- buildLibrary(library.controllers, buildController);
2379
- buildLibrary(library.images, buildImage);
2380
- buildLibrary(library.effects, buildEffect);
2381
- buildLibrary(library.materials, buildMaterial);
2382
- buildLibrary(library.cameras, buildCamera);
2383
- buildLibrary(library.lights, buildLight);
2384
- buildLibrary(library.geometries, buildGeometry);
2385
- buildLibrary(library.visualScenes, buildVisualScene);
2386
- setupAnimations();
2387
- setupKinematics();
2388
- const scene = parseScene(getElementsByTagName(collada, "scene")[0]);
2389
- scene.animations = animations;
2390
- if (asset.upAxis === "Z_UP") {
2391
- scene.quaternion.setFromEuler(new THREE.Euler(-Math.PI / 2, 0, 0));
2392
- }
2393
- scene.scale.multiplyScalar(asset.unit);
2394
- return {
2395
- get animations() {
2396
- console.warn("THREE.ColladaLoader: Please access animations over scene.animations now.");
2397
- return animations;
2398
- },
2399
- kinematics,
2400
- library,
2401
- scene
2402
- };
2403
- }
2404
- }
2405
- exports.ColladaLoader = ColladaLoader;