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,2042 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "three"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("three"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.three);
11
+ global.GLTFExporter = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.GLTFExporter = void 0;
20
+
21
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
22
+
23
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
24
+
25
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
+
27
+ 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); } }
28
+
29
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
30
+
31
+ var GLTFExporter = /*#__PURE__*/function () {
32
+ function GLTFExporter() {
33
+ _classCallCheck(this, GLTFExporter);
34
+
35
+ this.pluginCallbacks = [];
36
+ this.register(function (writer) {
37
+ return new GLTFLightExtension(writer);
38
+ });
39
+ this.register(function (writer) {
40
+ return new GLTFMaterialsUnlitExtension(writer);
41
+ });
42
+ this.register(function (writer) {
43
+ return new GLTFMaterialsPBRSpecularGlossiness(writer);
44
+ });
45
+ this.register(function (writer) {
46
+ return new GLTFMaterialsTransmissionExtension(writer);
47
+ });
48
+ this.register(function (writer) {
49
+ return new GLTFMaterialsVolumeExtension(writer);
50
+ });
51
+ this.register(function (writer) {
52
+ return new GLTFMaterialsClearcoatExtension(writer);
53
+ });
54
+ }
55
+
56
+ _createClass(GLTFExporter, [{
57
+ key: "register",
58
+ value: function register(callback) {
59
+ if (this.pluginCallbacks.indexOf(callback) === -1) {
60
+ this.pluginCallbacks.push(callback);
61
+ }
62
+
63
+ return this;
64
+ }
65
+ }, {
66
+ key: "unregister",
67
+ value: function unregister(callback) {
68
+ if (this.pluginCallbacks.indexOf(callback) !== -1) {
69
+ this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback), 1);
70
+ }
71
+
72
+ return this;
73
+ }
74
+ /**
75
+ * Parse scenes and generate GLTF output
76
+ * @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
77
+ * @param {Function} onDone Callback on completed
78
+ * @param {Function} onError Callback on errors
79
+ * @param {Object} options options
80
+ */
81
+
82
+ }, {
83
+ key: "parse",
84
+ value: function parse(input, onDone, onError, options) {
85
+ if (typeof onError === 'object') {
86
+ console.warn('THREE.GLTFExporter: parse() expects options as the fourth argument now.');
87
+ options = onError;
88
+ }
89
+
90
+ var writer = new GLTFWriter();
91
+ var plugins = [];
92
+
93
+ for (var i = 0, il = this.pluginCallbacks.length; i < il; i++) {
94
+ plugins.push(this.pluginCallbacks[i](writer));
95
+ }
96
+
97
+ writer.setPlugins(plugins);
98
+ writer.write(input, onDone, options).catch(onError);
99
+ }
100
+ }, {
101
+ key: "parseAsync",
102
+ value: function parseAsync(input, options) {
103
+ var scope = this;
104
+ return new Promise(function (resolve, reject) {
105
+ scope.parse(input, resolve, reject, options);
106
+ });
107
+ }
108
+ }]);
109
+
110
+ return GLTFExporter;
111
+ }(); //------------------------------------------------------------------------------
112
+ // Constants
113
+ //------------------------------------------------------------------------------
114
+
115
+
116
+ _exports.GLTFExporter = GLTFExporter;
117
+ var WEBGL_CONSTANTS = {
118
+ POINTS: 0x0000,
119
+ LINES: 0x0001,
120
+ LINE_LOOP: 0x0002,
121
+ LINE_STRIP: 0x0003,
122
+ TRIANGLES: 0x0004,
123
+ TRIANGLE_STRIP: 0x0005,
124
+ TRIANGLE_FAN: 0x0006,
125
+ UNSIGNED_BYTE: 0x1401,
126
+ UNSIGNED_SHORT: 0x1403,
127
+ FLOAT: 0x1406,
128
+ UNSIGNED_INT: 0x1405,
129
+ ARRAY_BUFFER: 0x8892,
130
+ ELEMENT_ARRAY_BUFFER: 0x8893,
131
+ NEAREST: 0x2600,
132
+ LINEAR: 0x2601,
133
+ NEAREST_MIPMAP_NEAREST: 0x2700,
134
+ LINEAR_MIPMAP_NEAREST: 0x2701,
135
+ NEAREST_MIPMAP_LINEAR: 0x2702,
136
+ LINEAR_MIPMAP_LINEAR: 0x2703,
137
+ CLAMP_TO_EDGE: 33071,
138
+ MIRRORED_REPEAT: 33648,
139
+ REPEAT: 10497
140
+ };
141
+ var THREE_TO_WEBGL = {};
142
+ THREE_TO_WEBGL[_three.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
143
+ THREE_TO_WEBGL[_three.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
144
+ THREE_TO_WEBGL[_three.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
145
+ THREE_TO_WEBGL[_three.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
146
+ THREE_TO_WEBGL[_three.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
147
+ THREE_TO_WEBGL[_three.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
148
+ THREE_TO_WEBGL[_three.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
149
+ THREE_TO_WEBGL[_three.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
150
+ THREE_TO_WEBGL[_three.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
151
+ var PATH_PROPERTIES = {
152
+ scale: 'scale',
153
+ position: 'translation',
154
+ quaternion: 'rotation',
155
+ morphTargetInfluences: 'weights'
156
+ }; // GLB constants
157
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
158
+
159
+ var GLB_HEADER_BYTES = 12;
160
+ var GLB_HEADER_MAGIC = 0x46546C67;
161
+ var GLB_VERSION = 2;
162
+ var GLB_CHUNK_PREFIX_BYTES = 8;
163
+ var GLB_CHUNK_TYPE_JSON = 0x4E4F534A;
164
+ var GLB_CHUNK_TYPE_BIN = 0x004E4942; //------------------------------------------------------------------------------
165
+ // Utility functions
166
+ //------------------------------------------------------------------------------
167
+
168
+ /**
169
+ * Compare two arrays
170
+ * @param {Array} array1 Array 1 to compare
171
+ * @param {Array} array2 Array 2 to compare
172
+ * @return {Boolean} Returns true if both arrays are equal
173
+ */
174
+
175
+ function equalArray(array1, array2) {
176
+ return array1.length === array2.length && array1.every(function (element, index) {
177
+ return element === array2[index];
178
+ });
179
+ }
180
+ /**
181
+ * Converts a string to an ArrayBuffer.
182
+ * @param {string} text
183
+ * @return {ArrayBuffer}
184
+ */
185
+
186
+
187
+ function stringToArrayBuffer(text) {
188
+ if (window.TextEncoder !== undefined) {
189
+ return new TextEncoder().encode(text).buffer;
190
+ }
191
+
192
+ var array = new Uint8Array(new ArrayBuffer(text.length));
193
+
194
+ for (var i = 0, il = text.length; i < il; i++) {
195
+ var value = text.charCodeAt(i); // Replacing multi-byte character with space(0x20).
196
+
197
+ array[i] = value > 0xFF ? 0x20 : value;
198
+ }
199
+
200
+ return array.buffer;
201
+ }
202
+ /**
203
+ * Is identity matrix
204
+ *
205
+ * @param {Matrix4} matrix
206
+ * @returns {Boolean} Returns true, if parameter is identity matrix
207
+ */
208
+
209
+
210
+ function isIdentityMatrix(matrix) {
211
+ return equalArray(matrix.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
212
+ }
213
+ /**
214
+ * Get the min and max vectors from the given attribute
215
+ * @param {BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
216
+ * @param {Integer} start
217
+ * @param {Integer} count
218
+ * @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
219
+ */
220
+
221
+
222
+ function getMinMax(attribute, start, count) {
223
+ var output = {
224
+ min: new Array(attribute.itemSize).fill(Number.POSITIVE_INFINITY),
225
+ max: new Array(attribute.itemSize).fill(Number.NEGATIVE_INFINITY)
226
+ };
227
+
228
+ for (var i = start; i < start + count; i++) {
229
+ for (var a = 0; a < attribute.itemSize; a++) {
230
+ var value = void 0;
231
+
232
+ if (attribute.itemSize > 4) {
233
+ // no support for interleaved data for itemSize > 4
234
+ value = attribute.array[i * attribute.itemSize + a];
235
+ } else {
236
+ if (a === 0) value = attribute.getX(i);else if (a === 1) value = attribute.getY(i);else if (a === 2) value = attribute.getZ(i);else if (a === 3) value = attribute.getW(i);
237
+ }
238
+
239
+ output.min[a] = Math.min(output.min[a], value);
240
+ output.max[a] = Math.max(output.max[a], value);
241
+ }
242
+ }
243
+
244
+ return output;
245
+ }
246
+ /**
247
+ * Get the required size + padding for a buffer, rounded to the next 4-byte boundary.
248
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
249
+ *
250
+ * @param {Integer} bufferSize The size the original buffer.
251
+ * @returns {Integer} new buffer size with required padding.
252
+ *
253
+ */
254
+
255
+
256
+ function getPaddedBufferSize(bufferSize) {
257
+ return Math.ceil(bufferSize / 4) * 4;
258
+ }
259
+ /**
260
+ * Returns a buffer aligned to 4-byte boundary.
261
+ *
262
+ * @param {ArrayBuffer} arrayBuffer Buffer to pad
263
+ * @param {Integer} paddingByte (Optional)
264
+ * @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
265
+ */
266
+
267
+
268
+ function getPaddedArrayBuffer(arrayBuffer) {
269
+ var paddingByte = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
270
+ var paddedLength = getPaddedBufferSize(arrayBuffer.byteLength);
271
+
272
+ if (paddedLength !== arrayBuffer.byteLength) {
273
+ var array = new Uint8Array(paddedLength);
274
+ array.set(new Uint8Array(arrayBuffer));
275
+
276
+ if (paddingByte !== 0) {
277
+ for (var i = arrayBuffer.byteLength; i < paddedLength; i++) {
278
+ array[i] = paddingByte;
279
+ }
280
+ }
281
+
282
+ return array.buffer;
283
+ }
284
+
285
+ return arrayBuffer;
286
+ }
287
+
288
+ var cachedCanvas = null;
289
+ /**
290
+ * Writer
291
+ */
292
+
293
+ var GLTFWriter = /*#__PURE__*/function () {
294
+ function GLTFWriter() {
295
+ _classCallCheck(this, GLTFWriter);
296
+
297
+ this.plugins = [];
298
+ this.options = {};
299
+ this.pending = [];
300
+ this.buffers = [];
301
+ this.byteOffset = 0;
302
+ this.buffers = [];
303
+ this.nodeMap = new Map();
304
+ this.skins = [];
305
+ this.extensionsUsed = {};
306
+ this.uids = new Map();
307
+ this.uid = 0;
308
+ this.json = {
309
+ asset: {
310
+ version: '2.0',
311
+ generator: 'THREE.GLTFExporter'
312
+ }
313
+ };
314
+ this.cache = {
315
+ meshes: new Map(),
316
+ attributes: new Map(),
317
+ attributesNormalized: new Map(),
318
+ materials: new Map(),
319
+ textures: new Map(),
320
+ images: new Map()
321
+ };
322
+ }
323
+
324
+ _createClass(GLTFWriter, [{
325
+ key: "setPlugins",
326
+ value: function setPlugins(plugins) {
327
+ this.plugins = plugins;
328
+ }
329
+ /**
330
+ * Parse scenes and generate GLTF output
331
+ * @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
332
+ * @param {Function} onDone Callback on completed
333
+ * @param {Object} options options
334
+ */
335
+
336
+ }, {
337
+ key: "write",
338
+ value: function () {
339
+ var _write = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(input, onDone, options) {
340
+ var writer, buffers, json, extensionsUsed, blob, extensionsUsedList, reader, _reader;
341
+
342
+ return regeneratorRuntime.wrap(function _callee$(_context) {
343
+ while (1) {
344
+ switch (_context.prev = _context.next) {
345
+ case 0:
346
+ this.options = Object.assign({}, {
347
+ // default options
348
+ binary: false,
349
+ trs: false,
350
+ onlyVisible: true,
351
+ truncateDrawRange: true,
352
+ embedImages: true,
353
+ maxTextureSize: Infinity,
354
+ animations: [],
355
+ includeCustomExtensions: false
356
+ }, options);
357
+
358
+ if (this.options.animations.length > 0) {
359
+ // Only TRS properties, and not matrices, may be targeted by animation.
360
+ this.options.trs = true;
361
+ }
362
+
363
+ this.processInput(input);
364
+ _context.next = 5;
365
+ return Promise.all(this.pending);
366
+
367
+ case 5:
368
+ writer = this;
369
+ buffers = writer.buffers;
370
+ json = writer.json;
371
+ options = writer.options;
372
+ extensionsUsed = writer.extensionsUsed; // Merge buffers.
373
+
374
+ blob = new Blob(buffers, {
375
+ type: 'application/octet-stream'
376
+ }); // Declare extensions.
377
+
378
+ extensionsUsedList = Object.keys(extensionsUsed);
379
+ if (extensionsUsedList.length > 0) json.extensionsUsed = extensionsUsedList; // Update bytelength of the single buffer.
380
+
381
+ if (json.buffers && json.buffers.length > 0) json.buffers[0].byteLength = blob.size;
382
+
383
+ if (options.binary === true) {
384
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
385
+ reader = new window.FileReader();
386
+ reader.readAsArrayBuffer(blob);
387
+
388
+ reader.onloadend = function () {
389
+ // Binary chunk.
390
+ var binaryChunk = getPaddedArrayBuffer(reader.result);
391
+ var binaryChunkPrefix = new DataView(new ArrayBuffer(GLB_CHUNK_PREFIX_BYTES));
392
+ binaryChunkPrefix.setUint32(0, binaryChunk.byteLength, true);
393
+ binaryChunkPrefix.setUint32(4, GLB_CHUNK_TYPE_BIN, true); // JSON chunk.
394
+
395
+ var jsonChunk = getPaddedArrayBuffer(stringToArrayBuffer(JSON.stringify(json)), 0x20);
396
+ var jsonChunkPrefix = new DataView(new ArrayBuffer(GLB_CHUNK_PREFIX_BYTES));
397
+ jsonChunkPrefix.setUint32(0, jsonChunk.byteLength, true);
398
+ jsonChunkPrefix.setUint32(4, GLB_CHUNK_TYPE_JSON, true); // GLB header.
399
+
400
+ var header = new ArrayBuffer(GLB_HEADER_BYTES);
401
+ var headerView = new DataView(header);
402
+ headerView.setUint32(0, GLB_HEADER_MAGIC, true);
403
+ headerView.setUint32(4, GLB_VERSION, true);
404
+ var totalByteLength = GLB_HEADER_BYTES + jsonChunkPrefix.byteLength + jsonChunk.byteLength + binaryChunkPrefix.byteLength + binaryChunk.byteLength;
405
+ headerView.setUint32(8, totalByteLength, true);
406
+ var glbBlob = new Blob([header, jsonChunkPrefix, jsonChunk, binaryChunkPrefix, binaryChunk], {
407
+ type: 'application/octet-stream'
408
+ });
409
+ var glbReader = new window.FileReader();
410
+ glbReader.readAsArrayBuffer(glbBlob);
411
+
412
+ glbReader.onloadend = function () {
413
+ onDone(glbReader.result);
414
+ };
415
+ };
416
+ } else {
417
+ if (json.buffers && json.buffers.length > 0) {
418
+ _reader = new window.FileReader();
419
+
420
+ _reader.readAsDataURL(blob);
421
+
422
+ _reader.onloadend = function () {
423
+ var base64data = _reader.result;
424
+ json.buffers[0].uri = base64data;
425
+ onDone(json);
426
+ };
427
+ } else {
428
+ onDone(json);
429
+ }
430
+ }
431
+
432
+ case 15:
433
+ case "end":
434
+ return _context.stop();
435
+ }
436
+ }
437
+ }, _callee, this);
438
+ }));
439
+
440
+ function write(_x, _x2, _x3) {
441
+ return _write.apply(this, arguments);
442
+ }
443
+
444
+ return write;
445
+ }()
446
+ /**
447
+ * Serializes a userData.
448
+ *
449
+ * @param {THREE.Object3D|THREE.Material} object
450
+ * @param {Object} objectDef
451
+ */
452
+
453
+ }, {
454
+ key: "serializeUserData",
455
+ value: function serializeUserData(object, objectDef) {
456
+ if (Object.keys(object.userData).length === 0) return;
457
+ var options = this.options;
458
+ var extensionsUsed = this.extensionsUsed;
459
+
460
+ try {
461
+ var json = JSON.parse(JSON.stringify(object.userData));
462
+
463
+ if (options.includeCustomExtensions && json.gltfExtensions) {
464
+ if (objectDef.extensions === undefined) objectDef.extensions = {};
465
+
466
+ for (var extensionName in json.gltfExtensions) {
467
+ objectDef.extensions[extensionName] = json.gltfExtensions[extensionName];
468
+ extensionsUsed[extensionName] = true;
469
+ }
470
+
471
+ delete json.gltfExtensions;
472
+ }
473
+
474
+ if (Object.keys(json).length > 0) objectDef.extras = json;
475
+ } catch (error) {
476
+ console.warn('THREE.GLTFExporter: userData of \'' + object.name + '\' ' + 'won\'t be serialized because of JSON.stringify error - ' + error.message);
477
+ }
478
+ }
479
+ /**
480
+ * Assign and return a temporal unique id for an object
481
+ * especially which doesn't have .uuid
482
+ * @param {Object} object
483
+ * @return {Integer}
484
+ */
485
+
486
+ }, {
487
+ key: "getUID",
488
+ value: function getUID(object) {
489
+ if (!this.uids.has(object)) this.uids.set(object, this.uid++);
490
+ return this.uids.get(object);
491
+ }
492
+ /**
493
+ * Checks if normal attribute values are normalized.
494
+ *
495
+ * @param {BufferAttribute} normal
496
+ * @returns {Boolean}
497
+ */
498
+
499
+ }, {
500
+ key: "isNormalizedNormalAttribute",
501
+ value: function isNormalizedNormalAttribute(normal) {
502
+ var cache = this.cache;
503
+ if (cache.attributesNormalized.has(normal)) return false;
504
+ var v = new _three.Vector3();
505
+
506
+ for (var i = 0, il = normal.count; i < il; i++) {
507
+ // 0.0005 is from glTF-validator
508
+ if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1.0) > 0.0005) return false;
509
+ }
510
+
511
+ return true;
512
+ }
513
+ /**
514
+ * Creates normalized normal buffer attribute.
515
+ *
516
+ * @param {BufferAttribute} normal
517
+ * @returns {BufferAttribute}
518
+ *
519
+ */
520
+
521
+ }, {
522
+ key: "createNormalizedNormalAttribute",
523
+ value: function createNormalizedNormalAttribute(normal) {
524
+ var cache = this.cache;
525
+ if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
526
+ var attribute = normal.clone();
527
+ var v = new _three.Vector3();
528
+
529
+ for (var i = 0, il = attribute.count; i < il; i++) {
530
+ v.fromBufferAttribute(attribute, i);
531
+
532
+ if (v.x === 0 && v.y === 0 && v.z === 0) {
533
+ // if values can't be normalized set (1, 0, 0)
534
+ v.setX(1.0);
535
+ } else {
536
+ v.normalize();
537
+ }
538
+
539
+ attribute.setXYZ(i, v.x, v.y, v.z);
540
+ }
541
+
542
+ cache.attributesNormalized.set(normal, attribute);
543
+ return attribute;
544
+ }
545
+ /**
546
+ * Applies a texture transform, if present, to the map definition. Requires
547
+ * the KHR_texture_transform extension.
548
+ *
549
+ * @param {Object} mapDef
550
+ * @param {THREE.Texture} texture
551
+ */
552
+
553
+ }, {
554
+ key: "applyTextureTransform",
555
+ value: function applyTextureTransform(mapDef, texture) {
556
+ var didTransform = false;
557
+ var transformDef = {};
558
+
559
+ if (texture.offset.x !== 0 || texture.offset.y !== 0) {
560
+ transformDef.offset = texture.offset.toArray();
561
+ didTransform = true;
562
+ }
563
+
564
+ if (texture.rotation !== 0) {
565
+ transformDef.rotation = texture.rotation;
566
+ didTransform = true;
567
+ }
568
+
569
+ if (texture.repeat.x !== 1 || texture.repeat.y !== 1) {
570
+ transformDef.scale = texture.repeat.toArray();
571
+ didTransform = true;
572
+ }
573
+
574
+ if (didTransform) {
575
+ mapDef.extensions = mapDef.extensions || {};
576
+ mapDef.extensions['KHR_texture_transform'] = transformDef;
577
+ this.extensionsUsed['KHR_texture_transform'] = true;
578
+ }
579
+ }
580
+ /**
581
+ * Process a buffer to append to the default one.
582
+ * @param {ArrayBuffer} buffer
583
+ * @return {Integer}
584
+ */
585
+
586
+ }, {
587
+ key: "processBuffer",
588
+ value: function processBuffer(buffer) {
589
+ var json = this.json;
590
+ var buffers = this.buffers;
591
+ if (!json.buffers) json.buffers = [{
592
+ byteLength: 0
593
+ }]; // All buffers are merged before export.
594
+
595
+ buffers.push(buffer);
596
+ return 0;
597
+ }
598
+ /**
599
+ * Process and generate a BufferView
600
+ * @param {BufferAttribute} attribute
601
+ * @param {number} componentType
602
+ * @param {number} start
603
+ * @param {number} count
604
+ * @param {number} target (Optional) Target usage of the BufferView
605
+ * @return {Object}
606
+ */
607
+
608
+ }, {
609
+ key: "processBufferView",
610
+ value: function processBufferView(attribute, componentType, start, count, target) {
611
+ var json = this.json;
612
+ if (!json.bufferViews) json.bufferViews = []; // Create a new dataview and dump the attribute's array into it
613
+
614
+ var componentSize;
615
+
616
+ if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) {
617
+ componentSize = 1;
618
+ } else if (componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT) {
619
+ componentSize = 2;
620
+ } else {
621
+ componentSize = 4;
622
+ }
623
+
624
+ var byteLength = getPaddedBufferSize(count * attribute.itemSize * componentSize);
625
+ var dataView = new DataView(new ArrayBuffer(byteLength));
626
+ var offset = 0;
627
+
628
+ for (var i = start; i < start + count; i++) {
629
+ for (var a = 0; a < attribute.itemSize; a++) {
630
+ var value = void 0;
631
+
632
+ if (attribute.itemSize > 4) {
633
+ // no support for interleaved data for itemSize > 4
634
+ value = attribute.array[i * attribute.itemSize + a];
635
+ } else {
636
+ if (a === 0) value = attribute.getX(i);else if (a === 1) value = attribute.getY(i);else if (a === 2) value = attribute.getZ(i);else if (a === 3) value = attribute.getW(i);
637
+ }
638
+
639
+ if (componentType === WEBGL_CONSTANTS.FLOAT) {
640
+ dataView.setFloat32(offset, value, true);
641
+ } else if (componentType === WEBGL_CONSTANTS.UNSIGNED_INT) {
642
+ dataView.setUint32(offset, value, true);
643
+ } else if (componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT) {
644
+ dataView.setUint16(offset, value, true);
645
+ } else if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) {
646
+ dataView.setUint8(offset, value);
647
+ }
648
+
649
+ offset += componentSize;
650
+ }
651
+ }
652
+
653
+ var bufferViewDef = {
654
+ buffer: this.processBuffer(dataView.buffer),
655
+ byteOffset: this.byteOffset,
656
+ byteLength: byteLength
657
+ };
658
+ if (target !== undefined) bufferViewDef.target = target;
659
+
660
+ if (target === WEBGL_CONSTANTS.ARRAY_BUFFER) {
661
+ // Only define byteStride for vertex attributes.
662
+ bufferViewDef.byteStride = attribute.itemSize * componentSize;
663
+ }
664
+
665
+ this.byteOffset += byteLength;
666
+ json.bufferViews.push(bufferViewDef); // @TODO Merge bufferViews where possible.
667
+
668
+ var output = {
669
+ id: json.bufferViews.length - 1,
670
+ byteLength: 0
671
+ };
672
+ return output;
673
+ }
674
+ /**
675
+ * Process and generate a BufferView from an image Blob.
676
+ * @param {Blob} blob
677
+ * @return {Promise<Integer>}
678
+ */
679
+
680
+ }, {
681
+ key: "processBufferViewImage",
682
+ value: function processBufferViewImage(blob) {
683
+ var writer = this;
684
+ var json = writer.json;
685
+ if (!json.bufferViews) json.bufferViews = [];
686
+ return new Promise(function (resolve) {
687
+ var reader = new window.FileReader();
688
+ reader.readAsArrayBuffer(blob);
689
+
690
+ reader.onloadend = function () {
691
+ var buffer = getPaddedArrayBuffer(reader.result);
692
+ var bufferViewDef = {
693
+ buffer: writer.processBuffer(buffer),
694
+ byteOffset: writer.byteOffset,
695
+ byteLength: buffer.byteLength
696
+ };
697
+ writer.byteOffset += buffer.byteLength;
698
+ resolve(json.bufferViews.push(bufferViewDef) - 1);
699
+ };
700
+ });
701
+ }
702
+ /**
703
+ * Process attribute to generate an accessor
704
+ * @param {BufferAttribute} attribute Attribute to process
705
+ * @param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
706
+ * @param {Integer} start (Optional)
707
+ * @param {Integer} count (Optional)
708
+ * @return {Integer|null} Index of the processed accessor on the "accessors" array
709
+ */
710
+
711
+ }, {
712
+ key: "processAccessor",
713
+ value: function processAccessor(attribute, geometry, start, count) {
714
+ var options = this.options;
715
+ var json = this.json;
716
+ var types = {
717
+ 1: 'SCALAR',
718
+ 2: 'VEC2',
719
+ 3: 'VEC3',
720
+ 4: 'VEC4',
721
+ 16: 'MAT4'
722
+ };
723
+ var componentType; // Detect the component type of the attribute array (float, uint or ushort)
724
+
725
+ if (attribute.array.constructor === Float32Array) {
726
+ componentType = WEBGL_CONSTANTS.FLOAT;
727
+ } else if (attribute.array.constructor === Uint32Array) {
728
+ componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
729
+ } else if (attribute.array.constructor === Uint16Array) {
730
+ componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
731
+ } else if (attribute.array.constructor === Uint8Array) {
732
+ componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
733
+ } else {
734
+ throw new Error('THREE.GLTFExporter: Unsupported bufferAttribute component type.');
735
+ }
736
+
737
+ if (start === undefined) start = 0;
738
+ if (count === undefined) count = attribute.count; // @TODO Indexed buffer geometry with drawRange not supported yet
739
+
740
+ if (options.truncateDrawRange && geometry !== undefined && geometry.index === null) {
741
+ var end = start + count;
742
+ var end2 = geometry.drawRange.count === Infinity ? attribute.count : geometry.drawRange.start + geometry.drawRange.count;
743
+ start = Math.max(start, geometry.drawRange.start);
744
+ count = Math.min(end, end2) - start;
745
+ if (count < 0) count = 0;
746
+ } // Skip creating an accessor if the attribute doesn't have data to export
747
+
748
+
749
+ if (count === 0) return null;
750
+ var minMax = getMinMax(attribute, start, count);
751
+ var bufferViewTarget; // If geometry isn't provided, don't infer the target usage of the bufferView. For
752
+ // animation samplers, target must not be set.
753
+
754
+ if (geometry !== undefined) {
755
+ bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS.ARRAY_BUFFER;
756
+ }
757
+
758
+ var bufferView = this.processBufferView(attribute, componentType, start, count, bufferViewTarget);
759
+ var accessorDef = {
760
+ bufferView: bufferView.id,
761
+ byteOffset: bufferView.byteOffset,
762
+ componentType: componentType,
763
+ count: count,
764
+ max: minMax.max,
765
+ min: minMax.min,
766
+ type: types[attribute.itemSize]
767
+ };
768
+ if (attribute.normalized === true) accessorDef.normalized = true;
769
+ if (!json.accessors) json.accessors = [];
770
+ return json.accessors.push(accessorDef) - 1;
771
+ }
772
+ /**
773
+ * Process image
774
+ * @param {Image} image to process
775
+ * @param {Integer} format of the image (e.g. RGBFormat, RGBAFormat etc)
776
+ * @param {Boolean} flipY before writing out the image
777
+ * @return {Integer} Index of the processed texture in the "images" array
778
+ */
779
+
780
+ }, {
781
+ key: "processImage",
782
+ value: function processImage(image, format, flipY) {
783
+ var writer = this;
784
+ var cache = writer.cache;
785
+ var json = writer.json;
786
+ var options = writer.options;
787
+ var pending = writer.pending;
788
+ if (!cache.images.has(image)) cache.images.set(image, {});
789
+ var cachedImages = cache.images.get(image);
790
+ var mimeType = format === _three.RGBAFormat ? 'image/png' : 'image/jpeg';
791
+ var key = mimeType + ':flipY/' + flipY.toString();
792
+ if (cachedImages[key] !== undefined) return cachedImages[key];
793
+ if (!json.images) json.images = [];
794
+ var imageDef = {
795
+ mimeType: mimeType
796
+ };
797
+
798
+ if (options.embedImages) {
799
+ var canvas = cachedCanvas = cachedCanvas || document.createElement('canvas');
800
+ canvas.width = Math.min(image.width, options.maxTextureSize);
801
+ canvas.height = Math.min(image.height, options.maxTextureSize);
802
+ var ctx = canvas.getContext('2d');
803
+
804
+ if (flipY === true) {
805
+ ctx.translate(0, canvas.height);
806
+ ctx.scale(1, -1);
807
+ }
808
+
809
+ if (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {
810
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
811
+ } else {
812
+ if (format !== _three.RGBAFormat && format !== _three.RGBFormat) {
813
+ console.error('GLTFExporter: Only RGB and RGBA formats are supported.');
814
+ }
815
+
816
+ if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
817
+ console.warn('GLTFExporter: Image size is bigger than maxTextureSize', image);
818
+ }
819
+
820
+ var data = new Uint8ClampedArray(image.height * image.width * 4);
821
+
822
+ if (format === _three.RGBAFormat) {
823
+ for (var i = 0; i < data.length; i += 4) {
824
+ data[i + 0] = image.data[i + 0];
825
+ data[i + 1] = image.data[i + 1];
826
+ data[i + 2] = image.data[i + 2];
827
+ data[i + 3] = image.data[i + 3];
828
+ }
829
+ } else {
830
+ for (var _i = 0, j = 0; _i < data.length; _i += 4, j += 3) {
831
+ data[_i + 0] = image.data[j + 0];
832
+ data[_i + 1] = image.data[j + 1];
833
+ data[_i + 2] = image.data[j + 2];
834
+ data[_i + 3] = 255;
835
+ }
836
+ }
837
+
838
+ ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);
839
+ }
840
+
841
+ if (options.binary === true) {
842
+ pending.push(new Promise(function (resolve) {
843
+ canvas.toBlob(function (blob) {
844
+ writer.processBufferViewImage(blob).then(function (bufferViewIndex) {
845
+ imageDef.bufferView = bufferViewIndex;
846
+ resolve();
847
+ });
848
+ }, mimeType);
849
+ }));
850
+ } else {
851
+ imageDef.uri = canvas.toDataURL(mimeType);
852
+ }
853
+ } else {
854
+ imageDef.uri = image.src;
855
+ }
856
+
857
+ var index = json.images.push(imageDef) - 1;
858
+ cachedImages[key] = index;
859
+ return index;
860
+ }
861
+ /**
862
+ * Process sampler
863
+ * @param {Texture} map Texture to process
864
+ * @return {Integer} Index of the processed texture in the "samplers" array
865
+ */
866
+
867
+ }, {
868
+ key: "processSampler",
869
+ value: function processSampler(map) {
870
+ var json = this.json;
871
+ if (!json.samplers) json.samplers = [];
872
+ var samplerDef = {
873
+ magFilter: THREE_TO_WEBGL[map.magFilter],
874
+ minFilter: THREE_TO_WEBGL[map.minFilter],
875
+ wrapS: THREE_TO_WEBGL[map.wrapS],
876
+ wrapT: THREE_TO_WEBGL[map.wrapT]
877
+ };
878
+ return json.samplers.push(samplerDef) - 1;
879
+ }
880
+ /**
881
+ * Process texture
882
+ * @param {Texture} map Map to process
883
+ * @return {Integer} Index of the processed texture in the "textures" array
884
+ */
885
+
886
+ }, {
887
+ key: "processTexture",
888
+ value: function processTexture(map) {
889
+ var cache = this.cache;
890
+ var json = this.json;
891
+ if (cache.textures.has(map)) return cache.textures.get(map);
892
+ if (!json.textures) json.textures = [];
893
+ var textureDef = {
894
+ sampler: this.processSampler(map),
895
+ source: this.processImage(map.image, map.format, map.flipY)
896
+ };
897
+ if (map.name) textureDef.name = map.name;
898
+
899
+ this._invokeAll(function (ext) {
900
+ ext.writeTexture && ext.writeTexture(map, textureDef);
901
+ });
902
+
903
+ var index = json.textures.push(textureDef) - 1;
904
+ cache.textures.set(map, index);
905
+ return index;
906
+ }
907
+ /**
908
+ * Process material
909
+ * @param {THREE.Material} material Material to process
910
+ * @return {Integer|null} Index of the processed material in the "materials" array
911
+ */
912
+
913
+ }, {
914
+ key: "processMaterial",
915
+ value: function processMaterial(material) {
916
+ var cache = this.cache;
917
+ var json = this.json;
918
+ if (cache.materials.has(material)) return cache.materials.get(material);
919
+
920
+ if (material.isShaderMaterial) {
921
+ console.warn('GLTFExporter: THREE.ShaderMaterial not supported.');
922
+ return null;
923
+ }
924
+
925
+ if (!json.materials) json.materials = []; // @QUESTION Should we avoid including any attribute that has the default value?
926
+
927
+ var materialDef = {
928
+ pbrMetallicRoughness: {}
929
+ };
930
+
931
+ if (material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true) {
932
+ console.warn('GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.');
933
+ } // pbrMetallicRoughness.baseColorFactor
934
+
935
+
936
+ var color = material.color.toArray().concat([material.opacity]);
937
+
938
+ if (!equalArray(color, [1, 1, 1, 1])) {
939
+ materialDef.pbrMetallicRoughness.baseColorFactor = color;
940
+ }
941
+
942
+ if (material.isMeshStandardMaterial) {
943
+ materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
944
+ materialDef.pbrMetallicRoughness.roughnessFactor = material.roughness;
945
+ } else {
946
+ materialDef.pbrMetallicRoughness.metallicFactor = 0.5;
947
+ materialDef.pbrMetallicRoughness.roughnessFactor = 0.5;
948
+ } // pbrMetallicRoughness.metallicRoughnessTexture
949
+
950
+
951
+ if (material.metalnessMap || material.roughnessMap) {
952
+ if (material.metalnessMap === material.roughnessMap) {
953
+ var metalRoughMapDef = {
954
+ index: this.processTexture(material.metalnessMap)
955
+ };
956
+ this.applyTextureTransform(metalRoughMapDef, material.metalnessMap);
957
+ materialDef.pbrMetallicRoughness.metallicRoughnessTexture = metalRoughMapDef;
958
+ } else {
959
+ console.warn('THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.');
960
+ }
961
+ } // pbrMetallicRoughness.baseColorTexture or pbrSpecularGlossiness diffuseTexture
962
+
963
+
964
+ if (material.map) {
965
+ var baseColorMapDef = {
966
+ index: this.processTexture(material.map)
967
+ };
968
+ this.applyTextureTransform(baseColorMapDef, material.map);
969
+ materialDef.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
970
+ }
971
+
972
+ if (material.emissive) {
973
+ // note: emissive components are limited to stay within the 0 - 1 range to accommodate glTF spec. see #21849 and #22000.
974
+ var emissive = material.emissive.clone().multiplyScalar(material.emissiveIntensity);
975
+ var maxEmissiveComponent = Math.max(emissive.r, emissive.g, emissive.b);
976
+
977
+ if (maxEmissiveComponent > 1) {
978
+ emissive.multiplyScalar(1 / maxEmissiveComponent);
979
+ console.warn('THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited');
980
+ }
981
+
982
+ if (maxEmissiveComponent > 0) {
983
+ materialDef.emissiveFactor = emissive.toArray();
984
+ } // emissiveTexture
985
+
986
+
987
+ if (material.emissiveMap) {
988
+ var emissiveMapDef = {
989
+ index: this.processTexture(material.emissiveMap)
990
+ };
991
+ this.applyTextureTransform(emissiveMapDef, material.emissiveMap);
992
+ materialDef.emissiveTexture = emissiveMapDef;
993
+ }
994
+ } // normalTexture
995
+
996
+
997
+ if (material.normalMap) {
998
+ var normalMapDef = {
999
+ index: this.processTexture(material.normalMap)
1000
+ };
1001
+
1002
+ if (material.normalScale && material.normalScale.x !== 1) {
1003
+ // glTF normal scale is univariate. Ignore `y`, which may be flipped.
1004
+ // Context: https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
1005
+ normalMapDef.scale = material.normalScale.x;
1006
+ }
1007
+
1008
+ this.applyTextureTransform(normalMapDef, material.normalMap);
1009
+ materialDef.normalTexture = normalMapDef;
1010
+ } // occlusionTexture
1011
+
1012
+
1013
+ if (material.aoMap) {
1014
+ var occlusionMapDef = {
1015
+ index: this.processTexture(material.aoMap),
1016
+ texCoord: 1
1017
+ };
1018
+
1019
+ if (material.aoMapIntensity !== 1.0) {
1020
+ occlusionMapDef.strength = material.aoMapIntensity;
1021
+ }
1022
+
1023
+ this.applyTextureTransform(occlusionMapDef, material.aoMap);
1024
+ materialDef.occlusionTexture = occlusionMapDef;
1025
+ } // alphaMode
1026
+
1027
+
1028
+ if (material.transparent) {
1029
+ materialDef.alphaMode = 'BLEND';
1030
+ } else {
1031
+ if (material.alphaTest > 0.0) {
1032
+ materialDef.alphaMode = 'MASK';
1033
+ materialDef.alphaCutoff = material.alphaTest;
1034
+ }
1035
+ } // doubleSided
1036
+
1037
+
1038
+ if (material.side === _three.DoubleSide) materialDef.doubleSided = true;
1039
+ if (material.name !== '') materialDef.name = material.name;
1040
+ this.serializeUserData(material, materialDef);
1041
+
1042
+ this._invokeAll(function (ext) {
1043
+ ext.writeMaterial && ext.writeMaterial(material, materialDef);
1044
+ });
1045
+
1046
+ var index = json.materials.push(materialDef) - 1;
1047
+ cache.materials.set(material, index);
1048
+ return index;
1049
+ }
1050
+ /**
1051
+ * Process mesh
1052
+ * @param {THREE.Mesh} mesh Mesh to process
1053
+ * @return {Integer|null} Index of the processed mesh in the "meshes" array
1054
+ */
1055
+
1056
+ }, {
1057
+ key: "processMesh",
1058
+ value: function processMesh(mesh) {
1059
+ var cache = this.cache;
1060
+ var json = this.json;
1061
+ var meshCacheKeyParts = [mesh.geometry.uuid];
1062
+
1063
+ if (Array.isArray(mesh.material)) {
1064
+ for (var i = 0, l = mesh.material.length; i < l; i++) {
1065
+ meshCacheKeyParts.push(mesh.material[i].uuid);
1066
+ }
1067
+ } else {
1068
+ meshCacheKeyParts.push(mesh.material.uuid);
1069
+ }
1070
+
1071
+ var meshCacheKey = meshCacheKeyParts.join(':');
1072
+ if (cache.meshes.has(meshCacheKey)) return cache.meshes.get(meshCacheKey);
1073
+ var geometry = mesh.geometry;
1074
+ var mode; // Use the correct mode
1075
+
1076
+ if (mesh.isLineSegments) {
1077
+ mode = WEBGL_CONSTANTS.LINES;
1078
+ } else if (mesh.isLineLoop) {
1079
+ mode = WEBGL_CONSTANTS.LINE_LOOP;
1080
+ } else if (mesh.isLine) {
1081
+ mode = WEBGL_CONSTANTS.LINE_STRIP;
1082
+ } else if (mesh.isPoints) {
1083
+ mode = WEBGL_CONSTANTS.POINTS;
1084
+ } else {
1085
+ mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
1086
+ }
1087
+
1088
+ if (geometry.isBufferGeometry !== true) {
1089
+ throw new Error('THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.');
1090
+ }
1091
+
1092
+ var meshDef = {};
1093
+ var attributes = {};
1094
+ var primitives = [];
1095
+ var targets = []; // Conversion between attributes names in threejs and gltf spec
1096
+
1097
+ var nameConversion = {
1098
+ uv: 'TEXCOORD_0',
1099
+ uv2: 'TEXCOORD_1',
1100
+ color: 'COLOR_0',
1101
+ skinWeight: 'WEIGHTS_0',
1102
+ skinIndex: 'JOINTS_0'
1103
+ };
1104
+ var originalNormal = geometry.getAttribute('normal');
1105
+
1106
+ if (originalNormal !== undefined && !this.isNormalizedNormalAttribute(originalNormal)) {
1107
+ console.warn('THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.');
1108
+ geometry.setAttribute('normal', this.createNormalizedNormalAttribute(originalNormal));
1109
+ } // @QUESTION Detect if .vertexColors = true?
1110
+ // For every attribute create an accessor
1111
+
1112
+
1113
+ var modifiedAttribute = null;
1114
+
1115
+ for (var attributeName in geometry.attributes) {
1116
+ // Ignore morph target attributes, which are exported later.
1117
+ if (attributeName.substr(0, 5) === 'morph') continue;
1118
+ var attribute = geometry.attributes[attributeName];
1119
+ attributeName = nameConversion[attributeName] || attributeName.toUpperCase(); // Prefix all geometry attributes except the ones specifically
1120
+ // listed in the spec; non-spec attributes are considered custom.
1121
+
1122
+ var validVertexAttributes = /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;
1123
+ if (!validVertexAttributes.test(attributeName)) attributeName = '_' + attributeName;
1124
+
1125
+ if (cache.attributes.has(this.getUID(attribute))) {
1126
+ attributes[attributeName] = cache.attributes.get(this.getUID(attribute));
1127
+ continue;
1128
+ } // JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT.
1129
+
1130
+
1131
+ modifiedAttribute = null;
1132
+ var array = attribute.array;
1133
+
1134
+ if (attributeName === 'JOINTS_0' && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
1135
+ console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
1136
+ modifiedAttribute = new _three.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
1137
+ }
1138
+
1139
+ var accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
1140
+
1141
+ if (accessor !== null) {
1142
+ attributes[attributeName] = accessor;
1143
+ cache.attributes.set(this.getUID(attribute), accessor);
1144
+ }
1145
+ }
1146
+
1147
+ if (originalNormal !== undefined) geometry.setAttribute('normal', originalNormal); // Skip if no exportable attributes found
1148
+
1149
+ if (Object.keys(attributes).length === 0) return null; // Morph targets
1150
+
1151
+ if (mesh.morphTargetInfluences !== undefined && mesh.morphTargetInfluences.length > 0) {
1152
+ var weights = [];
1153
+ var targetNames = [];
1154
+ var reverseDictionary = {};
1155
+
1156
+ if (mesh.morphTargetDictionary !== undefined) {
1157
+ for (var key in mesh.morphTargetDictionary) {
1158
+ reverseDictionary[mesh.morphTargetDictionary[key]] = key;
1159
+ }
1160
+ }
1161
+
1162
+ for (var _i2 = 0; _i2 < mesh.morphTargetInfluences.length; ++_i2) {
1163
+ var target = {};
1164
+ var warned = false;
1165
+
1166
+ for (var _attributeName in geometry.morphAttributes) {
1167
+ // glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
1168
+ // Three.js doesn't support TANGENT yet.
1169
+ if (_attributeName !== 'position' && _attributeName !== 'normal') {
1170
+ if (!warned) {
1171
+ console.warn('GLTFExporter: Only POSITION and NORMAL morph are supported.');
1172
+ warned = true;
1173
+ }
1174
+
1175
+ continue;
1176
+ }
1177
+
1178
+ var _attribute = geometry.morphAttributes[_attributeName][_i2];
1179
+
1180
+ var gltfAttributeName = _attributeName.toUpperCase(); // Three.js morph attribute has absolute values while the one of glTF has relative values.
1181
+ //
1182
+ // glTF 2.0 Specification:
1183
+ // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets
1184
+
1185
+
1186
+ var baseAttribute = geometry.attributes[_attributeName];
1187
+
1188
+ if (cache.attributes.has(this.getUID(_attribute))) {
1189
+ target[gltfAttributeName] = cache.attributes.get(this.getUID(_attribute));
1190
+ continue;
1191
+ } // Clones attribute not to override
1192
+
1193
+
1194
+ var relativeAttribute = _attribute.clone();
1195
+
1196
+ if (!geometry.morphTargetsRelative) {
1197
+ for (var j = 0, jl = _attribute.count; j < jl; j++) {
1198
+ relativeAttribute.setXYZ(j, _attribute.getX(j) - baseAttribute.getX(j), _attribute.getY(j) - baseAttribute.getY(j), _attribute.getZ(j) - baseAttribute.getZ(j));
1199
+ }
1200
+ }
1201
+
1202
+ target[gltfAttributeName] = this.processAccessor(relativeAttribute, geometry);
1203
+ cache.attributes.set(this.getUID(baseAttribute), target[gltfAttributeName]);
1204
+ }
1205
+
1206
+ targets.push(target);
1207
+ weights.push(mesh.morphTargetInfluences[_i2]);
1208
+ if (mesh.morphTargetDictionary !== undefined) targetNames.push(reverseDictionary[_i2]);
1209
+ }
1210
+
1211
+ meshDef.weights = weights;
1212
+
1213
+ if (targetNames.length > 0) {
1214
+ meshDef.extras = {};
1215
+ meshDef.extras.targetNames = targetNames;
1216
+ }
1217
+ }
1218
+
1219
+ var isMultiMaterial = Array.isArray(mesh.material);
1220
+ if (isMultiMaterial && geometry.groups.length === 0) return null;
1221
+ var materials = isMultiMaterial ? mesh.material : [mesh.material];
1222
+ var groups = isMultiMaterial ? geometry.groups : [{
1223
+ materialIndex: 0,
1224
+ start: undefined,
1225
+ count: undefined
1226
+ }];
1227
+
1228
+ for (var _i3 = 0, il = groups.length; _i3 < il; _i3++) {
1229
+ var primitive = {
1230
+ mode: mode,
1231
+ attributes: attributes
1232
+ };
1233
+ this.serializeUserData(geometry, primitive);
1234
+ if (targets.length > 0) primitive.targets = targets;
1235
+
1236
+ if (geometry.index !== null) {
1237
+ var cacheKey = this.getUID(geometry.index);
1238
+
1239
+ if (groups[_i3].start !== undefined || groups[_i3].count !== undefined) {
1240
+ cacheKey += ':' + groups[_i3].start + ':' + groups[_i3].count;
1241
+ }
1242
+
1243
+ if (cache.attributes.has(cacheKey)) {
1244
+ primitive.indices = cache.attributes.get(cacheKey);
1245
+ } else {
1246
+ primitive.indices = this.processAccessor(geometry.index, geometry, groups[_i3].start, groups[_i3].count);
1247
+ cache.attributes.set(cacheKey, primitive.indices);
1248
+ }
1249
+
1250
+ if (primitive.indices === null) delete primitive.indices;
1251
+ }
1252
+
1253
+ var material = this.processMaterial(materials[groups[_i3].materialIndex]);
1254
+ if (material !== null) primitive.material = material;
1255
+ primitives.push(primitive);
1256
+ }
1257
+
1258
+ meshDef.primitives = primitives;
1259
+ if (!json.meshes) json.meshes = [];
1260
+
1261
+ this._invokeAll(function (ext) {
1262
+ ext.writeMesh && ext.writeMesh(mesh, meshDef);
1263
+ });
1264
+
1265
+ var index = json.meshes.push(meshDef) - 1;
1266
+ cache.meshes.set(meshCacheKey, index);
1267
+ return index;
1268
+ }
1269
+ /**
1270
+ * Process camera
1271
+ * @param {THREE.Camera} camera Camera to process
1272
+ * @return {Integer} Index of the processed mesh in the "camera" array
1273
+ */
1274
+
1275
+ }, {
1276
+ key: "processCamera",
1277
+ value: function processCamera(camera) {
1278
+ var json = this.json;
1279
+ if (!json.cameras) json.cameras = [];
1280
+ var isOrtho = camera.isOrthographicCamera;
1281
+ var cameraDef = {
1282
+ type: isOrtho ? 'orthographic' : 'perspective'
1283
+ };
1284
+
1285
+ if (isOrtho) {
1286
+ cameraDef.orthographic = {
1287
+ xmag: camera.right * 2,
1288
+ ymag: camera.top * 2,
1289
+ zfar: camera.far <= 0 ? 0.001 : camera.far,
1290
+ znear: camera.near < 0 ? 0 : camera.near
1291
+ };
1292
+ } else {
1293
+ cameraDef.perspective = {
1294
+ aspectRatio: camera.aspect,
1295
+ yfov: _three.MathUtils.degToRad(camera.fov),
1296
+ zfar: camera.far <= 0 ? 0.001 : camera.far,
1297
+ znear: camera.near < 0 ? 0 : camera.near
1298
+ };
1299
+ } // Question: Is saving "type" as name intentional?
1300
+
1301
+
1302
+ if (camera.name !== '') cameraDef.name = camera.type;
1303
+ return json.cameras.push(cameraDef) - 1;
1304
+ }
1305
+ /**
1306
+ * Creates glTF animation entry from AnimationClip object.
1307
+ *
1308
+ * Status:
1309
+ * - Only properties listed in PATH_PROPERTIES may be animated.
1310
+ *
1311
+ * @param {THREE.AnimationClip} clip
1312
+ * @param {THREE.Object3D} root
1313
+ * @return {number|null}
1314
+ */
1315
+
1316
+ }, {
1317
+ key: "processAnimation",
1318
+ value: function processAnimation(clip, root) {
1319
+ var json = this.json;
1320
+ var nodeMap = this.nodeMap;
1321
+ if (!json.animations) json.animations = [];
1322
+ clip = GLTFExporter.Utils.mergeMorphTargetTracks(clip.clone(), root);
1323
+ var tracks = clip.tracks;
1324
+ var channels = [];
1325
+ var samplers = [];
1326
+
1327
+ for (var i = 0; i < tracks.length; ++i) {
1328
+ var track = tracks[i];
1329
+
1330
+ var trackBinding = _three.PropertyBinding.parseTrackName(track.name);
1331
+
1332
+ var trackNode = _three.PropertyBinding.findNode(root, trackBinding.nodeName);
1333
+
1334
+ var trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
1335
+
1336
+ if (trackBinding.objectName === 'bones') {
1337
+ if (trackNode.isSkinnedMesh === true) {
1338
+ trackNode = trackNode.skeleton.getBoneByName(trackBinding.objectIndex);
1339
+ } else {
1340
+ trackNode = undefined;
1341
+ }
1342
+ }
1343
+
1344
+ if (!trackNode || !trackProperty) {
1345
+ console.warn('THREE.GLTFExporter: Could not export animation track "%s".', track.name);
1346
+ return null;
1347
+ }
1348
+
1349
+ var inputItemSize = 1;
1350
+ var outputItemSize = track.values.length / track.times.length;
1351
+
1352
+ if (trackProperty === PATH_PROPERTIES.morphTargetInfluences) {
1353
+ outputItemSize /= trackNode.morphTargetInfluences.length;
1354
+ }
1355
+
1356
+ var interpolation = void 0; // @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
1357
+ // Detecting glTF cubic spline interpolant by checking factory method's special property
1358
+ // GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
1359
+ // valid value from .getInterpolation().
1360
+
1361
+ if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
1362
+ interpolation = 'CUBICSPLINE'; // itemSize of CUBICSPLINE keyframe is 9
1363
+ // (VEC3 * 3: inTangent, splineVertex, and outTangent)
1364
+ // but needs to be stored as VEC3 so dividing by 3 here.
1365
+
1366
+ outputItemSize /= 3;
1367
+ } else if (track.getInterpolation() === _three.InterpolateDiscrete) {
1368
+ interpolation = 'STEP';
1369
+ } else {
1370
+ interpolation = 'LINEAR';
1371
+ }
1372
+
1373
+ samplers.push({
1374
+ input: this.processAccessor(new _three.BufferAttribute(track.times, inputItemSize)),
1375
+ output: this.processAccessor(new _three.BufferAttribute(track.values, outputItemSize)),
1376
+ interpolation: interpolation
1377
+ });
1378
+ channels.push({
1379
+ sampler: samplers.length - 1,
1380
+ target: {
1381
+ node: nodeMap.get(trackNode),
1382
+ path: trackProperty
1383
+ }
1384
+ });
1385
+ }
1386
+
1387
+ json.animations.push({
1388
+ name: clip.name || 'clip_' + json.animations.length,
1389
+ samplers: samplers,
1390
+ channels: channels
1391
+ });
1392
+ return json.animations.length - 1;
1393
+ }
1394
+ /**
1395
+ * @param {THREE.Object3D} object
1396
+ * @return {number|null}
1397
+ */
1398
+
1399
+ }, {
1400
+ key: "processSkin",
1401
+ value: function processSkin(object) {
1402
+ var json = this.json;
1403
+ var nodeMap = this.nodeMap;
1404
+ var node = json.nodes[nodeMap.get(object)];
1405
+ var skeleton = object.skeleton;
1406
+ if (skeleton === undefined) return null;
1407
+ var rootJoint = object.skeleton.bones[0];
1408
+ if (rootJoint === undefined) return null;
1409
+ var joints = [];
1410
+ var inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
1411
+ var temporaryBoneInverse = new _three.Matrix4();
1412
+
1413
+ for (var i = 0; i < skeleton.bones.length; ++i) {
1414
+ joints.push(nodeMap.get(skeleton.bones[i]));
1415
+ temporaryBoneInverse.copy(skeleton.boneInverses[i]);
1416
+ temporaryBoneInverse.multiply(object.bindMatrix).toArray(inverseBindMatrices, i * 16);
1417
+ }
1418
+
1419
+ if (json.skins === undefined) json.skins = [];
1420
+ json.skins.push({
1421
+ inverseBindMatrices: this.processAccessor(new _three.BufferAttribute(inverseBindMatrices, 16)),
1422
+ joints: joints,
1423
+ skeleton: nodeMap.get(rootJoint)
1424
+ });
1425
+ var skinIndex = node.skin = json.skins.length - 1;
1426
+ return skinIndex;
1427
+ }
1428
+ /**
1429
+ * Process Object3D node
1430
+ * @param {THREE.Object3D} node Object3D to processNode
1431
+ * @return {Integer} Index of the node in the nodes list
1432
+ */
1433
+
1434
+ }, {
1435
+ key: "processNode",
1436
+ value: function processNode(object) {
1437
+ var json = this.json;
1438
+ var options = this.options;
1439
+ var nodeMap = this.nodeMap;
1440
+ if (!json.nodes) json.nodes = [];
1441
+ var nodeDef = {};
1442
+
1443
+ if (options.trs) {
1444
+ var rotation = object.quaternion.toArray();
1445
+ var position = object.position.toArray();
1446
+ var scale = object.scale.toArray();
1447
+
1448
+ if (!equalArray(rotation, [0, 0, 0, 1])) {
1449
+ nodeDef.rotation = rotation;
1450
+ }
1451
+
1452
+ if (!equalArray(position, [0, 0, 0])) {
1453
+ nodeDef.translation = position;
1454
+ }
1455
+
1456
+ if (!equalArray(scale, [1, 1, 1])) {
1457
+ nodeDef.scale = scale;
1458
+ }
1459
+ } else {
1460
+ if (object.matrixAutoUpdate) {
1461
+ object.updateMatrix();
1462
+ }
1463
+
1464
+ if (isIdentityMatrix(object.matrix) === false) {
1465
+ nodeDef.matrix = object.matrix.elements;
1466
+ }
1467
+ } // We don't export empty strings name because it represents no-name in Three.js.
1468
+
1469
+
1470
+ if (object.name !== '') nodeDef.name = String(object.name);
1471
+ this.serializeUserData(object, nodeDef);
1472
+
1473
+ if (object.isMesh || object.isLine || object.isPoints) {
1474
+ var meshIndex = this.processMesh(object);
1475
+ if (meshIndex !== null) nodeDef.mesh = meshIndex;
1476
+ } else if (object.isCamera) {
1477
+ nodeDef.camera = this.processCamera(object);
1478
+ }
1479
+
1480
+ if (object.isSkinnedMesh) this.skins.push(object);
1481
+
1482
+ if (object.children.length > 0) {
1483
+ var children = [];
1484
+
1485
+ for (var i = 0, l = object.children.length; i < l; i++) {
1486
+ var child = object.children[i];
1487
+
1488
+ if (child.visible || options.onlyVisible === false) {
1489
+ var _nodeIndex = this.processNode(child);
1490
+
1491
+ if (_nodeIndex !== null) children.push(_nodeIndex);
1492
+ }
1493
+ }
1494
+
1495
+ if (children.length > 0) nodeDef.children = children;
1496
+ }
1497
+
1498
+ this._invokeAll(function (ext) {
1499
+ ext.writeNode && ext.writeNode(object, nodeDef);
1500
+ });
1501
+
1502
+ var nodeIndex = json.nodes.push(nodeDef) - 1;
1503
+ nodeMap.set(object, nodeIndex);
1504
+ return nodeIndex;
1505
+ }
1506
+ /**
1507
+ * Process Scene
1508
+ * @param {Scene} node Scene to process
1509
+ */
1510
+
1511
+ }, {
1512
+ key: "processScene",
1513
+ value: function processScene(scene) {
1514
+ var json = this.json;
1515
+ var options = this.options;
1516
+
1517
+ if (!json.scenes) {
1518
+ json.scenes = [];
1519
+ json.scene = 0;
1520
+ }
1521
+
1522
+ var sceneDef = {};
1523
+ if (scene.name !== '') sceneDef.name = scene.name;
1524
+ json.scenes.push(sceneDef);
1525
+ var nodes = [];
1526
+
1527
+ for (var i = 0, l = scene.children.length; i < l; i++) {
1528
+ var child = scene.children[i];
1529
+
1530
+ if (child.visible || options.onlyVisible === false) {
1531
+ var nodeIndex = this.processNode(child);
1532
+ if (nodeIndex !== null) nodes.push(nodeIndex);
1533
+ }
1534
+ }
1535
+
1536
+ if (nodes.length > 0) sceneDef.nodes = nodes;
1537
+ this.serializeUserData(scene, sceneDef);
1538
+ }
1539
+ /**
1540
+ * Creates a Scene to hold a list of objects and parse it
1541
+ * @param {Array} objects List of objects to process
1542
+ */
1543
+
1544
+ }, {
1545
+ key: "processObjects",
1546
+ value: function processObjects(objects) {
1547
+ var scene = new _three.Scene();
1548
+ scene.name = 'AuxScene';
1549
+
1550
+ for (var i = 0; i < objects.length; i++) {
1551
+ // We push directly to children instead of calling `add` to prevent
1552
+ // modify the .parent and break its original scene and hierarchy
1553
+ scene.children.push(objects[i]);
1554
+ }
1555
+
1556
+ this.processScene(scene);
1557
+ }
1558
+ /**
1559
+ * @param {THREE.Object3D|Array<THREE.Object3D>} input
1560
+ */
1561
+
1562
+ }, {
1563
+ key: "processInput",
1564
+ value: function processInput(input) {
1565
+ var options = this.options;
1566
+ input = input instanceof Array ? input : [input];
1567
+
1568
+ this._invokeAll(function (ext) {
1569
+ ext.beforeParse && ext.beforeParse(input);
1570
+ });
1571
+
1572
+ var objectsWithoutScene = [];
1573
+
1574
+ for (var i = 0; i < input.length; i++) {
1575
+ if (input[i] instanceof _three.Scene) {
1576
+ this.processScene(input[i]);
1577
+ } else {
1578
+ objectsWithoutScene.push(input[i]);
1579
+ }
1580
+ }
1581
+
1582
+ if (objectsWithoutScene.length > 0) this.processObjects(objectsWithoutScene);
1583
+
1584
+ for (var _i4 = 0; _i4 < this.skins.length; ++_i4) {
1585
+ this.processSkin(this.skins[_i4]);
1586
+ }
1587
+
1588
+ for (var _i5 = 0; _i5 < options.animations.length; ++_i5) {
1589
+ this.processAnimation(options.animations[_i5], input[0]);
1590
+ }
1591
+
1592
+ this._invokeAll(function (ext) {
1593
+ ext.afterParse && ext.afterParse(input);
1594
+ });
1595
+ }
1596
+ }, {
1597
+ key: "_invokeAll",
1598
+ value: function _invokeAll(func) {
1599
+ for (var i = 0, il = this.plugins.length; i < il; i++) {
1600
+ func(this.plugins[i]);
1601
+ }
1602
+ }
1603
+ }]);
1604
+
1605
+ return GLTFWriter;
1606
+ }();
1607
+ /**
1608
+ * Punctual Lights Extension
1609
+ *
1610
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
1611
+ */
1612
+
1613
+
1614
+ var GLTFLightExtension = /*#__PURE__*/function () {
1615
+ function GLTFLightExtension(writer) {
1616
+ _classCallCheck(this, GLTFLightExtension);
1617
+
1618
+ this.writer = writer;
1619
+ this.name = 'KHR_lights_punctual';
1620
+ }
1621
+
1622
+ _createClass(GLTFLightExtension, [{
1623
+ key: "writeNode",
1624
+ value: function writeNode(light, nodeDef) {
1625
+ if (!light.isLight) return;
1626
+
1627
+ if (!light.isDirectionalLight && !light.isPointLight && !light.isSpotLight) {
1628
+ console.warn('THREE.GLTFExporter: Only directional, point, and spot lights are supported.', light);
1629
+ return;
1630
+ }
1631
+
1632
+ var writer = this.writer;
1633
+ var json = writer.json;
1634
+ var extensionsUsed = writer.extensionsUsed;
1635
+ var lightDef = {};
1636
+ if (light.name) lightDef.name = light.name;
1637
+ lightDef.color = light.color.toArray();
1638
+ lightDef.intensity = light.intensity;
1639
+
1640
+ if (light.isDirectionalLight) {
1641
+ lightDef.type = 'directional';
1642
+ } else if (light.isPointLight) {
1643
+ lightDef.type = 'point';
1644
+ if (light.distance > 0) lightDef.range = light.distance;
1645
+ } else if (light.isSpotLight) {
1646
+ lightDef.type = 'spot';
1647
+ if (light.distance > 0) lightDef.range = light.distance;
1648
+ lightDef.spot = {};
1649
+ lightDef.spot.innerConeAngle = (light.penumbra - 1.0) * light.angle * -1.0;
1650
+ lightDef.spot.outerConeAngle = light.angle;
1651
+ }
1652
+
1653
+ if (light.decay !== undefined && light.decay !== 2) {
1654
+ console.warn('THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, ' + 'and expects light.decay=2.');
1655
+ }
1656
+
1657
+ if (light.target && (light.target.parent !== light || light.target.position.x !== 0 || light.target.position.y !== 0 || light.target.position.z !== -1)) {
1658
+ console.warn('THREE.GLTFExporter: Light direction may be lost. For best results, ' + 'make light.target a child of the light with position 0,0,-1.');
1659
+ }
1660
+
1661
+ if (!extensionsUsed[this.name]) {
1662
+ json.extensions = json.extensions || {};
1663
+ json.extensions[this.name] = {
1664
+ lights: []
1665
+ };
1666
+ extensionsUsed[this.name] = true;
1667
+ }
1668
+
1669
+ var lights = json.extensions[this.name].lights;
1670
+ lights.push(lightDef);
1671
+ nodeDef.extensions = nodeDef.extensions || {};
1672
+ nodeDef.extensions[this.name] = {
1673
+ light: lights.length - 1
1674
+ };
1675
+ }
1676
+ }]);
1677
+
1678
+ return GLTFLightExtension;
1679
+ }();
1680
+ /**
1681
+ * Unlit Materials Extension
1682
+ *
1683
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
1684
+ */
1685
+
1686
+
1687
+ var GLTFMaterialsUnlitExtension = /*#__PURE__*/function () {
1688
+ function GLTFMaterialsUnlitExtension(writer) {
1689
+ _classCallCheck(this, GLTFMaterialsUnlitExtension);
1690
+
1691
+ this.writer = writer;
1692
+ this.name = 'KHR_materials_unlit';
1693
+ }
1694
+
1695
+ _createClass(GLTFMaterialsUnlitExtension, [{
1696
+ key: "writeMaterial",
1697
+ value: function writeMaterial(material, materialDef) {
1698
+ if (!material.isMeshBasicMaterial) return;
1699
+ var writer = this.writer;
1700
+ var extensionsUsed = writer.extensionsUsed;
1701
+ materialDef.extensions = materialDef.extensions || {};
1702
+ materialDef.extensions[this.name] = {};
1703
+ extensionsUsed[this.name] = true;
1704
+ materialDef.pbrMetallicRoughness.metallicFactor = 0.0;
1705
+ materialDef.pbrMetallicRoughness.roughnessFactor = 0.9;
1706
+ }
1707
+ }]);
1708
+
1709
+ return GLTFMaterialsUnlitExtension;
1710
+ }();
1711
+ /**
1712
+ * Specular-Glossiness Extension
1713
+ *
1714
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
1715
+ */
1716
+
1717
+
1718
+ var GLTFMaterialsPBRSpecularGlossiness = /*#__PURE__*/function () {
1719
+ function GLTFMaterialsPBRSpecularGlossiness(writer) {
1720
+ _classCallCheck(this, GLTFMaterialsPBRSpecularGlossiness);
1721
+
1722
+ this.writer = writer;
1723
+ this.name = 'KHR_materials_pbrSpecularGlossiness';
1724
+ }
1725
+
1726
+ _createClass(GLTFMaterialsPBRSpecularGlossiness, [{
1727
+ key: "writeMaterial",
1728
+ value: function writeMaterial(material, materialDef) {
1729
+ if (!material.isGLTFSpecularGlossinessMaterial) return;
1730
+ var writer = this.writer;
1731
+ var extensionsUsed = writer.extensionsUsed;
1732
+ var extensionDef = {};
1733
+
1734
+ if (materialDef.pbrMetallicRoughness.baseColorFactor) {
1735
+ extensionDef.diffuseFactor = materialDef.pbrMetallicRoughness.baseColorFactor;
1736
+ }
1737
+
1738
+ var specularFactor = [1, 1, 1];
1739
+ material.specular.toArray(specularFactor, 0);
1740
+ extensionDef.specularFactor = specularFactor;
1741
+ extensionDef.glossinessFactor = material.glossiness;
1742
+
1743
+ if (materialDef.pbrMetallicRoughness.baseColorTexture) {
1744
+ extensionDef.diffuseTexture = materialDef.pbrMetallicRoughness.baseColorTexture;
1745
+ }
1746
+
1747
+ if (material.specularMap) {
1748
+ var specularMapDef = {
1749
+ index: writer.processTexture(material.specularMap)
1750
+ };
1751
+ writer.applyTextureTransform(specularMapDef, material.specularMap);
1752
+ extensionDef.specularGlossinessTexture = specularMapDef;
1753
+ }
1754
+
1755
+ materialDef.extensions = materialDef.extensions || {};
1756
+ materialDef.extensions[this.name] = extensionDef;
1757
+ extensionsUsed[this.name] = true;
1758
+ }
1759
+ }]);
1760
+
1761
+ return GLTFMaterialsPBRSpecularGlossiness;
1762
+ }();
1763
+ /**
1764
+ * Clearcoat Materials Extension
1765
+ *
1766
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
1767
+ */
1768
+
1769
+
1770
+ var GLTFMaterialsClearcoatExtension = /*#__PURE__*/function () {
1771
+ function GLTFMaterialsClearcoatExtension(writer) {
1772
+ _classCallCheck(this, GLTFMaterialsClearcoatExtension);
1773
+
1774
+ this.writer = writer;
1775
+ this.name = 'KHR_materials_clearcoat';
1776
+ }
1777
+
1778
+ _createClass(GLTFMaterialsClearcoatExtension, [{
1779
+ key: "writeMaterial",
1780
+ value: function writeMaterial(material, materialDef) {
1781
+ if (!material.isMeshPhysicalMaterial) return;
1782
+ var writer = this.writer;
1783
+ var extensionsUsed = writer.extensionsUsed;
1784
+ var extensionDef = {};
1785
+ extensionDef.clearcoatFactor = material.clearcoat;
1786
+
1787
+ if (material.clearcoatMap) {
1788
+ var clearcoatMapDef = {
1789
+ index: writer.processTexture(material.clearcoatMap)
1790
+ };
1791
+ writer.applyTextureTransform(clearcoatMapDef, material.clearcoatMap);
1792
+ extensionDef.clearcoatTexture = clearcoatMapDef;
1793
+ }
1794
+
1795
+ extensionDef.clearcoatRoughnessFactor = material.clearcoatRoughness;
1796
+
1797
+ if (material.clearcoatRoughnessMap) {
1798
+ var clearcoatRoughnessMapDef = {
1799
+ index: writer.processTexture(material.clearcoatRoughnessMap)
1800
+ };
1801
+ writer.applyTextureTransform(clearcoatRoughnessMapDef, material.clearcoatRoughnessMap);
1802
+ extensionDef.clearcoatRoughnessTexture = clearcoatRoughnessMapDef;
1803
+ }
1804
+
1805
+ if (material.clearcoatNormalMap) {
1806
+ var clearcoatNormalMapDef = {
1807
+ index: writer.processTexture(material.clearcoatNormalMap)
1808
+ };
1809
+ writer.applyTextureTransform(clearcoatNormalMapDef, material.clearcoatNormalMap);
1810
+ extensionDef.clearcoatNormalTexture = clearcoatNormalMapDef;
1811
+ }
1812
+
1813
+ materialDef.extensions = materialDef.extensions || {};
1814
+ materialDef.extensions[this.name] = extensionDef;
1815
+ extensionsUsed[this.name] = true;
1816
+ }
1817
+ }]);
1818
+
1819
+ return GLTFMaterialsClearcoatExtension;
1820
+ }();
1821
+ /**
1822
+ * Transmission Materials Extension
1823
+ *
1824
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
1825
+ */
1826
+
1827
+
1828
+ var GLTFMaterialsTransmissionExtension = /*#__PURE__*/function () {
1829
+ function GLTFMaterialsTransmissionExtension(writer) {
1830
+ _classCallCheck(this, GLTFMaterialsTransmissionExtension);
1831
+
1832
+ this.writer = writer;
1833
+ this.name = 'KHR_materials_transmission';
1834
+ }
1835
+
1836
+ _createClass(GLTFMaterialsTransmissionExtension, [{
1837
+ key: "writeMaterial",
1838
+ value: function writeMaterial(material, materialDef) {
1839
+ if (!material.isMeshPhysicalMaterial || material.transmission === 0) return;
1840
+ var writer = this.writer;
1841
+ var extensionsUsed = writer.extensionsUsed;
1842
+ var extensionDef = {};
1843
+ extensionDef.transmissionFactor = material.transmission;
1844
+
1845
+ if (material.transmissionMap) {
1846
+ var transmissionMapDef = {
1847
+ index: writer.processTexture(material.transmissionMap)
1848
+ };
1849
+ writer.applyTextureTransform(transmissionMapDef, material.transmissionMap);
1850
+ extensionDef.transmissionTexture = transmissionMapDef;
1851
+ }
1852
+
1853
+ materialDef.extensions = materialDef.extensions || {};
1854
+ materialDef.extensions[this.name] = extensionDef;
1855
+ extensionsUsed[this.name] = true;
1856
+ }
1857
+ }]);
1858
+
1859
+ return GLTFMaterialsTransmissionExtension;
1860
+ }();
1861
+ /**
1862
+ * Materials Volume Extension
1863
+ *
1864
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
1865
+ */
1866
+
1867
+
1868
+ var GLTFMaterialsVolumeExtension = /*#__PURE__*/function () {
1869
+ function GLTFMaterialsVolumeExtension(writer) {
1870
+ _classCallCheck(this, GLTFMaterialsVolumeExtension);
1871
+
1872
+ this.writer = writer;
1873
+ this.name = 'KHR_materials_volume';
1874
+ }
1875
+
1876
+ _createClass(GLTFMaterialsVolumeExtension, [{
1877
+ key: "writeMaterial",
1878
+ value: function writeMaterial(material, materialDef) {
1879
+ if (!material.isMeshPhysicalMaterial || material.transmission === 0) return;
1880
+ var writer = this.writer;
1881
+ var extensionsUsed = writer.extensionsUsed;
1882
+ var extensionDef = {};
1883
+ extensionDef.thicknessFactor = material.thickness;
1884
+
1885
+ if (material.thicknessMap) {
1886
+ var thicknessMapDef = {
1887
+ index: writer.processTexture(material.thicknessMap)
1888
+ };
1889
+ writer.applyTextureTransform(thicknessMapDef, material.thicknessMap);
1890
+ extensionDef.thicknessTexture = thicknessMapDef;
1891
+ }
1892
+
1893
+ extensionDef.attenuationDistance = material.attenuationDistance;
1894
+ extensionDef.attenuationColor = material.attenuationColor.toArray();
1895
+ materialDef.extensions = materialDef.extensions || {};
1896
+ materialDef.extensions[this.name] = extensionDef;
1897
+ extensionsUsed[this.name] = true;
1898
+ }
1899
+ }]);
1900
+
1901
+ return GLTFMaterialsVolumeExtension;
1902
+ }();
1903
+ /**
1904
+ * Static utility functions
1905
+ */
1906
+
1907
+
1908
+ GLTFExporter.Utils = {
1909
+ insertKeyframe: function insertKeyframe(track, time) {
1910
+ var tolerance = 0.001; // 1ms
1911
+
1912
+ var valueSize = track.getValueSize();
1913
+ var times = new track.TimeBufferType(track.times.length + 1);
1914
+ var values = new track.ValueBufferType(track.values.length + valueSize);
1915
+ var interpolant = track.createInterpolant(new track.ValueBufferType(valueSize));
1916
+ var index;
1917
+
1918
+ if (track.times.length === 0) {
1919
+ times[0] = time;
1920
+
1921
+ for (var i = 0; i < valueSize; i++) {
1922
+ values[i] = 0;
1923
+ }
1924
+
1925
+ index = 0;
1926
+ } else if (time < track.times[0]) {
1927
+ if (Math.abs(track.times[0] - time) < tolerance) return 0;
1928
+ times[0] = time;
1929
+ times.set(track.times, 1);
1930
+ values.set(interpolant.evaluate(time), 0);
1931
+ values.set(track.values, valueSize);
1932
+ index = 0;
1933
+ } else if (time > track.times[track.times.length - 1]) {
1934
+ if (Math.abs(track.times[track.times.length - 1] - time) < tolerance) {
1935
+ return track.times.length - 1;
1936
+ }
1937
+
1938
+ times[times.length - 1] = time;
1939
+ times.set(track.times, 0);
1940
+ values.set(track.values, 0);
1941
+ values.set(interpolant.evaluate(time), track.values.length);
1942
+ index = times.length - 1;
1943
+ } else {
1944
+ for (var _i6 = 0; _i6 < track.times.length; _i6++) {
1945
+ if (Math.abs(track.times[_i6] - time) < tolerance) return _i6;
1946
+
1947
+ if (track.times[_i6] < time && track.times[_i6 + 1] > time) {
1948
+ times.set(track.times.slice(0, _i6 + 1), 0);
1949
+ times[_i6 + 1] = time;
1950
+ times.set(track.times.slice(_i6 + 1), _i6 + 2);
1951
+ values.set(track.values.slice(0, (_i6 + 1) * valueSize), 0);
1952
+ values.set(interpolant.evaluate(time), (_i6 + 1) * valueSize);
1953
+ values.set(track.values.slice((_i6 + 1) * valueSize), (_i6 + 2) * valueSize);
1954
+ index = _i6 + 1;
1955
+ break;
1956
+ }
1957
+ }
1958
+ }
1959
+
1960
+ track.times = times;
1961
+ track.values = values;
1962
+ return index;
1963
+ },
1964
+ mergeMorphTargetTracks: function mergeMorphTargetTracks(clip, root) {
1965
+ var tracks = [];
1966
+ var mergedTracks = {};
1967
+ var sourceTracks = clip.tracks;
1968
+
1969
+ for (var i = 0; i < sourceTracks.length; ++i) {
1970
+ var sourceTrack = sourceTracks[i];
1971
+
1972
+ var sourceTrackBinding = _three.PropertyBinding.parseTrackName(sourceTrack.name);
1973
+
1974
+ var sourceTrackNode = _three.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
1975
+
1976
+ if (sourceTrackBinding.propertyName !== 'morphTargetInfluences' || sourceTrackBinding.propertyIndex === undefined) {
1977
+ // Tracks that don't affect morph targets, or that affect all morph targets together, can be left as-is.
1978
+ tracks.push(sourceTrack);
1979
+ continue;
1980
+ }
1981
+
1982
+ if (sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodDiscrete && sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodLinear) {
1983
+ if (sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) {
1984
+ // This should never happen, because glTF morph target animations
1985
+ // affect all targets already.
1986
+ throw new Error('THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.');
1987
+ }
1988
+
1989
+ console.warn('THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.');
1990
+ sourceTrack = sourceTrack.clone();
1991
+ sourceTrack.setInterpolation(_three.InterpolateLinear);
1992
+ }
1993
+
1994
+ var targetCount = sourceTrackNode.morphTargetInfluences.length;
1995
+ var targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
1996
+
1997
+ if (targetIndex === undefined) {
1998
+ throw new Error('THREE.GLTFExporter: Morph target name not found: ' + sourceTrackBinding.propertyIndex);
1999
+ }
2000
+
2001
+ var mergedTrack = void 0; // If this is the first time we've seen this object, create a new
2002
+ // track to store merged keyframe data for each morph target.
2003
+
2004
+ if (mergedTracks[sourceTrackNode.uuid] === undefined) {
2005
+ mergedTrack = sourceTrack.clone();
2006
+ var values = new mergedTrack.ValueBufferType(targetCount * mergedTrack.times.length);
2007
+
2008
+ for (var j = 0; j < mergedTrack.times.length; j++) {
2009
+ values[j * targetCount + targetIndex] = mergedTrack.values[j];
2010
+ } // We need to take into consideration the intended target node
2011
+ // of our original un-merged morphTarget animation.
2012
+
2013
+
2014
+ mergedTrack.name = (sourceTrackBinding.nodeName || '') + '.morphTargetInfluences';
2015
+ mergedTrack.values = values;
2016
+ mergedTracks[sourceTrackNode.uuid] = mergedTrack;
2017
+ tracks.push(mergedTrack);
2018
+ continue;
2019
+ }
2020
+
2021
+ var sourceInterpolant = sourceTrack.createInterpolant(new sourceTrack.ValueBufferType(1));
2022
+ mergedTrack = mergedTracks[sourceTrackNode.uuid]; // For every existing keyframe of the merged track, write a (possibly
2023
+ // interpolated) value from the source track.
2024
+
2025
+ for (var _j = 0; _j < mergedTrack.times.length; _j++) {
2026
+ mergedTrack.values[_j * targetCount + targetIndex] = sourceInterpolant.evaluate(mergedTrack.times[_j]);
2027
+ } // For every existing keyframe of the source track, write a (possibly
2028
+ // new) keyframe to the merged track. Values from the previous loop may
2029
+ // be written again, but keyframes are de-duplicated.
2030
+
2031
+
2032
+ for (var _j2 = 0; _j2 < sourceTrack.times.length; _j2++) {
2033
+ var keyframeIndex = this.insertKeyframe(mergedTrack, sourceTrack.times[_j2]);
2034
+ mergedTrack.values[keyframeIndex * targetCount + targetIndex] = sourceTrack.values[_j2];
2035
+ }
2036
+ }
2037
+
2038
+ clip.tracks = tracks;
2039
+ return clip;
2040
+ }
2041
+ };
2042
+ });