opal-js_wrap-three 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +4 -4
  4. data/lib/opal/js_wrap/three/version.rb +1 -1
  5. data/lib-opal/js_wrap/three/WebGL.js +102 -0
  6. data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
  7. data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
  8. data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
  9. data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
  10. data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
  11. data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
  12. data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
  13. data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
  14. data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
  15. data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
  16. data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
  17. data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
  18. data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
  19. data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
  20. data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
  21. data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
  22. data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
  23. data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
  24. data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
  25. data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
  26. data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
  27. data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
  28. data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
  29. data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
  30. data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
  31. data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
  32. data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
  33. data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
  34. data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
  35. data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
  36. data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
  37. data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
  38. data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
  39. data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
  40. data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
  41. data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
  42. data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
  43. data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
  44. data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
  45. data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
  46. data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
  47. data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
  48. data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
  49. data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
  50. data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
  51. data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
  52. data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
  53. data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
  54. data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
  55. data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
  56. data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
  57. data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
  58. data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
  59. data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
  60. data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
  61. data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
  62. data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
  63. data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
  64. data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
  65. data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
  66. data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
  67. data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
  68. data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
  69. data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
  70. data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
  71. data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
  72. data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
  73. data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
  74. data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
  75. data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
  76. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
  77. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
  78. data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
  79. data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
  80. data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
  81. data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
  82. data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
  83. data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
  84. data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
  85. data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
  86. data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
  87. data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
  88. data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
  89. data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
  90. data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
  91. data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
  92. data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
  93. data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
  94. data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
  95. data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
  96. data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
  97. data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
  98. data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
  99. data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
  100. data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
  101. data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
  102. data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
  103. data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
  104. data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
  105. data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
  106. data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
  107. data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
  108. data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
  109. data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
  110. data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
  111. data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
  112. data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
  113. data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
  114. data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
  115. data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
  116. data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
  117. data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
  118. data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
  119. data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
  120. data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
  121. data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
  122. data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
  123. data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
  124. data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
  125. data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
  126. data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
  127. data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
  128. data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
  129. data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
  130. data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
  131. data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
  132. data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
  133. data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
  134. data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
  135. data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
  136. data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
  137. data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
  138. data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
  139. data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
  140. data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
  141. data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
  142. data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
  143. data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
  144. data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
  145. data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
  146. data/lib-opal/js_wrap/three/math/Lut.js +170 -0
  147. data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
  148. data/lib-opal/js_wrap/three/math/OBB.js +345 -0
  149. data/lib-opal/js_wrap/three/math/Octree.js +409 -0
  150. data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
  151. data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
  152. data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
  153. data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
  154. data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
  155. data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
  156. data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
  157. data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
  158. data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
  159. data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
  160. data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
  161. data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
  162. data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
  163. data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
  164. data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
  165. data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
  166. data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
  167. data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
  168. data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
  169. data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
  170. data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
  171. data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
  172. data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
  173. data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
  174. data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
  175. data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
  176. data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
  177. data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
  178. data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
  179. data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
  180. data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
  181. data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
  182. data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
  183. data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
  184. data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
  185. data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
  186. data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
  187. data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
  188. data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
  189. data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
  190. data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
  191. data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
  192. data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
  193. data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
  194. data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
  195. data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
  196. data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
  197. data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
  198. data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
  199. data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
  200. data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
  201. data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
  202. data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
  203. data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
  204. data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
  205. data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
  206. data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
  207. data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
  208. data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
  209. data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
  210. data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
  211. data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
  212. data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
  213. data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
  214. data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
  215. data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
  216. data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
  217. data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
  218. data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
  219. data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
  220. data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
  221. data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
  222. data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
  223. data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
  224. data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
  225. data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
  226. data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
  227. data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
  228. data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
  229. data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
  230. data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
  231. data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
  232. data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
  233. data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
  234. data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
  235. data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
  236. data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
  237. data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
  238. data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
  239. data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
  240. data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
  241. data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
  242. data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
  243. data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
  244. data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
  245. data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
  246. data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
  247. data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
  248. data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
  249. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
  250. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
  251. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
  252. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
  253. data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
  254. data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
  255. data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
  256. data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
  257. data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
  258. data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
  259. data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
  260. data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
  261. data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
  262. data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
  263. data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
  264. data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
  265. data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
  266. data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
  267. data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
  268. data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
  269. data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
  270. data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
  271. data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
  272. data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
  273. data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
  274. data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
  275. data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
  276. data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
  277. data/lib-opal/js_wrap/three/objects/Water.js +246 -0
  278. data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
  279. data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
  280. data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
  281. data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
  282. data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
  283. data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
  284. data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
  285. data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
  286. data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
  287. data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
  288. data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
  289. data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
  290. data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
  291. data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
  292. data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
  293. data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
  294. data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
  295. data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
  296. data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
  297. data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
  298. data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
  299. data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
  300. data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
  301. data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
  302. data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
  303. data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
  304. data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
  305. data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
  306. data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
  307. data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
  308. data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
  309. data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
  310. data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
  311. data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
  312. data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
  313. data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
  314. data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
  315. data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
  316. data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
  317. data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
  318. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
  319. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
  320. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
  321. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
  322. data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
  323. data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
  324. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
  325. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
  326. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
  327. data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
  328. data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
  329. data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
  330. data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
  331. data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
  332. data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
  333. data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
  334. data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
  335. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
  336. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
  337. data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
  338. data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
  339. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
  340. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
  341. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
  342. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
  343. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
  344. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
  345. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
  346. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
  347. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
  348. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
  349. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
  350. data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
  351. data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
  352. data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
  353. data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
  354. data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
  355. data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
  356. data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
  357. data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
  358. data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
  359. data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
  360. data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
  361. data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
  362. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
  363. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
  364. data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
  365. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
  366. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
  367. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
  368. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
  369. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
  370. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
  371. data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
  372. data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
  373. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
  374. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
  375. data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
  376. data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
  377. data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
  378. data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
  379. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
  380. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
  381. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
  382. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
  383. data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
  384. data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
  385. data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
  386. data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
  387. data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
  388. data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
  389. data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
  390. data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
  391. data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
  392. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
  393. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
  394. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
  395. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
  396. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
  397. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
  398. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
  399. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
  400. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
  401. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
  402. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
  403. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
  404. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
  405. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
  406. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
  407. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
  408. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
  409. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
  410. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
  411. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
  412. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
  413. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
  414. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
  415. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
  416. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
  417. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
  418. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
  419. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
  420. data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
  421. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
  422. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
  423. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
  424. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
  425. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
  426. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
  427. data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
  428. data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
  429. data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
  430. data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
  431. data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
  432. data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
  433. data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
  434. data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
  435. data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
  436. data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
  437. data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
  438. data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
  439. data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
  440. data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
  441. data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
  442. data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
  443. data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
  444. data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
  445. data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
  446. data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
  447. data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
  448. data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
  449. data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
  450. data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
  451. data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
  452. data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
  453. data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
  454. data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
  455. data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
  456. data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
  457. data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
  458. data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
  459. data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
  460. data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
  461. data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
  462. data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
  463. data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
  464. data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
  465. data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
  466. data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
  467. data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
  468. data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
  469. data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
  470. data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
  471. data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
  472. data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
  473. data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
  474. data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
  475. data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
  476. data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
  477. data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
  478. data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
  479. data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
  480. data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
  481. data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
  482. data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
  483. data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
  484. data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
  485. data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
  486. data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
  487. data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
  488. data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
  489. data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
  490. data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
  491. data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
  492. data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
  493. data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
  494. data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
  495. data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
  496. data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
  497. data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
  498. data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
  499. data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
  500. data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
  501. data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
  502. data/opal-js_wrap-three.gemspec +4 -4
  503. metadata +502 -5
@@ -0,0 +1,3046 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "three", "../loaders/TGALoader.js"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("three"), require("../loaders/TGALoader.js"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.three, global.TGALoader);
11
+ global.ColladaLoader = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three, _TGALoader) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.ColladaLoader = void 0;
20
+
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24
+
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+
27
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
28
+
29
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+
31
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
32
+
33
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
34
+
35
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
36
+
37
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
38
+
39
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+
41
+ var ColladaLoader = /*#__PURE__*/function (_Loader) {
42
+ _inherits(ColladaLoader, _Loader);
43
+
44
+ var _super = _createSuper(ColladaLoader);
45
+
46
+ function ColladaLoader(manager) {
47
+ _classCallCheck(this, ColladaLoader);
48
+
49
+ return _super.call(this, manager);
50
+ }
51
+
52
+ _createClass(ColladaLoader, [{
53
+ key: "load",
54
+ value: function load(url, onLoad, onProgress, onError) {
55
+ var scope = this;
56
+ var path = scope.path === '' ? _three.LoaderUtils.extractUrlBase(url) : scope.path;
57
+ var loader = new _three.FileLoader(scope.manager);
58
+ loader.setPath(scope.path);
59
+ loader.setRequestHeader(scope.requestHeader);
60
+ loader.setWithCredentials(scope.withCredentials);
61
+ loader.load(url, function (text) {
62
+ try {
63
+ onLoad(scope.parse(text, path));
64
+ } catch (e) {
65
+ if (onError) {
66
+ onError(e);
67
+ } else {
68
+ console.error(e);
69
+ }
70
+
71
+ scope.manager.itemError(url);
72
+ }
73
+ }, onProgress, onError);
74
+ }
75
+ }, {
76
+ key: "parse",
77
+ value: function parse(text, path) {
78
+ function getElementsByTagName(xml, name) {
79
+ // Non recursive xml.getElementsByTagName() ...
80
+ var array = [];
81
+ var childNodes = xml.childNodes;
82
+
83
+ for (var i = 0, l = childNodes.length; i < l; i++) {
84
+ var child = childNodes[i];
85
+
86
+ if (child.nodeName === name) {
87
+ array.push(child);
88
+ }
89
+ }
90
+
91
+ return array;
92
+ }
93
+
94
+ function parseStrings(text) {
95
+ if (text.length === 0) return [];
96
+ var parts = text.trim().split(/\s+/);
97
+ var array = new Array(parts.length);
98
+
99
+ for (var i = 0, l = parts.length; i < l; i++) {
100
+ array[i] = parts[i];
101
+ }
102
+
103
+ return array;
104
+ }
105
+
106
+ function parseFloats(text) {
107
+ if (text.length === 0) return [];
108
+ var parts = text.trim().split(/\s+/);
109
+ var array = new Array(parts.length);
110
+
111
+ for (var i = 0, l = parts.length; i < l; i++) {
112
+ array[i] = parseFloat(parts[i]);
113
+ }
114
+
115
+ return array;
116
+ }
117
+
118
+ function parseInts(text) {
119
+ if (text.length === 0) return [];
120
+ var parts = text.trim().split(/\s+/);
121
+ var array = new Array(parts.length);
122
+
123
+ for (var i = 0, l = parts.length; i < l; i++) {
124
+ array[i] = parseInt(parts[i]);
125
+ }
126
+
127
+ return array;
128
+ }
129
+
130
+ function parseId(text) {
131
+ return text.substring(1);
132
+ }
133
+
134
+ function generateId() {
135
+ return 'three_default_' + count++;
136
+ }
137
+
138
+ function isEmpty(object) {
139
+ return Object.keys(object).length === 0;
140
+ } // asset
141
+
142
+
143
+ function parseAsset(xml) {
144
+ return {
145
+ unit: parseAssetUnit(getElementsByTagName(xml, 'unit')[0]),
146
+ upAxis: parseAssetUpAxis(getElementsByTagName(xml, 'up_axis')[0])
147
+ };
148
+ }
149
+
150
+ function parseAssetUnit(xml) {
151
+ if (xml !== undefined && xml.hasAttribute('meter') === true) {
152
+ return parseFloat(xml.getAttribute('meter'));
153
+ } else {
154
+ return 1; // default 1 meter
155
+ }
156
+ }
157
+
158
+ function parseAssetUpAxis(xml) {
159
+ return xml !== undefined ? xml.textContent : 'Y_UP';
160
+ } // library
161
+
162
+
163
+ function parseLibrary(xml, libraryName, nodeName, parser) {
164
+ var library = getElementsByTagName(xml, libraryName)[0];
165
+
166
+ if (library !== undefined) {
167
+ var elements = getElementsByTagName(library, nodeName);
168
+
169
+ for (var i = 0; i < elements.length; i++) {
170
+ parser(elements[i]);
171
+ }
172
+ }
173
+ }
174
+
175
+ function buildLibrary(data, builder) {
176
+ for (var name in data) {
177
+ var object = data[name];
178
+ object.build = builder(data[name]);
179
+ }
180
+ } // get
181
+
182
+
183
+ function getBuild(data, builder) {
184
+ if (data.build !== undefined) return data.build;
185
+ data.build = builder(data);
186
+ return data.build;
187
+ } // animation
188
+
189
+
190
+ function parseAnimation(xml) {
191
+ var data = {
192
+ sources: {},
193
+ samplers: {},
194
+ channels: {}
195
+ };
196
+ var hasChildren = false;
197
+
198
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
199
+ var child = xml.childNodes[i];
200
+ if (child.nodeType !== 1) continue;
201
+ var id = void 0;
202
+
203
+ switch (child.nodeName) {
204
+ case 'source':
205
+ id = child.getAttribute('id');
206
+ data.sources[id] = parseSource(child);
207
+ break;
208
+
209
+ case 'sampler':
210
+ id = child.getAttribute('id');
211
+ data.samplers[id] = parseAnimationSampler(child);
212
+ break;
213
+
214
+ case 'channel':
215
+ id = child.getAttribute('target');
216
+ data.channels[id] = parseAnimationChannel(child);
217
+ break;
218
+
219
+ case 'animation':
220
+ // hierarchy of related animations
221
+ parseAnimation(child);
222
+ hasChildren = true;
223
+ break;
224
+
225
+ default:
226
+ console.log(child);
227
+ }
228
+ }
229
+
230
+ if (hasChildren === false) {
231
+ // since 'id' attributes can be optional, it's necessary to generate a UUID for unqiue assignment
232
+ library.animations[xml.getAttribute('id') || _three.MathUtils.generateUUID()] = data;
233
+ }
234
+ }
235
+
236
+ function parseAnimationSampler(xml) {
237
+ var data = {
238
+ inputs: {}
239
+ };
240
+
241
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
242
+ var child = xml.childNodes[i];
243
+ if (child.nodeType !== 1) continue;
244
+
245
+ switch (child.nodeName) {
246
+ case 'input':
247
+ var id = parseId(child.getAttribute('source'));
248
+ var semantic = child.getAttribute('semantic');
249
+ data.inputs[semantic] = id;
250
+ break;
251
+ }
252
+ }
253
+
254
+ return data;
255
+ }
256
+
257
+ function parseAnimationChannel(xml) {
258
+ var data = {};
259
+ var target = xml.getAttribute('target'); // parsing SID Addressing Syntax
260
+
261
+ var parts = target.split('/');
262
+ var id = parts.shift();
263
+ var sid = parts.shift(); // check selection syntax
264
+
265
+ var arraySyntax = sid.indexOf('(') !== -1;
266
+ var memberSyntax = sid.indexOf('.') !== -1;
267
+
268
+ if (memberSyntax) {
269
+ // member selection access
270
+ parts = sid.split('.');
271
+ sid = parts.shift();
272
+ data.member = parts.shift();
273
+ } else if (arraySyntax) {
274
+ // array-access syntax. can be used to express fields in one-dimensional vectors or two-dimensional matrices.
275
+ var indices = sid.split('(');
276
+ sid = indices.shift();
277
+
278
+ for (var i = 0; i < indices.length; i++) {
279
+ indices[i] = parseInt(indices[i].replace(/\)/, ''));
280
+ }
281
+
282
+ data.indices = indices;
283
+ }
284
+
285
+ data.id = id;
286
+ data.sid = sid;
287
+ data.arraySyntax = arraySyntax;
288
+ data.memberSyntax = memberSyntax;
289
+ data.sampler = parseId(xml.getAttribute('source'));
290
+ return data;
291
+ }
292
+
293
+ function buildAnimation(data) {
294
+ var tracks = [];
295
+ var channels = data.channels;
296
+ var samplers = data.samplers;
297
+ var sources = data.sources;
298
+
299
+ for (var target in channels) {
300
+ if (channels.hasOwnProperty(target)) {
301
+ var channel = channels[target];
302
+ var sampler = samplers[channel.sampler];
303
+ var inputId = sampler.inputs.INPUT;
304
+ var outputId = sampler.inputs.OUTPUT;
305
+ var inputSource = sources[inputId];
306
+ var outputSource = sources[outputId];
307
+ var animation = buildAnimationChannel(channel, inputSource, outputSource);
308
+ createKeyframeTracks(animation, tracks);
309
+ }
310
+ }
311
+
312
+ return tracks;
313
+ }
314
+
315
+ function getAnimation(id) {
316
+ return getBuild(library.animations[id], buildAnimation);
317
+ }
318
+
319
+ function buildAnimationChannel(channel, inputSource, outputSource) {
320
+ var node = library.nodes[channel.id];
321
+ var object3D = getNode(node.id);
322
+ var transform = node.transforms[channel.sid];
323
+ var defaultMatrix = node.matrix.clone().transpose();
324
+ var time, stride;
325
+ var i, il, j, jl;
326
+ var data = {}; // the collada spec allows the animation of data in various ways.
327
+ // depending on the transform type (matrix, translate, rotate, scale), we execute different logic
328
+
329
+ switch (transform) {
330
+ case 'matrix':
331
+ for (i = 0, il = inputSource.array.length; i < il; i++) {
332
+ time = inputSource.array[i];
333
+ stride = i * outputSource.stride;
334
+ if (data[time] === undefined) data[time] = {};
335
+
336
+ if (channel.arraySyntax === true) {
337
+ var value = outputSource.array[stride];
338
+ var index = channel.indices[0] + 4 * channel.indices[1];
339
+ data[time][index] = value;
340
+ } else {
341
+ for (j = 0, jl = outputSource.stride; j < jl; j++) {
342
+ data[time][j] = outputSource.array[stride + j];
343
+ }
344
+ }
345
+ }
346
+
347
+ break;
348
+
349
+ case 'translate':
350
+ console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform);
351
+ break;
352
+
353
+ case 'rotate':
354
+ console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform);
355
+ break;
356
+
357
+ case 'scale':
358
+ console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform);
359
+ break;
360
+ }
361
+
362
+ var keyframes = prepareAnimationData(data, defaultMatrix);
363
+ var animation = {
364
+ name: object3D.uuid,
365
+ keyframes: keyframes
366
+ };
367
+ return animation;
368
+ }
369
+
370
+ function prepareAnimationData(data, defaultMatrix) {
371
+ var keyframes = []; // transfer data into a sortable array
372
+
373
+ for (var time in data) {
374
+ keyframes.push({
375
+ time: parseFloat(time),
376
+ value: data[time]
377
+ });
378
+ } // ensure keyframes are sorted by time
379
+
380
+
381
+ keyframes.sort(ascending); // now we clean up all animation data, so we can use them for keyframe tracks
382
+
383
+ for (var i = 0; i < 16; i++) {
384
+ transformAnimationData(keyframes, i, defaultMatrix.elements[i]);
385
+ }
386
+
387
+ return keyframes; // array sort function
388
+
389
+ function ascending(a, b) {
390
+ return a.time - b.time;
391
+ }
392
+ }
393
+
394
+ var position = new _three.Vector3();
395
+ var scale = new _three.Vector3();
396
+ var quaternion = new _three.Quaternion();
397
+
398
+ function createKeyframeTracks(animation, tracks) {
399
+ var keyframes = animation.keyframes;
400
+ var name = animation.name;
401
+ var times = [];
402
+ var positionData = [];
403
+ var quaternionData = [];
404
+ var scaleData = [];
405
+
406
+ for (var i = 0, l = keyframes.length; i < l; i++) {
407
+ var keyframe = keyframes[i];
408
+ var time = keyframe.time;
409
+ var value = keyframe.value;
410
+ matrix.fromArray(value).transpose();
411
+ matrix.decompose(position, quaternion, scale);
412
+ times.push(time);
413
+ positionData.push(position.x, position.y, position.z);
414
+ quaternionData.push(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
415
+ scaleData.push(scale.x, scale.y, scale.z);
416
+ }
417
+
418
+ if (positionData.length > 0) tracks.push(new _three.VectorKeyframeTrack(name + '.position', times, positionData));
419
+ if (quaternionData.length > 0) tracks.push(new _three.QuaternionKeyframeTrack(name + '.quaternion', times, quaternionData));
420
+ if (scaleData.length > 0) tracks.push(new _three.VectorKeyframeTrack(name + '.scale', times, scaleData));
421
+ return tracks;
422
+ }
423
+
424
+ function transformAnimationData(keyframes, property, defaultValue) {
425
+ var keyframe;
426
+ var empty = true;
427
+ var i, l; // check, if values of a property are missing in our keyframes
428
+
429
+ for (i = 0, l = keyframes.length; i < l; i++) {
430
+ keyframe = keyframes[i];
431
+
432
+ if (keyframe.value[property] === undefined) {
433
+ keyframe.value[property] = null; // mark as missing
434
+ } else {
435
+ empty = false;
436
+ }
437
+ }
438
+
439
+ if (empty === true) {
440
+ // no values at all, so we set a default value
441
+ for (i = 0, l = keyframes.length; i < l; i++) {
442
+ keyframe = keyframes[i];
443
+ keyframe.value[property] = defaultValue;
444
+ }
445
+ } else {
446
+ // filling gaps
447
+ createMissingKeyframes(keyframes, property);
448
+ }
449
+ }
450
+
451
+ function createMissingKeyframes(keyframes, property) {
452
+ var prev, next;
453
+
454
+ for (var i = 0, l = keyframes.length; i < l; i++) {
455
+ var keyframe = keyframes[i];
456
+
457
+ if (keyframe.value[property] === null) {
458
+ prev = getPrev(keyframes, i, property);
459
+ next = getNext(keyframes, i, property);
460
+
461
+ if (prev === null) {
462
+ keyframe.value[property] = next.value[property];
463
+ continue;
464
+ }
465
+
466
+ if (next === null) {
467
+ keyframe.value[property] = prev.value[property];
468
+ continue;
469
+ }
470
+
471
+ interpolate(keyframe, prev, next, property);
472
+ }
473
+ }
474
+ }
475
+
476
+ function getPrev(keyframes, i, property) {
477
+ while (i >= 0) {
478
+ var keyframe = keyframes[i];
479
+ if (keyframe.value[property] !== null) return keyframe;
480
+ i--;
481
+ }
482
+
483
+ return null;
484
+ }
485
+
486
+ function getNext(keyframes, i, property) {
487
+ while (i < keyframes.length) {
488
+ var keyframe = keyframes[i];
489
+ if (keyframe.value[property] !== null) return keyframe;
490
+ i++;
491
+ }
492
+
493
+ return null;
494
+ }
495
+
496
+ function interpolate(key, prev, next, property) {
497
+ if (next.time - prev.time === 0) {
498
+ key.value[property] = prev.value[property];
499
+ return;
500
+ }
501
+
502
+ key.value[property] = (key.time - prev.time) * (next.value[property] - prev.value[property]) / (next.time - prev.time) + prev.value[property];
503
+ } // animation clips
504
+
505
+
506
+ function parseAnimationClip(xml) {
507
+ var data = {
508
+ name: xml.getAttribute('id') || 'default',
509
+ start: parseFloat(xml.getAttribute('start') || 0),
510
+ end: parseFloat(xml.getAttribute('end') || 0),
511
+ animations: []
512
+ };
513
+
514
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
515
+ var child = xml.childNodes[i];
516
+ if (child.nodeType !== 1) continue;
517
+
518
+ switch (child.nodeName) {
519
+ case 'instance_animation':
520
+ data.animations.push(parseId(child.getAttribute('url')));
521
+ break;
522
+ }
523
+ }
524
+
525
+ library.clips[xml.getAttribute('id')] = data;
526
+ }
527
+
528
+ function buildAnimationClip(data) {
529
+ var tracks = [];
530
+ var name = data.name;
531
+ var duration = data.end - data.start || -1;
532
+ var animations = data.animations;
533
+
534
+ for (var i = 0, il = animations.length; i < il; i++) {
535
+ var animationTracks = getAnimation(animations[i]);
536
+
537
+ for (var j = 0, jl = animationTracks.length; j < jl; j++) {
538
+ tracks.push(animationTracks[j]);
539
+ }
540
+ }
541
+
542
+ return new _three.AnimationClip(name, duration, tracks);
543
+ }
544
+
545
+ function getAnimationClip(id) {
546
+ return getBuild(library.clips[id], buildAnimationClip);
547
+ } // controller
548
+
549
+
550
+ function parseController(xml) {
551
+ var data = {};
552
+
553
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
554
+ var child = xml.childNodes[i];
555
+ if (child.nodeType !== 1) continue;
556
+
557
+ switch (child.nodeName) {
558
+ case 'skin':
559
+ // there is exactly one skin per controller
560
+ data.id = parseId(child.getAttribute('source'));
561
+ data.skin = parseSkin(child);
562
+ break;
563
+
564
+ case 'morph':
565
+ data.id = parseId(child.getAttribute('source'));
566
+ console.warn('THREE.ColladaLoader: Morph target animation not supported yet.');
567
+ break;
568
+ }
569
+ }
570
+
571
+ library.controllers[xml.getAttribute('id')] = data;
572
+ }
573
+
574
+ function parseSkin(xml) {
575
+ var data = {
576
+ sources: {}
577
+ };
578
+
579
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
580
+ var child = xml.childNodes[i];
581
+ if (child.nodeType !== 1) continue;
582
+
583
+ switch (child.nodeName) {
584
+ case 'bind_shape_matrix':
585
+ data.bindShapeMatrix = parseFloats(child.textContent);
586
+ break;
587
+
588
+ case 'source':
589
+ var id = child.getAttribute('id');
590
+ data.sources[id] = parseSource(child);
591
+ break;
592
+
593
+ case 'joints':
594
+ data.joints = parseJoints(child);
595
+ break;
596
+
597
+ case 'vertex_weights':
598
+ data.vertexWeights = parseVertexWeights(child);
599
+ break;
600
+ }
601
+ }
602
+
603
+ return data;
604
+ }
605
+
606
+ function parseJoints(xml) {
607
+ var data = {
608
+ inputs: {}
609
+ };
610
+
611
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
612
+ var child = xml.childNodes[i];
613
+ if (child.nodeType !== 1) continue;
614
+
615
+ switch (child.nodeName) {
616
+ case 'input':
617
+ var semantic = child.getAttribute('semantic');
618
+ var id = parseId(child.getAttribute('source'));
619
+ data.inputs[semantic] = id;
620
+ break;
621
+ }
622
+ }
623
+
624
+ return data;
625
+ }
626
+
627
+ function parseVertexWeights(xml) {
628
+ var data = {
629
+ inputs: {}
630
+ };
631
+
632
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
633
+ var child = xml.childNodes[i];
634
+ if (child.nodeType !== 1) continue;
635
+
636
+ switch (child.nodeName) {
637
+ case 'input':
638
+ var semantic = child.getAttribute('semantic');
639
+ var id = parseId(child.getAttribute('source'));
640
+ var offset = parseInt(child.getAttribute('offset'));
641
+ data.inputs[semantic] = {
642
+ id: id,
643
+ offset: offset
644
+ };
645
+ break;
646
+
647
+ case 'vcount':
648
+ data.vcount = parseInts(child.textContent);
649
+ break;
650
+
651
+ case 'v':
652
+ data.v = parseInts(child.textContent);
653
+ break;
654
+ }
655
+ }
656
+
657
+ return data;
658
+ }
659
+
660
+ function buildController(data) {
661
+ var build = {
662
+ id: data.id
663
+ };
664
+ var geometry = library.geometries[build.id];
665
+
666
+ if (data.skin !== undefined) {
667
+ build.skin = buildSkin(data.skin); // we enhance the 'sources' property of the corresponding geometry with our skin data
668
+
669
+ geometry.sources.skinIndices = build.skin.indices;
670
+ geometry.sources.skinWeights = build.skin.weights;
671
+ }
672
+
673
+ return build;
674
+ }
675
+
676
+ function buildSkin(data) {
677
+ var BONE_LIMIT = 4;
678
+ var build = {
679
+ joints: [],
680
+ // this must be an array to preserve the joint order
681
+ indices: {
682
+ array: [],
683
+ stride: BONE_LIMIT
684
+ },
685
+ weights: {
686
+ array: [],
687
+ stride: BONE_LIMIT
688
+ }
689
+ };
690
+ var sources = data.sources;
691
+ var vertexWeights = data.vertexWeights;
692
+ var vcount = vertexWeights.vcount;
693
+ var v = vertexWeights.v;
694
+ var jointOffset = vertexWeights.inputs.JOINT.offset;
695
+ var weightOffset = vertexWeights.inputs.WEIGHT.offset;
696
+ var jointSource = data.sources[data.joints.inputs.JOINT];
697
+ var inverseSource = data.sources[data.joints.inputs.INV_BIND_MATRIX];
698
+ var weights = sources[vertexWeights.inputs.WEIGHT.id].array;
699
+ var stride = 0;
700
+ var i, j, l; // procces skin data for each vertex
701
+
702
+ for (i = 0, l = vcount.length; i < l; i++) {
703
+ var jointCount = vcount[i]; // this is the amount of joints that affect a single vertex
704
+
705
+ var vertexSkinData = [];
706
+
707
+ for (j = 0; j < jointCount; j++) {
708
+ var skinIndex = v[stride + jointOffset];
709
+ var weightId = v[stride + weightOffset];
710
+ var skinWeight = weights[weightId];
711
+ vertexSkinData.push({
712
+ index: skinIndex,
713
+ weight: skinWeight
714
+ });
715
+ stride += 2;
716
+ } // we sort the joints in descending order based on the weights.
717
+ // this ensures, we only procced the most important joints of the vertex
718
+
719
+
720
+ vertexSkinData.sort(descending); // now we provide for each vertex a set of four index and weight values.
721
+ // the order of the skin data matches the order of vertices
722
+
723
+ for (j = 0; j < BONE_LIMIT; j++) {
724
+ var d = vertexSkinData[j];
725
+
726
+ if (d !== undefined) {
727
+ build.indices.array.push(d.index);
728
+ build.weights.array.push(d.weight);
729
+ } else {
730
+ build.indices.array.push(0);
731
+ build.weights.array.push(0);
732
+ }
733
+ }
734
+ } // setup bind matrix
735
+
736
+
737
+ if (data.bindShapeMatrix) {
738
+ build.bindMatrix = new _three.Matrix4().fromArray(data.bindShapeMatrix).transpose();
739
+ } else {
740
+ build.bindMatrix = new _three.Matrix4().identity();
741
+ } // process bones and inverse bind matrix data
742
+
743
+
744
+ for (i = 0, l = jointSource.array.length; i < l; i++) {
745
+ var name = jointSource.array[i];
746
+ var boneInverse = new _three.Matrix4().fromArray(inverseSource.array, i * inverseSource.stride).transpose();
747
+ build.joints.push({
748
+ name: name,
749
+ boneInverse: boneInverse
750
+ });
751
+ }
752
+
753
+ return build; // array sort function
754
+
755
+ function descending(a, b) {
756
+ return b.weight - a.weight;
757
+ }
758
+ }
759
+
760
+ function getController(id) {
761
+ return getBuild(library.controllers[id], buildController);
762
+ } // image
763
+
764
+
765
+ function parseImage(xml) {
766
+ var data = {
767
+ init_from: getElementsByTagName(xml, 'init_from')[0].textContent
768
+ };
769
+ library.images[xml.getAttribute('id')] = data;
770
+ }
771
+
772
+ function buildImage(data) {
773
+ if (data.build !== undefined) return data.build;
774
+ return data.init_from;
775
+ }
776
+
777
+ function getImage(id) {
778
+ var data = library.images[id];
779
+
780
+ if (data !== undefined) {
781
+ return getBuild(data, buildImage);
782
+ }
783
+
784
+ console.warn('THREE.ColladaLoader: Couldn\'t find image with ID:', id);
785
+ return null;
786
+ } // effect
787
+
788
+
789
+ function parseEffect(xml) {
790
+ var data = {};
791
+
792
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
793
+ var child = xml.childNodes[i];
794
+ if (child.nodeType !== 1) continue;
795
+
796
+ switch (child.nodeName) {
797
+ case 'profile_COMMON':
798
+ data.profile = parseEffectProfileCOMMON(child);
799
+ break;
800
+ }
801
+ }
802
+
803
+ library.effects[xml.getAttribute('id')] = data;
804
+ }
805
+
806
+ function parseEffectProfileCOMMON(xml) {
807
+ var data = {
808
+ surfaces: {},
809
+ samplers: {}
810
+ };
811
+
812
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
813
+ var child = xml.childNodes[i];
814
+ if (child.nodeType !== 1) continue;
815
+
816
+ switch (child.nodeName) {
817
+ case 'newparam':
818
+ parseEffectNewparam(child, data);
819
+ break;
820
+
821
+ case 'technique':
822
+ data.technique = parseEffectTechnique(child);
823
+ break;
824
+
825
+ case 'extra':
826
+ data.extra = parseEffectExtra(child);
827
+ break;
828
+ }
829
+ }
830
+
831
+ return data;
832
+ }
833
+
834
+ function parseEffectNewparam(xml, data) {
835
+ var sid = xml.getAttribute('sid');
836
+
837
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
838
+ var child = xml.childNodes[i];
839
+ if (child.nodeType !== 1) continue;
840
+
841
+ switch (child.nodeName) {
842
+ case 'surface':
843
+ data.surfaces[sid] = parseEffectSurface(child);
844
+ break;
845
+
846
+ case 'sampler2D':
847
+ data.samplers[sid] = parseEffectSampler(child);
848
+ break;
849
+ }
850
+ }
851
+ }
852
+
853
+ function parseEffectSurface(xml) {
854
+ var data = {};
855
+
856
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
857
+ var child = xml.childNodes[i];
858
+ if (child.nodeType !== 1) continue;
859
+
860
+ switch (child.nodeName) {
861
+ case 'init_from':
862
+ data.init_from = child.textContent;
863
+ break;
864
+ }
865
+ }
866
+
867
+ return data;
868
+ }
869
+
870
+ function parseEffectSampler(xml) {
871
+ var data = {};
872
+
873
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
874
+ var child = xml.childNodes[i];
875
+ if (child.nodeType !== 1) continue;
876
+
877
+ switch (child.nodeName) {
878
+ case 'source':
879
+ data.source = child.textContent;
880
+ break;
881
+ }
882
+ }
883
+
884
+ return data;
885
+ }
886
+
887
+ function parseEffectTechnique(xml) {
888
+ var data = {};
889
+
890
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
891
+ var child = xml.childNodes[i];
892
+ if (child.nodeType !== 1) continue;
893
+
894
+ switch (child.nodeName) {
895
+ case 'constant':
896
+ case 'lambert':
897
+ case 'blinn':
898
+ case 'phong':
899
+ data.type = child.nodeName;
900
+ data.parameters = parseEffectParameters(child);
901
+ break;
902
+
903
+ case 'extra':
904
+ data.extra = parseEffectExtra(child);
905
+ break;
906
+ }
907
+ }
908
+
909
+ return data;
910
+ }
911
+
912
+ function parseEffectParameters(xml) {
913
+ var data = {};
914
+
915
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
916
+ var child = xml.childNodes[i];
917
+ if (child.nodeType !== 1) continue;
918
+
919
+ switch (child.nodeName) {
920
+ case 'emission':
921
+ case 'diffuse':
922
+ case 'specular':
923
+ case 'bump':
924
+ case 'ambient':
925
+ case 'shininess':
926
+ case 'transparency':
927
+ data[child.nodeName] = parseEffectParameter(child);
928
+ break;
929
+
930
+ case 'transparent':
931
+ data[child.nodeName] = {
932
+ opaque: child.getAttribute('opaque'),
933
+ data: parseEffectParameter(child)
934
+ };
935
+ break;
936
+ }
937
+ }
938
+
939
+ return data;
940
+ }
941
+
942
+ function parseEffectParameter(xml) {
943
+ var data = {};
944
+
945
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
946
+ var child = xml.childNodes[i];
947
+ if (child.nodeType !== 1) continue;
948
+
949
+ switch (child.nodeName) {
950
+ case 'color':
951
+ data[child.nodeName] = parseFloats(child.textContent);
952
+ break;
953
+
954
+ case 'float':
955
+ data[child.nodeName] = parseFloat(child.textContent);
956
+ break;
957
+
958
+ case 'texture':
959
+ data[child.nodeName] = {
960
+ id: child.getAttribute('texture'),
961
+ extra: parseEffectParameterTexture(child)
962
+ };
963
+ break;
964
+ }
965
+ }
966
+
967
+ return data;
968
+ }
969
+
970
+ function parseEffectParameterTexture(xml) {
971
+ var data = {
972
+ technique: {}
973
+ };
974
+
975
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
976
+ var child = xml.childNodes[i];
977
+ if (child.nodeType !== 1) continue;
978
+
979
+ switch (child.nodeName) {
980
+ case 'extra':
981
+ parseEffectParameterTextureExtra(child, data);
982
+ break;
983
+ }
984
+ }
985
+
986
+ return data;
987
+ }
988
+
989
+ function parseEffectParameterTextureExtra(xml, data) {
990
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
991
+ var child = xml.childNodes[i];
992
+ if (child.nodeType !== 1) continue;
993
+
994
+ switch (child.nodeName) {
995
+ case 'technique':
996
+ parseEffectParameterTextureExtraTechnique(child, data);
997
+ break;
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ function parseEffectParameterTextureExtraTechnique(xml, data) {
1003
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1004
+ var child = xml.childNodes[i];
1005
+ if (child.nodeType !== 1) continue;
1006
+
1007
+ switch (child.nodeName) {
1008
+ case 'repeatU':
1009
+ case 'repeatV':
1010
+ case 'offsetU':
1011
+ case 'offsetV':
1012
+ data.technique[child.nodeName] = parseFloat(child.textContent);
1013
+ break;
1014
+
1015
+ case 'wrapU':
1016
+ case 'wrapV':
1017
+ // some files have values for wrapU/wrapV which become NaN via parseInt
1018
+ if (child.textContent.toUpperCase() === 'TRUE') {
1019
+ data.technique[child.nodeName] = 1;
1020
+ } else if (child.textContent.toUpperCase() === 'FALSE') {
1021
+ data.technique[child.nodeName] = 0;
1022
+ } else {
1023
+ data.technique[child.nodeName] = parseInt(child.textContent);
1024
+ }
1025
+
1026
+ break;
1027
+
1028
+ case 'bump':
1029
+ data[child.nodeName] = parseEffectExtraTechniqueBump(child);
1030
+ break;
1031
+ }
1032
+ }
1033
+ }
1034
+
1035
+ function parseEffectExtra(xml) {
1036
+ var data = {};
1037
+
1038
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1039
+ var child = xml.childNodes[i];
1040
+ if (child.nodeType !== 1) continue;
1041
+
1042
+ switch (child.nodeName) {
1043
+ case 'technique':
1044
+ data.technique = parseEffectExtraTechnique(child);
1045
+ break;
1046
+ }
1047
+ }
1048
+
1049
+ return data;
1050
+ }
1051
+
1052
+ function parseEffectExtraTechnique(xml) {
1053
+ var data = {};
1054
+
1055
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1056
+ var child = xml.childNodes[i];
1057
+ if (child.nodeType !== 1) continue;
1058
+
1059
+ switch (child.nodeName) {
1060
+ case 'double_sided':
1061
+ data[child.nodeName] = parseInt(child.textContent);
1062
+ break;
1063
+
1064
+ case 'bump':
1065
+ data[child.nodeName] = parseEffectExtraTechniqueBump(child);
1066
+ break;
1067
+ }
1068
+ }
1069
+
1070
+ return data;
1071
+ }
1072
+
1073
+ function parseEffectExtraTechniqueBump(xml) {
1074
+ var data = {};
1075
+
1076
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1077
+ var child = xml.childNodes[i];
1078
+ if (child.nodeType !== 1) continue;
1079
+
1080
+ switch (child.nodeName) {
1081
+ case 'texture':
1082
+ data[child.nodeName] = {
1083
+ id: child.getAttribute('texture'),
1084
+ texcoord: child.getAttribute('texcoord'),
1085
+ extra: parseEffectParameterTexture(child)
1086
+ };
1087
+ break;
1088
+ }
1089
+ }
1090
+
1091
+ return data;
1092
+ }
1093
+
1094
+ function buildEffect(data) {
1095
+ return data;
1096
+ }
1097
+
1098
+ function getEffect(id) {
1099
+ return getBuild(library.effects[id], buildEffect);
1100
+ } // material
1101
+
1102
+
1103
+ function parseMaterial(xml) {
1104
+ var data = {
1105
+ name: xml.getAttribute('name')
1106
+ };
1107
+
1108
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1109
+ var child = xml.childNodes[i];
1110
+ if (child.nodeType !== 1) continue;
1111
+
1112
+ switch (child.nodeName) {
1113
+ case 'instance_effect':
1114
+ data.url = parseId(child.getAttribute('url'));
1115
+ break;
1116
+ }
1117
+ }
1118
+
1119
+ library.materials[xml.getAttribute('id')] = data;
1120
+ }
1121
+
1122
+ function getTextureLoader(image) {
1123
+ var loader;
1124
+ var extension = image.slice((image.lastIndexOf('.') - 1 >>> 0) + 2); // http://www.jstips.co/en/javascript/get-file-extension/
1125
+
1126
+ extension = extension.toLowerCase();
1127
+
1128
+ switch (extension) {
1129
+ case 'tga':
1130
+ loader = tgaLoader;
1131
+ break;
1132
+
1133
+ default:
1134
+ loader = textureLoader;
1135
+ }
1136
+
1137
+ return loader;
1138
+ }
1139
+
1140
+ function buildMaterial(data) {
1141
+ var effect = getEffect(data.url);
1142
+ var technique = effect.profile.technique;
1143
+ var material;
1144
+
1145
+ switch (technique.type) {
1146
+ case 'phong':
1147
+ case 'blinn':
1148
+ material = new _three.MeshPhongMaterial();
1149
+ break;
1150
+
1151
+ case 'lambert':
1152
+ material = new _three.MeshLambertMaterial();
1153
+ break;
1154
+
1155
+ default:
1156
+ material = new _three.MeshBasicMaterial();
1157
+ break;
1158
+ }
1159
+
1160
+ material.name = data.name || '';
1161
+
1162
+ function getTexture(textureObject) {
1163
+ var sampler = effect.profile.samplers[textureObject.id];
1164
+ var image = null; // get image
1165
+
1166
+ if (sampler !== undefined) {
1167
+ var surface = effect.profile.surfaces[sampler.source];
1168
+ image = getImage(surface.init_from);
1169
+ } else {
1170
+ console.warn('THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530).');
1171
+ image = getImage(textureObject.id);
1172
+ } // create texture if image is avaiable
1173
+
1174
+
1175
+ if (image !== null) {
1176
+ var loader = getTextureLoader(image);
1177
+
1178
+ if (loader !== undefined) {
1179
+ var texture = loader.load(image);
1180
+ var extra = textureObject.extra;
1181
+
1182
+ if (extra !== undefined && extra.technique !== undefined && isEmpty(extra.technique) === false) {
1183
+ var _technique = extra.technique;
1184
+ texture.wrapS = _technique.wrapU ? _three.RepeatWrapping : _three.ClampToEdgeWrapping;
1185
+ texture.wrapT = _technique.wrapV ? _three.RepeatWrapping : _three.ClampToEdgeWrapping;
1186
+ texture.offset.set(_technique.offsetU || 0, _technique.offsetV || 0);
1187
+ texture.repeat.set(_technique.repeatU || 1, _technique.repeatV || 1);
1188
+ } else {
1189
+ texture.wrapS = _three.RepeatWrapping;
1190
+ texture.wrapT = _three.RepeatWrapping;
1191
+ }
1192
+
1193
+ return texture;
1194
+ } else {
1195
+ console.warn('THREE.ColladaLoader: Loader for texture %s not found.', image);
1196
+ return null;
1197
+ }
1198
+ } else {
1199
+ console.warn('THREE.ColladaLoader: Couldn\'t create texture with ID:', textureObject.id);
1200
+ return null;
1201
+ }
1202
+ }
1203
+
1204
+ var parameters = technique.parameters;
1205
+
1206
+ for (var key in parameters) {
1207
+ var parameter = parameters[key];
1208
+
1209
+ switch (key) {
1210
+ case 'diffuse':
1211
+ if (parameter.color) material.color.fromArray(parameter.color);
1212
+ if (parameter.texture) material.map = getTexture(parameter.texture);
1213
+ break;
1214
+
1215
+ case 'specular':
1216
+ if (parameter.color && material.specular) material.specular.fromArray(parameter.color);
1217
+ if (parameter.texture) material.specularMap = getTexture(parameter.texture);
1218
+ break;
1219
+
1220
+ case 'bump':
1221
+ if (parameter.texture) material.normalMap = getTexture(parameter.texture);
1222
+ break;
1223
+
1224
+ case 'ambient':
1225
+ if (parameter.texture) material.lightMap = getTexture(parameter.texture);
1226
+ break;
1227
+
1228
+ case 'shininess':
1229
+ if (parameter.float && material.shininess) material.shininess = parameter.float;
1230
+ break;
1231
+
1232
+ case 'emission':
1233
+ if (parameter.color && material.emissive) material.emissive.fromArray(parameter.color);
1234
+ if (parameter.texture) material.emissiveMap = getTexture(parameter.texture);
1235
+ break;
1236
+ }
1237
+ } //
1238
+
1239
+
1240
+ var transparent = parameters['transparent'];
1241
+ var transparency = parameters['transparency']; // <transparency> does not exist but <transparent>
1242
+
1243
+ if (transparency === undefined && transparent) {
1244
+ transparency = {
1245
+ float: 1
1246
+ };
1247
+ } // <transparent> does not exist but <transparency>
1248
+
1249
+
1250
+ if (transparent === undefined && transparency) {
1251
+ transparent = {
1252
+ opaque: 'A_ONE',
1253
+ data: {
1254
+ color: [1, 1, 1, 1]
1255
+ }
1256
+ };
1257
+ }
1258
+
1259
+ if (transparent && transparency) {
1260
+ // handle case if a texture exists but no color
1261
+ if (transparent.data.texture) {
1262
+ // we do not set an alpha map (see #13792)
1263
+ material.transparent = true;
1264
+ } else {
1265
+ var color = transparent.data.color;
1266
+
1267
+ switch (transparent.opaque) {
1268
+ case 'A_ONE':
1269
+ material.opacity = color[3] * transparency.float;
1270
+ break;
1271
+
1272
+ case 'RGB_ZERO':
1273
+ material.opacity = 1 - color[0] * transparency.float;
1274
+ break;
1275
+
1276
+ case 'A_ZERO':
1277
+ material.opacity = 1 - color[3] * transparency.float;
1278
+ break;
1279
+
1280
+ case 'RGB_ONE':
1281
+ material.opacity = color[0] * transparency.float;
1282
+ break;
1283
+
1284
+ default:
1285
+ material.opacity = 1 - transparency.float;
1286
+ console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.', transparent.opaque);
1287
+ }
1288
+
1289
+ if (material.opacity < 1) material.transparent = true;
1290
+ }
1291
+ } //
1292
+
1293
+
1294
+ if (technique.extra !== undefined && technique.extra.technique !== undefined) {
1295
+ var techniques = technique.extra.technique;
1296
+
1297
+ for (var k in techniques) {
1298
+ var v = techniques[k];
1299
+
1300
+ switch (k) {
1301
+ case 'double_sided':
1302
+ material.side = v === 1 ? _three.DoubleSide : _three.FrontSide;
1303
+ break;
1304
+
1305
+ case 'bump':
1306
+ material.normalMap = getTexture(v.texture);
1307
+ material.normalScale = new _three.Vector2(1, 1);
1308
+ break;
1309
+ }
1310
+ }
1311
+ }
1312
+
1313
+ return material;
1314
+ }
1315
+
1316
+ function getMaterial(id) {
1317
+ return getBuild(library.materials[id], buildMaterial);
1318
+ } // camera
1319
+
1320
+
1321
+ function parseCamera(xml) {
1322
+ var data = {
1323
+ name: xml.getAttribute('name')
1324
+ };
1325
+
1326
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1327
+ var child = xml.childNodes[i];
1328
+ if (child.nodeType !== 1) continue;
1329
+
1330
+ switch (child.nodeName) {
1331
+ case 'optics':
1332
+ data.optics = parseCameraOptics(child);
1333
+ break;
1334
+ }
1335
+ }
1336
+
1337
+ library.cameras[xml.getAttribute('id')] = data;
1338
+ }
1339
+
1340
+ function parseCameraOptics(xml) {
1341
+ for (var i = 0; i < xml.childNodes.length; i++) {
1342
+ var child = xml.childNodes[i];
1343
+
1344
+ switch (child.nodeName) {
1345
+ case 'technique_common':
1346
+ return parseCameraTechnique(child);
1347
+ }
1348
+ }
1349
+
1350
+ return {};
1351
+ }
1352
+
1353
+ function parseCameraTechnique(xml) {
1354
+ var data = {};
1355
+
1356
+ for (var i = 0; i < xml.childNodes.length; i++) {
1357
+ var child = xml.childNodes[i];
1358
+
1359
+ switch (child.nodeName) {
1360
+ case 'perspective':
1361
+ case 'orthographic':
1362
+ data.technique = child.nodeName;
1363
+ data.parameters = parseCameraParameters(child);
1364
+ break;
1365
+ }
1366
+ }
1367
+
1368
+ return data;
1369
+ }
1370
+
1371
+ function parseCameraParameters(xml) {
1372
+ var data = {};
1373
+
1374
+ for (var i = 0; i < xml.childNodes.length; i++) {
1375
+ var child = xml.childNodes[i];
1376
+
1377
+ switch (child.nodeName) {
1378
+ case 'xfov':
1379
+ case 'yfov':
1380
+ case 'xmag':
1381
+ case 'ymag':
1382
+ case 'znear':
1383
+ case 'zfar':
1384
+ case 'aspect_ratio':
1385
+ data[child.nodeName] = parseFloat(child.textContent);
1386
+ break;
1387
+ }
1388
+ }
1389
+
1390
+ return data;
1391
+ }
1392
+
1393
+ function buildCamera(data) {
1394
+ var camera;
1395
+
1396
+ switch (data.optics.technique) {
1397
+ case 'perspective':
1398
+ camera = new _three.PerspectiveCamera(data.optics.parameters.yfov, data.optics.parameters.aspect_ratio, data.optics.parameters.znear, data.optics.parameters.zfar);
1399
+ break;
1400
+
1401
+ case 'orthographic':
1402
+ var ymag = data.optics.parameters.ymag;
1403
+ var xmag = data.optics.parameters.xmag;
1404
+ var aspectRatio = data.optics.parameters.aspect_ratio;
1405
+ xmag = xmag === undefined ? ymag * aspectRatio : xmag;
1406
+ ymag = ymag === undefined ? xmag / aspectRatio : ymag;
1407
+ xmag *= 0.5;
1408
+ ymag *= 0.5;
1409
+ camera = new _three.OrthographicCamera(-xmag, xmag, ymag, -ymag, // left, right, top, bottom
1410
+ data.optics.parameters.znear, data.optics.parameters.zfar);
1411
+ break;
1412
+
1413
+ default:
1414
+ camera = new _three.PerspectiveCamera();
1415
+ break;
1416
+ }
1417
+
1418
+ camera.name = data.name || '';
1419
+ return camera;
1420
+ }
1421
+
1422
+ function getCamera(id) {
1423
+ var data = library.cameras[id];
1424
+
1425
+ if (data !== undefined) {
1426
+ return getBuild(data, buildCamera);
1427
+ }
1428
+
1429
+ console.warn('THREE.ColladaLoader: Couldn\'t find camera with ID:', id);
1430
+ return null;
1431
+ } // light
1432
+
1433
+
1434
+ function parseLight(xml) {
1435
+ var data = {};
1436
+
1437
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1438
+ var child = xml.childNodes[i];
1439
+ if (child.nodeType !== 1) continue;
1440
+
1441
+ switch (child.nodeName) {
1442
+ case 'technique_common':
1443
+ data = parseLightTechnique(child);
1444
+ break;
1445
+ }
1446
+ }
1447
+
1448
+ library.lights[xml.getAttribute('id')] = data;
1449
+ }
1450
+
1451
+ function parseLightTechnique(xml) {
1452
+ var data = {};
1453
+
1454
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1455
+ var child = xml.childNodes[i];
1456
+ if (child.nodeType !== 1) continue;
1457
+
1458
+ switch (child.nodeName) {
1459
+ case 'directional':
1460
+ case 'point':
1461
+ case 'spot':
1462
+ case 'ambient':
1463
+ data.technique = child.nodeName;
1464
+ data.parameters = parseLightParameters(child);
1465
+ }
1466
+ }
1467
+
1468
+ return data;
1469
+ }
1470
+
1471
+ function parseLightParameters(xml) {
1472
+ var data = {};
1473
+
1474
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1475
+ var child = xml.childNodes[i];
1476
+ if (child.nodeType !== 1) continue;
1477
+
1478
+ switch (child.nodeName) {
1479
+ case 'color':
1480
+ var array = parseFloats(child.textContent);
1481
+ data.color = new _three.Color().fromArray(array);
1482
+ break;
1483
+
1484
+ case 'falloff_angle':
1485
+ data.falloffAngle = parseFloat(child.textContent);
1486
+ break;
1487
+
1488
+ case 'quadratic_attenuation':
1489
+ var f = parseFloat(child.textContent);
1490
+ data.distance = f ? Math.sqrt(1 / f) : 0;
1491
+ break;
1492
+ }
1493
+ }
1494
+
1495
+ return data;
1496
+ }
1497
+
1498
+ function buildLight(data) {
1499
+ var light;
1500
+
1501
+ switch (data.technique) {
1502
+ case 'directional':
1503
+ light = new _three.DirectionalLight();
1504
+ break;
1505
+
1506
+ case 'point':
1507
+ light = new _three.PointLight();
1508
+ break;
1509
+
1510
+ case 'spot':
1511
+ light = new _three.SpotLight();
1512
+ break;
1513
+
1514
+ case 'ambient':
1515
+ light = new _three.AmbientLight();
1516
+ break;
1517
+ }
1518
+
1519
+ if (data.parameters.color) light.color.copy(data.parameters.color);
1520
+ if (data.parameters.distance) light.distance = data.parameters.distance;
1521
+ return light;
1522
+ }
1523
+
1524
+ function getLight(id) {
1525
+ var data = library.lights[id];
1526
+
1527
+ if (data !== undefined) {
1528
+ return getBuild(data, buildLight);
1529
+ }
1530
+
1531
+ console.warn('THREE.ColladaLoader: Couldn\'t find light with ID:', id);
1532
+ return null;
1533
+ } // geometry
1534
+
1535
+
1536
+ function parseGeometry(xml) {
1537
+ var data = {
1538
+ name: xml.getAttribute('name'),
1539
+ sources: {},
1540
+ vertices: {},
1541
+ primitives: []
1542
+ };
1543
+ var mesh = getElementsByTagName(xml, 'mesh')[0]; // the following tags inside geometry are not supported yet (see https://github.com/mrdoob/three.js/pull/12606): convex_mesh, spline, brep
1544
+
1545
+ if (mesh === undefined) return;
1546
+
1547
+ for (var i = 0; i < mesh.childNodes.length; i++) {
1548
+ var child = mesh.childNodes[i];
1549
+ if (child.nodeType !== 1) continue;
1550
+ var id = child.getAttribute('id');
1551
+
1552
+ switch (child.nodeName) {
1553
+ case 'source':
1554
+ data.sources[id] = parseSource(child);
1555
+ break;
1556
+
1557
+ case 'vertices':
1558
+ // data.sources[ id ] = data.sources[ parseId( getElementsByTagName( child, 'input' )[ 0 ].getAttribute( 'source' ) ) ];
1559
+ data.vertices = parseGeometryVertices(child);
1560
+ break;
1561
+
1562
+ case 'polygons':
1563
+ console.warn('THREE.ColladaLoader: Unsupported primitive type: ', child.nodeName);
1564
+ break;
1565
+
1566
+ case 'lines':
1567
+ case 'linestrips':
1568
+ case 'polylist':
1569
+ case 'triangles':
1570
+ data.primitives.push(parseGeometryPrimitive(child));
1571
+ break;
1572
+
1573
+ default:
1574
+ console.log(child);
1575
+ }
1576
+ }
1577
+
1578
+ library.geometries[xml.getAttribute('id')] = data;
1579
+ }
1580
+
1581
+ function parseSource(xml) {
1582
+ var data = {
1583
+ array: [],
1584
+ stride: 3
1585
+ };
1586
+
1587
+ for (var i = 0; i < xml.childNodes.length; i++) {
1588
+ var child = xml.childNodes[i];
1589
+ if (child.nodeType !== 1) continue;
1590
+
1591
+ switch (child.nodeName) {
1592
+ case 'float_array':
1593
+ data.array = parseFloats(child.textContent);
1594
+ break;
1595
+
1596
+ case 'Name_array':
1597
+ data.array = parseStrings(child.textContent);
1598
+ break;
1599
+
1600
+ case 'technique_common':
1601
+ var accessor = getElementsByTagName(child, 'accessor')[0];
1602
+
1603
+ if (accessor !== undefined) {
1604
+ data.stride = parseInt(accessor.getAttribute('stride'));
1605
+ }
1606
+
1607
+ break;
1608
+ }
1609
+ }
1610
+
1611
+ return data;
1612
+ }
1613
+
1614
+ function parseGeometryVertices(xml) {
1615
+ var data = {};
1616
+
1617
+ for (var i = 0; i < xml.childNodes.length; i++) {
1618
+ var child = xml.childNodes[i];
1619
+ if (child.nodeType !== 1) continue;
1620
+ data[child.getAttribute('semantic')] = parseId(child.getAttribute('source'));
1621
+ }
1622
+
1623
+ return data;
1624
+ }
1625
+
1626
+ function parseGeometryPrimitive(xml) {
1627
+ var primitive = {
1628
+ type: xml.nodeName,
1629
+ material: xml.getAttribute('material'),
1630
+ count: parseInt(xml.getAttribute('count')),
1631
+ inputs: {},
1632
+ stride: 0,
1633
+ hasUV: false
1634
+ };
1635
+
1636
+ for (var i = 0, l = xml.childNodes.length; i < l; i++) {
1637
+ var child = xml.childNodes[i];
1638
+ if (child.nodeType !== 1) continue;
1639
+
1640
+ switch (child.nodeName) {
1641
+ case 'input':
1642
+ var id = parseId(child.getAttribute('source'));
1643
+ var semantic = child.getAttribute('semantic');
1644
+ var offset = parseInt(child.getAttribute('offset'));
1645
+ var set = parseInt(child.getAttribute('set'));
1646
+ var inputname = set > 0 ? semantic + set : semantic;
1647
+ primitive.inputs[inputname] = {
1648
+ id: id,
1649
+ offset: offset
1650
+ };
1651
+ primitive.stride = Math.max(primitive.stride, offset + 1);
1652
+ if (semantic === 'TEXCOORD') primitive.hasUV = true;
1653
+ break;
1654
+
1655
+ case 'vcount':
1656
+ primitive.vcount = parseInts(child.textContent);
1657
+ break;
1658
+
1659
+ case 'p':
1660
+ primitive.p = parseInts(child.textContent);
1661
+ break;
1662
+ }
1663
+ }
1664
+
1665
+ return primitive;
1666
+ }
1667
+
1668
+ function groupPrimitives(primitives) {
1669
+ var build = {};
1670
+
1671
+ for (var i = 0; i < primitives.length; i++) {
1672
+ var primitive = primitives[i];
1673
+ if (build[primitive.type] === undefined) build[primitive.type] = [];
1674
+ build[primitive.type].push(primitive);
1675
+ }
1676
+
1677
+ return build;
1678
+ }
1679
+
1680
+ function checkUVCoordinates(primitives) {
1681
+ var count = 0;
1682
+
1683
+ for (var i = 0, l = primitives.length; i < l; i++) {
1684
+ var primitive = primitives[i];
1685
+
1686
+ if (primitive.hasUV === true) {
1687
+ count++;
1688
+ }
1689
+ }
1690
+
1691
+ if (count > 0 && count < primitives.length) {
1692
+ primitives.uvsNeedsFix = true;
1693
+ }
1694
+ }
1695
+
1696
+ function buildGeometry(data) {
1697
+ var build = {};
1698
+ var sources = data.sources;
1699
+ var vertices = data.vertices;
1700
+ var primitives = data.primitives;
1701
+ if (primitives.length === 0) return {}; // our goal is to create one buffer geometry for a single type of primitives
1702
+ // first, we group all primitives by their type
1703
+
1704
+ var groupedPrimitives = groupPrimitives(primitives);
1705
+
1706
+ for (var type in groupedPrimitives) {
1707
+ var primitiveType = groupedPrimitives[type]; // second, ensure consistent uv coordinates for each type of primitives (polylist,triangles or lines)
1708
+
1709
+ checkUVCoordinates(primitiveType); // third, create a buffer geometry for each type of primitives
1710
+
1711
+ build[type] = buildGeometryType(primitiveType, sources, vertices);
1712
+ }
1713
+
1714
+ return build;
1715
+ }
1716
+
1717
+ function buildGeometryType(primitives, sources, vertices) {
1718
+ var build = {};
1719
+ var position = {
1720
+ array: [],
1721
+ stride: 0
1722
+ };
1723
+ var normal = {
1724
+ array: [],
1725
+ stride: 0
1726
+ };
1727
+ var uv = {
1728
+ array: [],
1729
+ stride: 0
1730
+ };
1731
+ var uv2 = {
1732
+ array: [],
1733
+ stride: 0
1734
+ };
1735
+ var color = {
1736
+ array: [],
1737
+ stride: 0
1738
+ };
1739
+ var skinIndex = {
1740
+ array: [],
1741
+ stride: 4
1742
+ };
1743
+ var skinWeight = {
1744
+ array: [],
1745
+ stride: 4
1746
+ };
1747
+ var geometry = new _three.BufferGeometry();
1748
+ var materialKeys = [];
1749
+ var start = 0;
1750
+
1751
+ for (var p = 0; p < primitives.length; p++) {
1752
+ var primitive = primitives[p];
1753
+ var inputs = primitive.inputs; // groups
1754
+
1755
+ var _count = 0;
1756
+
1757
+ switch (primitive.type) {
1758
+ case 'lines':
1759
+ case 'linestrips':
1760
+ _count = primitive.count * 2;
1761
+ break;
1762
+
1763
+ case 'triangles':
1764
+ _count = primitive.count * 3;
1765
+ break;
1766
+
1767
+ case 'polylist':
1768
+ for (var g = 0; g < primitive.count; g++) {
1769
+ var vc = primitive.vcount[g];
1770
+
1771
+ switch (vc) {
1772
+ case 3:
1773
+ _count += 3; // single triangle
1774
+
1775
+ break;
1776
+
1777
+ case 4:
1778
+ _count += 6; // quad, subdivided into two triangles
1779
+
1780
+ break;
1781
+
1782
+ default:
1783
+ _count += (vc - 2) * 3; // polylist with more than four vertices
1784
+
1785
+ break;
1786
+ }
1787
+ }
1788
+
1789
+ break;
1790
+
1791
+ default:
1792
+ console.warn('THREE.ColladaLoader: Unknow primitive type:', primitive.type);
1793
+ }
1794
+
1795
+ geometry.addGroup(start, _count, p);
1796
+ start += _count; // material
1797
+
1798
+ if (primitive.material) {
1799
+ materialKeys.push(primitive.material);
1800
+ } // geometry data
1801
+
1802
+
1803
+ for (var name in inputs) {
1804
+ var input = inputs[name];
1805
+
1806
+ switch (name) {
1807
+ case 'VERTEX':
1808
+ for (var key in vertices) {
1809
+ var id = vertices[key];
1810
+
1811
+ switch (key) {
1812
+ case 'POSITION':
1813
+ var prevLength = position.array.length;
1814
+ buildGeometryData(primitive, sources[id], input.offset, position.array);
1815
+ position.stride = sources[id].stride;
1816
+
1817
+ if (sources.skinWeights && sources.skinIndices) {
1818
+ buildGeometryData(primitive, sources.skinIndices, input.offset, skinIndex.array);
1819
+ buildGeometryData(primitive, sources.skinWeights, input.offset, skinWeight.array);
1820
+ } // see #3803
1821
+
1822
+
1823
+ if (primitive.hasUV === false && primitives.uvsNeedsFix === true) {
1824
+ var _count2 = (position.array.length - prevLength) / position.stride;
1825
+
1826
+ for (var i = 0; i < _count2; i++) {
1827
+ // fill missing uv coordinates
1828
+ uv.array.push(0, 0);
1829
+ }
1830
+ }
1831
+
1832
+ break;
1833
+
1834
+ case 'NORMAL':
1835
+ buildGeometryData(primitive, sources[id], input.offset, normal.array);
1836
+ normal.stride = sources[id].stride;
1837
+ break;
1838
+
1839
+ case 'COLOR':
1840
+ buildGeometryData(primitive, sources[id], input.offset, color.array);
1841
+ color.stride = sources[id].stride;
1842
+ break;
1843
+
1844
+ case 'TEXCOORD':
1845
+ buildGeometryData(primitive, sources[id], input.offset, uv.array);
1846
+ uv.stride = sources[id].stride;
1847
+ break;
1848
+
1849
+ case 'TEXCOORD1':
1850
+ buildGeometryData(primitive, sources[id], input.offset, uv2.array);
1851
+ uv.stride = sources[id].stride;
1852
+ break;
1853
+
1854
+ default:
1855
+ console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.', key);
1856
+ }
1857
+ }
1858
+
1859
+ break;
1860
+
1861
+ case 'NORMAL':
1862
+ buildGeometryData(primitive, sources[input.id], input.offset, normal.array);
1863
+ normal.stride = sources[input.id].stride;
1864
+ break;
1865
+
1866
+ case 'COLOR':
1867
+ buildGeometryData(primitive, sources[input.id], input.offset, color.array);
1868
+ color.stride = sources[input.id].stride;
1869
+ break;
1870
+
1871
+ case 'TEXCOORD':
1872
+ buildGeometryData(primitive, sources[input.id], input.offset, uv.array);
1873
+ uv.stride = sources[input.id].stride;
1874
+ break;
1875
+
1876
+ case 'TEXCOORD1':
1877
+ buildGeometryData(primitive, sources[input.id], input.offset, uv2.array);
1878
+ uv2.stride = sources[input.id].stride;
1879
+ break;
1880
+ }
1881
+ }
1882
+ } // build geometry
1883
+
1884
+
1885
+ if (position.array.length > 0) geometry.setAttribute('position', new _three.Float32BufferAttribute(position.array, position.stride));
1886
+ if (normal.array.length > 0) geometry.setAttribute('normal', new _three.Float32BufferAttribute(normal.array, normal.stride));
1887
+ if (color.array.length > 0) geometry.setAttribute('color', new _three.Float32BufferAttribute(color.array, color.stride));
1888
+ if (uv.array.length > 0) geometry.setAttribute('uv', new _three.Float32BufferAttribute(uv.array, uv.stride));
1889
+ if (uv2.array.length > 0) geometry.setAttribute('uv2', new _three.Float32BufferAttribute(uv2.array, uv2.stride));
1890
+ if (skinIndex.array.length > 0) geometry.setAttribute('skinIndex', new _three.Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1891
+ if (skinWeight.array.length > 0) geometry.setAttribute('skinWeight', new _three.Float32BufferAttribute(skinWeight.array, skinWeight.stride));
1892
+ build.data = geometry;
1893
+ build.type = primitives[0].type;
1894
+ build.materialKeys = materialKeys;
1895
+ return build;
1896
+ }
1897
+
1898
+ function buildGeometryData(primitive, source, offset, array) {
1899
+ var indices = primitive.p;
1900
+ var stride = primitive.stride;
1901
+ var vcount = primitive.vcount;
1902
+
1903
+ function pushVector(i) {
1904
+ var index = indices[i + offset] * sourceStride;
1905
+ var length = index + sourceStride;
1906
+
1907
+ for (; index < length; index++) {
1908
+ array.push(sourceArray[index]);
1909
+ }
1910
+ }
1911
+
1912
+ var sourceArray = source.array;
1913
+ var sourceStride = source.stride;
1914
+
1915
+ if (primitive.vcount !== undefined) {
1916
+ var index = 0;
1917
+
1918
+ for (var i = 0, l = vcount.length; i < l; i++) {
1919
+ var _count3 = vcount[i];
1920
+
1921
+ if (_count3 === 4) {
1922
+ var a = index + stride * 0;
1923
+ var b = index + stride * 1;
1924
+ var c = index + stride * 2;
1925
+ var d = index + stride * 3;
1926
+ pushVector(a);
1927
+ pushVector(b);
1928
+ pushVector(d);
1929
+ pushVector(b);
1930
+ pushVector(c);
1931
+ pushVector(d);
1932
+ } else if (_count3 === 3) {
1933
+ var _a = index + stride * 0;
1934
+
1935
+ var _b = index + stride * 1;
1936
+
1937
+ var _c = index + stride * 2;
1938
+
1939
+ pushVector(_a);
1940
+ pushVector(_b);
1941
+ pushVector(_c);
1942
+ } else if (_count3 > 4) {
1943
+ for (var k = 1, kl = _count3 - 2; k <= kl; k++) {
1944
+ var _a2 = index + stride * 0;
1945
+
1946
+ var _b2 = index + stride * k;
1947
+
1948
+ var _c2 = index + stride * (k + 1);
1949
+
1950
+ pushVector(_a2);
1951
+ pushVector(_b2);
1952
+ pushVector(_c2);
1953
+ }
1954
+ }
1955
+
1956
+ index += stride * _count3;
1957
+ }
1958
+ } else {
1959
+ for (var _i = 0, _l = indices.length; _i < _l; _i += stride) {
1960
+ pushVector(_i);
1961
+ }
1962
+ }
1963
+ }
1964
+
1965
+ function getGeometry(id) {
1966
+ return getBuild(library.geometries[id], buildGeometry);
1967
+ } // kinematics
1968
+
1969
+
1970
+ function parseKinematicsModel(xml) {
1971
+ var data = {
1972
+ name: xml.getAttribute('name') || '',
1973
+ joints: {},
1974
+ links: []
1975
+ };
1976
+
1977
+ for (var i = 0; i < xml.childNodes.length; i++) {
1978
+ var child = xml.childNodes[i];
1979
+ if (child.nodeType !== 1) continue;
1980
+
1981
+ switch (child.nodeName) {
1982
+ case 'technique_common':
1983
+ parseKinematicsTechniqueCommon(child, data);
1984
+ break;
1985
+ }
1986
+ }
1987
+
1988
+ library.kinematicsModels[xml.getAttribute('id')] = data;
1989
+ }
1990
+
1991
+ function buildKinematicsModel(data) {
1992
+ if (data.build !== undefined) return data.build;
1993
+ return data;
1994
+ }
1995
+
1996
+ function getKinematicsModel(id) {
1997
+ return getBuild(library.kinematicsModels[id], buildKinematicsModel);
1998
+ }
1999
+
2000
+ function parseKinematicsTechniqueCommon(xml, data) {
2001
+ for (var i = 0; i < xml.childNodes.length; i++) {
2002
+ var child = xml.childNodes[i];
2003
+ if (child.nodeType !== 1) continue;
2004
+
2005
+ switch (child.nodeName) {
2006
+ case 'joint':
2007
+ data.joints[child.getAttribute('sid')] = parseKinematicsJoint(child);
2008
+ break;
2009
+
2010
+ case 'link':
2011
+ data.links.push(parseKinematicsLink(child));
2012
+ break;
2013
+ }
2014
+ }
2015
+ }
2016
+
2017
+ function parseKinematicsJoint(xml) {
2018
+ var data;
2019
+
2020
+ for (var i = 0; i < xml.childNodes.length; i++) {
2021
+ var child = xml.childNodes[i];
2022
+ if (child.nodeType !== 1) continue;
2023
+
2024
+ switch (child.nodeName) {
2025
+ case 'prismatic':
2026
+ case 'revolute':
2027
+ data = parseKinematicsJointParameter(child);
2028
+ break;
2029
+ }
2030
+ }
2031
+
2032
+ return data;
2033
+ }
2034
+
2035
+ function parseKinematicsJointParameter(xml) {
2036
+ var data = {
2037
+ sid: xml.getAttribute('sid'),
2038
+ name: xml.getAttribute('name') || '',
2039
+ axis: new _three.Vector3(),
2040
+ limits: {
2041
+ min: 0,
2042
+ max: 0
2043
+ },
2044
+ type: xml.nodeName,
2045
+ static: false,
2046
+ zeroPosition: 0,
2047
+ middlePosition: 0
2048
+ };
2049
+
2050
+ for (var i = 0; i < xml.childNodes.length; i++) {
2051
+ var child = xml.childNodes[i];
2052
+ if (child.nodeType !== 1) continue;
2053
+
2054
+ switch (child.nodeName) {
2055
+ case 'axis':
2056
+ var array = parseFloats(child.textContent);
2057
+ data.axis.fromArray(array);
2058
+ break;
2059
+
2060
+ case 'limits':
2061
+ var max = child.getElementsByTagName('max')[0];
2062
+ var min = child.getElementsByTagName('min')[0];
2063
+ data.limits.max = parseFloat(max.textContent);
2064
+ data.limits.min = parseFloat(min.textContent);
2065
+ break;
2066
+ }
2067
+ } // if min is equal to or greater than max, consider the joint static
2068
+
2069
+
2070
+ if (data.limits.min >= data.limits.max) {
2071
+ data.static = true;
2072
+ } // calculate middle position
2073
+
2074
+
2075
+ data.middlePosition = (data.limits.min + data.limits.max) / 2.0;
2076
+ return data;
2077
+ }
2078
+
2079
+ function parseKinematicsLink(xml) {
2080
+ var data = {
2081
+ sid: xml.getAttribute('sid'),
2082
+ name: xml.getAttribute('name') || '',
2083
+ attachments: [],
2084
+ transforms: []
2085
+ };
2086
+
2087
+ for (var i = 0; i < xml.childNodes.length; i++) {
2088
+ var child = xml.childNodes[i];
2089
+ if (child.nodeType !== 1) continue;
2090
+
2091
+ switch (child.nodeName) {
2092
+ case 'attachment_full':
2093
+ data.attachments.push(parseKinematicsAttachment(child));
2094
+ break;
2095
+
2096
+ case 'matrix':
2097
+ case 'translate':
2098
+ case 'rotate':
2099
+ data.transforms.push(parseKinematicsTransform(child));
2100
+ break;
2101
+ }
2102
+ }
2103
+
2104
+ return data;
2105
+ }
2106
+
2107
+ function parseKinematicsAttachment(xml) {
2108
+ var data = {
2109
+ joint: xml.getAttribute('joint').split('/').pop(),
2110
+ transforms: [],
2111
+ links: []
2112
+ };
2113
+
2114
+ for (var i = 0; i < xml.childNodes.length; i++) {
2115
+ var child = xml.childNodes[i];
2116
+ if (child.nodeType !== 1) continue;
2117
+
2118
+ switch (child.nodeName) {
2119
+ case 'link':
2120
+ data.links.push(parseKinematicsLink(child));
2121
+ break;
2122
+
2123
+ case 'matrix':
2124
+ case 'translate':
2125
+ case 'rotate':
2126
+ data.transforms.push(parseKinematicsTransform(child));
2127
+ break;
2128
+ }
2129
+ }
2130
+
2131
+ return data;
2132
+ }
2133
+
2134
+ function parseKinematicsTransform(xml) {
2135
+ var data = {
2136
+ type: xml.nodeName
2137
+ };
2138
+ var array = parseFloats(xml.textContent);
2139
+
2140
+ switch (data.type) {
2141
+ case 'matrix':
2142
+ data.obj = new _three.Matrix4();
2143
+ data.obj.fromArray(array).transpose();
2144
+ break;
2145
+
2146
+ case 'translate':
2147
+ data.obj = new _three.Vector3();
2148
+ data.obj.fromArray(array);
2149
+ break;
2150
+
2151
+ case 'rotate':
2152
+ data.obj = new _three.Vector3();
2153
+ data.obj.fromArray(array);
2154
+ data.angle = _three.MathUtils.degToRad(array[3]);
2155
+ break;
2156
+ }
2157
+
2158
+ return data;
2159
+ } // physics
2160
+
2161
+
2162
+ function parsePhysicsModel(xml) {
2163
+ var data = {
2164
+ name: xml.getAttribute('name') || '',
2165
+ rigidBodies: {}
2166
+ };
2167
+
2168
+ for (var i = 0; i < xml.childNodes.length; i++) {
2169
+ var child = xml.childNodes[i];
2170
+ if (child.nodeType !== 1) continue;
2171
+
2172
+ switch (child.nodeName) {
2173
+ case 'rigid_body':
2174
+ data.rigidBodies[child.getAttribute('name')] = {};
2175
+ parsePhysicsRigidBody(child, data.rigidBodies[child.getAttribute('name')]);
2176
+ break;
2177
+ }
2178
+ }
2179
+
2180
+ library.physicsModels[xml.getAttribute('id')] = data;
2181
+ }
2182
+
2183
+ function parsePhysicsRigidBody(xml, data) {
2184
+ for (var i = 0; i < xml.childNodes.length; i++) {
2185
+ var child = xml.childNodes[i];
2186
+ if (child.nodeType !== 1) continue;
2187
+
2188
+ switch (child.nodeName) {
2189
+ case 'technique_common':
2190
+ parsePhysicsTechniqueCommon(child, data);
2191
+ break;
2192
+ }
2193
+ }
2194
+ }
2195
+
2196
+ function parsePhysicsTechniqueCommon(xml, data) {
2197
+ for (var i = 0; i < xml.childNodes.length; i++) {
2198
+ var child = xml.childNodes[i];
2199
+ if (child.nodeType !== 1) continue;
2200
+
2201
+ switch (child.nodeName) {
2202
+ case 'inertia':
2203
+ data.inertia = parseFloats(child.textContent);
2204
+ break;
2205
+
2206
+ case 'mass':
2207
+ data.mass = parseFloats(child.textContent)[0];
2208
+ break;
2209
+ }
2210
+ }
2211
+ } // scene
2212
+
2213
+
2214
+ function parseKinematicsScene(xml) {
2215
+ var data = {
2216
+ bindJointAxis: []
2217
+ };
2218
+
2219
+ for (var i = 0; i < xml.childNodes.length; i++) {
2220
+ var child = xml.childNodes[i];
2221
+ if (child.nodeType !== 1) continue;
2222
+
2223
+ switch (child.nodeName) {
2224
+ case 'bind_joint_axis':
2225
+ data.bindJointAxis.push(parseKinematicsBindJointAxis(child));
2226
+ break;
2227
+ }
2228
+ }
2229
+
2230
+ library.kinematicsScenes[parseId(xml.getAttribute('url'))] = data;
2231
+ }
2232
+
2233
+ function parseKinematicsBindJointAxis(xml) {
2234
+ var data = {
2235
+ target: xml.getAttribute('target').split('/').pop()
2236
+ };
2237
+
2238
+ for (var i = 0; i < xml.childNodes.length; i++) {
2239
+ var child = xml.childNodes[i];
2240
+ if (child.nodeType !== 1) continue;
2241
+
2242
+ switch (child.nodeName) {
2243
+ case 'axis':
2244
+ var param = child.getElementsByTagName('param')[0];
2245
+ data.axis = param.textContent;
2246
+ var tmpJointIndex = data.axis.split('inst_').pop().split('axis')[0];
2247
+ data.jointIndex = tmpJointIndex.substr(0, tmpJointIndex.length - 1);
2248
+ break;
2249
+ }
2250
+ }
2251
+
2252
+ return data;
2253
+ }
2254
+
2255
+ function buildKinematicsScene(data) {
2256
+ if (data.build !== undefined) return data.build;
2257
+ return data;
2258
+ }
2259
+
2260
+ function getKinematicsScene(id) {
2261
+ return getBuild(library.kinematicsScenes[id], buildKinematicsScene);
2262
+ }
2263
+
2264
+ function setupKinematics() {
2265
+ var kinematicsModelId = Object.keys(library.kinematicsModels)[0];
2266
+ var kinematicsSceneId = Object.keys(library.kinematicsScenes)[0];
2267
+ var visualSceneId = Object.keys(library.visualScenes)[0];
2268
+ if (kinematicsModelId === undefined || kinematicsSceneId === undefined) return;
2269
+ var kinematicsModel = getKinematicsModel(kinematicsModelId);
2270
+ var kinematicsScene = getKinematicsScene(kinematicsSceneId);
2271
+ var visualScene = getVisualScene(visualSceneId);
2272
+ var bindJointAxis = kinematicsScene.bindJointAxis;
2273
+ var jointMap = {};
2274
+
2275
+ for (var i = 0, l = bindJointAxis.length; i < l; i++) {
2276
+ var axis = bindJointAxis[i]; // the result of the following query is an element of type 'translate', 'rotate','scale' or 'matrix'
2277
+
2278
+ var targetElement = collada.querySelector('[sid="' + axis.target + '"]');
2279
+
2280
+ if (targetElement) {
2281
+ // get the parent of the transform element
2282
+ var parentVisualElement = targetElement.parentElement; // connect the joint of the kinematics model with the element in the visual scene
2283
+
2284
+ connect(axis.jointIndex, parentVisualElement);
2285
+ }
2286
+ }
2287
+
2288
+ function connect(jointIndex, visualElement) {
2289
+ var visualElementName = visualElement.getAttribute('name');
2290
+ var joint = kinematicsModel.joints[jointIndex];
2291
+ visualScene.traverse(function (object) {
2292
+ if (object.name === visualElementName) {
2293
+ jointMap[jointIndex] = {
2294
+ object: object,
2295
+ transforms: buildTransformList(visualElement),
2296
+ joint: joint,
2297
+ position: joint.zeroPosition
2298
+ };
2299
+ }
2300
+ });
2301
+ }
2302
+
2303
+ var m0 = new _three.Matrix4();
2304
+ kinematics = {
2305
+ joints: kinematicsModel && kinematicsModel.joints,
2306
+ getJointValue: function getJointValue(jointIndex) {
2307
+ var jointData = jointMap[jointIndex];
2308
+
2309
+ if (jointData) {
2310
+ return jointData.position;
2311
+ } else {
2312
+ console.warn('THREE.ColladaLoader: Joint ' + jointIndex + ' doesn\'t exist.');
2313
+ }
2314
+ },
2315
+ setJointValue: function setJointValue(jointIndex, value) {
2316
+ var jointData = jointMap[jointIndex];
2317
+
2318
+ if (jointData) {
2319
+ var joint = jointData.joint;
2320
+
2321
+ if (value > joint.limits.max || value < joint.limits.min) {
2322
+ console.warn('THREE.ColladaLoader: Joint ' + jointIndex + ' value ' + value + ' outside of limits (min: ' + joint.limits.min + ', max: ' + joint.limits.max + ').');
2323
+ } else if (joint.static) {
2324
+ console.warn('THREE.ColladaLoader: Joint ' + jointIndex + ' is static.');
2325
+ } else {
2326
+ var object = jointData.object;
2327
+ var _axis = joint.axis;
2328
+ var transforms = jointData.transforms;
2329
+ matrix.identity(); // each update, we have to apply all transforms in the correct order
2330
+
2331
+ for (var _i2 = 0; _i2 < transforms.length; _i2++) {
2332
+ var transform = transforms[_i2]; // if there is a connection of the transform node with a joint, apply the joint value
2333
+
2334
+ if (transform.sid && transform.sid.indexOf(jointIndex) !== -1) {
2335
+ switch (joint.type) {
2336
+ case 'revolute':
2337
+ matrix.multiply(m0.makeRotationAxis(_axis, _three.MathUtils.degToRad(value)));
2338
+ break;
2339
+
2340
+ case 'prismatic':
2341
+ matrix.multiply(m0.makeTranslation(_axis.x * value, _axis.y * value, _axis.z * value));
2342
+ break;
2343
+
2344
+ default:
2345
+ console.warn('THREE.ColladaLoader: Unknown joint type: ' + joint.type);
2346
+ break;
2347
+ }
2348
+ } else {
2349
+ switch (transform.type) {
2350
+ case 'matrix':
2351
+ matrix.multiply(transform.obj);
2352
+ break;
2353
+
2354
+ case 'translate':
2355
+ matrix.multiply(m0.makeTranslation(transform.obj.x, transform.obj.y, transform.obj.z));
2356
+ break;
2357
+
2358
+ case 'scale':
2359
+ matrix.scale(transform.obj);
2360
+ break;
2361
+
2362
+ case 'rotate':
2363
+ matrix.multiply(m0.makeRotationAxis(transform.obj, transform.angle));
2364
+ break;
2365
+ }
2366
+ }
2367
+ }
2368
+
2369
+ object.matrix.copy(matrix);
2370
+ object.matrix.decompose(object.position, object.quaternion, object.scale);
2371
+ jointMap[jointIndex].position = value;
2372
+ }
2373
+ } else {
2374
+ console.log('THREE.ColladaLoader: ' + jointIndex + ' does not exist.');
2375
+ }
2376
+ }
2377
+ };
2378
+ }
2379
+
2380
+ function buildTransformList(node) {
2381
+ var transforms = [];
2382
+ var xml = collada.querySelector('[id="' + node.id + '"]');
2383
+
2384
+ for (var i = 0; i < xml.childNodes.length; i++) {
2385
+ var child = xml.childNodes[i];
2386
+ if (child.nodeType !== 1) continue;
2387
+
2388
+ var array = void 0,
2389
+ _vector = void 0;
2390
+
2391
+ switch (child.nodeName) {
2392
+ case 'matrix':
2393
+ array = parseFloats(child.textContent);
2394
+
2395
+ var _matrix = new _three.Matrix4().fromArray(array).transpose();
2396
+
2397
+ transforms.push({
2398
+ sid: child.getAttribute('sid'),
2399
+ type: child.nodeName,
2400
+ obj: _matrix
2401
+ });
2402
+ break;
2403
+
2404
+ case 'translate':
2405
+ case 'scale':
2406
+ array = parseFloats(child.textContent);
2407
+ _vector = new _three.Vector3().fromArray(array);
2408
+ transforms.push({
2409
+ sid: child.getAttribute('sid'),
2410
+ type: child.nodeName,
2411
+ obj: _vector
2412
+ });
2413
+ break;
2414
+
2415
+ case 'rotate':
2416
+ array = parseFloats(child.textContent);
2417
+ _vector = new _three.Vector3().fromArray(array);
2418
+
2419
+ var angle = _three.MathUtils.degToRad(array[3]);
2420
+
2421
+ transforms.push({
2422
+ sid: child.getAttribute('sid'),
2423
+ type: child.nodeName,
2424
+ obj: _vector,
2425
+ angle: angle
2426
+ });
2427
+ break;
2428
+ }
2429
+ }
2430
+
2431
+ return transforms;
2432
+ } // nodes
2433
+
2434
+
2435
+ function prepareNodes(xml) {
2436
+ var elements = xml.getElementsByTagName('node'); // ensure all node elements have id attributes
2437
+
2438
+ for (var i = 0; i < elements.length; i++) {
2439
+ var element = elements[i];
2440
+
2441
+ if (element.hasAttribute('id') === false) {
2442
+ element.setAttribute('id', generateId());
2443
+ }
2444
+ }
2445
+ }
2446
+
2447
+ var matrix = new _three.Matrix4();
2448
+ var vector = new _three.Vector3();
2449
+
2450
+ function parseNode(xml) {
2451
+ var data = {
2452
+ name: xml.getAttribute('name') || '',
2453
+ type: xml.getAttribute('type'),
2454
+ id: xml.getAttribute('id'),
2455
+ sid: xml.getAttribute('sid'),
2456
+ matrix: new _three.Matrix4(),
2457
+ nodes: [],
2458
+ instanceCameras: [],
2459
+ instanceControllers: [],
2460
+ instanceLights: [],
2461
+ instanceGeometries: [],
2462
+ instanceNodes: [],
2463
+ transforms: {}
2464
+ };
2465
+
2466
+ for (var i = 0; i < xml.childNodes.length; i++) {
2467
+ var child = xml.childNodes[i];
2468
+ if (child.nodeType !== 1) continue;
2469
+ var array = void 0;
2470
+
2471
+ switch (child.nodeName) {
2472
+ case 'node':
2473
+ data.nodes.push(child.getAttribute('id'));
2474
+ parseNode(child);
2475
+ break;
2476
+
2477
+ case 'instance_camera':
2478
+ data.instanceCameras.push(parseId(child.getAttribute('url')));
2479
+ break;
2480
+
2481
+ case 'instance_controller':
2482
+ data.instanceControllers.push(parseNodeInstance(child));
2483
+ break;
2484
+
2485
+ case 'instance_light':
2486
+ data.instanceLights.push(parseId(child.getAttribute('url')));
2487
+ break;
2488
+
2489
+ case 'instance_geometry':
2490
+ data.instanceGeometries.push(parseNodeInstance(child));
2491
+ break;
2492
+
2493
+ case 'instance_node':
2494
+ data.instanceNodes.push(parseId(child.getAttribute('url')));
2495
+ break;
2496
+
2497
+ case 'matrix':
2498
+ array = parseFloats(child.textContent);
2499
+ data.matrix.multiply(matrix.fromArray(array).transpose());
2500
+ data.transforms[child.getAttribute('sid')] = child.nodeName;
2501
+ break;
2502
+
2503
+ case 'translate':
2504
+ array = parseFloats(child.textContent);
2505
+ vector.fromArray(array);
2506
+ data.matrix.multiply(matrix.makeTranslation(vector.x, vector.y, vector.z));
2507
+ data.transforms[child.getAttribute('sid')] = child.nodeName;
2508
+ break;
2509
+
2510
+ case 'rotate':
2511
+ array = parseFloats(child.textContent);
2512
+
2513
+ var angle = _three.MathUtils.degToRad(array[3]);
2514
+
2515
+ data.matrix.multiply(matrix.makeRotationAxis(vector.fromArray(array), angle));
2516
+ data.transforms[child.getAttribute('sid')] = child.nodeName;
2517
+ break;
2518
+
2519
+ case 'scale':
2520
+ array = parseFloats(child.textContent);
2521
+ data.matrix.scale(vector.fromArray(array));
2522
+ data.transforms[child.getAttribute('sid')] = child.nodeName;
2523
+ break;
2524
+
2525
+ case 'extra':
2526
+ break;
2527
+
2528
+ default:
2529
+ console.log(child);
2530
+ }
2531
+ }
2532
+
2533
+ if (hasNode(data.id)) {
2534
+ console.warn('THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.', data.id);
2535
+ } else {
2536
+ library.nodes[data.id] = data;
2537
+ }
2538
+
2539
+ return data;
2540
+ }
2541
+
2542
+ function parseNodeInstance(xml) {
2543
+ var data = {
2544
+ id: parseId(xml.getAttribute('url')),
2545
+ materials: {},
2546
+ skeletons: []
2547
+ };
2548
+
2549
+ for (var i = 0; i < xml.childNodes.length; i++) {
2550
+ var child = xml.childNodes[i];
2551
+
2552
+ switch (child.nodeName) {
2553
+ case 'bind_material':
2554
+ var instances = child.getElementsByTagName('instance_material');
2555
+
2556
+ for (var j = 0; j < instances.length; j++) {
2557
+ var instance = instances[j];
2558
+ var symbol = instance.getAttribute('symbol');
2559
+ var target = instance.getAttribute('target');
2560
+ data.materials[symbol] = parseId(target);
2561
+ }
2562
+
2563
+ break;
2564
+
2565
+ case 'skeleton':
2566
+ data.skeletons.push(parseId(child.textContent));
2567
+ break;
2568
+
2569
+ default:
2570
+ break;
2571
+ }
2572
+ }
2573
+
2574
+ return data;
2575
+ }
2576
+
2577
+ function buildSkeleton(skeletons, joints) {
2578
+ var boneData = [];
2579
+ var sortedBoneData = [];
2580
+ var i, j, data; // a skeleton can have multiple root bones. collada expresses this
2581
+ // situtation with multiple "skeleton" tags per controller instance
2582
+
2583
+ for (i = 0; i < skeletons.length; i++) {
2584
+ var skeleton = skeletons[i];
2585
+ var root = void 0;
2586
+
2587
+ if (hasNode(skeleton)) {
2588
+ root = getNode(skeleton);
2589
+ buildBoneHierarchy(root, joints, boneData);
2590
+ } else if (hasVisualScene(skeleton)) {
2591
+ // handle case where the skeleton refers to the visual scene (#13335)
2592
+ var visualScene = library.visualScenes[skeleton];
2593
+ var children = visualScene.children;
2594
+
2595
+ for (var _j = 0; _j < children.length; _j++) {
2596
+ var child = children[_j];
2597
+
2598
+ if (child.type === 'JOINT') {
2599
+ var _root = getNode(child.id);
2600
+
2601
+ buildBoneHierarchy(_root, joints, boneData);
2602
+ }
2603
+ }
2604
+ } else {
2605
+ console.error('THREE.ColladaLoader: Unable to find root bone of skeleton with ID:', skeleton);
2606
+ }
2607
+ } // sort bone data (the order is defined in the corresponding controller)
2608
+
2609
+
2610
+ for (i = 0; i < joints.length; i++) {
2611
+ for (j = 0; j < boneData.length; j++) {
2612
+ data = boneData[j];
2613
+
2614
+ if (data.bone.name === joints[i].name) {
2615
+ sortedBoneData[i] = data;
2616
+ data.processed = true;
2617
+ break;
2618
+ }
2619
+ }
2620
+ } // add unprocessed bone data at the end of the list
2621
+
2622
+
2623
+ for (i = 0; i < boneData.length; i++) {
2624
+ data = boneData[i];
2625
+
2626
+ if (data.processed === false) {
2627
+ sortedBoneData.push(data);
2628
+ data.processed = true;
2629
+ }
2630
+ } // setup arrays for skeleton creation
2631
+
2632
+
2633
+ var bones = [];
2634
+ var boneInverses = [];
2635
+
2636
+ for (i = 0; i < sortedBoneData.length; i++) {
2637
+ data = sortedBoneData[i];
2638
+ bones.push(data.bone);
2639
+ boneInverses.push(data.boneInverse);
2640
+ }
2641
+
2642
+ return new _three.Skeleton(bones, boneInverses);
2643
+ }
2644
+
2645
+ function buildBoneHierarchy(root, joints, boneData) {
2646
+ // setup bone data from visual scene
2647
+ root.traverse(function (object) {
2648
+ if (object.isBone === true) {
2649
+ var boneInverse; // retrieve the boneInverse from the controller data
2650
+
2651
+ for (var i = 0; i < joints.length; i++) {
2652
+ var joint = joints[i];
2653
+
2654
+ if (joint.name === object.name) {
2655
+ boneInverse = joint.boneInverse;
2656
+ break;
2657
+ }
2658
+ }
2659
+
2660
+ if (boneInverse === undefined) {
2661
+ // Unfortunately, there can be joints in the visual scene that are not part of the
2662
+ // corresponding controller. In this case, we have to create a dummy boneInverse matrix
2663
+ // for the respective bone. This bone won't affect any vertices, because there are no skin indices
2664
+ // and weights defined for it. But we still have to add the bone to the sorted bone list in order to
2665
+ // ensure a correct animation of the model.
2666
+ boneInverse = new _three.Matrix4();
2667
+ }
2668
+
2669
+ boneData.push({
2670
+ bone: object,
2671
+ boneInverse: boneInverse,
2672
+ processed: false
2673
+ });
2674
+ }
2675
+ });
2676
+ }
2677
+
2678
+ function buildNode(data) {
2679
+ var objects = [];
2680
+ var matrix = data.matrix;
2681
+ var nodes = data.nodes;
2682
+ var type = data.type;
2683
+ var instanceCameras = data.instanceCameras;
2684
+ var instanceControllers = data.instanceControllers;
2685
+ var instanceLights = data.instanceLights;
2686
+ var instanceGeometries = data.instanceGeometries;
2687
+ var instanceNodes = data.instanceNodes; // nodes
2688
+
2689
+ for (var i = 0, l = nodes.length; i < l; i++) {
2690
+ objects.push(getNode(nodes[i]));
2691
+ } // instance cameras
2692
+
2693
+
2694
+ for (var _i3 = 0, _l2 = instanceCameras.length; _i3 < _l2; _i3++) {
2695
+ var instanceCamera = getCamera(instanceCameras[_i3]);
2696
+
2697
+ if (instanceCamera !== null) {
2698
+ objects.push(instanceCamera.clone());
2699
+ }
2700
+ } // instance controllers
2701
+
2702
+
2703
+ for (var _i4 = 0, _l3 = instanceControllers.length; _i4 < _l3; _i4++) {
2704
+ var instance = instanceControllers[_i4];
2705
+ var controller = getController(instance.id);
2706
+ var geometries = getGeometry(controller.id);
2707
+ var newObjects = buildObjects(geometries, instance.materials);
2708
+ var skeletons = instance.skeletons;
2709
+ var joints = controller.skin.joints;
2710
+ var skeleton = buildSkeleton(skeletons, joints);
2711
+
2712
+ for (var j = 0, jl = newObjects.length; j < jl; j++) {
2713
+ var _object = newObjects[j];
2714
+
2715
+ if (_object.isSkinnedMesh) {
2716
+ _object.bind(skeleton, controller.skin.bindMatrix);
2717
+
2718
+ _object.normalizeSkinWeights();
2719
+ }
2720
+
2721
+ objects.push(_object);
2722
+ }
2723
+ } // instance lights
2724
+
2725
+
2726
+ for (var _i5 = 0, _l4 = instanceLights.length; _i5 < _l4; _i5++) {
2727
+ var instanceLight = getLight(instanceLights[_i5]);
2728
+
2729
+ if (instanceLight !== null) {
2730
+ objects.push(instanceLight.clone());
2731
+ }
2732
+ } // instance geometries
2733
+
2734
+
2735
+ for (var _i6 = 0, _l5 = instanceGeometries.length; _i6 < _l5; _i6++) {
2736
+ var _instance = instanceGeometries[_i6]; // a single geometry instance in collada can lead to multiple object3Ds.
2737
+ // this is the case when primitives are combined like triangles and lines
2738
+
2739
+ var _geometries = getGeometry(_instance.id);
2740
+
2741
+ var _newObjects = buildObjects(_geometries, _instance.materials);
2742
+
2743
+ for (var _j2 = 0, _jl = _newObjects.length; _j2 < _jl; _j2++) {
2744
+ objects.push(_newObjects[_j2]);
2745
+ }
2746
+ } // instance nodes
2747
+
2748
+
2749
+ for (var _i7 = 0, _l6 = instanceNodes.length; _i7 < _l6; _i7++) {
2750
+ objects.push(getNode(instanceNodes[_i7]).clone());
2751
+ }
2752
+
2753
+ var object;
2754
+
2755
+ if (nodes.length === 0 && objects.length === 1) {
2756
+ object = objects[0];
2757
+ } else {
2758
+ object = type === 'JOINT' ? new _three.Bone() : new _three.Group();
2759
+
2760
+ for (var _i8 = 0; _i8 < objects.length; _i8++) {
2761
+ object.add(objects[_i8]);
2762
+ }
2763
+ }
2764
+
2765
+ object.name = type === 'JOINT' ? data.sid : data.name;
2766
+ object.matrix.copy(matrix);
2767
+ object.matrix.decompose(object.position, object.quaternion, object.scale);
2768
+ return object;
2769
+ }
2770
+
2771
+ var fallbackMaterial = new _three.MeshBasicMaterial({
2772
+ color: 0xff00ff
2773
+ });
2774
+
2775
+ function resolveMaterialBinding(keys, instanceMaterials) {
2776
+ var materials = [];
2777
+
2778
+ for (var i = 0, l = keys.length; i < l; i++) {
2779
+ var id = instanceMaterials[keys[i]];
2780
+
2781
+ if (id === undefined) {
2782
+ console.warn('THREE.ColladaLoader: Material with key %s not found. Apply fallback material.', keys[i]);
2783
+ materials.push(fallbackMaterial);
2784
+ } else {
2785
+ materials.push(getMaterial(id));
2786
+ }
2787
+ }
2788
+
2789
+ return materials;
2790
+ }
2791
+
2792
+ function buildObjects(geometries, instanceMaterials) {
2793
+ var objects = [];
2794
+
2795
+ for (var type in geometries) {
2796
+ var geometry = geometries[type];
2797
+ var materials = resolveMaterialBinding(geometry.materialKeys, instanceMaterials); // handle case if no materials are defined
2798
+
2799
+ if (materials.length === 0) {
2800
+ if (type === 'lines' || type === 'linestrips') {
2801
+ materials.push(new _three.LineBasicMaterial());
2802
+ } else {
2803
+ materials.push(new _three.MeshPhongMaterial());
2804
+ }
2805
+ } // regard skinning
2806
+
2807
+
2808
+ var skinning = geometry.data.attributes.skinIndex !== undefined; // choose between a single or multi materials (material array)
2809
+
2810
+ var material = materials.length === 1 ? materials[0] : materials; // now create a specific 3D object
2811
+
2812
+ var object = void 0;
2813
+
2814
+ switch (type) {
2815
+ case 'lines':
2816
+ object = new _three.LineSegments(geometry.data, material);
2817
+ break;
2818
+
2819
+ case 'linestrips':
2820
+ object = new _three.Line(geometry.data, material);
2821
+ break;
2822
+
2823
+ case 'triangles':
2824
+ case 'polylist':
2825
+ if (skinning) {
2826
+ object = new _three.SkinnedMesh(geometry.data, material);
2827
+ } else {
2828
+ object = new _three.Mesh(geometry.data, material);
2829
+ }
2830
+
2831
+ break;
2832
+ }
2833
+
2834
+ objects.push(object);
2835
+ }
2836
+
2837
+ return objects;
2838
+ }
2839
+
2840
+ function hasNode(id) {
2841
+ return library.nodes[id] !== undefined;
2842
+ }
2843
+
2844
+ function getNode(id) {
2845
+ return getBuild(library.nodes[id], buildNode);
2846
+ } // visual scenes
2847
+
2848
+
2849
+ function parseVisualScene(xml) {
2850
+ var data = {
2851
+ name: xml.getAttribute('name'),
2852
+ children: []
2853
+ };
2854
+ prepareNodes(xml);
2855
+ var elements = getElementsByTagName(xml, 'node');
2856
+
2857
+ for (var i = 0; i < elements.length; i++) {
2858
+ data.children.push(parseNode(elements[i]));
2859
+ }
2860
+
2861
+ library.visualScenes[xml.getAttribute('id')] = data;
2862
+ }
2863
+
2864
+ function buildVisualScene(data) {
2865
+ var group = new _three.Group();
2866
+ group.name = data.name;
2867
+ var children = data.children;
2868
+
2869
+ for (var i = 0; i < children.length; i++) {
2870
+ var child = children[i];
2871
+ group.add(getNode(child.id));
2872
+ }
2873
+
2874
+ return group;
2875
+ }
2876
+
2877
+ function hasVisualScene(id) {
2878
+ return library.visualScenes[id] !== undefined;
2879
+ }
2880
+
2881
+ function getVisualScene(id) {
2882
+ return getBuild(library.visualScenes[id], buildVisualScene);
2883
+ } // scenes
2884
+
2885
+
2886
+ function parseScene(xml) {
2887
+ var instance = getElementsByTagName(xml, 'instance_visual_scene')[0];
2888
+ return getVisualScene(parseId(instance.getAttribute('url')));
2889
+ }
2890
+
2891
+ function setupAnimations() {
2892
+ var clips = library.clips;
2893
+
2894
+ if (isEmpty(clips) === true) {
2895
+ if (isEmpty(library.animations) === false) {
2896
+ // if there are animations but no clips, we create a default clip for playback
2897
+ var tracks = [];
2898
+
2899
+ for (var id in library.animations) {
2900
+ var animationTracks = getAnimation(id);
2901
+
2902
+ for (var i = 0, l = animationTracks.length; i < l; i++) {
2903
+ tracks.push(animationTracks[i]);
2904
+ }
2905
+ }
2906
+
2907
+ animations.push(new _three.AnimationClip('default', -1, tracks));
2908
+ }
2909
+ } else {
2910
+ for (var _id in clips) {
2911
+ animations.push(getAnimationClip(_id));
2912
+ }
2913
+ }
2914
+ } // convert the parser error element into text with each child elements text
2915
+ // separated by new lines.
2916
+
2917
+
2918
+ function parserErrorToText(parserError) {
2919
+ var result = '';
2920
+ var stack = [parserError];
2921
+
2922
+ while (stack.length) {
2923
+ var node = stack.shift();
2924
+
2925
+ if (node.nodeType === Node.TEXT_NODE) {
2926
+ result += node.textContent;
2927
+ } else {
2928
+ result += '\n';
2929
+ stack.push.apply(stack, node.childNodes);
2930
+ }
2931
+ }
2932
+
2933
+ return result.trim();
2934
+ }
2935
+
2936
+ if (text.length === 0) {
2937
+ return {
2938
+ scene: new _three.Scene()
2939
+ };
2940
+ }
2941
+
2942
+ var xml = new DOMParser().parseFromString(text, 'application/xml');
2943
+ var collada = getElementsByTagName(xml, 'COLLADA')[0];
2944
+ var parserError = xml.getElementsByTagName('parsererror')[0];
2945
+
2946
+ if (parserError !== undefined) {
2947
+ // Chrome will return parser error with a div in it
2948
+ var errorElement = getElementsByTagName(parserError, 'div')[0];
2949
+ var errorText;
2950
+
2951
+ if (errorElement) {
2952
+ errorText = errorElement.textContent;
2953
+ } else {
2954
+ errorText = parserErrorToText(parserError);
2955
+ }
2956
+
2957
+ console.error('THREE.ColladaLoader: Failed to parse collada file.\n', errorText);
2958
+ return null;
2959
+ } // metadata
2960
+
2961
+
2962
+ var version = collada.getAttribute('version');
2963
+ console.log('THREE.ColladaLoader: File version', version);
2964
+ var asset = parseAsset(getElementsByTagName(collada, 'asset')[0]);
2965
+ var textureLoader = new _three.TextureLoader(this.manager);
2966
+ textureLoader.setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
2967
+ var tgaLoader;
2968
+
2969
+ if (_TGALoader.TGALoader) {
2970
+ tgaLoader = new _TGALoader.TGALoader(this.manager);
2971
+ tgaLoader.setPath(this.resourcePath || path);
2972
+ } //
2973
+
2974
+
2975
+ var animations = [];
2976
+ var kinematics = {};
2977
+ var count = 0; //
2978
+
2979
+ var library = {
2980
+ animations: {},
2981
+ clips: {},
2982
+ controllers: {},
2983
+ images: {},
2984
+ effects: {},
2985
+ materials: {},
2986
+ cameras: {},
2987
+ lights: {},
2988
+ geometries: {},
2989
+ nodes: {},
2990
+ visualScenes: {},
2991
+ kinematicsModels: {},
2992
+ physicsModels: {},
2993
+ kinematicsScenes: {}
2994
+ };
2995
+ parseLibrary(collada, 'library_animations', 'animation', parseAnimation);
2996
+ parseLibrary(collada, 'library_animation_clips', 'animation_clip', parseAnimationClip);
2997
+ parseLibrary(collada, 'library_controllers', 'controller', parseController);
2998
+ parseLibrary(collada, 'library_images', 'image', parseImage);
2999
+ parseLibrary(collada, 'library_effects', 'effect', parseEffect);
3000
+ parseLibrary(collada, 'library_materials', 'material', parseMaterial);
3001
+ parseLibrary(collada, 'library_cameras', 'camera', parseCamera);
3002
+ parseLibrary(collada, 'library_lights', 'light', parseLight);
3003
+ parseLibrary(collada, 'library_geometries', 'geometry', parseGeometry);
3004
+ parseLibrary(collada, 'library_nodes', 'node', parseNode);
3005
+ parseLibrary(collada, 'library_visual_scenes', 'visual_scene', parseVisualScene);
3006
+ parseLibrary(collada, 'library_kinematics_models', 'kinematics_model', parseKinematicsModel);
3007
+ parseLibrary(collada, 'library_physics_models', 'physics_model', parsePhysicsModel);
3008
+ parseLibrary(collada, 'scene', 'instance_kinematics_scene', parseKinematicsScene);
3009
+ buildLibrary(library.animations, buildAnimation);
3010
+ buildLibrary(library.clips, buildAnimationClip);
3011
+ buildLibrary(library.controllers, buildController);
3012
+ buildLibrary(library.images, buildImage);
3013
+ buildLibrary(library.effects, buildEffect);
3014
+ buildLibrary(library.materials, buildMaterial);
3015
+ buildLibrary(library.cameras, buildCamera);
3016
+ buildLibrary(library.lights, buildLight);
3017
+ buildLibrary(library.geometries, buildGeometry);
3018
+ buildLibrary(library.visualScenes, buildVisualScene);
3019
+ setupAnimations();
3020
+ setupKinematics();
3021
+ var scene = parseScene(getElementsByTagName(collada, 'scene')[0]);
3022
+ scene.animations = animations;
3023
+
3024
+ if (asset.upAxis === 'Z_UP') {
3025
+ scene.quaternion.setFromEuler(new _three.Euler(-Math.PI / 2, 0, 0));
3026
+ }
3027
+
3028
+ scene.scale.multiplyScalar(asset.unit);
3029
+ return {
3030
+ get animations() {
3031
+ console.warn('THREE.ColladaLoader: Please access animations over scene.animations now.');
3032
+ return animations;
3033
+ },
3034
+
3035
+ kinematics: kinematics,
3036
+ library: library,
3037
+ scene: scene
3038
+ };
3039
+ }
3040
+ }]);
3041
+
3042
+ return ColladaLoader;
3043
+ }(_three.Loader);
3044
+
3045
+ _exports.ColladaLoader = ColladaLoader;
3046
+ });