@gnsx/three 0.184.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +85 -0
  3. package/build/three.cjs +79695 -0
  4. package/build/three.core.js +59732 -0
  5. package/build/three.core.min.js +6 -0
  6. package/build/three.module.js +19552 -0
  7. package/build/three.module.min.js +6 -0
  8. package/build/three.tsl.js +654 -0
  9. package/build/three.tsl.min.js +6 -0
  10. package/build/three.webgpu.js +83969 -0
  11. package/build/three.webgpu.min.js +6 -0
  12. package/build/three.webgpu.nodes.js +83702 -0
  13. package/build/three.webgpu.nodes.min.js +6 -0
  14. package/examples/fonts/LICENSE +13 -0
  15. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  16. package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
  17. package/examples/fonts/README.md +11 -0
  18. package/examples/fonts/droid/NOTICE +190 -0
  19. package/examples/fonts/droid/README.txt +18 -0
  20. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  21. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  22. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  23. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  24. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  25. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  26. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  27. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  28. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  29. package/examples/fonts/optimer_bold.typeface.json +1 -0
  30. package/examples/fonts/optimer_regular.typeface.json +1 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/jsm/Addons.js +293 -0
  34. package/examples/jsm/animation/AnimationClipCreator.js +168 -0
  35. package/examples/jsm/animation/CCDIKSolver.js +595 -0
  36. package/examples/jsm/capabilities/WebGL.js +113 -0
  37. package/examples/jsm/capabilities/WebGPU.js +59 -0
  38. package/examples/jsm/controls/ArcballControls.js +3539 -0
  39. package/examples/jsm/controls/DragControls.js +452 -0
  40. package/examples/jsm/controls/FirstPersonControls.js +451 -0
  41. package/examples/jsm/controls/FlyControls.js +384 -0
  42. package/examples/jsm/controls/MapControls.js +116 -0
  43. package/examples/jsm/controls/OrbitControls.js +1963 -0
  44. package/examples/jsm/controls/PointerLockControls.js +264 -0
  45. package/examples/jsm/controls/TrackballControls.js +1001 -0
  46. package/examples/jsm/controls/TransformControls.js +1950 -0
  47. package/examples/jsm/csm/CSM.js +598 -0
  48. package/examples/jsm/csm/CSMFrustum.js +209 -0
  49. package/examples/jsm/csm/CSMHelper.js +243 -0
  50. package/examples/jsm/csm/CSMShader.js +307 -0
  51. package/examples/jsm/csm/CSMShadowNode.js +603 -0
  52. package/examples/jsm/curves/CurveExtras.js +694 -0
  53. package/examples/jsm/curves/NURBSCurve.js +155 -0
  54. package/examples/jsm/curves/NURBSSurface.js +98 -0
  55. package/examples/jsm/curves/NURBSUtils.js +532 -0
  56. package/examples/jsm/curves/NURBSVolume.js +82 -0
  57. package/examples/jsm/effects/AnaglyphEffect.js +274 -0
  58. package/examples/jsm/effects/AsciiEffect.js +310 -0
  59. package/examples/jsm/effects/OutlineEffect.js +489 -0
  60. package/examples/jsm/effects/ParallaxBarrierEffect.js +155 -0
  61. package/examples/jsm/effects/StereoEffect.js +91 -0
  62. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  63. package/examples/jsm/environments/DebugEnvironment.js +102 -0
  64. package/examples/jsm/environments/RoomEnvironment.js +185 -0
  65. package/examples/jsm/exporters/DRACOExporter.js +311 -0
  66. package/examples/jsm/exporters/EXRExporter.js +618 -0
  67. package/examples/jsm/exporters/GLTFExporter.js +3738 -0
  68. package/examples/jsm/exporters/KTX2Exporter.js +347 -0
  69. package/examples/jsm/exporters/OBJExporter.js +308 -0
  70. package/examples/jsm/exporters/PLYExporter.js +562 -0
  71. package/examples/jsm/exporters/STLExporter.js +221 -0
  72. package/examples/jsm/exporters/USDZExporter.js +1254 -0
  73. package/examples/jsm/geometries/BoxLineGeometry.js +92 -0
  74. package/examples/jsm/geometries/ConvexGeometry.js +72 -0
  75. package/examples/jsm/geometries/DecalGeometry.js +420 -0
  76. package/examples/jsm/geometries/ParametricFunctions.js +100 -0
  77. package/examples/jsm/geometries/ParametricGeometry.js +172 -0
  78. package/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  79. package/examples/jsm/geometries/TeapotGeometry.js +689 -0
  80. package/examples/jsm/geometries/TextGeometry.js +102 -0
  81. package/examples/jsm/gpgpu/BitonicSort.js +715 -0
  82. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  83. package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
  84. package/examples/jsm/helpers/LightProbeHelper.js +165 -0
  85. package/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
  86. package/examples/jsm/helpers/OctreeHelper.js +109 -0
  87. package/examples/jsm/helpers/PositionalAudioHelper.js +169 -0
  88. package/examples/jsm/helpers/RapierHelper.js +59 -0
  89. package/examples/jsm/helpers/RectAreaLightHelper.js +118 -0
  90. package/examples/jsm/helpers/TextureHelper.js +265 -0
  91. package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
  92. package/examples/jsm/helpers/VertexNormalsHelper.js +155 -0
  93. package/examples/jsm/helpers/VertexTangentsHelper.js +133 -0
  94. package/examples/jsm/helpers/ViewHelper.js +519 -0
  95. package/examples/jsm/inspector/Extension.js +13 -0
  96. package/examples/jsm/inspector/Inspector.js +542 -0
  97. package/examples/jsm/inspector/RendererInspector.js +425 -0
  98. package/examples/jsm/inspector/extensions/extensions.json +6 -0
  99. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
  100. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
  101. package/examples/jsm/inspector/tabs/Console.js +238 -0
  102. package/examples/jsm/inspector/tabs/Memory.js +128 -0
  103. package/examples/jsm/inspector/tabs/Parameters.js +380 -0
  104. package/examples/jsm/inspector/tabs/Performance.js +268 -0
  105. package/examples/jsm/inspector/tabs/Settings.js +264 -0
  106. package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
  107. package/examples/jsm/inspector/tabs/Viewer.js +268 -0
  108. package/examples/jsm/inspector/ui/Graph.js +95 -0
  109. package/examples/jsm/inspector/ui/Item.js +170 -0
  110. package/examples/jsm/inspector/ui/List.js +75 -0
  111. package/examples/jsm/inspector/ui/Profiler.js +2072 -0
  112. package/examples/jsm/inspector/ui/Style.js +1667 -0
  113. package/examples/jsm/inspector/ui/Tab.js +265 -0
  114. package/examples/jsm/inspector/ui/Values.js +476 -0
  115. package/examples/jsm/inspector/ui/utils.js +69 -0
  116. package/examples/jsm/interaction/InteractionManager.js +226 -0
  117. package/examples/jsm/interactive/HTMLMesh.js +601 -0
  118. package/examples/jsm/interactive/InteractiveGroup.js +224 -0
  119. package/examples/jsm/interactive/SelectionBox.js +324 -0
  120. package/examples/jsm/interactive/SelectionHelper.js +150 -0
  121. package/examples/jsm/libs/ammo.wasm.js +822 -0
  122. package/examples/jsm/libs/ammo.wasm.wasm +0 -0
  123. package/examples/jsm/libs/basis/README.md +46 -0
  124. package/examples/jsm/libs/basis/basis_transcoder.js +19 -0
  125. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  126. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  127. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  128. package/examples/jsm/libs/draco/README.md +32 -0
  129. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  130. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  131. package/examples/jsm/libs/draco/draco_encoder.js +33 -0
  132. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  133. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  134. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  135. package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -0
  136. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  137. package/examples/jsm/libs/ecsy.module.js +1792 -0
  138. package/examples/jsm/libs/fflate.module.js +2672 -0
  139. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  140. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  141. package/examples/jsm/libs/lottie_canvas.module.js +14849 -0
  142. package/examples/jsm/libs/meshopt_decoder.module.js +196 -0
  143. package/examples/jsm/libs/mikktspace.module.js +128 -0
  144. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  145. package/examples/jsm/libs/opentype.module.js +14506 -0
  146. package/examples/jsm/libs/potpack.module.js +125 -0
  147. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  148. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  149. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  150. package/examples/jsm/libs/stats.module.js +167 -0
  151. package/examples/jsm/libs/surfaceNet.js +201 -0
  152. package/examples/jsm/libs/tween.module.js +876 -0
  153. package/examples/jsm/libs/utif.module.js +1665 -0
  154. package/examples/jsm/libs/zstddec.module.js +1 -0
  155. package/examples/jsm/lighting/DynamicLighting.js +82 -0
  156. package/examples/jsm/lighting/LightProbeGrid.js +651 -0
  157. package/examples/jsm/lighting/TiledLighting.js +42 -0
  158. package/examples/jsm/lights/LightProbeGenerator.js +337 -0
  159. package/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
  160. package/examples/jsm/lights/RectAreaLightUniformsLib.js +40 -0
  161. package/examples/jsm/lines/Line2.js +56 -0
  162. package/examples/jsm/lines/LineGeometry.js +157 -0
  163. package/examples/jsm/lines/LineMaterial.js +703 -0
  164. package/examples/jsm/lines/LineSegments2.js +426 -0
  165. package/examples/jsm/lines/LineSegmentsGeometry.js +298 -0
  166. package/examples/jsm/lines/Wireframe.js +108 -0
  167. package/examples/jsm/lines/WireframeGeometry2.js +49 -0
  168. package/examples/jsm/lines/webgpu/Line2.js +46 -0
  169. package/examples/jsm/lines/webgpu/LineSegments2.js +411 -0
  170. package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
  171. package/examples/jsm/loaders/3DMLoader.js +1836 -0
  172. package/examples/jsm/loaders/3MFLoader.js +1621 -0
  173. package/examples/jsm/loaders/AMFLoader.js +541 -0
  174. package/examples/jsm/loaders/BVHLoader.js +484 -0
  175. package/examples/jsm/loaders/ColladaLoader.js +153 -0
  176. package/examples/jsm/loaders/DDSLoader.js +385 -0
  177. package/examples/jsm/loaders/DRACOLoader.js +739 -0
  178. package/examples/jsm/loaders/EXRLoader.js +3423 -0
  179. package/examples/jsm/loaders/FBXLoader.js +4580 -0
  180. package/examples/jsm/loaders/FontLoader.js +260 -0
  181. package/examples/jsm/loaders/GCodeLoader.js +318 -0
  182. package/examples/jsm/loaders/GLTFLoader.js +4860 -0
  183. package/examples/jsm/loaders/HDRCubeTextureLoader.js +164 -0
  184. package/examples/jsm/loaders/HDRLoader.js +485 -0
  185. package/examples/jsm/loaders/IESLoader.js +379 -0
  186. package/examples/jsm/loaders/KMZLoader.js +163 -0
  187. package/examples/jsm/loaders/KTX2Loader.js +1257 -0
  188. package/examples/jsm/loaders/KTXLoader.js +197 -0
  189. package/examples/jsm/loaders/LDrawLoader.js +2510 -0
  190. package/examples/jsm/loaders/LUT3dlLoader.js +205 -0
  191. package/examples/jsm/loaders/LUTCubeLoader.js +190 -0
  192. package/examples/jsm/loaders/LUTImageLoader.js +190 -0
  193. package/examples/jsm/loaders/LWOLoader.js +1047 -0
  194. package/examples/jsm/loaders/LottieLoader.js +130 -0
  195. package/examples/jsm/loaders/MD2Loader.js +435 -0
  196. package/examples/jsm/loaders/MDDLoader.js +147 -0
  197. package/examples/jsm/loaders/MTLLoader.js +593 -0
  198. package/examples/jsm/loaders/MaterialXLoader.js +1104 -0
  199. package/examples/jsm/loaders/NRRDLoader.js +718 -0
  200. package/examples/jsm/loaders/OBJLoader.js +955 -0
  201. package/examples/jsm/loaders/PCDLoader.js +620 -0
  202. package/examples/jsm/loaders/PDBLoader.js +272 -0
  203. package/examples/jsm/loaders/PLYLoader.js +805 -0
  204. package/examples/jsm/loaders/PVRLoader.js +270 -0
  205. package/examples/jsm/loaders/RGBELoader.js +18 -0
  206. package/examples/jsm/loaders/STLLoader.js +421 -0
  207. package/examples/jsm/loaders/SVGLoader.js +3267 -0
  208. package/examples/jsm/loaders/TDSLoader.js +1142 -0
  209. package/examples/jsm/loaders/TGALoader.js +538 -0
  210. package/examples/jsm/loaders/TIFFLoader.js +59 -0
  211. package/examples/jsm/loaders/TTFLoader.js +261 -0
  212. package/examples/jsm/loaders/USDLoader.js +279 -0
  213. package/examples/jsm/loaders/USDZLoader.js +16 -0
  214. package/examples/jsm/loaders/UltraHDRLoader.js +755 -0
  215. package/examples/jsm/loaders/VOXLoader.js +919 -0
  216. package/examples/jsm/loaders/VRMLLoader.js +3646 -0
  217. package/examples/jsm/loaders/VTKLoader.js +1293 -0
  218. package/examples/jsm/loaders/XYZLoader.js +143 -0
  219. package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
  220. package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
  221. package/examples/jsm/loaders/lwo/IFFParser.js +1217 -0
  222. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  223. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  224. package/examples/jsm/loaders/usd/USDAParser.js +828 -0
  225. package/examples/jsm/loaders/usd/USDCParser.js +1878 -0
  226. package/examples/jsm/loaders/usd/USDComposer.js +4594 -0
  227. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
  228. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
  229. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  230. package/examples/jsm/math/Capsule.js +159 -0
  231. package/examples/jsm/math/ColorConverter.js +58 -0
  232. package/examples/jsm/math/ColorSpaces.js +147 -0
  233. package/examples/jsm/math/ConvexHull.js +1695 -0
  234. package/examples/jsm/math/ImprovedNoise.js +88 -0
  235. package/examples/jsm/math/Lut.js +317 -0
  236. package/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  237. package/examples/jsm/math/OBB.js +535 -0
  238. package/examples/jsm/math/Octree.js +822 -0
  239. package/examples/jsm/math/SimplexNoise.js +470 -0
  240. package/examples/jsm/misc/ConvexObjectBreaker.js +539 -0
  241. package/examples/jsm/misc/GPUComputationRenderer.js +508 -0
  242. package/examples/jsm/misc/Gyroscope.js +78 -0
  243. package/examples/jsm/misc/MD2Character.js +391 -0
  244. package/examples/jsm/misc/MD2CharacterComplex.js +740 -0
  245. package/examples/jsm/misc/MorphAnimMesh.js +119 -0
  246. package/examples/jsm/misc/MorphBlendMesh.js +425 -0
  247. package/examples/jsm/misc/ProgressiveLightMap.js +370 -0
  248. package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
  249. package/examples/jsm/misc/RollerCoaster.js +661 -0
  250. package/examples/jsm/misc/TubePainter.js +599 -0
  251. package/examples/jsm/misc/Volume.js +520 -0
  252. package/examples/jsm/misc/VolumeSlice.js +275 -0
  253. package/examples/jsm/modifiers/CurveModifier.js +374 -0
  254. package/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
  255. package/examples/jsm/modifiers/EdgeSplitModifier.js +299 -0
  256. package/examples/jsm/modifiers/SimplifyModifier.js +632 -0
  257. package/examples/jsm/modifiers/TessellateModifier.js +340 -0
  258. package/examples/jsm/objects/GroundedSkybox.js +69 -0
  259. package/examples/jsm/objects/Lensflare.js +489 -0
  260. package/examples/jsm/objects/LensflareMesh.js +376 -0
  261. package/examples/jsm/objects/MarchingCubes.js +1261 -0
  262. package/examples/jsm/objects/Reflector.js +386 -0
  263. package/examples/jsm/objects/ReflectorForSSRPass.js +393 -0
  264. package/examples/jsm/objects/Refractor.js +389 -0
  265. package/examples/jsm/objects/ShadowMesh.js +130 -0
  266. package/examples/jsm/objects/Sky.js +321 -0
  267. package/examples/jsm/objects/SkyMesh.js +377 -0
  268. package/examples/jsm/objects/Water.js +374 -0
  269. package/examples/jsm/objects/Water2.js +403 -0
  270. package/examples/jsm/objects/Water2Mesh.js +199 -0
  271. package/examples/jsm/objects/WaterMesh.js +194 -0
  272. package/examples/jsm/offscreen/jank.js +45 -0
  273. package/examples/jsm/offscreen/offscreen.js +8 -0
  274. package/examples/jsm/offscreen/scene.js +86 -0
  275. package/examples/jsm/physics/AmmoPhysics.js +359 -0
  276. package/examples/jsm/physics/JoltPhysics.js +334 -0
  277. package/examples/jsm/physics/RapierPhysics.js +436 -0
  278. package/examples/jsm/postprocessing/AfterimagePass.js +185 -0
  279. package/examples/jsm/postprocessing/BloomPass.js +274 -0
  280. package/examples/jsm/postprocessing/BokehPass.js +218 -0
  281. package/examples/jsm/postprocessing/ClearPass.js +97 -0
  282. package/examples/jsm/postprocessing/CubeTexturePass.js +146 -0
  283. package/examples/jsm/postprocessing/DotScreenPass.js +114 -0
  284. package/examples/jsm/postprocessing/EffectComposer.js +365 -0
  285. package/examples/jsm/postprocessing/FXAAPass.js +40 -0
  286. package/examples/jsm/postprocessing/FilmPass.js +113 -0
  287. package/examples/jsm/postprocessing/GTAOPass.js +727 -0
  288. package/examples/jsm/postprocessing/GlitchPass.js +177 -0
  289. package/examples/jsm/postprocessing/HalftonePass.js +134 -0
  290. package/examples/jsm/postprocessing/LUTPass.js +138 -0
  291. package/examples/jsm/postprocessing/MaskPass.js +195 -0
  292. package/examples/jsm/postprocessing/OutlinePass.js +776 -0
  293. package/examples/jsm/postprocessing/OutputPass.js +148 -0
  294. package/examples/jsm/postprocessing/Pass.js +191 -0
  295. package/examples/jsm/postprocessing/RenderPass.js +193 -0
  296. package/examples/jsm/postprocessing/RenderPixelatedPass.js +314 -0
  297. package/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
  298. package/examples/jsm/postprocessing/SAOPass.js +407 -0
  299. package/examples/jsm/postprocessing/SMAAPass.js +230 -0
  300. package/examples/jsm/postprocessing/SSAARenderPass.js +313 -0
  301. package/examples/jsm/postprocessing/SSAOPass.js +527 -0
  302. package/examples/jsm/postprocessing/SSRPass.js +856 -0
  303. package/examples/jsm/postprocessing/SavePass.js +132 -0
  304. package/examples/jsm/postprocessing/ShaderPass.js +135 -0
  305. package/examples/jsm/postprocessing/TAARenderPass.js +243 -0
  306. package/examples/jsm/postprocessing/TexturePass.js +131 -0
  307. package/examples/jsm/postprocessing/UnrealBloomPass.js +524 -0
  308. package/examples/jsm/renderers/CSS2DRenderer.js +328 -0
  309. package/examples/jsm/renderers/CSS3DRenderer.js +454 -0
  310. package/examples/jsm/renderers/Projector.js +1154 -0
  311. package/examples/jsm/renderers/SVGRenderer.js +799 -0
  312. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +96 -0
  313. package/examples/jsm/shaders/AfterimageShader.js +63 -0
  314. package/examples/jsm/shaders/BasicShader.js +36 -0
  315. package/examples/jsm/shaders/BleachBypassShader.js +68 -0
  316. package/examples/jsm/shaders/BlendShader.js +56 -0
  317. package/examples/jsm/shaders/BokehShader.js +151 -0
  318. package/examples/jsm/shaders/BokehShader2.js +404 -0
  319. package/examples/jsm/shaders/BrightnessContrastShader.js +62 -0
  320. package/examples/jsm/shaders/ColorCorrectionShader.js +59 -0
  321. package/examples/jsm/shaders/ColorifyShader.js +57 -0
  322. package/examples/jsm/shaders/ConvolutionShader.js +74 -0
  323. package/examples/jsm/shaders/CopyShader.js +52 -0
  324. package/examples/jsm/shaders/DOFMipMapShader.js +63 -0
  325. package/examples/jsm/shaders/DepthLimitedBlurShader.js +180 -0
  326. package/examples/jsm/shaders/DigitalGlitch.js +104 -0
  327. package/examples/jsm/shaders/DotScreenShader.js +75 -0
  328. package/examples/jsm/shaders/ExposureShader.js +51 -0
  329. package/examples/jsm/shaders/FXAAShader.js +298 -0
  330. package/examples/jsm/shaders/FilmShader.js +72 -0
  331. package/examples/jsm/shaders/FocusShader.js +94 -0
  332. package/examples/jsm/shaders/FreiChenShader.js +103 -0
  333. package/examples/jsm/shaders/GTAOShader.js +434 -0
  334. package/examples/jsm/shaders/GammaCorrectionShader.js +52 -0
  335. package/examples/jsm/shaders/HalftoneShader.js +332 -0
  336. package/examples/jsm/shaders/HorizontalBlurShader.js +68 -0
  337. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +70 -0
  338. package/examples/jsm/shaders/HueSaturationShader.js +74 -0
  339. package/examples/jsm/shaders/KaleidoShader.js +65 -0
  340. package/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
  341. package/examples/jsm/shaders/LuminosityShader.js +54 -0
  342. package/examples/jsm/shaders/MirrorShader.js +62 -0
  343. package/examples/jsm/shaders/NormalMapShader.js +60 -0
  344. package/examples/jsm/shaders/OutputShader.js +103 -0
  345. package/examples/jsm/shaders/PoissonDenoiseShader.js +239 -0
  346. package/examples/jsm/shaders/RGBShiftShader.js +61 -0
  347. package/examples/jsm/shaders/SAOShader.js +201 -0
  348. package/examples/jsm/shaders/SMAAShader.js +489 -0
  349. package/examples/jsm/shaders/SSAOShader.js +331 -0
  350. package/examples/jsm/shaders/SSRShader.js +396 -0
  351. package/examples/jsm/shaders/SepiaShader.js +57 -0
  352. package/examples/jsm/shaders/SobelOperatorShader.js +98 -0
  353. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +95 -0
  354. package/examples/jsm/shaders/TechnicolorShader.js +51 -0
  355. package/examples/jsm/shaders/ToonShader.js +349 -0
  356. package/examples/jsm/shaders/TriangleBlurShader.js +79 -0
  357. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +60 -0
  358. package/examples/jsm/shaders/VelocityShader.js +137 -0
  359. package/examples/jsm/shaders/VerticalBlurShader.js +66 -0
  360. package/examples/jsm/shaders/VerticalTiltShiftShader.js +70 -0
  361. package/examples/jsm/shaders/VignetteShader.js +56 -0
  362. package/examples/jsm/shaders/VolumeShader.js +298 -0
  363. package/examples/jsm/shaders/WaterRefractionShader.js +106 -0
  364. package/examples/jsm/textures/FlakesTexture.js +54 -0
  365. package/examples/jsm/transpiler/AST.js +675 -0
  366. package/examples/jsm/transpiler/GLSLDecoder.js +1228 -0
  367. package/examples/jsm/transpiler/Linker.js +327 -0
  368. package/examples/jsm/transpiler/ShaderToyDecoder.js +51 -0
  369. package/examples/jsm/transpiler/TSLEncoder.js +983 -0
  370. package/examples/jsm/transpiler/Transpiler.js +67 -0
  371. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  372. package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
  373. package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
  374. package/examples/jsm/tsl/display/AfterImageNode.js +254 -0
  375. package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
  376. package/examples/jsm/tsl/display/AnamorphicNode.js +293 -0
  377. package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
  378. package/examples/jsm/tsl/display/BleachBypass.js +33 -0
  379. package/examples/jsm/tsl/display/BloomNode.js +534 -0
  380. package/examples/jsm/tsl/display/CRT.js +150 -0
  381. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +174 -0
  382. package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
  383. package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
  384. package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
  385. package/examples/jsm/tsl/display/FSR1Node.js +477 -0
  386. package/examples/jsm/tsl/display/FXAANode.js +365 -0
  387. package/examples/jsm/tsl/display/FilmNode.js +101 -0
  388. package/examples/jsm/tsl/display/GTAONode.js +572 -0
  389. package/examples/jsm/tsl/display/GaussianBlurNode.js +399 -0
  390. package/examples/jsm/tsl/display/GodraysNode.js +615 -0
  391. package/examples/jsm/tsl/display/LensflareNode.js +279 -0
  392. package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
  393. package/examples/jsm/tsl/display/MotionBlur.js +33 -0
  394. package/examples/jsm/tsl/display/OutlineNode.js +812 -0
  395. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
  396. package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
  397. package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
  398. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  399. package/examples/jsm/tsl/display/SMAANode.js +768 -0
  400. package/examples/jsm/tsl/display/SSAAPassNode.js +358 -0
  401. package/examples/jsm/tsl/display/SSGINode.js +638 -0
  402. package/examples/jsm/tsl/display/SSRNode.js +656 -0
  403. package/examples/jsm/tsl/display/SSSNode.js +490 -0
  404. package/examples/jsm/tsl/display/Sepia.js +24 -0
  405. package/examples/jsm/tsl/display/Shape.js +29 -0
  406. package/examples/jsm/tsl/display/SharpenNode.js +283 -0
  407. package/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
  408. package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
  409. package/examples/jsm/tsl/display/StereoPassNode.js +119 -0
  410. package/examples/jsm/tsl/display/TAAUNode.js +835 -0
  411. package/examples/jsm/tsl/display/TRAANode.js +767 -0
  412. package/examples/jsm/tsl/display/TransitionNode.js +141 -0
  413. package/examples/jsm/tsl/display/boxBlur.js +65 -0
  414. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  415. package/examples/jsm/tsl/display/hashBlur.js +54 -0
  416. package/examples/jsm/tsl/display/radialBlur.js +68 -0
  417. package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
  418. package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
  419. package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
  420. package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
  421. package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
  422. package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
  423. package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
  424. package/examples/jsm/tsl/math/Bayer.js +84 -0
  425. package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
  426. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
  427. package/examples/jsm/tsl/utils/Raymarching.js +70 -0
  428. package/examples/jsm/utils/BufferGeometryUtils.js +1434 -0
  429. package/examples/jsm/utils/CameraUtils.js +82 -0
  430. package/examples/jsm/utils/ColorUtils.js +76 -0
  431. package/examples/jsm/utils/GeometryCompressionUtils.js +547 -0
  432. package/examples/jsm/utils/GeometryUtils.js +226 -0
  433. package/examples/jsm/utils/LDrawUtils.js +211 -0
  434. package/examples/jsm/utils/SceneOptimizer.js +458 -0
  435. package/examples/jsm/utils/SceneUtils.js +363 -0
  436. package/examples/jsm/utils/ShadowMapViewer.js +244 -0
  437. package/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
  438. package/examples/jsm/utils/SkeletonUtils.js +496 -0
  439. package/examples/jsm/utils/SortUtils.js +175 -0
  440. package/examples/jsm/utils/UVsDebug.js +173 -0
  441. package/examples/jsm/utils/WebGLTextureUtils.js +115 -0
  442. package/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
  443. package/examples/jsm/utils/WorkerPool.js +167 -0
  444. package/examples/jsm/webxr/ARButton.js +251 -0
  445. package/examples/jsm/webxr/OculusHandModel.js +194 -0
  446. package/examples/jsm/webxr/OculusHandPointerModel.js +539 -0
  447. package/examples/jsm/webxr/Text2D.js +52 -0
  448. package/examples/jsm/webxr/VRButton.js +264 -0
  449. package/examples/jsm/webxr/XRButton.js +246 -0
  450. package/examples/jsm/webxr/XRControllerModelFactory.js +403 -0
  451. package/examples/jsm/webxr/XREstimatedLight.js +254 -0
  452. package/examples/jsm/webxr/XRHandMeshModel.js +177 -0
  453. package/examples/jsm/webxr/XRHandModelFactory.js +198 -0
  454. package/examples/jsm/webxr/XRHandPrimitiveModel.js +147 -0
  455. package/examples/jsm/webxr/XRPlanes.js +118 -0
  456. package/package.json +123 -0
  457. package/src/Three.Core.js +187 -0
  458. package/src/Three.Legacy.js +0 -0
  459. package/src/Three.TSL.js +647 -0
  460. package/src/Three.WebGPU.Nodes.js +31 -0
  461. package/src/Three.WebGPU.js +37 -0
  462. package/src/Three.js +10 -0
  463. package/src/animation/AnimationAction.js +942 -0
  464. package/src/animation/AnimationClip.js +628 -0
  465. package/src/animation/AnimationMixer.js +860 -0
  466. package/src/animation/AnimationObjectGroup.js +411 -0
  467. package/src/animation/AnimationUtils.js +495 -0
  468. package/src/animation/KeyframeTrack.js +636 -0
  469. package/src/animation/PropertyBinding.js +794 -0
  470. package/src/animation/PropertyMixer.js +385 -0
  471. package/src/animation/tracks/BooleanKeyframeTrack.js +55 -0
  472. package/src/animation/tracks/ColorKeyframeTrack.js +36 -0
  473. package/src/animation/tracks/NumberKeyframeTrack.js +36 -0
  474. package/src/animation/tracks/QuaternionKeyframeTrack.js +51 -0
  475. package/src/animation/tracks/StringKeyframeTrack.js +55 -0
  476. package/src/animation/tracks/VectorKeyframeTrack.js +36 -0
  477. package/src/audio/Audio.js +778 -0
  478. package/src/audio/AudioAnalyser.js +97 -0
  479. package/src/audio/AudioContext.js +40 -0
  480. package/src/audio/AudioListener.js +218 -0
  481. package/src/audio/PositionalAudio.js +253 -0
  482. package/src/cameras/ArrayCamera.js +54 -0
  483. package/src/cameras/Camera.js +160 -0
  484. package/src/cameras/CubeCamera.js +259 -0
  485. package/src/cameras/OrthographicCamera.js +245 -0
  486. package/src/cameras/PerspectiveCamera.js +407 -0
  487. package/src/cameras/StereoCamera.js +146 -0
  488. package/src/constants.js +1760 -0
  489. package/src/core/BufferAttribute.js +1056 -0
  490. package/src/core/BufferGeometry.js +1458 -0
  491. package/src/core/Clock.js +135 -0
  492. package/src/core/EventDispatcher.js +131 -0
  493. package/src/core/GLBufferAttribute.js +171 -0
  494. package/src/core/InstancedBufferAttribute.js +68 -0
  495. package/src/core/InstancedBufferGeometry.js +60 -0
  496. package/src/core/InstancedInterleavedBuffer.js +74 -0
  497. package/src/core/InterleavedBuffer.js +291 -0
  498. package/src/core/InterleavedBufferAttribute.js +549 -0
  499. package/src/core/Layers.js +121 -0
  500. package/src/core/Object3D.js +1667 -0
  501. package/src/core/Raycaster.js +262 -0
  502. package/src/core/RenderTarget.js +392 -0
  503. package/src/core/RenderTarget3D.js +48 -0
  504. package/src/core/Timer.js +184 -0
  505. package/src/core/Uniform.js +46 -0
  506. package/src/core/UniformsGroup.js +180 -0
  507. package/src/extras/Controls.js +120 -0
  508. package/src/extras/DataUtils.js +217 -0
  509. package/src/extras/Earcut.js +28 -0
  510. package/src/extras/ImageUtils.js +137 -0
  511. package/src/extras/PMREMGenerator.js +1167 -0
  512. package/src/extras/ShapeUtils.js +114 -0
  513. package/src/extras/TextureUtils.js +297 -0
  514. package/src/extras/core/Curve.js +517 -0
  515. package/src/extras/core/CurvePath.js +296 -0
  516. package/src/extras/core/Interpolations.js +111 -0
  517. package/src/extras/core/Path.js +329 -0
  518. package/src/extras/core/Shape.js +165 -0
  519. package/src/extras/core/ShapePath.js +367 -0
  520. package/src/extras/curves/ArcCurve.js +39 -0
  521. package/src/extras/curves/CatmullRomCurve3.js +327 -0
  522. package/src/extras/curves/CubicBezierCurve.js +145 -0
  523. package/src/extras/curves/CubicBezierCurve3.js +129 -0
  524. package/src/extras/curves/Curves.js +10 -0
  525. package/src/extras/curves/EllipseCurve.js +258 -0
  526. package/src/extras/curves/LineCurve.js +128 -0
  527. package/src/extras/curves/LineCurve3.js +128 -0
  528. package/src/extras/curves/QuadraticBezierCurve.js +133 -0
  529. package/src/extras/curves/QuadraticBezierCurve3.js +118 -0
  530. package/src/extras/curves/SplineCurve.js +145 -0
  531. package/src/extras/lib/earcut.js +685 -0
  532. package/src/geometries/BoxGeometry.js +219 -0
  533. package/src/geometries/CapsuleGeometry.js +218 -0
  534. package/src/geometries/CircleGeometry.js +142 -0
  535. package/src/geometries/ConeGeometry.js +70 -0
  536. package/src/geometries/CylinderGeometry.js +333 -0
  537. package/src/geometries/DodecahedronGeometry.js +99 -0
  538. package/src/geometries/EdgesGeometry.js +180 -0
  539. package/src/geometries/ExtrudeGeometry.js +910 -0
  540. package/src/geometries/Geometries.js +21 -0
  541. package/src/geometries/IcosahedronGeometry.js +75 -0
  542. package/src/geometries/LatheGeometry.js +230 -0
  543. package/src/geometries/OctahedronGeometry.js +70 -0
  544. package/src/geometries/PlaneGeometry.js +133 -0
  545. package/src/geometries/PolyhedronGeometry.js +348 -0
  546. package/src/geometries/RingGeometry.js +165 -0
  547. package/src/geometries/ShapeGeometry.js +233 -0
  548. package/src/geometries/SphereGeometry.js +175 -0
  549. package/src/geometries/TetrahedronGeometry.js +67 -0
  550. package/src/geometries/TorusGeometry.js +161 -0
  551. package/src/geometries/TorusKnotGeometry.js +206 -0
  552. package/src/geometries/TubeGeometry.js +253 -0
  553. package/src/geometries/WireframeGeometry.js +179 -0
  554. package/src/helpers/ArrowHelper.js +171 -0
  555. package/src/helpers/AxesHelper.js +96 -0
  556. package/src/helpers/Box3Helper.js +83 -0
  557. package/src/helpers/BoxHelper.js +149 -0
  558. package/src/helpers/CameraHelper.js +345 -0
  559. package/src/helpers/DirectionalLightHelper.js +148 -0
  560. package/src/helpers/GridHelper.js +82 -0
  561. package/src/helpers/HemisphereLightHelper.js +130 -0
  562. package/src/helpers/PlaneHelper.js +96 -0
  563. package/src/helpers/PointLightHelper.js +111 -0
  564. package/src/helpers/PolarGridHelper.js +126 -0
  565. package/src/helpers/SkeletonHelper.js +194 -0
  566. package/src/helpers/SpotLightHelper.js +154 -0
  567. package/src/lights/AmbientLight.js +42 -0
  568. package/src/lights/DirectionalLight.js +113 -0
  569. package/src/lights/DirectionalLightShadow.js +31 -0
  570. package/src/lights/HemisphereLight.js +76 -0
  571. package/src/lights/Light.js +85 -0
  572. package/src/lights/LightProbe.js +75 -0
  573. package/src/lights/LightShadow.js +347 -0
  574. package/src/lights/PointLight.js +131 -0
  575. package/src/lights/PointLightShadow.js +31 -0
  576. package/src/lights/RectAreaLight.js +115 -0
  577. package/src/lights/SpotLight.js +194 -0
  578. package/src/lights/SpotLightShadow.js +80 -0
  579. package/src/lights/webgpu/IESSpotLight.js +47 -0
  580. package/src/lights/webgpu/ProjectorLight.js +46 -0
  581. package/src/loaders/AnimationLoader.js +98 -0
  582. package/src/loaders/AudioLoader.js +108 -0
  583. package/src/loaders/BufferGeometryLoader.js +242 -0
  584. package/src/loaders/Cache.js +115 -0
  585. package/src/loaders/CompressedTextureLoader.js +167 -0
  586. package/src/loaders/CubeTextureLoader.js +103 -0
  587. package/src/loaders/DataTextureLoader.js +174 -0
  588. package/src/loaders/FileLoader.js +367 -0
  589. package/src/loaders/ImageBitmapLoader.js +223 -0
  590. package/src/loaders/ImageLoader.js +168 -0
  591. package/src/loaders/Loader.js +222 -0
  592. package/src/loaders/LoaderUtils.js +59 -0
  593. package/src/loaders/LoadingManager.js +329 -0
  594. package/src/loaders/MaterialLoader.js +439 -0
  595. package/src/loaders/ObjectLoader.js +1304 -0
  596. package/src/loaders/TextureLoader.js +74 -0
  597. package/src/loaders/nodes/NodeLoader.js +194 -0
  598. package/src/loaders/nodes/NodeMaterialLoader.js +108 -0
  599. package/src/loaders/nodes/NodeObjectLoader.js +169 -0
  600. package/src/materials/LineBasicMaterial.js +122 -0
  601. package/src/materials/LineDashedMaterial.js +86 -0
  602. package/src/materials/Material.js +1017 -0
  603. package/src/materials/Materials.js +39 -0
  604. package/src/materials/MeshBasicMaterial.js +250 -0
  605. package/src/materials/MeshDepthMaterial.js +148 -0
  606. package/src/materials/MeshDistanceMaterial.js +119 -0
  607. package/src/materials/MeshLambertMaterial.js +402 -0
  608. package/src/materials/MeshMatcapMaterial.js +245 -0
  609. package/src/materials/MeshNormalMaterial.js +175 -0
  610. package/src/materials/MeshPhongMaterial.js +421 -0
  611. package/src/materials/MeshPhysicalMaterial.js +536 -0
  612. package/src/materials/MeshStandardMaterial.js +425 -0
  613. package/src/materials/MeshToonMaterial.js +321 -0
  614. package/src/materials/PointsMaterial.js +139 -0
  615. package/src/materials/RawShaderMaterial.js +42 -0
  616. package/src/materials/ShaderMaterial.js +413 -0
  617. package/src/materials/ShadowMaterial.js +91 -0
  618. package/src/materials/SpriteMaterial.js +136 -0
  619. package/src/materials/nodes/Line2NodeMaterial.js +569 -0
  620. package/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
  621. package/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
  622. package/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
  623. package/src/materials/nodes/MeshLambertNodeMaterial.js +82 -0
  624. package/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
  625. package/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
  626. package/src/materials/nodes/MeshPhongNodeMaterial.js +141 -0
  627. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +521 -0
  628. package/src/materials/nodes/MeshSSSNodeMaterial.js +175 -0
  629. package/src/materials/nodes/MeshStandardNodeMaterial.js +187 -0
  630. package/src/materials/nodes/MeshToonNodeMaterial.js +66 -0
  631. package/src/materials/nodes/NodeMaterial.js +1330 -0
  632. package/src/materials/nodes/NodeMaterials.js +21 -0
  633. package/src/materials/nodes/PointsNodeMaterial.js +211 -0
  634. package/src/materials/nodes/ShadowNodeMaterial.js +76 -0
  635. package/src/materials/nodes/SpriteNodeMaterial.js +186 -0
  636. package/src/materials/nodes/VolumeNodeMaterial.js +81 -0
  637. package/src/materials/nodes/manager/NodeMaterialObserver.js +718 -0
  638. package/src/math/Box2.js +381 -0
  639. package/src/math/Box3.js +805 -0
  640. package/src/math/Color.js +967 -0
  641. package/src/math/ColorManagement.js +215 -0
  642. package/src/math/Cylindrical.js +120 -0
  643. package/src/math/Euler.js +449 -0
  644. package/src/math/Frustum.js +285 -0
  645. package/src/math/FrustumArray.js +258 -0
  646. package/src/math/Interpolant.js +320 -0
  647. package/src/math/Line3.js +337 -0
  648. package/src/math/MathUtils.js +751 -0
  649. package/src/math/Matrix2.js +128 -0
  650. package/src/math/Matrix3.js +617 -0
  651. package/src/math/Matrix4.js +1314 -0
  652. package/src/math/Plane.js +368 -0
  653. package/src/math/Quaternion.js +918 -0
  654. package/src/math/Ray.js +655 -0
  655. package/src/math/Sphere.js +420 -0
  656. package/src/math/Spherical.js +147 -0
  657. package/src/math/SphericalHarmonics3.js +341 -0
  658. package/src/math/Triangle.js +539 -0
  659. package/src/math/Vector2.js +870 -0
  660. package/src/math/Vector3.js +1263 -0
  661. package/src/math/Vector4.js +1067 -0
  662. package/src/math/interpolants/BezierInterpolant.js +108 -0
  663. package/src/math/interpolants/CubicInterpolant.js +159 -0
  664. package/src/math/interpolants/DiscreteInterpolant.js +34 -0
  665. package/src/math/interpolants/LinearInterpolant.js +51 -0
  666. package/src/math/interpolants/QuaternionLinearInterpolant.js +48 -0
  667. package/src/nodes/Nodes.js +166 -0
  668. package/src/nodes/TSL.js +173 -0
  669. package/src/nodes/accessors/AccessorsUtils.js +53 -0
  670. package/src/nodes/accessors/Arrays.js +68 -0
  671. package/src/nodes/accessors/BatchNode.js +163 -0
  672. package/src/nodes/accessors/Bitangent.js +82 -0
  673. package/src/nodes/accessors/BufferAttributeNode.js +432 -0
  674. package/src/nodes/accessors/BufferNode.js +128 -0
  675. package/src/nodes/accessors/BuiltinNode.js +63 -0
  676. package/src/nodes/accessors/Camera.js +403 -0
  677. package/src/nodes/accessors/ClippingNode.js +255 -0
  678. package/src/nodes/accessors/CubeTextureNode.js +215 -0
  679. package/src/nodes/accessors/InstanceNode.js +349 -0
  680. package/src/nodes/accessors/InstancedMeshNode.js +50 -0
  681. package/src/nodes/accessors/Lights.js +139 -0
  682. package/src/nodes/accessors/MaterialNode.js +783 -0
  683. package/src/nodes/accessors/MaterialProperties.js +56 -0
  684. package/src/nodes/accessors/MaterialReferenceNode.js +84 -0
  685. package/src/nodes/accessors/ModelNode.js +184 -0
  686. package/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
  687. package/src/nodes/accessors/MorphNode.js +310 -0
  688. package/src/nodes/accessors/Normal.js +243 -0
  689. package/src/nodes/accessors/Object3DNode.js +268 -0
  690. package/src/nodes/accessors/PointUVNode.js +55 -0
  691. package/src/nodes/accessors/Position.js +122 -0
  692. package/src/nodes/accessors/ReferenceBaseNode.js +357 -0
  693. package/src/nodes/accessors/ReferenceNode.js +424 -0
  694. package/src/nodes/accessors/ReflectVector.js +36 -0
  695. package/src/nodes/accessors/RendererReferenceNode.js +78 -0
  696. package/src/nodes/accessors/SceneProperties.js +47 -0
  697. package/src/nodes/accessors/SkinningNode.js +328 -0
  698. package/src/nodes/accessors/StorageBufferNode.js +405 -0
  699. package/src/nodes/accessors/StorageTextureNode.js +295 -0
  700. package/src/nodes/accessors/Tangent.js +60 -0
  701. package/src/nodes/accessors/TangentUtils.js +46 -0
  702. package/src/nodes/accessors/Texture3DNode.js +196 -0
  703. package/src/nodes/accessors/TextureBicubic.js +92 -0
  704. package/src/nodes/accessors/TextureNode.js +971 -0
  705. package/src/nodes/accessors/TextureSizeNode.js +77 -0
  706. package/src/nodes/accessors/UV.js +11 -0
  707. package/src/nodes/accessors/UniformArrayNode.js +350 -0
  708. package/src/nodes/accessors/UserDataNode.js +76 -0
  709. package/src/nodes/accessors/VelocityNode.js +224 -0
  710. package/src/nodes/accessors/VertexColorNode.js +109 -0
  711. package/src/nodes/code/CodeNode.js +181 -0
  712. package/src/nodes/code/ExpressionNode.js +68 -0
  713. package/src/nodes/code/FunctionCallNode.js +187 -0
  714. package/src/nodes/code/FunctionNode.js +182 -0
  715. package/src/nodes/core/ArrayNode.js +174 -0
  716. package/src/nodes/core/AssignNode.js +202 -0
  717. package/src/nodes/core/AttributeNode.js +168 -0
  718. package/src/nodes/core/BypassNode.js +93 -0
  719. package/src/nodes/core/ConstNode.js +67 -0
  720. package/src/nodes/core/ContextNode.js +283 -0
  721. package/src/nodes/core/IndexNode.js +165 -0
  722. package/src/nodes/core/InputNode.js +136 -0
  723. package/src/nodes/core/InspectorNode.js +128 -0
  724. package/src/nodes/core/IsolateNode.js +133 -0
  725. package/src/nodes/core/LightingModel.js +77 -0
  726. package/src/nodes/core/MRTNode.js +196 -0
  727. package/src/nodes/core/Node.js +1180 -0
  728. package/src/nodes/core/NodeAttribute.js +53 -0
  729. package/src/nodes/core/NodeBuilder.js +3299 -0
  730. package/src/nodes/core/NodeCache.js +75 -0
  731. package/src/nodes/core/NodeCode.js +46 -0
  732. package/src/nodes/core/NodeError.js +28 -0
  733. package/src/nodes/core/NodeFrame.js +314 -0
  734. package/src/nodes/core/NodeFunction.js +69 -0
  735. package/src/nodes/core/NodeFunctionInput.js +61 -0
  736. package/src/nodes/core/NodeParser.js +23 -0
  737. package/src/nodes/core/NodeUniform.js +91 -0
  738. package/src/nodes/core/NodeUtils.js +408 -0
  739. package/src/nodes/core/NodeVar.js +60 -0
  740. package/src/nodes/core/NodeVarying.js +63 -0
  741. package/src/nodes/core/OutputStructNode.js +105 -0
  742. package/src/nodes/core/ParameterNode.js +94 -0
  743. package/src/nodes/core/PropertyNode.js +367 -0
  744. package/src/nodes/core/StackNode.js +426 -0
  745. package/src/nodes/core/StackTrace.js +139 -0
  746. package/src/nodes/core/StructNode.js +134 -0
  747. package/src/nodes/core/StructType.js +13 -0
  748. package/src/nodes/core/StructTypeNode.js +148 -0
  749. package/src/nodes/core/SubBuildNode.js +89 -0
  750. package/src/nodes/core/TempNode.js +88 -0
  751. package/src/nodes/core/UniformGroupNode.js +167 -0
  752. package/src/nodes/core/UniformNode.js +259 -0
  753. package/src/nodes/core/VarNode.js +367 -0
  754. package/src/nodes/core/VaryingNode.js +210 -0
  755. package/src/nodes/core/constants.js +68 -0
  756. package/src/nodes/display/BlendModes.js +171 -0
  757. package/src/nodes/display/BumpMapNode.js +117 -0
  758. package/src/nodes/display/ColorAdjustment.js +158 -0
  759. package/src/nodes/display/ColorSpaceFunctions.js +54 -0
  760. package/src/nodes/display/ColorSpaceNode.js +164 -0
  761. package/src/nodes/display/FrontFacingNode.js +102 -0
  762. package/src/nodes/display/NormalMapNode.js +153 -0
  763. package/src/nodes/display/PassNode.js +1055 -0
  764. package/src/nodes/display/RenderOutputNode.js +150 -0
  765. package/src/nodes/display/ScreenNode.js +292 -0
  766. package/src/nodes/display/ToneMappingFunctions.js +242 -0
  767. package/src/nodes/display/ToneMappingNode.js +147 -0
  768. package/src/nodes/display/ToonOutlinePassNode.js +191 -0
  769. package/src/nodes/display/ViewportDepthNode.js +342 -0
  770. package/src/nodes/display/ViewportDepthTextureNode.js +63 -0
  771. package/src/nodes/display/ViewportSharedTextureNode.js +73 -0
  772. package/src/nodes/display/ViewportTextureNode.js +256 -0
  773. package/src/nodes/fog/Fog.js +97 -0
  774. package/src/nodes/functions/BSDF/BRDF_GGX.js +55 -0
  775. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
  776. package/src/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  777. package/src/nodes/functions/BSDF/BRDF_Sheen.js +57 -0
  778. package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
  779. package/src/nodes/functions/BSDF/D_GGX.js +23 -0
  780. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  781. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
  782. package/src/nodes/functions/BSDF/F_Schlick.js +16 -0
  783. package/src/nodes/functions/BSDF/LTC.js +175 -0
  784. package/src/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
  785. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +26 -0
  786. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  787. package/src/nodes/functions/BasicLightingModel.js +100 -0
  788. package/src/nodes/functions/PhongLightingModel.js +99 -0
  789. package/src/nodes/functions/PhysicalLightingModel.js +878 -0
  790. package/src/nodes/functions/ShadowMaskModel.js +58 -0
  791. package/src/nodes/functions/ToonLightingModel.js +70 -0
  792. package/src/nodes/functions/VolumetricLightingModel.js +183 -0
  793. package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
  794. package/src/nodes/functions/material/getGeometryRoughness.js +19 -0
  795. package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
  796. package/src/nodes/functions/material/getRoughness.js +18 -0
  797. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  798. package/src/nodes/geometry/RangeNode.js +210 -0
  799. package/src/nodes/gpgpu/AtomicFunctionNode.js +274 -0
  800. package/src/nodes/gpgpu/BarrierNode.js +98 -0
  801. package/src/nodes/gpgpu/ComputeBuiltinNode.js +227 -0
  802. package/src/nodes/gpgpu/ComputeNode.js +310 -0
  803. package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
  804. package/src/nodes/gpgpu/WorkgroupInfoNode.js +234 -0
  805. package/src/nodes/lighting/AONode.js +45 -0
  806. package/src/nodes/lighting/AmbientLightNode.js +35 -0
  807. package/src/nodes/lighting/AnalyticLightNode.js +309 -0
  808. package/src/nodes/lighting/BasicEnvironmentNode.js +49 -0
  809. package/src/nodes/lighting/BasicLightMapNode.js +49 -0
  810. package/src/nodes/lighting/DirectionalLightNode.js +39 -0
  811. package/src/nodes/lighting/EnvironmentNode.js +178 -0
  812. package/src/nodes/lighting/HemisphereLightNode.js +87 -0
  813. package/src/nodes/lighting/IESSpotLightNode.js +49 -0
  814. package/src/nodes/lighting/IrradianceNode.js +44 -0
  815. package/src/nodes/lighting/LightProbeNode.js +73 -0
  816. package/src/nodes/lighting/LightUtils.js +25 -0
  817. package/src/nodes/lighting/LightingContextNode.js +115 -0
  818. package/src/nodes/lighting/LightingNode.js +36 -0
  819. package/src/nodes/lighting/LightsNode.js +432 -0
  820. package/src/nodes/lighting/PointLightNode.js +102 -0
  821. package/src/nodes/lighting/PointShadowNode.js +325 -0
  822. package/src/nodes/lighting/ProjectorLightNode.js +91 -0
  823. package/src/nodes/lighting/RectAreaLightNode.js +133 -0
  824. package/src/nodes/lighting/ShadowBaseNode.js +81 -0
  825. package/src/nodes/lighting/ShadowFilterNode.js +264 -0
  826. package/src/nodes/lighting/ShadowNode.js +889 -0
  827. package/src/nodes/lighting/SpotLightNode.js +168 -0
  828. package/src/nodes/materialx/DISCLAIMER.md +199 -0
  829. package/src/nodes/materialx/MaterialXNodes.js +197 -0
  830. package/src/nodes/materialx/lib/mx_hsv.js +127 -0
  831. package/src/nodes/materialx/lib/mx_noise.js +1491 -0
  832. package/src/nodes/materialx/lib/mx_transform_color.js +23 -0
  833. package/src/nodes/math/BitcastNode.js +156 -0
  834. package/src/nodes/math/BitcountNode.js +433 -0
  835. package/src/nodes/math/ConditionalNode.js +245 -0
  836. package/src/nodes/math/Hash.js +21 -0
  837. package/src/nodes/math/MathNode.js +1202 -0
  838. package/src/nodes/math/MathUtils.js +54 -0
  839. package/src/nodes/math/OperatorNode.js +752 -0
  840. package/src/nodes/math/PackFloatNode.js +98 -0
  841. package/src/nodes/math/TriNoise3D.js +71 -0
  842. package/src/nodes/math/UnpackFloatNode.js +96 -0
  843. package/src/nodes/parsers/GLSLNodeFunction.js +168 -0
  844. package/src/nodes/parsers/GLSLNodeParser.js +25 -0
  845. package/src/nodes/pmrem/PMREMNode.js +397 -0
  846. package/src/nodes/pmrem/PMREMUtils.js +397 -0
  847. package/src/nodes/procedural/Checker.js +22 -0
  848. package/src/nodes/shapes/Shapes.js +33 -0
  849. package/src/nodes/tsl/TSLBase.js +36 -0
  850. package/src/nodes/tsl/TSLCore.js +1250 -0
  851. package/src/nodes/utils/ArrayElementNode.js +90 -0
  852. package/src/nodes/utils/ConvertNode.js +100 -0
  853. package/src/nodes/utils/CubeMapNode.js +237 -0
  854. package/src/nodes/utils/DebugNode.js +83 -0
  855. package/src/nodes/utils/Discard.js +24 -0
  856. package/src/nodes/utils/EquirectUV.js +27 -0
  857. package/src/nodes/utils/EventNode.js +148 -0
  858. package/src/nodes/utils/FlipNode.js +106 -0
  859. package/src/nodes/utils/FunctionOverloadingNode.js +170 -0
  860. package/src/nodes/utils/JoinNode.js +117 -0
  861. package/src/nodes/utils/LoopNode.js +349 -0
  862. package/src/nodes/utils/MatcapUV.js +22 -0
  863. package/src/nodes/utils/MaxMipLevelNode.js +103 -0
  864. package/src/nodes/utils/MemberNode.js +120 -0
  865. package/src/nodes/utils/Oscillators.js +41 -0
  866. package/src/nodes/utils/Packing.js +33 -0
  867. package/src/nodes/utils/PostProcessingUtils.js +154 -0
  868. package/src/nodes/utils/RTTNode.js +289 -0
  869. package/src/nodes/utils/ReflectorNode.js +629 -0
  870. package/src/nodes/utils/Remap.js +48 -0
  871. package/src/nodes/utils/RotateNode.js +103 -0
  872. package/src/nodes/utils/SampleNode.js +91 -0
  873. package/src/nodes/utils/SetNode.js +108 -0
  874. package/src/nodes/utils/SplitNode.js +179 -0
  875. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  876. package/src/nodes/utils/SpriteUtils.js +63 -0
  877. package/src/nodes/utils/StorageArrayElementNode.js +143 -0
  878. package/src/nodes/utils/Timer.js +26 -0
  879. package/src/nodes/utils/TriplanarTextures.js +65 -0
  880. package/src/nodes/utils/UVUtils.js +67 -0
  881. package/src/nodes/utils/ViewportUtils.js +26 -0
  882. package/src/objects/BatchedMesh.js +1682 -0
  883. package/src/objects/Bone.js +41 -0
  884. package/src/objects/ClippingGroup.js +68 -0
  885. package/src/objects/Group.js +41 -0
  886. package/src/objects/InstancedMesh.js +422 -0
  887. package/src/objects/LOD.js +329 -0
  888. package/src/objects/Line.js +329 -0
  889. package/src/objects/LineLoop.js +37 -0
  890. package/src/objects/LineSegments.js +74 -0
  891. package/src/objects/Mesh.js +496 -0
  892. package/src/objects/Points.js +228 -0
  893. package/src/objects/Skeleton.js +392 -0
  894. package/src/objects/SkinnedMesh.js +370 -0
  895. package/src/objects/Sprite.js +245 -0
  896. package/src/renderers/WebGL3DRenderTarget.js +48 -0
  897. package/src/renderers/WebGLArrayRenderTarget.js +48 -0
  898. package/src/renderers/WebGLCubeRenderTarget.js +182 -0
  899. package/src/renderers/WebGLRenderTarget.js +34 -0
  900. package/src/renderers/WebGLRenderer.js +3699 -0
  901. package/src/renderers/common/Animation.js +159 -0
  902. package/src/renderers/common/Attributes.js +132 -0
  903. package/src/renderers/common/Backend.js +769 -0
  904. package/src/renderers/common/Background.js +225 -0
  905. package/src/renderers/common/BindGroup.js +46 -0
  906. package/src/renderers/common/Binding.js +71 -0
  907. package/src/renderers/common/Bindings.js +394 -0
  908. package/src/renderers/common/BlendMode.js +143 -0
  909. package/src/renderers/common/Buffer.js +127 -0
  910. package/src/renderers/common/BufferUtils.js +58 -0
  911. package/src/renderers/common/BundleGroup.js +83 -0
  912. package/src/renderers/common/CanvasTarget.js +341 -0
  913. package/src/renderers/common/ChainMap.js +122 -0
  914. package/src/renderers/common/ClippingContext.js +262 -0
  915. package/src/renderers/common/Color4.js +77 -0
  916. package/src/renderers/common/ComputePipeline.js +41 -0
  917. package/src/renderers/common/Constants.js +15 -0
  918. package/src/renderers/common/CubeRenderTarget.js +147 -0
  919. package/src/renderers/common/DataMap.js +90 -0
  920. package/src/renderers/common/Geometries.js +396 -0
  921. package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
  922. package/src/renderers/common/Info.js +501 -0
  923. package/src/renderers/common/InspectorBase.js +151 -0
  924. package/src/renderers/common/Lighting.js +57 -0
  925. package/src/renderers/common/Pipeline.js +35 -0
  926. package/src/renderers/common/Pipelines.js +498 -0
  927. package/src/renderers/common/PostProcessing.js +28 -0
  928. package/src/renderers/common/ProgrammableStage.js +78 -0
  929. package/src/renderers/common/QuadMesh.js +112 -0
  930. package/src/renderers/common/ReadbackBuffer.js +78 -0
  931. package/src/renderers/common/RenderBundle.js +26 -0
  932. package/src/renderers/common/RenderBundles.js +71 -0
  933. package/src/renderers/common/RenderContext.js +281 -0
  934. package/src/renderers/common/RenderContexts.js +100 -0
  935. package/src/renderers/common/RenderList.js +404 -0
  936. package/src/renderers/common/RenderLists.js +78 -0
  937. package/src/renderers/common/RenderObject.js +915 -0
  938. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  939. package/src/renderers/common/RenderObjects.js +218 -0
  940. package/src/renderers/common/RenderPipeline.js +255 -0
  941. package/src/renderers/common/Renderer.js +3654 -0
  942. package/src/renderers/common/RendererUtils.js +200 -0
  943. package/src/renderers/common/SampledTexture.js +152 -0
  944. package/src/renderers/common/Sampler.js +165 -0
  945. package/src/renderers/common/Storage3DTexture.js +100 -0
  946. package/src/renderers/common/StorageArrayTexture.js +84 -0
  947. package/src/renderers/common/StorageBuffer.js +53 -0
  948. package/src/renderers/common/StorageBufferAttribute.js +46 -0
  949. package/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
  950. package/src/renderers/common/StorageTexture.js +86 -0
  951. package/src/renderers/common/Textures.js +629 -0
  952. package/src/renderers/common/TimestampQueryPool.js +163 -0
  953. package/src/renderers/common/Uniform.js +375 -0
  954. package/src/renderers/common/UniformBuffer.js +34 -0
  955. package/src/renderers/common/UniformsGroup.js +548 -0
  956. package/src/renderers/common/XRManager.js +1684 -0
  957. package/src/renderers/common/XRRenderTarget.js +91 -0
  958. package/src/renderers/common/extras/PMREMGenerator.js +1042 -0
  959. package/src/renderers/common/nodes/NodeBuilderState.js +152 -0
  960. package/src/renderers/common/nodes/NodeLibrary.js +196 -0
  961. package/src/renderers/common/nodes/NodeManager.js +983 -0
  962. package/src/renderers/common/nodes/NodeSampledTexture.js +140 -0
  963. package/src/renderers/common/nodes/NodeSampler.js +62 -0
  964. package/src/renderers/common/nodes/NodeStorageBuffer.js +72 -0
  965. package/src/renderers/common/nodes/NodeUniform.js +418 -0
  966. package/src/renderers/common/nodes/NodeUniformBuffer.js +105 -0
  967. package/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
  968. package/src/renderers/shaders/DFGLUTData.js +49 -0
  969. package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
  970. package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
  971. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  972. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  973. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -0
  974. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  975. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -0
  976. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  977. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +49 -0
  978. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
  979. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -0
  980. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  981. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -0
  982. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -0
  983. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  984. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -0
  985. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  986. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -0
  987. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  988. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  989. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  990. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +7 -0
  991. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +7 -0
  992. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +7 -0
  993. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +29 -0
  994. package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -0
  995. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +15 -0
  996. package/src/renderers/shaders/ShaderChunk/common.glsl.js +125 -0
  997. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -0
  998. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  999. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1000. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -0
  1001. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1002. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1003. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1004. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1005. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +17 -0
  1006. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1007. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1008. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +58 -0
  1009. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1010. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1011. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -0
  1012. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1013. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1014. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1015. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1016. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1018. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -0
  1019. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1021. package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
  1022. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +213 -0
  1023. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +19 -0
  1024. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +44 -0
  1025. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1026. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
  1027. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +216 -0
  1028. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -0
  1030. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +161 -0
  1031. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +656 -0
  1032. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1033. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -0
  1034. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1035. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1036. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +8 -0
  1037. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +8 -0
  1038. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1039. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1040. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -0
  1041. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -0
  1042. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1043. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1044. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1045. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  1046. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +16 -0
  1047. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +26 -0
  1048. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -0
  1050. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +40 -0
  1051. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1052. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1053. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1054. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1055. package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -0
  1056. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +116 -0
  1057. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +7 -0
  1058. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -0
  1059. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1060. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1061. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +376 -0
  1062. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +71 -0
  1063. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +78 -0
  1064. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1065. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1066. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -0
  1067. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1068. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1069. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1070. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1071. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +200 -0
  1073. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1074. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +235 -0
  1075. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -0
  1076. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -0
  1077. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -0
  1078. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -0
  1079. package/src/renderers/shaders/ShaderChunk.js +272 -0
  1080. package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -0
  1081. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  1082. package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -0
  1083. package/src/renderers/shaders/ShaderLib/depth.glsl.js +117 -0
  1084. package/src/renderers/shaders/ShaderLib/distance.glsl.js +77 -0
  1085. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1086. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -0
  1087. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -0
  1088. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +126 -0
  1089. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -0
  1090. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +86 -0
  1091. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +128 -0
  1092. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +224 -0
  1093. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +118 -0
  1094. package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -0
  1095. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -0
  1096. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1097. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +51 -0
  1098. package/src/renderers/shaders/ShaderLib.js +362 -0
  1099. package/src/renderers/shaders/UniformsLib.js +234 -0
  1100. package/src/renderers/shaders/UniformsUtils.js +154 -0
  1101. package/src/renderers/webgl/WebGLAnimation.js +54 -0
  1102. package/src/renderers/webgl/WebGLAttributes.js +237 -0
  1103. package/src/renderers/webgl/WebGLBackground.js +303 -0
  1104. package/src/renderers/webgl/WebGLBindingStates.js +666 -0
  1105. package/src/renderers/webgl/WebGLBufferRenderer.js +57 -0
  1106. package/src/renderers/webgl/WebGLCapabilities.js +150 -0
  1107. package/src/renderers/webgl/WebGLClipping.js +171 -0
  1108. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  1109. package/src/renderers/webgl/WebGLExtensions.js +61 -0
  1110. package/src/renderers/webgl/WebGLGeometries.js +186 -0
  1111. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +68 -0
  1112. package/src/renderers/webgl/WebGLInfo.js +73 -0
  1113. package/src/renderers/webgl/WebGLLights.js +584 -0
  1114. package/src/renderers/webgl/WebGLMaterials.js +602 -0
  1115. package/src/renderers/webgl/WebGLMorphtargets.js +168 -0
  1116. package/src/renderers/webgl/WebGLObjects.js +94 -0
  1117. package/src/renderers/webgl/WebGLOutput.js +270 -0
  1118. package/src/renderers/webgl/WebGLProgram.js +1031 -0
  1119. package/src/renderers/webgl/WebGLPrograms.js +679 -0
  1120. package/src/renderers/webgl/WebGLProperties.js +55 -0
  1121. package/src/renderers/webgl/WebGLRenderLists.js +253 -0
  1122. package/src/renderers/webgl/WebGLRenderStates.js +124 -0
  1123. package/src/renderers/webgl/WebGLShader.js +12 -0
  1124. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1125. package/src/renderers/webgl/WebGLShadowMap.js +600 -0
  1126. package/src/renderers/webgl/WebGLState.js +1370 -0
  1127. package/src/renderers/webgl/WebGLTextures.js +2506 -0
  1128. package/src/renderers/webgl/WebGLUniforms.js +1203 -0
  1129. package/src/renderers/webgl/WebGLUniformsGroups.js +413 -0
  1130. package/src/renderers/webgl/WebGLUtils.js +217 -0
  1131. package/src/renderers/webgl-fallback/WebGLBackend.js +2783 -0
  1132. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +99 -0
  1133. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1676 -0
  1134. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +359 -0
  1135. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +89 -0
  1136. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +13 -0
  1137. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
  1138. package/src/renderers/webgl-fallback/utils/WebGLState.js +1361 -0
  1139. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1324 -0
  1140. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
  1141. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +317 -0
  1142. package/src/renderers/webgpu/WebGPUBackend.js +2602 -0
  1143. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
  1144. package/src/renderers/webgpu/WebGPURenderer.js +107 -0
  1145. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
  1146. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +100 -0
  1147. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2523 -0
  1148. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +187 -0
  1149. package/src/renderers/webgpu/nodes/WGSLNodeParser.js +25 -0
  1150. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +522 -0
  1151. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +642 -0
  1152. package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
  1153. package/src/renderers/webgpu/utils/WebGPUConstants.js +354 -0
  1154. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +846 -0
  1155. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +389 -0
  1156. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1673 -0
  1157. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
  1158. package/src/renderers/webgpu/utils/WebGPUUtils.js +269 -0
  1159. package/src/renderers/webxr/WebXRController.js +440 -0
  1160. package/src/renderers/webxr/WebXRDepthSensing.js +155 -0
  1161. package/src/renderers/webxr/WebXRManager.js +1103 -0
  1162. package/src/scenes/Fog.js +98 -0
  1163. package/src/scenes/FogExp2.js +86 -0
  1164. package/src/scenes/Scene.js +165 -0
  1165. package/src/textures/CanvasTexture.js +45 -0
  1166. package/src/textures/CompressedArrayTexture.js +89 -0
  1167. package/src/textures/CompressedCubeTexture.js +48 -0
  1168. package/src/textures/CompressedTexture.js +86 -0
  1169. package/src/textures/CubeDepthTexture.js +76 -0
  1170. package/src/textures/CubeTexture.js +81 -0
  1171. package/src/textures/Data3DTexture.js +112 -0
  1172. package/src/textures/DataArrayTexture.js +134 -0
  1173. package/src/textures/DataTexture.js +87 -0
  1174. package/src/textures/DepthTexture.js +104 -0
  1175. package/src/textures/ExternalTexture.js +56 -0
  1176. package/src/textures/FramebufferTexture.js +85 -0
  1177. package/src/textures/HTMLTexture.js +74 -0
  1178. package/src/textures/Source.js +230 -0
  1179. package/src/textures/Texture.js +812 -0
  1180. package/src/textures/VideoFrameTexture.js +72 -0
  1181. package/src/textures/VideoTexture.js +127 -0
  1182. package/src/utils.js +493 -0
@@ -0,0 +1,3738 @@
1
+ import {
2
+ BufferAttribute,
3
+ ClampToEdgeWrapping,
4
+ Color,
5
+ DoubleSide,
6
+ InterpolateDiscrete,
7
+ InterpolateLinear,
8
+ NoColorSpace,
9
+ LinearFilter,
10
+ LinearMipmapLinearFilter,
11
+ LinearMipmapNearestFilter,
12
+ MathUtils,
13
+ Matrix4,
14
+ MirroredRepeatWrapping,
15
+ NearestFilter,
16
+ NearestMipmapLinearFilter,
17
+ NearestMipmapNearestFilter,
18
+ PropertyBinding,
19
+ RGBAFormat,
20
+ RepeatWrapping,
21
+ Scene,
22
+ Source,
23
+ SRGBColorSpace,
24
+ CompressedTexture,
25
+ Vector3,
26
+ Quaternion,
27
+ REVISION,
28
+ ImageUtils
29
+ } from 'three';
30
+
31
+ /**
32
+ * The KHR_mesh_quantization extension allows these extra attribute component types
33
+ *
34
+ * @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#extending-mesh-attributes
35
+ */
36
+ const KHR_mesh_quantization_ExtraAttrTypes = {
37
+ POSITION: [
38
+ 'byte',
39
+ 'byte normalized',
40
+ 'unsigned byte',
41
+ 'unsigned byte normalized',
42
+ 'short',
43
+ 'short normalized',
44
+ 'unsigned short',
45
+ 'unsigned short normalized',
46
+ ],
47
+ NORMAL: [
48
+ 'byte normalized',
49
+ 'short normalized',
50
+ ],
51
+ TANGENT: [
52
+ 'byte normalized',
53
+ 'short normalized',
54
+ ],
55
+ TEXCOORD: [
56
+ 'byte',
57
+ 'byte normalized',
58
+ 'unsigned byte',
59
+ 'short',
60
+ 'short normalized',
61
+ 'unsigned short',
62
+ ],
63
+ };
64
+
65
+ /**
66
+ * An exporter for `glTF` 2.0.
67
+ *
68
+ * glTF (GL Transmission Format) is an [open format specification](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0)
69
+ * for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf)
70
+ * or binary (.glb) format. External files store textures (.jpg, .png) and additional binary
71
+ * data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials,
72
+ * textures, skins, skeletons, morph targets, animations, lights, and/or cameras.
73
+ *
74
+ * GLTFExporter supports the [glTF 2.0 extensions](https://github.com/KhronosGroup/glTF/tree/master/extensions/):
75
+ *
76
+ * - KHR_lights_punctual
77
+ * - KHR_materials_clearcoat
78
+ * - KHR_materials_dispersion
79
+ * - KHR_materials_emissive_strength
80
+ * - KHR_materials_ior
81
+ * - KHR_materials_iridescence
82
+ * - KHR_materials_specular
83
+ * - KHR_materials_sheen
84
+ * - KHR_materials_transmission
85
+ * - KHR_materials_unlit
86
+ * - KHR_materials_volume
87
+ * - KHR_mesh_quantization
88
+ * - KHR_texture_transform
89
+ * - EXT_materials_bump
90
+ * - EXT_mesh_gpu_instancing
91
+ * - EXT_texture_webp
92
+ *
93
+ * The following glTF 2.0 extension is supported by an external user plugin:
94
+ *
95
+ * - [KHR_materials_variants](https://github.com/takahirox/three-gltf-extensions)
96
+ *
97
+ * ```js
98
+ * const exporter = new GLTFExporter();
99
+ * const data = await exporter.parseAsync( scene, options );
100
+ * ```
101
+ *
102
+ * @three_import import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
103
+ */
104
+ class GLTFExporter {
105
+
106
+ /**
107
+ * Constructs a new glTF exporter.
108
+ */
109
+ constructor() {
110
+
111
+ /**
112
+ * A reference to a texture utils module.
113
+ *
114
+ * @type {?(WebGLTextureUtils|WebGPUTextureUtils)}
115
+ * @default null
116
+ */
117
+ this.textureUtils = null;
118
+
119
+ this.pluginCallbacks = [];
120
+
121
+ this.register( function ( writer ) {
122
+
123
+ return new GLTFLightExtension( writer );
124
+
125
+ } );
126
+
127
+ this.register( function ( writer ) {
128
+
129
+ return new GLTFMaterialsUnlitExtension( writer );
130
+
131
+ } );
132
+
133
+ this.register( function ( writer ) {
134
+
135
+ return new GLTFMaterialsTransmissionExtension( writer );
136
+
137
+ } );
138
+
139
+ this.register( function ( writer ) {
140
+
141
+ return new GLTFMaterialsVolumeExtension( writer );
142
+
143
+ } );
144
+
145
+ this.register( function ( writer ) {
146
+
147
+ return new GLTFMaterialsIorExtension( writer );
148
+
149
+ } );
150
+
151
+ this.register( function ( writer ) {
152
+
153
+ return new GLTFMaterialsSpecularExtension( writer );
154
+
155
+ } );
156
+
157
+ this.register( function ( writer ) {
158
+
159
+ return new GLTFMaterialsClearcoatExtension( writer );
160
+
161
+ } );
162
+
163
+ this.register( function ( writer ) {
164
+
165
+ return new GLTFMaterialsDispersionExtension( writer );
166
+
167
+ } );
168
+
169
+ this.register( function ( writer ) {
170
+
171
+ return new GLTFMaterialsIridescenceExtension( writer );
172
+
173
+ } );
174
+
175
+ this.register( function ( writer ) {
176
+
177
+ return new GLTFMaterialsSheenExtension( writer );
178
+
179
+ } );
180
+
181
+ this.register( function ( writer ) {
182
+
183
+ return new GLTFMaterialsAnisotropyExtension( writer );
184
+
185
+ } );
186
+
187
+ this.register( function ( writer ) {
188
+
189
+ return new GLTFMaterialsEmissiveStrengthExtension( writer );
190
+
191
+ } );
192
+
193
+ this.register( function ( writer ) {
194
+
195
+ return new GLTFMaterialsBumpExtension( writer );
196
+
197
+ } );
198
+
199
+ this.register( function ( writer ) {
200
+
201
+ return new GLTFMeshGpuInstancing( writer );
202
+
203
+ } );
204
+
205
+ }
206
+
207
+ /**
208
+ * Registers a plugin callback. This API is internally used to implement the various
209
+ * glTF extensions but can also used by third-party code to add additional logic
210
+ * to the exporter.
211
+ *
212
+ * @param {function(writer:GLTFWriter)} callback - The callback function to register.
213
+ * @return {GLTFExporter} A reference to this exporter.
214
+ */
215
+ register( callback ) {
216
+
217
+ if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
218
+
219
+ this.pluginCallbacks.push( callback );
220
+
221
+ }
222
+
223
+ return this;
224
+
225
+ }
226
+
227
+ /**
228
+ * Unregisters a plugin callback.
229
+ *
230
+ * @param {Function} callback - The callback function to unregister.
231
+ * @return {GLTFExporter} A reference to this exporter.
232
+ */
233
+ unregister( callback ) {
234
+
235
+ if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
236
+
237
+ this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 );
238
+
239
+ }
240
+
241
+ return this;
242
+
243
+ }
244
+
245
+ /**
246
+ * Sets the texture utils for this exporter. Only relevant when compressed textures have to be exported.
247
+ *
248
+ * Depending on whether you use {@link WebGLRenderer} or {@link WebGPURenderer}, you must inject the
249
+ * corresponding texture utils {@link WebGLTextureUtils} or {@link WebGPUTextureUtils}.
250
+ *
251
+ * @param {WebGLTextureUtils|WebGPUTextureUtils} utils - The texture utils.
252
+ * @return {GLTFExporter} A reference to this exporter.
253
+ */
254
+ setTextureUtils( utils ) {
255
+
256
+ this.textureUtils = utils;
257
+
258
+ return this;
259
+
260
+ }
261
+
262
+ /**
263
+ * Parses the given scenes and generates the glTF output.
264
+ *
265
+ * @param {Scene|Array<Scene>} input - A scene or an array of scenes.
266
+ * @param {GLTFExporter~OnDone} onDone - A callback function that is executed when the export has finished.
267
+ * @param {GLTFExporter~OnError} onError - A callback function that is executed when an error happens.
268
+ * @param {GLTFExporter~Options} options - options
269
+ */
270
+ parse( input, onDone, onError, options ) {
271
+
272
+ const writer = new GLTFWriter();
273
+ const plugins = [];
274
+
275
+ for ( let i = 0, il = this.pluginCallbacks.length; i < il; i ++ ) {
276
+
277
+ plugins.push( this.pluginCallbacks[ i ]( writer ) );
278
+
279
+ }
280
+
281
+ writer.setPlugins( plugins );
282
+ writer.setTextureUtils( this.textureUtils );
283
+ writer.writeAsync( input, onDone, options ).catch( onError );
284
+
285
+ }
286
+
287
+ /**
288
+ * Async version of {@link GLTFExporter#parse}.
289
+ *
290
+ * @param {Scene|Array<Scene>} input - A scene or an array of scenes.
291
+ * @param {GLTFExporter~Options} options - options.
292
+ * @return {Promise<ArrayBuffer|string>} A Promise that resolved with the exported glTF data.
293
+ */
294
+ parseAsync( input, options ) {
295
+
296
+ const scope = this;
297
+
298
+ return new Promise( function ( resolve, reject ) {
299
+
300
+ scope.parse( input, resolve, reject, options );
301
+
302
+ } );
303
+
304
+ }
305
+
306
+ }
307
+
308
+ //------------------------------------------------------------------------------
309
+ // Constants
310
+ //------------------------------------------------------------------------------
311
+
312
+ const WEBGL_CONSTANTS = {
313
+ POINTS: 0x0000,
314
+ LINES: 0x0001,
315
+ LINE_LOOP: 0x0002,
316
+ LINE_STRIP: 0x0003,
317
+ TRIANGLES: 0x0004,
318
+ TRIANGLE_STRIP: 0x0005,
319
+ TRIANGLE_FAN: 0x0006,
320
+
321
+ BYTE: 0x1400,
322
+ UNSIGNED_BYTE: 0x1401,
323
+ SHORT: 0x1402,
324
+ UNSIGNED_SHORT: 0x1403,
325
+ INT: 0x1404,
326
+ UNSIGNED_INT: 0x1405,
327
+ FLOAT: 0x1406,
328
+
329
+ ARRAY_BUFFER: 0x8892,
330
+ ELEMENT_ARRAY_BUFFER: 0x8893,
331
+
332
+ NEAREST: 0x2600,
333
+ LINEAR: 0x2601,
334
+ NEAREST_MIPMAP_NEAREST: 0x2700,
335
+ LINEAR_MIPMAP_NEAREST: 0x2701,
336
+ NEAREST_MIPMAP_LINEAR: 0x2702,
337
+ LINEAR_MIPMAP_LINEAR: 0x2703,
338
+
339
+ CLAMP_TO_EDGE: 33071,
340
+ MIRRORED_REPEAT: 33648,
341
+ REPEAT: 10497
342
+ };
343
+
344
+ const KHR_MESH_QUANTIZATION = 'KHR_mesh_quantization';
345
+
346
+ const THREE_TO_WEBGL = {};
347
+
348
+ THREE_TO_WEBGL[ NearestFilter ] = WEBGL_CONSTANTS.NEAREST;
349
+ THREE_TO_WEBGL[ NearestMipmapNearestFilter ] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
350
+ THREE_TO_WEBGL[ NearestMipmapLinearFilter ] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
351
+ THREE_TO_WEBGL[ LinearFilter ] = WEBGL_CONSTANTS.LINEAR;
352
+ THREE_TO_WEBGL[ LinearMipmapNearestFilter ] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
353
+ THREE_TO_WEBGL[ LinearMipmapLinearFilter ] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
354
+
355
+ THREE_TO_WEBGL[ ClampToEdgeWrapping ] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
356
+ THREE_TO_WEBGL[ RepeatWrapping ] = WEBGL_CONSTANTS.REPEAT;
357
+ THREE_TO_WEBGL[ MirroredRepeatWrapping ] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
358
+
359
+ const PATH_PROPERTIES = {
360
+ scale: 'scale',
361
+ position: 'translation',
362
+ quaternion: 'rotation',
363
+ morphTargetInfluences: 'weights'
364
+ };
365
+
366
+ const DEFAULT_SPECULAR_COLOR = new Color();
367
+
368
+ // GLB constants
369
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
370
+
371
+ const GLB_HEADER_BYTES = 12;
372
+ const GLB_HEADER_MAGIC = 0x46546C67;
373
+ const GLB_VERSION = 2;
374
+
375
+ const GLB_CHUNK_PREFIX_BYTES = 8;
376
+ const GLB_CHUNK_TYPE_JSON = 0x4E4F534A;
377
+ const GLB_CHUNK_TYPE_BIN = 0x004E4942;
378
+
379
+ //------------------------------------------------------------------------------
380
+ // Utility functions
381
+ //------------------------------------------------------------------------------
382
+
383
+ /**
384
+ * Compare two arrays
385
+ *
386
+ * @private
387
+ * @param {Array} array1 Array 1 to compare
388
+ * @param {Array} array2 Array 2 to compare
389
+ * @return {boolean} Returns true if both arrays are equal
390
+ */
391
+ function equalArray( array1, array2 ) {
392
+
393
+ return ( array1.length === array2.length ) && array1.every( function ( element, index ) {
394
+
395
+ return element === array2[ index ];
396
+
397
+ } );
398
+
399
+ }
400
+
401
+ /**
402
+ * Converts a string to an ArrayBuffer.
403
+ *
404
+ * @private
405
+ * @param {string} text
406
+ * @return {ArrayBuffer}
407
+ */
408
+ function stringToArrayBuffer( text ) {
409
+
410
+ return new TextEncoder().encode( text ).buffer;
411
+
412
+ }
413
+
414
+ /**
415
+ * Is identity matrix
416
+ *
417
+ * @private
418
+ * @param {Matrix4} matrix
419
+ * @returns {boolean} Returns true, if parameter is identity matrix
420
+ */
421
+ function isIdentityMatrix( matrix ) {
422
+
423
+ return equalArray( matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] );
424
+
425
+ }
426
+
427
+ /**
428
+ * Get the min and max vectors from the given attribute
429
+ *
430
+ * @private
431
+ * @param {BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
432
+ * @param {number} start Start index
433
+ * @param {number} count Range to cover
434
+ * @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
435
+ */
436
+ function getMinMax( attribute, start, count ) {
437
+
438
+ const output = {
439
+
440
+ min: new Array( attribute.itemSize ).fill( Number.POSITIVE_INFINITY ),
441
+ max: new Array( attribute.itemSize ).fill( Number.NEGATIVE_INFINITY )
442
+
443
+ };
444
+
445
+ for ( let i = start; i < start + count; i ++ ) {
446
+
447
+ for ( let a = 0; a < attribute.itemSize; a ++ ) {
448
+
449
+ let value;
450
+
451
+ if ( attribute.itemSize > 4 ) {
452
+
453
+ // no support for interleaved data for itemSize > 4
454
+
455
+ value = attribute.array[ i * attribute.itemSize + a ];
456
+
457
+ } else {
458
+
459
+ if ( a === 0 ) value = attribute.getX( i );
460
+ else if ( a === 1 ) value = attribute.getY( i );
461
+ else if ( a === 2 ) value = attribute.getZ( i );
462
+ else if ( a === 3 ) value = attribute.getW( i );
463
+
464
+ if ( attribute.normalized === true ) {
465
+
466
+ value = MathUtils.normalize( value, attribute.array );
467
+
468
+ }
469
+
470
+ }
471
+
472
+ output.min[ a ] = Math.min( output.min[ a ], value );
473
+ output.max[ a ] = Math.max( output.max[ a ], value );
474
+
475
+ }
476
+
477
+ }
478
+
479
+ return output;
480
+
481
+ }
482
+
483
+ /**
484
+ * Get the required size + padding for a buffer, rounded to the next 4-byte boundary.
485
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
486
+ *
487
+ * @private
488
+ * @param {number} bufferSize The size the original buffer. Should be an integer.
489
+ * @returns {number} new buffer size with required padding as an integer.
490
+ *
491
+ */
492
+ function getPaddedBufferSize( bufferSize ) {
493
+
494
+ return Math.ceil( bufferSize / 4 ) * 4;
495
+
496
+ }
497
+
498
+ /**
499
+ * Returns a buffer aligned to 4-byte boundary.
500
+ *
501
+ * @private
502
+ * @param {ArrayBuffer} arrayBuffer Buffer to pad
503
+ * @param {number} [paddingByte=0] Should be an integer
504
+ * @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
505
+ */
506
+ function getPaddedArrayBuffer( arrayBuffer, paddingByte = 0 ) {
507
+
508
+ const paddedLength = getPaddedBufferSize( arrayBuffer.byteLength );
509
+
510
+ if ( paddedLength !== arrayBuffer.byteLength ) {
511
+
512
+ const array = new Uint8Array( paddedLength );
513
+ array.set( new Uint8Array( arrayBuffer ) );
514
+
515
+ if ( paddingByte !== 0 ) {
516
+
517
+ for ( let i = arrayBuffer.byteLength; i < paddedLength; i ++ ) {
518
+
519
+ array[ i ] = paddingByte;
520
+
521
+ }
522
+
523
+ }
524
+
525
+ return array.buffer;
526
+
527
+ }
528
+
529
+ return arrayBuffer;
530
+
531
+ }
532
+
533
+ function getCanvas() {
534
+
535
+ if ( typeof document === 'undefined' && typeof OffscreenCanvas !== 'undefined' ) {
536
+
537
+ return new OffscreenCanvas( 1, 1 );
538
+
539
+ }
540
+
541
+ return document.createElement( 'canvas' );
542
+
543
+ }
544
+
545
+ function getToBlobPromise( canvas, mimeType ) {
546
+
547
+ if ( typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas ) {
548
+
549
+ let quality;
550
+
551
+ // Blink's implementation of convertToBlob seems to default to a quality level of 100%
552
+ // Use the Blink default quality levels of toBlob instead so that file sizes are comparable.
553
+ if ( mimeType === 'image/jpeg' ) {
554
+
555
+ quality = 0.92;
556
+
557
+ } else if ( mimeType === 'image/webp' ) {
558
+
559
+ quality = 0.8;
560
+
561
+ }
562
+
563
+ return canvas.convertToBlob( {
564
+
565
+ type: mimeType,
566
+ quality: quality
567
+
568
+ } );
569
+
570
+ } else {
571
+
572
+ // HTMLCanvasElement code path
573
+
574
+ return new Promise( ( resolve ) => canvas.toBlob( resolve, mimeType ) );
575
+
576
+ }
577
+
578
+ }
579
+
580
+ /**
581
+ * Writer
582
+ *
583
+ * @private
584
+ */
585
+ class GLTFWriter {
586
+
587
+ constructor() {
588
+
589
+ this.plugins = [];
590
+
591
+ this.options = {};
592
+ this.pending = [];
593
+ this.buffers = [];
594
+
595
+ this.byteOffset = 0;
596
+ this.buffers = [];
597
+ this.nodeMap = new Map();
598
+ this.skins = [];
599
+
600
+ this.extensionsUsed = {};
601
+ this.extensionsRequired = {};
602
+
603
+ this.uids = new Map();
604
+ this.uid = 0;
605
+
606
+ this.json = {
607
+ asset: {
608
+ version: '2.0',
609
+ generator: 'THREE.GLTFExporter r' + REVISION
610
+ }
611
+ };
612
+
613
+ this.cache = {
614
+ meshes: new Map(),
615
+ attributes: new Map(),
616
+ attributesNormalized: new Map(),
617
+ materials: new Map(),
618
+ textures: new Map(),
619
+ images: new Map()
620
+ };
621
+
622
+ this.textureUtils = null;
623
+
624
+ }
625
+
626
+ setPlugins( plugins ) {
627
+
628
+ this.plugins = plugins;
629
+
630
+ }
631
+
632
+ setTextureUtils( utils ) {
633
+
634
+ this.textureUtils = utils;
635
+
636
+ }
637
+
638
+ /**
639
+ * Parse scenes and generate GLTF output
640
+ *
641
+ * @param {Scene|Array<Scene>} input Scene or Array of THREE.Scenes
642
+ * @param {Function} onDone Callback on completed
643
+ * @param {Object} options options
644
+ */
645
+ async writeAsync( input, onDone, options = {} ) {
646
+
647
+ this.options = Object.assign( {
648
+ // default options
649
+ binary: false,
650
+ trs: false,
651
+ onlyVisible: true,
652
+ maxTextureSize: Infinity,
653
+ animations: [],
654
+ includeCustomExtensions: false
655
+ }, options );
656
+
657
+ if ( this.options.animations.length > 0 ) {
658
+
659
+ // Only TRS properties, and not matrices, may be targeted by animation.
660
+ this.options.trs = true;
661
+
662
+ }
663
+
664
+ await this.processInputAsync( input );
665
+
666
+ await Promise.all( this.pending );
667
+
668
+ const writer = this;
669
+ const buffers = writer.buffers;
670
+ const json = writer.json;
671
+ options = writer.options;
672
+
673
+ const extensionsUsed = writer.extensionsUsed;
674
+ const extensionsRequired = writer.extensionsRequired;
675
+
676
+ // Merge buffers.
677
+ const blob = new Blob( buffers, { type: 'application/octet-stream' } );
678
+
679
+ // Declare extensions.
680
+ const extensionsUsedList = Object.keys( extensionsUsed );
681
+ const extensionsRequiredList = Object.keys( extensionsRequired );
682
+
683
+ if ( extensionsUsedList.length > 0 ) json.extensionsUsed = extensionsUsedList;
684
+ if ( extensionsRequiredList.length > 0 ) json.extensionsRequired = extensionsRequiredList;
685
+
686
+ // Update bytelength of the single buffer.
687
+ if ( json.buffers && json.buffers.length > 0 ) json.buffers[ 0 ].byteLength = blob.size;
688
+
689
+ if ( options.binary === true ) {
690
+
691
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
692
+
693
+ const reader = new FileReader();
694
+ reader.readAsArrayBuffer( blob );
695
+ reader.onloadend = function () {
696
+
697
+ // Binary chunk.
698
+ const binaryChunk = getPaddedArrayBuffer( reader.result );
699
+ const binaryChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
700
+ binaryChunkPrefix.setUint32( 0, binaryChunk.byteLength, true );
701
+ binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true );
702
+
703
+ // JSON chunk.
704
+ const jsonChunk = getPaddedArrayBuffer( stringToArrayBuffer( JSON.stringify( json ) ), 0x20 );
705
+ const jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
706
+ jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true );
707
+ jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true );
708
+
709
+ // GLB header.
710
+ const header = new ArrayBuffer( GLB_HEADER_BYTES );
711
+ const headerView = new DataView( header );
712
+ headerView.setUint32( 0, GLB_HEADER_MAGIC, true );
713
+ headerView.setUint32( 4, GLB_VERSION, true );
714
+ const totalByteLength = GLB_HEADER_BYTES
715
+ + jsonChunkPrefix.byteLength + jsonChunk.byteLength
716
+ + binaryChunkPrefix.byteLength + binaryChunk.byteLength;
717
+ headerView.setUint32( 8, totalByteLength, true );
718
+
719
+ const glbBlob = new Blob( [
720
+ header,
721
+ jsonChunkPrefix,
722
+ jsonChunk,
723
+ binaryChunkPrefix,
724
+ binaryChunk
725
+ ], { type: 'application/octet-stream' } );
726
+
727
+ const glbReader = new FileReader();
728
+ glbReader.readAsArrayBuffer( glbBlob );
729
+ glbReader.onloadend = function () {
730
+
731
+ onDone( glbReader.result );
732
+
733
+ };
734
+
735
+ };
736
+
737
+ } else {
738
+
739
+ if ( json.buffers && json.buffers.length > 0 ) {
740
+
741
+ const reader = new FileReader();
742
+ reader.readAsDataURL( blob );
743
+ reader.onloadend = function () {
744
+
745
+ const base64data = reader.result;
746
+ json.buffers[ 0 ].uri = base64data;
747
+ onDone( json );
748
+
749
+ };
750
+
751
+ } else {
752
+
753
+ onDone( json );
754
+
755
+ }
756
+
757
+ }
758
+
759
+
760
+ }
761
+
762
+ /**
763
+ * Serializes a userData.
764
+ *
765
+ * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
766
+ * @param {Object} objectDef
767
+ */
768
+ serializeUserData( object, objectDef ) {
769
+
770
+ if ( Object.keys( object.userData ).length === 0 ) return;
771
+
772
+ const options = this.options;
773
+ const extensionsUsed = this.extensionsUsed;
774
+
775
+ try {
776
+
777
+ const json = JSON.parse( JSON.stringify( object.userData ) );
778
+
779
+ if ( options.includeCustomExtensions && json.gltfExtensions ) {
780
+
781
+ if ( objectDef.extensions === undefined ) objectDef.extensions = {};
782
+
783
+ for ( const extensionName in json.gltfExtensions ) {
784
+
785
+ objectDef.extensions[ extensionName ] = json.gltfExtensions[ extensionName ];
786
+ extensionsUsed[ extensionName ] = true;
787
+
788
+ }
789
+
790
+ delete json.gltfExtensions;
791
+
792
+ }
793
+
794
+ if ( Object.keys( json ).length > 0 ) objectDef.extras = json;
795
+
796
+ } catch ( error ) {
797
+
798
+ console.warn( 'THREE.GLTFExporter: userData of \'' + object.name + '\' ' +
799
+ 'won\'t be serialized because of JSON.stringify error - ' + error.message );
800
+
801
+ }
802
+
803
+ }
804
+
805
+ /**
806
+ * Returns ids for buffer attributes.
807
+ *
808
+ * @param {Object} attribute
809
+ * @param {boolean} [isRelativeCopy=false]
810
+ * @return {number} An integer
811
+ */
812
+ getUID( attribute, isRelativeCopy = false ) {
813
+
814
+ if ( this.uids.has( attribute ) === false ) {
815
+
816
+ const uids = new Map();
817
+
818
+ uids.set( true, this.uid ++ );
819
+ uids.set( false, this.uid ++ );
820
+
821
+ this.uids.set( attribute, uids );
822
+
823
+ }
824
+
825
+ const uids = this.uids.get( attribute );
826
+
827
+ return uids.get( isRelativeCopy );
828
+
829
+ }
830
+
831
+ /**
832
+ * Checks if normal attribute values are normalized.
833
+ *
834
+ * @param {BufferAttribute} normal
835
+ * @returns {boolean}
836
+ */
837
+ isNormalizedNormalAttribute( normal ) {
838
+
839
+ const cache = this.cache;
840
+
841
+ if ( cache.attributesNormalized.has( normal ) ) return false;
842
+
843
+ const v = new Vector3();
844
+
845
+ for ( let i = 0, il = normal.count; i < il; i ++ ) {
846
+
847
+ // 0.0005 is from glTF-validator
848
+ if ( Math.abs( v.fromBufferAttribute( normal, i ).length() - 1.0 ) > 0.0005 ) return false;
849
+
850
+ }
851
+
852
+ return true;
853
+
854
+ }
855
+
856
+ /**
857
+ * Creates normalized normal buffer attribute.
858
+ *
859
+ * @param {BufferAttribute} normal
860
+ * @returns {BufferAttribute}
861
+ *
862
+ */
863
+ createNormalizedNormalAttribute( normal ) {
864
+
865
+ const cache = this.cache;
866
+
867
+ if ( cache.attributesNormalized.has( normal ) ) return cache.attributesNormalized.get( normal );
868
+
869
+ const attribute = normal.clone();
870
+ const v = new Vector3();
871
+
872
+ for ( let i = 0, il = attribute.count; i < il; i ++ ) {
873
+
874
+ v.fromBufferAttribute( attribute, i );
875
+
876
+ if ( v.x === 0 && v.y === 0 && v.z === 0 ) {
877
+
878
+ // if values can't be normalized set (1, 0, 0)
879
+ v.setX( 1.0 );
880
+
881
+ } else {
882
+
883
+ v.normalize();
884
+
885
+ }
886
+
887
+ attribute.setXYZ( i, v.x, v.y, v.z );
888
+
889
+ }
890
+
891
+ cache.attributesNormalized.set( normal, attribute );
892
+
893
+ return attribute;
894
+
895
+ }
896
+
897
+ /**
898
+ * Applies a texture transform, if present, to the map definition. Requires
899
+ * the KHR_texture_transform extension.
900
+ *
901
+ * @param {Object} mapDef
902
+ * @param {THREE.Texture} texture
903
+ */
904
+ applyTextureTransform( mapDef, texture ) {
905
+
906
+ let didTransform = false;
907
+ const transformDef = {};
908
+
909
+ if ( texture.offset.x !== 0 || texture.offset.y !== 0 ) {
910
+
911
+ transformDef.offset = texture.offset.toArray();
912
+ didTransform = true;
913
+
914
+ }
915
+
916
+ if ( texture.rotation !== 0 ) {
917
+
918
+ transformDef.rotation = texture.rotation;
919
+ didTransform = true;
920
+
921
+ }
922
+
923
+ if ( texture.repeat.x !== 1 || texture.repeat.y !== 1 ) {
924
+
925
+ transformDef.scale = texture.repeat.toArray();
926
+ didTransform = true;
927
+
928
+ }
929
+
930
+ if ( didTransform ) {
931
+
932
+ mapDef.extensions = mapDef.extensions || {};
933
+ mapDef.extensions[ 'KHR_texture_transform' ] = transformDef;
934
+ this.extensionsUsed[ 'KHR_texture_transform' ] = true;
935
+
936
+ }
937
+
938
+ }
939
+
940
+ async buildMetalRoughTextureAsync( metalnessMap, roughnessMap ) {
941
+
942
+ if ( metalnessMap === roughnessMap ) return metalnessMap;
943
+
944
+ function getEncodingConversion( map ) {
945
+
946
+ if ( map.colorSpace === SRGBColorSpace ) {
947
+
948
+ return function SRGBToLinear( c ) {
949
+
950
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
951
+
952
+ };
953
+
954
+ }
955
+
956
+ return function LinearToLinear( c ) {
957
+
958
+ return c;
959
+
960
+ };
961
+
962
+ }
963
+
964
+ if ( metalnessMap instanceof CompressedTexture ) {
965
+
966
+ metalnessMap = await this.decompressTextureAsync( metalnessMap );
967
+
968
+ }
969
+
970
+ if ( roughnessMap instanceof CompressedTexture ) {
971
+
972
+ roughnessMap = await this.decompressTextureAsync( roughnessMap );
973
+
974
+ }
975
+
976
+ const metalness = metalnessMap ? metalnessMap.image : null;
977
+ const roughness = roughnessMap ? roughnessMap.image : null;
978
+
979
+ const width = Math.max( metalness ? metalness.width : 0, roughness ? roughness.width : 0 );
980
+ const height = Math.max( metalness ? metalness.height : 0, roughness ? roughness.height : 0 );
981
+
982
+ const canvas = getCanvas();
983
+ canvas.width = width;
984
+ canvas.height = height;
985
+
986
+ const context = canvas.getContext( '2d', {
987
+ willReadFrequently: true,
988
+ } );
989
+ context.fillStyle = '#00ffff';
990
+ context.fillRect( 0, 0, width, height );
991
+
992
+ const composite = context.getImageData( 0, 0, width, height );
993
+
994
+ if ( metalness ) {
995
+
996
+ context.drawImage( metalness, 0, 0, width, height );
997
+
998
+ const convert = getEncodingConversion( metalnessMap );
999
+ const data = context.getImageData( 0, 0, width, height ).data;
1000
+
1001
+ for ( let i = 2; i < data.length; i += 4 ) {
1002
+
1003
+ composite.data[ i ] = convert( data[ i ] / 256 ) * 256;
1004
+
1005
+ }
1006
+
1007
+ }
1008
+
1009
+ if ( roughness ) {
1010
+
1011
+ context.drawImage( roughness, 0, 0, width, height );
1012
+
1013
+ const convert = getEncodingConversion( roughnessMap );
1014
+ const data = context.getImageData( 0, 0, width, height ).data;
1015
+
1016
+ for ( let i = 1; i < data.length; i += 4 ) {
1017
+
1018
+ composite.data[ i ] = convert( data[ i ] / 256 ) * 256;
1019
+
1020
+ }
1021
+
1022
+ }
1023
+
1024
+ context.putImageData( composite, 0, 0 );
1025
+
1026
+ //
1027
+
1028
+ const reference = metalnessMap || roughnessMap;
1029
+
1030
+ const texture = reference.clone();
1031
+
1032
+ texture.source = new Source( canvas );
1033
+ texture.colorSpace = NoColorSpace;
1034
+ texture.channel = ( metalnessMap || roughnessMap ).channel;
1035
+
1036
+ if ( metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel ) {
1037
+
1038
+ console.warn( 'THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.' );
1039
+
1040
+ }
1041
+
1042
+ console.warn( 'THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.' );
1043
+
1044
+ return texture;
1045
+
1046
+ }
1047
+
1048
+
1049
+ async decompressTextureAsync( texture, maxTextureSize = Infinity ) {
1050
+
1051
+ if ( this.textureUtils === null ) {
1052
+
1053
+ throw new Error( 'THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.' );
1054
+
1055
+ }
1056
+
1057
+ return await this.textureUtils.decompress( texture, maxTextureSize );
1058
+
1059
+ }
1060
+
1061
+ /**
1062
+ * Process a buffer to append to the default one.
1063
+ * @param {ArrayBuffer} buffer
1064
+ * @return {0}
1065
+ */
1066
+ processBuffer( buffer ) {
1067
+
1068
+ const json = this.json;
1069
+ const buffers = this.buffers;
1070
+
1071
+ if ( ! json.buffers ) json.buffers = [ { byteLength: 0 } ];
1072
+
1073
+ // All buffers are merged before export.
1074
+ buffers.push( buffer );
1075
+
1076
+ return 0;
1077
+
1078
+ }
1079
+
1080
+ /**
1081
+ * Process and generate a BufferView
1082
+ * @param {BufferAttribute} attribute
1083
+ * @param {number} componentType
1084
+ * @param {number} start
1085
+ * @param {number} count
1086
+ * @param {number} [target] Target usage of the BufferView
1087
+ * @return {Object}
1088
+ */
1089
+ processBufferView( attribute, componentType, start, count, target ) {
1090
+
1091
+ const json = this.json;
1092
+
1093
+ if ( ! json.bufferViews ) json.bufferViews = [];
1094
+
1095
+ // Create a new dataview and dump the attribute's array into it
1096
+
1097
+ let componentSize;
1098
+
1099
+ switch ( componentType ) {
1100
+
1101
+ case WEBGL_CONSTANTS.BYTE:
1102
+ case WEBGL_CONSTANTS.UNSIGNED_BYTE:
1103
+
1104
+ componentSize = 1;
1105
+
1106
+ break;
1107
+
1108
+ case WEBGL_CONSTANTS.SHORT:
1109
+ case WEBGL_CONSTANTS.UNSIGNED_SHORT:
1110
+
1111
+ componentSize = 2;
1112
+
1113
+ break;
1114
+
1115
+ default:
1116
+
1117
+ componentSize = 4;
1118
+
1119
+ }
1120
+
1121
+ let byteStride = attribute.itemSize * componentSize;
1122
+
1123
+ if ( target === WEBGL_CONSTANTS.ARRAY_BUFFER ) {
1124
+
1125
+ // Each element of a vertex attribute MUST be aligned to 4-byte boundaries
1126
+ // inside a bufferView
1127
+ byteStride = Math.ceil( byteStride / 4 ) * 4;
1128
+
1129
+ }
1130
+
1131
+ const byteLength = getPaddedBufferSize( count * byteStride );
1132
+ const dataView = new DataView( new ArrayBuffer( byteLength ) );
1133
+ let offset = 0;
1134
+
1135
+ for ( let i = start; i < start + count; i ++ ) {
1136
+
1137
+ for ( let a = 0; a < attribute.itemSize; a ++ ) {
1138
+
1139
+ let value;
1140
+
1141
+ if ( attribute.itemSize > 4 ) {
1142
+
1143
+ // no support for interleaved data for itemSize > 4
1144
+
1145
+ value = attribute.array[ i * attribute.itemSize + a ];
1146
+
1147
+ } else {
1148
+
1149
+ if ( a === 0 ) value = attribute.getX( i );
1150
+ else if ( a === 1 ) value = attribute.getY( i );
1151
+ else if ( a === 2 ) value = attribute.getZ( i );
1152
+ else if ( a === 3 ) value = attribute.getW( i );
1153
+
1154
+ if ( attribute.normalized === true ) {
1155
+
1156
+ value = MathUtils.normalize( value, attribute.array );
1157
+
1158
+ }
1159
+
1160
+ }
1161
+
1162
+ if ( componentType === WEBGL_CONSTANTS.FLOAT ) {
1163
+
1164
+ dataView.setFloat32( offset, value, true );
1165
+
1166
+ } else if ( componentType === WEBGL_CONSTANTS.INT ) {
1167
+
1168
+ dataView.setInt32( offset, value, true );
1169
+
1170
+ } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_INT ) {
1171
+
1172
+ dataView.setUint32( offset, value, true );
1173
+
1174
+ } else if ( componentType === WEBGL_CONSTANTS.SHORT ) {
1175
+
1176
+ dataView.setInt16( offset, value, true );
1177
+
1178
+ } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) {
1179
+
1180
+ dataView.setUint16( offset, value, true );
1181
+
1182
+ } else if ( componentType === WEBGL_CONSTANTS.BYTE ) {
1183
+
1184
+ dataView.setInt8( offset, value );
1185
+
1186
+ } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) {
1187
+
1188
+ dataView.setUint8( offset, value );
1189
+
1190
+ }
1191
+
1192
+ offset += componentSize;
1193
+
1194
+ }
1195
+
1196
+ if ( ( offset % byteStride ) !== 0 ) {
1197
+
1198
+ offset += byteStride - ( offset % byteStride );
1199
+
1200
+ }
1201
+
1202
+ }
1203
+
1204
+ const bufferViewDef = {
1205
+
1206
+ buffer: this.processBuffer( dataView.buffer ),
1207
+ byteOffset: this.byteOffset,
1208
+ byteLength: byteLength
1209
+
1210
+ };
1211
+
1212
+ if ( target !== undefined ) bufferViewDef.target = target;
1213
+
1214
+ if ( target === WEBGL_CONSTANTS.ARRAY_BUFFER ) {
1215
+
1216
+ // Only define byteStride for vertex attributes.
1217
+ bufferViewDef.byteStride = byteStride;
1218
+
1219
+ }
1220
+
1221
+ this.byteOffset += byteLength;
1222
+
1223
+ json.bufferViews.push( bufferViewDef );
1224
+
1225
+ // @TODO Merge bufferViews where possible.
1226
+ const output = {
1227
+
1228
+ id: json.bufferViews.length - 1,
1229
+ byteLength: 0
1230
+
1231
+ };
1232
+
1233
+ return output;
1234
+
1235
+ }
1236
+
1237
+ /**
1238
+ * Process and generate a BufferView from an image Blob.
1239
+ * @param {Blob} blob
1240
+ * @return {Promise<number>} An integer
1241
+ */
1242
+ processBufferViewImage( blob ) {
1243
+
1244
+ const writer = this;
1245
+ const json = writer.json;
1246
+
1247
+ if ( ! json.bufferViews ) json.bufferViews = [];
1248
+
1249
+ return new Promise( function ( resolve ) {
1250
+
1251
+ const reader = new FileReader();
1252
+ reader.readAsArrayBuffer( blob );
1253
+ reader.onloadend = function () {
1254
+
1255
+ const buffer = getPaddedArrayBuffer( reader.result );
1256
+
1257
+ const bufferViewDef = {
1258
+ buffer: writer.processBuffer( buffer ),
1259
+ byteOffset: writer.byteOffset,
1260
+ byteLength: buffer.byteLength
1261
+ };
1262
+
1263
+ writer.byteOffset += buffer.byteLength;
1264
+ resolve( json.bufferViews.push( bufferViewDef ) - 1 );
1265
+
1266
+ };
1267
+
1268
+ } );
1269
+
1270
+ }
1271
+
1272
+ /**
1273
+ * Process attribute to generate an accessor
1274
+ * @param {BufferAttribute} attribute Attribute to process
1275
+ * @param {?BufferGeometry} [geometry] Geometry used for truncated draw range
1276
+ * @param {number} [start=0]
1277
+ * @param {number} [count=Infinity]
1278
+ * @return {?number} Index of the processed accessor on the "accessors" array
1279
+ */
1280
+ processAccessor( attribute, geometry, start, count ) {
1281
+
1282
+ const json = this.json;
1283
+
1284
+ const types = {
1285
+
1286
+ 1: 'SCALAR',
1287
+ 2: 'VEC2',
1288
+ 3: 'VEC3',
1289
+ 4: 'VEC4',
1290
+ 9: 'MAT3',
1291
+ 16: 'MAT4'
1292
+
1293
+ };
1294
+
1295
+ let componentType;
1296
+
1297
+ // Detect the component type of the attribute array
1298
+ if ( attribute.array.constructor === Float32Array ) {
1299
+
1300
+ componentType = WEBGL_CONSTANTS.FLOAT;
1301
+
1302
+ } else if ( attribute.array.constructor === Int32Array ) {
1303
+
1304
+ componentType = WEBGL_CONSTANTS.INT;
1305
+
1306
+ } else if ( attribute.array.constructor === Uint32Array ) {
1307
+
1308
+ componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
1309
+
1310
+ } else if ( attribute.array.constructor === Int16Array ) {
1311
+
1312
+ componentType = WEBGL_CONSTANTS.SHORT;
1313
+
1314
+ } else if ( attribute.array.constructor === Uint16Array ) {
1315
+
1316
+ componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
1317
+
1318
+ } else if ( attribute.array.constructor === Int8Array ) {
1319
+
1320
+ componentType = WEBGL_CONSTANTS.BYTE;
1321
+
1322
+ } else if ( attribute.array.constructor === Uint8Array ) {
1323
+
1324
+ componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
1325
+
1326
+ } else {
1327
+
1328
+ throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor.name );
1329
+
1330
+ }
1331
+
1332
+ if ( start === undefined ) start = 0;
1333
+ if ( count === undefined || count === Infinity ) count = attribute.count;
1334
+
1335
+ // Skip creating an accessor if the attribute doesn't have data to export
1336
+ if ( count === 0 ) return null;
1337
+
1338
+ const minMax = getMinMax( attribute, start, count );
1339
+ let bufferViewTarget;
1340
+
1341
+ // If geometry isn't provided, don't infer the target usage of the bufferView. For
1342
+ // animation samplers, target must not be set.
1343
+ if ( geometry !== undefined ) {
1344
+
1345
+ bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS.ARRAY_BUFFER;
1346
+
1347
+ }
1348
+
1349
+ const bufferView = this.processBufferView( attribute, componentType, start, count, bufferViewTarget );
1350
+
1351
+ const accessorDef = {
1352
+
1353
+ bufferView: bufferView.id,
1354
+ byteOffset: bufferView.byteOffset,
1355
+ componentType: componentType,
1356
+ count: count,
1357
+ max: minMax.max,
1358
+ min: minMax.min,
1359
+ type: types[ attribute.itemSize ]
1360
+
1361
+ };
1362
+
1363
+ if ( attribute.normalized === true ) accessorDef.normalized = true;
1364
+ if ( ! json.accessors ) json.accessors = [];
1365
+
1366
+ return json.accessors.push( accessorDef ) - 1;
1367
+
1368
+ }
1369
+
1370
+ /**
1371
+ * Process image
1372
+ * @param {Image} image to process
1373
+ * @param {number} format Identifier of the format (RGBAFormat)
1374
+ * @param {boolean} flipY before writing out the image
1375
+ * @param {string} mimeType export format
1376
+ * @return {number} Index of the processed texture in the "images" array
1377
+ */
1378
+ processImage( image, format, flipY, mimeType = 'image/png' ) {
1379
+
1380
+ if ( image !== null ) {
1381
+
1382
+ const writer = this;
1383
+ const cache = writer.cache;
1384
+ const json = writer.json;
1385
+ const options = writer.options;
1386
+ const pending = writer.pending;
1387
+
1388
+ if ( ! cache.images.has( image ) ) cache.images.set( image, {} );
1389
+
1390
+ const cachedImages = cache.images.get( image );
1391
+
1392
+ const key = mimeType + ':flipY/' + flipY.toString();
1393
+
1394
+ if ( cachedImages[ key ] !== undefined ) return cachedImages[ key ];
1395
+
1396
+ if ( ! json.images ) json.images = [];
1397
+
1398
+ const imageDef = { mimeType: mimeType };
1399
+
1400
+ const canvas = getCanvas();
1401
+
1402
+ canvas.width = Math.min( image.width, options.maxTextureSize );
1403
+ canvas.height = Math.min( image.height, options.maxTextureSize );
1404
+
1405
+ const ctx = canvas.getContext( '2d', {
1406
+ willReadFrequently: true,
1407
+ } );
1408
+
1409
+ if ( flipY === true ) {
1410
+
1411
+ ctx.translate( 0, canvas.height );
1412
+ ctx.scale( 1, - 1 );
1413
+
1414
+ }
1415
+
1416
+ if ( image.data !== undefined ) { // THREE.DataTexture
1417
+
1418
+ if ( format !== RGBAFormat ) {
1419
+
1420
+ console.error( 'GLTFExporter: Only RGBAFormat is supported.', format );
1421
+
1422
+ }
1423
+
1424
+ if ( image.width > options.maxTextureSize || image.height > options.maxTextureSize ) {
1425
+
1426
+ console.warn( 'GLTFExporter: Image size is bigger than maxTextureSize', image );
1427
+
1428
+ }
1429
+
1430
+ const data = new Uint8ClampedArray( image.height * image.width * 4 );
1431
+
1432
+ for ( let i = 0; i < data.length; i += 4 ) {
1433
+
1434
+ data[ i + 0 ] = image.data[ i + 0 ];
1435
+ data[ i + 1 ] = image.data[ i + 1 ];
1436
+ data[ i + 2 ] = image.data[ i + 2 ];
1437
+ data[ i + 3 ] = image.data[ i + 3 ];
1438
+
1439
+ }
1440
+
1441
+ ctx.putImageData( new ImageData( data, image.width, image.height ), 0, 0 );
1442
+
1443
+ } else {
1444
+
1445
+ if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
1446
+ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
1447
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
1448
+ ( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ) {
1449
+
1450
+ ctx.drawImage( image, 0, 0, canvas.width, canvas.height );
1451
+
1452
+ } else {
1453
+
1454
+ throw new Error( 'THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.' );
1455
+
1456
+ }
1457
+
1458
+ }
1459
+
1460
+ if ( options.binary === true ) {
1461
+
1462
+ pending.push(
1463
+
1464
+ getToBlobPromise( canvas, mimeType )
1465
+ .then( blob => writer.processBufferViewImage( blob ) )
1466
+ .then( bufferViewIndex => {
1467
+
1468
+ imageDef.bufferView = bufferViewIndex;
1469
+
1470
+ } )
1471
+
1472
+ );
1473
+
1474
+ } else {
1475
+
1476
+ imageDef.uri = ImageUtils.getDataURL( canvas, mimeType );
1477
+
1478
+ }
1479
+
1480
+ const index = json.images.push( imageDef ) - 1;
1481
+ cachedImages[ key ] = index;
1482
+ return index;
1483
+
1484
+ } else {
1485
+
1486
+ throw new Error( 'THREE.GLTFExporter: No valid image data found. Unable to process texture.' );
1487
+
1488
+ }
1489
+
1490
+ }
1491
+
1492
+ /**
1493
+ * Process sampler
1494
+ * @param {Texture} map Texture to process
1495
+ * @return {number} Index of the processed texture in the "samplers" array
1496
+ */
1497
+ processSampler( map ) {
1498
+
1499
+ const json = this.json;
1500
+
1501
+ if ( ! json.samplers ) json.samplers = [];
1502
+
1503
+ const samplerDef = {
1504
+ magFilter: THREE_TO_WEBGL[ map.magFilter ],
1505
+ minFilter: THREE_TO_WEBGL[ map.minFilter ],
1506
+ wrapS: THREE_TO_WEBGL[ map.wrapS ],
1507
+ wrapT: THREE_TO_WEBGL[ map.wrapT ]
1508
+ };
1509
+
1510
+ return json.samplers.push( samplerDef ) - 1;
1511
+
1512
+ }
1513
+
1514
+ /**
1515
+ * Process texture
1516
+ * @param {Texture} map Map to process
1517
+ * @return {Promise<number>} Index of the processed texture in the "textures" array
1518
+ */
1519
+ async processTextureAsync( map ) {
1520
+
1521
+ const writer = this;
1522
+ const options = writer.options;
1523
+ const cache = this.cache;
1524
+ const json = this.json;
1525
+
1526
+ if ( cache.textures.has( map ) ) return cache.textures.get( map );
1527
+
1528
+ if ( ! json.textures ) json.textures = [];
1529
+
1530
+ // make non-readable textures (e.g. CompressedTexture) readable by blitting them into a new texture
1531
+ if ( map instanceof CompressedTexture ) {
1532
+
1533
+ map = await this.decompressTextureAsync( map, options.maxTextureSize );
1534
+
1535
+ }
1536
+
1537
+ const mimeType = map.userData.mimeType;
1538
+
1539
+ const imageIndex = this.processImage( map.image, map.format, map.flipY, mimeType );
1540
+
1541
+ const textureDef = {
1542
+ sampler: this.processSampler( map )
1543
+ };
1544
+
1545
+ if ( mimeType === 'image/webp' ) {
1546
+
1547
+ textureDef.extensions = textureDef.extensions || {};
1548
+ textureDef.extensions[ 'EXT_texture_webp' ] = {
1549
+ source: imageIndex
1550
+ };
1551
+
1552
+ this.extensionsUsed[ 'EXT_texture_webp' ] = true;
1553
+ this.extensionsRequired[ 'EXT_texture_webp' ] = true;
1554
+
1555
+ } else {
1556
+
1557
+ textureDef.source = imageIndex;
1558
+
1559
+ }
1560
+
1561
+ if ( map.name ) textureDef.name = map.name;
1562
+
1563
+ await this._invokeAllAsync( async function ( ext ) {
1564
+
1565
+ ext.writeTexture && await ext.writeTexture( map, textureDef );
1566
+
1567
+ } );
1568
+
1569
+ const index = json.textures.push( textureDef ) - 1;
1570
+ cache.textures.set( map, index );
1571
+ return index;
1572
+
1573
+ }
1574
+
1575
+ /**
1576
+ * Process material
1577
+ * @param {THREE.Material} material Material to process
1578
+ * @return {Promise<?number>} Index of the processed material in the "materials" array
1579
+ */
1580
+ async processMaterialAsync( material ) {
1581
+
1582
+ const cache = this.cache;
1583
+ const json = this.json;
1584
+
1585
+ if ( cache.materials.has( material ) ) return cache.materials.get( material );
1586
+
1587
+ if ( material.isShaderMaterial ) {
1588
+
1589
+ console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' );
1590
+ return null;
1591
+
1592
+ }
1593
+
1594
+ if ( ! json.materials ) json.materials = [];
1595
+
1596
+ // @QUESTION Should we avoid including any attribute that has the default value?
1597
+ const materialDef = { pbrMetallicRoughness: {} };
1598
+
1599
+ if ( material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true ) {
1600
+
1601
+ console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' );
1602
+
1603
+ }
1604
+
1605
+ // pbrMetallicRoughness.baseColorFactor
1606
+ const color = material.color.toArray().concat( [ material.opacity ] );
1607
+
1608
+ if ( ! equalArray( color, [ 1, 1, 1, 1 ] ) ) {
1609
+
1610
+ materialDef.pbrMetallicRoughness.baseColorFactor = color;
1611
+
1612
+ }
1613
+
1614
+ if ( material.isMeshStandardMaterial ) {
1615
+
1616
+ materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
1617
+ materialDef.pbrMetallicRoughness.roughnessFactor = material.roughness;
1618
+
1619
+ } else {
1620
+
1621
+ materialDef.pbrMetallicRoughness.metallicFactor = 0;
1622
+ materialDef.pbrMetallicRoughness.roughnessFactor = 1;
1623
+
1624
+ }
1625
+
1626
+ // pbrMetallicRoughness.metallicRoughnessTexture
1627
+ if ( material.metalnessMap || material.roughnessMap ) {
1628
+
1629
+ const metalRoughTexture = await this.buildMetalRoughTextureAsync( material.metalnessMap, material.roughnessMap );
1630
+
1631
+ const metalRoughMapDef = {
1632
+ index: await this.processTextureAsync( metalRoughTexture ),
1633
+ texCoord: metalRoughTexture.channel
1634
+ };
1635
+ this.applyTextureTransform( metalRoughMapDef, metalRoughTexture );
1636
+ materialDef.pbrMetallicRoughness.metallicRoughnessTexture = metalRoughMapDef;
1637
+
1638
+ }
1639
+
1640
+ // pbrMetallicRoughness.baseColorTexture
1641
+ if ( material.map ) {
1642
+
1643
+ const baseColorMapDef = {
1644
+ index: await this.processTextureAsync( material.map ),
1645
+ texCoord: material.map.channel
1646
+ };
1647
+ this.applyTextureTransform( baseColorMapDef, material.map );
1648
+ materialDef.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
1649
+
1650
+ }
1651
+
1652
+ if ( material.emissive ) {
1653
+
1654
+ const emissive = material.emissive;
1655
+ const maxEmissiveComponent = Math.max( emissive.r, emissive.g, emissive.b );
1656
+
1657
+ if ( maxEmissiveComponent > 0 ) {
1658
+
1659
+ materialDef.emissiveFactor = material.emissive.toArray();
1660
+
1661
+ }
1662
+
1663
+ // emissiveTexture
1664
+ if ( material.emissiveMap ) {
1665
+
1666
+ const emissiveMapDef = {
1667
+ index: await this.processTextureAsync( material.emissiveMap ),
1668
+ texCoord: material.emissiveMap.channel
1669
+ };
1670
+ this.applyTextureTransform( emissiveMapDef, material.emissiveMap );
1671
+ materialDef.emissiveTexture = emissiveMapDef;
1672
+
1673
+ }
1674
+
1675
+ }
1676
+
1677
+ // normalTexture
1678
+ if ( material.normalMap ) {
1679
+
1680
+ const normalMapDef = {
1681
+ index: await this.processTextureAsync( material.normalMap ),
1682
+ texCoord: material.normalMap.channel
1683
+ };
1684
+
1685
+ if ( material.normalScale && material.normalScale.x !== 1 ) {
1686
+
1687
+ // glTF normal scale is univariate. Ignore `y`, which may be flipped.
1688
+ // Context: https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
1689
+ normalMapDef.scale = material.normalScale.x;
1690
+
1691
+ }
1692
+
1693
+ this.applyTextureTransform( normalMapDef, material.normalMap );
1694
+ materialDef.normalTexture = normalMapDef;
1695
+
1696
+ }
1697
+
1698
+ // occlusionTexture
1699
+ if ( material.aoMap ) {
1700
+
1701
+ const occlusionMapDef = {
1702
+ index: await this.processTextureAsync( material.aoMap ),
1703
+ texCoord: material.aoMap.channel
1704
+ };
1705
+
1706
+ if ( material.aoMapIntensity !== 1.0 ) {
1707
+
1708
+ occlusionMapDef.strength = material.aoMapIntensity;
1709
+
1710
+ }
1711
+
1712
+ this.applyTextureTransform( occlusionMapDef, material.aoMap );
1713
+ materialDef.occlusionTexture = occlusionMapDef;
1714
+
1715
+ }
1716
+
1717
+ // alphaMode
1718
+ if ( material.transparent ) {
1719
+
1720
+ materialDef.alphaMode = 'BLEND';
1721
+
1722
+ } else {
1723
+
1724
+ if ( material.alphaTest > 0.0 ) {
1725
+
1726
+ materialDef.alphaMode = 'MASK';
1727
+ materialDef.alphaCutoff = material.alphaTest;
1728
+
1729
+ }
1730
+
1731
+ }
1732
+
1733
+ // doubleSided
1734
+ if ( material.side === DoubleSide ) materialDef.doubleSided = true;
1735
+ if ( material.name !== '' ) materialDef.name = material.name;
1736
+
1737
+ this.serializeUserData( material, materialDef );
1738
+
1739
+ await this._invokeAllAsync( async function ( ext ) {
1740
+
1741
+ ext.writeMaterialAsync && await ext.writeMaterialAsync( material, materialDef );
1742
+
1743
+ } );
1744
+
1745
+ const index = json.materials.push( materialDef ) - 1;
1746
+ cache.materials.set( material, index );
1747
+ return index;
1748
+
1749
+ }
1750
+
1751
+ /**
1752
+ * Process mesh
1753
+ * @param {THREE.Mesh} mesh Mesh to process
1754
+ * @return {Promise<?number>} Index of the processed mesh in the "meshes" array
1755
+ */
1756
+ async processMeshAsync( mesh ) {
1757
+
1758
+ const cache = this.cache;
1759
+ const json = this.json;
1760
+
1761
+ const meshCacheKeyParts = [ mesh.geometry.uuid ];
1762
+
1763
+ if ( Array.isArray( mesh.material ) ) {
1764
+
1765
+ for ( let i = 0, l = mesh.material.length; i < l; i ++ ) {
1766
+
1767
+ meshCacheKeyParts.push( mesh.material[ i ].uuid );
1768
+
1769
+ }
1770
+
1771
+ } else {
1772
+
1773
+ meshCacheKeyParts.push( mesh.material.uuid );
1774
+
1775
+ }
1776
+
1777
+ const meshCacheKey = meshCacheKeyParts.join( ':' );
1778
+
1779
+ if ( cache.meshes.has( meshCacheKey ) ) return cache.meshes.get( meshCacheKey );
1780
+
1781
+ const geometry = mesh.geometry;
1782
+
1783
+ let mode;
1784
+
1785
+ // Use the correct mode
1786
+ if ( mesh.isLineSegments ) {
1787
+
1788
+ mode = WEBGL_CONSTANTS.LINES;
1789
+
1790
+ } else if ( mesh.isLineLoop ) {
1791
+
1792
+ mode = WEBGL_CONSTANTS.LINE_LOOP;
1793
+
1794
+ } else if ( mesh.isLine ) {
1795
+
1796
+ mode = WEBGL_CONSTANTS.LINE_STRIP;
1797
+
1798
+ } else if ( mesh.isPoints ) {
1799
+
1800
+ mode = WEBGL_CONSTANTS.POINTS;
1801
+
1802
+ } else {
1803
+
1804
+ mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
1805
+
1806
+ }
1807
+
1808
+ const meshDef = {};
1809
+ const attributes = {};
1810
+ const primitives = [];
1811
+ const targets = [];
1812
+
1813
+ // Conversion between attributes names in threejs and gltf spec
1814
+ const nameConversion = {
1815
+ uv: 'TEXCOORD_0',
1816
+ uv1: 'TEXCOORD_1',
1817
+ uv2: 'TEXCOORD_2',
1818
+ uv3: 'TEXCOORD_3',
1819
+ color: 'COLOR_0',
1820
+ skinWeight: 'WEIGHTS_0',
1821
+ skinIndex: 'JOINTS_0'
1822
+ };
1823
+
1824
+ const originalNormal = geometry.getAttribute( 'normal' );
1825
+
1826
+ if ( originalNormal !== undefined && ! this.isNormalizedNormalAttribute( originalNormal ) ) {
1827
+
1828
+ console.warn( 'THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.' );
1829
+
1830
+ geometry.setAttribute( 'normal', this.createNormalizedNormalAttribute( originalNormal ) );
1831
+
1832
+ }
1833
+
1834
+ // @QUESTION Detect if .vertexColors = true?
1835
+ // For every attribute create an accessor
1836
+ let modifiedAttribute = null;
1837
+
1838
+ for ( let attributeName in geometry.attributes ) {
1839
+
1840
+ // Ignore morph target attributes, which are exported later.
1841
+ if ( attributeName.slice( 0, 5 ) === 'morph' ) continue;
1842
+
1843
+ const attribute = geometry.attributes[ attributeName ];
1844
+ attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
1845
+
1846
+ // Prefix all geometry attributes except the ones specifically
1847
+ // listed in the spec; non-spec attributes are considered custom.
1848
+ const validVertexAttributes =
1849
+ /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;
1850
+
1851
+ if ( ! validVertexAttributes.test( attributeName ) && ! attributeName.startsWith( '_' ) ) attributeName = '_' + attributeName;
1852
+
1853
+ if ( cache.attributes.has( this.getUID( attribute ) ) ) {
1854
+
1855
+ attributes[ attributeName ] = cache.attributes.get( this.getUID( attribute ) );
1856
+ continue;
1857
+
1858
+ }
1859
+
1860
+ // Enforce glTF vertex attribute requirements:
1861
+ // - JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT
1862
+ // - Only custom attributes may be INT or UNSIGNED_INT
1863
+ modifiedAttribute = null;
1864
+ const array = attribute.array;
1865
+
1866
+ if ( attributeName === 'JOINTS_0' &&
1867
+ ! ( array instanceof Uint16Array ) &&
1868
+ ! ( array instanceof Uint8Array ) ) {
1869
+
1870
+ console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
1871
+ modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Uint16Array );
1872
+
1873
+ } else if ( ( array instanceof Uint32Array || array instanceof Int32Array ) && ! attributeName.startsWith( '_' ) ) {
1874
+
1875
+ console.warn( `GLTFExporter: Attribute "${ attributeName }" converted to type FLOAT.` );
1876
+ modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Float32Array );
1877
+
1878
+ }
1879
+
1880
+ const accessor = this.processAccessor( modifiedAttribute || attribute, geometry );
1881
+
1882
+ if ( accessor !== null ) {
1883
+
1884
+ if ( ! attributeName.startsWith( '_' ) ) {
1885
+
1886
+ this.detectMeshQuantization( attributeName, attribute );
1887
+
1888
+ }
1889
+
1890
+ attributes[ attributeName ] = accessor;
1891
+ cache.attributes.set( this.getUID( attribute ), accessor );
1892
+
1893
+ }
1894
+
1895
+ }
1896
+
1897
+ if ( originalNormal !== undefined ) geometry.setAttribute( 'normal', originalNormal );
1898
+
1899
+ // Skip if no exportable attributes found
1900
+ if ( Object.keys( attributes ).length === 0 ) return null;
1901
+
1902
+ // Morph targets
1903
+ if ( mesh.morphTargetInfluences !== undefined && mesh.morphTargetInfluences.length > 0 ) {
1904
+
1905
+ const weights = [];
1906
+ const targetNames = [];
1907
+ const reverseDictionary = {};
1908
+
1909
+ if ( mesh.morphTargetDictionary !== undefined ) {
1910
+
1911
+ for ( const key in mesh.morphTargetDictionary ) {
1912
+
1913
+ reverseDictionary[ mesh.morphTargetDictionary[ key ] ] = key;
1914
+
1915
+ }
1916
+
1917
+ }
1918
+
1919
+ for ( let i = 0; i < mesh.morphTargetInfluences.length; ++ i ) {
1920
+
1921
+ const target = {};
1922
+ let warned = false;
1923
+
1924
+ for ( const attributeName in geometry.morphAttributes ) {
1925
+
1926
+ // glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
1927
+ // Three.js doesn't support TANGENT yet.
1928
+
1929
+ if ( attributeName !== 'position' && attributeName !== 'normal' ) {
1930
+
1931
+ if ( ! warned ) {
1932
+
1933
+ console.warn( 'GLTFExporter: Only POSITION and NORMAL morph are supported.' );
1934
+ warned = true;
1935
+
1936
+ }
1937
+
1938
+ continue;
1939
+
1940
+ }
1941
+
1942
+ const attribute = geometry.morphAttributes[ attributeName ][ i ];
1943
+ const gltfAttributeName = attributeName.toUpperCase();
1944
+
1945
+ // Three.js morph attribute has absolute values while the one of glTF has relative values.
1946
+ //
1947
+ // glTF 2.0 Specification:
1948
+ // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets
1949
+
1950
+ const baseAttribute = geometry.attributes[ attributeName ];
1951
+
1952
+ if ( cache.attributes.has( this.getUID( attribute, true ) ) ) {
1953
+
1954
+ target[ gltfAttributeName ] = cache.attributes.get( this.getUID( attribute, true ) );
1955
+ continue;
1956
+
1957
+ }
1958
+
1959
+ // Clones attribute not to override
1960
+ const relativeAttribute = attribute.clone();
1961
+
1962
+ if ( ! geometry.morphTargetsRelative ) {
1963
+
1964
+ for ( let j = 0, jl = attribute.count; j < jl; j ++ ) {
1965
+
1966
+ for ( let a = 0; a < attribute.itemSize; a ++ ) {
1967
+
1968
+ if ( a === 0 ) relativeAttribute.setX( j, attribute.getX( j ) - baseAttribute.getX( j ) );
1969
+ if ( a === 1 ) relativeAttribute.setY( j, attribute.getY( j ) - baseAttribute.getY( j ) );
1970
+ if ( a === 2 ) relativeAttribute.setZ( j, attribute.getZ( j ) - baseAttribute.getZ( j ) );
1971
+ if ( a === 3 ) relativeAttribute.setW( j, attribute.getW( j ) - baseAttribute.getW( j ) );
1972
+
1973
+ }
1974
+
1975
+ }
1976
+
1977
+ }
1978
+
1979
+ target[ gltfAttributeName ] = this.processAccessor( relativeAttribute, geometry );
1980
+ cache.attributes.set( this.getUID( baseAttribute, true ), target[ gltfAttributeName ] );
1981
+
1982
+ }
1983
+
1984
+ targets.push( target );
1985
+
1986
+ weights.push( mesh.morphTargetInfluences[ i ] );
1987
+
1988
+ if ( mesh.morphTargetDictionary !== undefined ) targetNames.push( reverseDictionary[ i ] );
1989
+
1990
+ }
1991
+
1992
+ meshDef.weights = weights;
1993
+
1994
+ if ( targetNames.length > 0 ) {
1995
+
1996
+ meshDef.extras = {};
1997
+ meshDef.extras.targetNames = targetNames;
1998
+
1999
+ }
2000
+
2001
+ }
2002
+
2003
+ const isMultiMaterial = Array.isArray( mesh.material );
2004
+
2005
+ if ( isMultiMaterial && geometry.groups.length === 0 ) return null;
2006
+
2007
+ let didForceIndices = false;
2008
+
2009
+ if ( isMultiMaterial && geometry.index === null ) {
2010
+
2011
+ const indices = [];
2012
+
2013
+ for ( let i = 0, il = geometry.attributes.position.count; i < il; i ++ ) {
2014
+
2015
+ indices[ i ] = i;
2016
+
2017
+ }
2018
+
2019
+ geometry.setIndex( indices );
2020
+
2021
+ didForceIndices = true;
2022
+
2023
+ }
2024
+
2025
+ const materials = isMultiMaterial ? mesh.material : [ mesh.material ];
2026
+ const groups = isMultiMaterial ? geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ];
2027
+
2028
+ for ( let i = 0, il = groups.length; i < il; i ++ ) {
2029
+
2030
+ const primitive = {
2031
+ mode: mode,
2032
+ attributes: attributes,
2033
+ };
2034
+
2035
+ this.serializeUserData( geometry, primitive );
2036
+
2037
+ if ( targets.length > 0 ) primitive.targets = targets;
2038
+
2039
+ if ( geometry.index !== null ) {
2040
+
2041
+ let cacheKey = this.getUID( geometry.index );
2042
+
2043
+ if ( groups[ i ].start !== undefined || groups[ i ].count !== undefined ) {
2044
+
2045
+ cacheKey += ':' + groups[ i ].start + ':' + groups[ i ].count;
2046
+
2047
+ }
2048
+
2049
+ if ( cache.attributes.has( cacheKey ) ) {
2050
+
2051
+ primitive.indices = cache.attributes.get( cacheKey );
2052
+
2053
+ } else {
2054
+
2055
+ primitive.indices = this.processAccessor( geometry.index, geometry, groups[ i ].start, groups[ i ].count );
2056
+ cache.attributes.set( cacheKey, primitive.indices );
2057
+
2058
+ }
2059
+
2060
+ if ( primitive.indices === null ) delete primitive.indices;
2061
+
2062
+ }
2063
+
2064
+ const material = await this.processMaterialAsync( materials[ groups[ i ].materialIndex ] );
2065
+
2066
+ if ( material !== null ) primitive.material = material;
2067
+
2068
+ primitives.push( primitive );
2069
+
2070
+ }
2071
+
2072
+ if ( didForceIndices === true ) {
2073
+
2074
+ geometry.setIndex( null );
2075
+
2076
+ }
2077
+
2078
+ meshDef.primitives = primitives;
2079
+
2080
+ if ( ! json.meshes ) json.meshes = [];
2081
+
2082
+ await this._invokeAllAsync( function ( ext ) {
2083
+
2084
+ ext.writeMesh && ext.writeMesh( mesh, meshDef );
2085
+
2086
+ } );
2087
+
2088
+ const index = json.meshes.push( meshDef ) - 1;
2089
+ cache.meshes.set( meshCacheKey, index );
2090
+ return index;
2091
+
2092
+ }
2093
+
2094
+ /**
2095
+ * If a vertex attribute with a
2096
+ * [non-standard data type](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview)
2097
+ * is used, it is checked whether it is a valid data type according to the
2098
+ * [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md)
2099
+ * extension.
2100
+ * In this case the extension is automatically added to the list of used extensions.
2101
+ *
2102
+ * @param {string} attributeName
2103
+ * @param {THREE.BufferAttribute} attribute
2104
+ */
2105
+ detectMeshQuantization( attributeName, attribute ) {
2106
+
2107
+ if ( this.extensionsUsed[ KHR_MESH_QUANTIZATION ] ) return;
2108
+
2109
+ let attrType = undefined;
2110
+
2111
+ switch ( attribute.array.constructor ) {
2112
+
2113
+ case Int8Array:
2114
+
2115
+ attrType = 'byte';
2116
+
2117
+ break;
2118
+
2119
+ case Uint8Array:
2120
+
2121
+ attrType = 'unsigned byte';
2122
+
2123
+ break;
2124
+
2125
+ case Int16Array:
2126
+
2127
+ attrType = 'short';
2128
+
2129
+ break;
2130
+
2131
+ case Uint16Array:
2132
+
2133
+ attrType = 'unsigned short';
2134
+
2135
+ break;
2136
+
2137
+ default:
2138
+
2139
+ return;
2140
+
2141
+ }
2142
+
2143
+ if ( attribute.normalized ) attrType += ' normalized';
2144
+
2145
+ const attrNamePrefix = attributeName.split( '_', 1 )[ 0 ];
2146
+
2147
+ if ( KHR_mesh_quantization_ExtraAttrTypes[ attrNamePrefix ] && KHR_mesh_quantization_ExtraAttrTypes[ attrNamePrefix ].includes( attrType ) ) {
2148
+
2149
+ this.extensionsUsed[ KHR_MESH_QUANTIZATION ] = true;
2150
+ this.extensionsRequired[ KHR_MESH_QUANTIZATION ] = true;
2151
+
2152
+ }
2153
+
2154
+ }
2155
+
2156
+ /**
2157
+ * Process camera
2158
+ * @param {THREE.Camera} camera Camera to process
2159
+ * @return {number} Index of the processed mesh in the "camera" array
2160
+ */
2161
+ processCamera( camera ) {
2162
+
2163
+ const json = this.json;
2164
+
2165
+ if ( ! json.cameras ) json.cameras = [];
2166
+
2167
+ const isOrtho = camera.isOrthographicCamera;
2168
+
2169
+ const cameraDef = {
2170
+ type: isOrtho ? 'orthographic' : 'perspective'
2171
+ };
2172
+
2173
+ if ( isOrtho ) {
2174
+
2175
+ cameraDef.orthographic = {
2176
+ xmag: camera.right * 2,
2177
+ ymag: camera.top * 2,
2178
+ zfar: camera.far <= 0 ? 0.001 : camera.far,
2179
+ znear: camera.near < 0 ? 0 : camera.near
2180
+ };
2181
+
2182
+ } else {
2183
+
2184
+ cameraDef.perspective = {
2185
+ aspectRatio: camera.aspect,
2186
+ yfov: MathUtils.degToRad( camera.fov ),
2187
+ zfar: camera.far <= 0 ? 0.001 : camera.far,
2188
+ znear: camera.near < 0 ? 0 : camera.near
2189
+ };
2190
+
2191
+ }
2192
+
2193
+ // Question: Is saving "type" as name intentional?
2194
+ if ( camera.name !== '' ) cameraDef.name = camera.type;
2195
+
2196
+ return json.cameras.push( cameraDef ) - 1;
2197
+
2198
+ }
2199
+
2200
+ /**
2201
+ * Creates glTF animation entry from AnimationClip object.
2202
+ *
2203
+ * Status:
2204
+ * - Only properties listed in PATH_PROPERTIES may be animated.
2205
+ *
2206
+ * @param {THREE.AnimationClip} clip
2207
+ * @param {THREE.Object3D} root
2208
+ * @return {?number}
2209
+ */
2210
+ processAnimation( clip, root ) {
2211
+
2212
+ const json = this.json;
2213
+ const nodeMap = this.nodeMap;
2214
+
2215
+ if ( ! json.animations ) json.animations = [];
2216
+
2217
+ clip = GLTFExporter.Utils.mergeMorphTargetTracks( clip.clone(), root );
2218
+
2219
+ const tracks = clip.tracks;
2220
+ const channels = [];
2221
+ const samplers = [];
2222
+
2223
+ for ( let i = 0; i < tracks.length; ++ i ) {
2224
+
2225
+ const track = tracks[ i ];
2226
+ const trackBinding = PropertyBinding.parseTrackName( track.name );
2227
+ let trackNode = PropertyBinding.findNode( root, trackBinding.nodeName );
2228
+ const trackProperty = PATH_PROPERTIES[ trackBinding.propertyName ];
2229
+
2230
+ if ( trackBinding.objectName === 'bones' ) {
2231
+
2232
+ if ( trackNode.isSkinnedMesh === true ) {
2233
+
2234
+ trackNode = trackNode.skeleton.getBoneByName( trackBinding.objectIndex );
2235
+
2236
+ } else {
2237
+
2238
+ trackNode = undefined;
2239
+
2240
+ }
2241
+
2242
+ }
2243
+
2244
+ if ( ! trackNode || ! trackProperty ) {
2245
+
2246
+ console.warn( 'THREE.GLTFExporter: Could not export animation track "%s".', track.name );
2247
+ continue;
2248
+
2249
+ }
2250
+
2251
+ const inputItemSize = 1;
2252
+ let outputItemSize = track.values.length / track.times.length;
2253
+
2254
+ if ( trackProperty === PATH_PROPERTIES.morphTargetInfluences ) {
2255
+
2256
+ outputItemSize /= trackNode.morphTargetInfluences.length;
2257
+
2258
+ }
2259
+
2260
+ let interpolation;
2261
+
2262
+ // @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
2263
+
2264
+ // Detecting glTF cubic spline interpolant by checking factory method's special property
2265
+ // GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
2266
+ // valid value from .getInterpolation().
2267
+ if ( track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true ) {
2268
+
2269
+ interpolation = 'CUBICSPLINE';
2270
+
2271
+ // itemSize of CUBICSPLINE keyframe is 9
2272
+ // (VEC3 * 3: inTangent, splineVertex, and outTangent)
2273
+ // but needs to be stored as VEC3 so dividing by 3 here.
2274
+ outputItemSize /= 3;
2275
+
2276
+ } else if ( track.getInterpolation() === InterpolateDiscrete ) {
2277
+
2278
+ interpolation = 'STEP';
2279
+
2280
+ } else {
2281
+
2282
+ interpolation = 'LINEAR';
2283
+
2284
+ }
2285
+
2286
+ samplers.push( {
2287
+ input: this.processAccessor( new BufferAttribute( track.times, inputItemSize ) ),
2288
+ output: this.processAccessor( new BufferAttribute( track.values, outputItemSize ) ),
2289
+ interpolation: interpolation
2290
+ } );
2291
+
2292
+ channels.push( {
2293
+ sampler: samplers.length - 1,
2294
+ target: {
2295
+ node: nodeMap.get( trackNode ),
2296
+ path: trackProperty
2297
+ }
2298
+ } );
2299
+
2300
+ }
2301
+
2302
+ const animationDef = {
2303
+ name: clip.name || 'clip_' + json.animations.length,
2304
+ samplers: samplers,
2305
+ channels: channels
2306
+ };
2307
+
2308
+ this.serializeUserData( clip, animationDef );
2309
+
2310
+ json.animations.push( animationDef );
2311
+
2312
+ return json.animations.length - 1;
2313
+
2314
+ }
2315
+
2316
+ /**
2317
+ * @param {THREE.Object3D} object
2318
+ * @return {?number}
2319
+ */
2320
+ processSkin( object ) {
2321
+
2322
+ const json = this.json;
2323
+ const nodeMap = this.nodeMap;
2324
+
2325
+ const node = json.nodes[ nodeMap.get( object ) ];
2326
+
2327
+ const skeleton = object.skeleton;
2328
+
2329
+ if ( skeleton === undefined ) return null;
2330
+
2331
+ const rootJoint = object.skeleton.bones[ 0 ];
2332
+
2333
+ if ( rootJoint === undefined ) return null;
2334
+
2335
+ const joints = [];
2336
+ const inverseBindMatrices = new Float32Array( skeleton.bones.length * 16 );
2337
+ const temporaryBoneInverse = new Matrix4();
2338
+
2339
+ for ( let i = 0; i < skeleton.bones.length; ++ i ) {
2340
+
2341
+ joints.push( nodeMap.get( skeleton.bones[ i ] ) );
2342
+ temporaryBoneInverse.copy( skeleton.boneInverses[ i ] );
2343
+ temporaryBoneInverse.multiply( object.bindMatrix ).toArray( inverseBindMatrices, i * 16 );
2344
+
2345
+ }
2346
+
2347
+ if ( json.skins === undefined ) json.skins = [];
2348
+
2349
+ json.skins.push( {
2350
+ inverseBindMatrices: this.processAccessor( new BufferAttribute( inverseBindMatrices, 16 ) ),
2351
+ joints: joints,
2352
+ skeleton: nodeMap.get( rootJoint )
2353
+ } );
2354
+
2355
+ const skinIndex = node.skin = json.skins.length - 1;
2356
+
2357
+ return skinIndex;
2358
+
2359
+ }
2360
+
2361
+ /**
2362
+ * Process Object3D node
2363
+ * @param {THREE.Object3D} object Object3D to processNodeAsync
2364
+ * @return {Promise<number>} Index of the node in the nodes list
2365
+ */
2366
+ async processNodeAsync( object ) {
2367
+
2368
+ const json = this.json;
2369
+ const options = this.options;
2370
+ const nodeMap = this.nodeMap;
2371
+
2372
+ if ( ! json.nodes ) json.nodes = [];
2373
+
2374
+ // Handle pivot by creating a container node
2375
+ if ( object.pivot !== null ) {
2376
+
2377
+ return await this._processNodeWithPivotAsync( object );
2378
+
2379
+ }
2380
+
2381
+ const nodeDef = {};
2382
+
2383
+ if ( options.trs ) {
2384
+
2385
+ const rotation = object.quaternion.toArray();
2386
+ const position = object.position.toArray();
2387
+ const scale = object.scale.toArray();
2388
+
2389
+ if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) {
2390
+
2391
+ nodeDef.rotation = rotation;
2392
+
2393
+ }
2394
+
2395
+ if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
2396
+
2397
+ nodeDef.translation = position;
2398
+
2399
+ }
2400
+
2401
+ if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) {
2402
+
2403
+ nodeDef.scale = scale;
2404
+
2405
+ }
2406
+
2407
+ } else {
2408
+
2409
+ if ( object.matrixAutoUpdate ) {
2410
+
2411
+ object.updateMatrix();
2412
+
2413
+ }
2414
+
2415
+ if ( isIdentityMatrix( object.matrix ) === false ) {
2416
+
2417
+ nodeDef.matrix = object.matrix.elements;
2418
+
2419
+ }
2420
+
2421
+ }
2422
+
2423
+ // We don't export empty strings name because it represents no-name in Three.js.
2424
+ if ( object.name !== '' ) nodeDef.name = String( object.name );
2425
+
2426
+ this.serializeUserData( object, nodeDef );
2427
+
2428
+ if ( object.isMesh || object.isLine || object.isPoints ) {
2429
+
2430
+ const meshIndex = await this.processMeshAsync( object );
2431
+
2432
+ if ( meshIndex !== null ) nodeDef.mesh = meshIndex;
2433
+
2434
+ } else if ( object.isCamera ) {
2435
+
2436
+ nodeDef.camera = this.processCamera( object );
2437
+
2438
+ }
2439
+
2440
+ if ( object.isSkinnedMesh ) this.skins.push( object );
2441
+
2442
+ const nodeIndex = json.nodes.push( nodeDef ) - 1;
2443
+ nodeMap.set( object, nodeIndex );
2444
+
2445
+ if ( object.children.length > 0 ) {
2446
+
2447
+ const children = [];
2448
+
2449
+ for ( let i = 0, l = object.children.length; i < l; i ++ ) {
2450
+
2451
+ const child = object.children[ i ];
2452
+
2453
+ if ( child.visible || options.onlyVisible === false ) {
2454
+
2455
+ const childNodeIndex = await this.processNodeAsync( child );
2456
+
2457
+ if ( childNodeIndex !== null ) children.push( childNodeIndex );
2458
+
2459
+ }
2460
+
2461
+ }
2462
+
2463
+ if ( children.length > 0 ) nodeDef.children = children;
2464
+
2465
+ }
2466
+
2467
+ await this._invokeAllAsync( function ( ext ) {
2468
+
2469
+ ext.writeNode && ext.writeNode( object, nodeDef );
2470
+
2471
+ } );
2472
+
2473
+ return nodeIndex;
2474
+
2475
+ }
2476
+
2477
+ /**
2478
+ * Process Object3D node with pivot using container approach
2479
+ * @param {THREE.Object3D} object Object3D with pivot
2480
+ * @return {Promise<number>} Index of the container node
2481
+ */
2482
+ async _processNodeWithPivotAsync( object ) {
2483
+
2484
+ const json = this.json;
2485
+ const options = this.options;
2486
+ const nodeMap = this.nodeMap;
2487
+
2488
+ const pivot = object.pivot;
2489
+
2490
+ // Container node: holds position + pivot offset, rotation, scale
2491
+ // Animations will target this node
2492
+ const containerDef = {};
2493
+
2494
+ const rotation = object.quaternion.toArray();
2495
+ const position = [
2496
+ object.position.x + pivot.x,
2497
+ object.position.y + pivot.y,
2498
+ object.position.z + pivot.z
2499
+ ];
2500
+ const scale = object.scale.toArray();
2501
+
2502
+ if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) {
2503
+
2504
+ containerDef.rotation = rotation;
2505
+
2506
+ }
2507
+
2508
+ if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
2509
+
2510
+ containerDef.translation = position;
2511
+
2512
+ }
2513
+
2514
+ if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) {
2515
+
2516
+ containerDef.scale = scale;
2517
+
2518
+ }
2519
+
2520
+ // Store pivot in extras for round-trip reconstruction
2521
+ containerDef.extras = { pivot: pivot.toArray() };
2522
+
2523
+ if ( object.name !== '' ) containerDef.name = String( object.name );
2524
+
2525
+ this.serializeUserData( object, containerDef );
2526
+
2527
+ const containerIndex = json.nodes.push( containerDef ) - 1;
2528
+
2529
+ // Map original object to container so animations target it
2530
+ nodeMap.set( object, containerIndex );
2531
+
2532
+ // Child node: holds mesh with -pivot offset
2533
+ const childDef = {};
2534
+
2535
+ const childPosition = [ - pivot.x, - pivot.y, - pivot.z ];
2536
+
2537
+ if ( ! equalArray( childPosition, [ 0, 0, 0 ] ) ) {
2538
+
2539
+ childDef.translation = childPosition;
2540
+
2541
+ }
2542
+
2543
+ if ( object.isMesh || object.isLine || object.isPoints ) {
2544
+
2545
+ const meshIndex = await this.processMeshAsync( object );
2546
+
2547
+ if ( meshIndex !== null ) childDef.mesh = meshIndex;
2548
+
2549
+ } else if ( object.isCamera ) {
2550
+
2551
+ childDef.camera = this.processCamera( object );
2552
+
2553
+ }
2554
+
2555
+ if ( object.isSkinnedMesh ) this.skins.push( object );
2556
+
2557
+ const childIndex = json.nodes.push( childDef ) - 1;
2558
+
2559
+ // Build children array for container
2560
+ const containerChildren = [ childIndex ];
2561
+
2562
+ // Process object's children as children of the child node
2563
+ if ( object.children.length > 0 ) {
2564
+
2565
+ const grandchildren = [];
2566
+
2567
+ for ( let i = 0, l = object.children.length; i < l; i ++ ) {
2568
+
2569
+ const child = object.children[ i ];
2570
+
2571
+ if ( child.visible || options.onlyVisible === false ) {
2572
+
2573
+ const childNodeIndex = await this.processNodeAsync( child );
2574
+
2575
+ if ( childNodeIndex !== null ) grandchildren.push( childNodeIndex );
2576
+
2577
+ }
2578
+
2579
+ }
2580
+
2581
+ if ( grandchildren.length > 0 ) childDef.children = grandchildren;
2582
+
2583
+ }
2584
+
2585
+ containerDef.children = containerChildren;
2586
+
2587
+ await this._invokeAllAsync( function ( ext ) {
2588
+
2589
+ ext.writeNode && ext.writeNode( object, containerDef );
2590
+
2591
+ } );
2592
+
2593
+ return containerIndex;
2594
+
2595
+ }
2596
+
2597
+ /**
2598
+ * Process Scene
2599
+ * @param {Scene} scene Scene to process
2600
+ */
2601
+ async processSceneAsync( scene ) {
2602
+
2603
+ const json = this.json;
2604
+ const options = this.options;
2605
+
2606
+ if ( ! json.scenes ) {
2607
+
2608
+ json.scenes = [];
2609
+ json.scene = 0;
2610
+
2611
+ }
2612
+
2613
+ const sceneDef = {};
2614
+
2615
+ if ( scene.name !== '' ) sceneDef.name = scene.name;
2616
+
2617
+ json.scenes.push( sceneDef );
2618
+
2619
+ const nodes = [];
2620
+
2621
+ for ( let i = 0, l = scene.children.length; i < l; i ++ ) {
2622
+
2623
+ const child = scene.children[ i ];
2624
+
2625
+ if ( child.visible || options.onlyVisible === false ) {
2626
+
2627
+ const nodeIndex = await this.processNodeAsync( child );
2628
+
2629
+ if ( nodeIndex !== null ) nodes.push( nodeIndex );
2630
+
2631
+ }
2632
+
2633
+ }
2634
+
2635
+ if ( nodes.length > 0 ) sceneDef.nodes = nodes;
2636
+
2637
+ this.serializeUserData( scene, sceneDef );
2638
+
2639
+ }
2640
+
2641
+ /**
2642
+ * Creates a Scene to hold a list of objects and parse it
2643
+ * @param {Array<THREE.Object3D>} objects List of objects to process
2644
+ */
2645
+ async processObjectsAsync( objects ) {
2646
+
2647
+ const scene = new Scene();
2648
+ scene.name = 'AuxScene';
2649
+
2650
+ for ( let i = 0; i < objects.length; i ++ ) {
2651
+
2652
+ // We push directly to children instead of calling `add` to prevent
2653
+ // modify the .parent and break its original scene and hierarchy
2654
+ scene.children.push( objects[ i ] );
2655
+
2656
+ }
2657
+
2658
+ await this.processSceneAsync( scene );
2659
+
2660
+ }
2661
+
2662
+ /**
2663
+ * @param {THREE.Object3D|Array<THREE.Object3D>} input
2664
+ */
2665
+ async processInputAsync( input ) {
2666
+
2667
+ const options = this.options;
2668
+
2669
+ input = input instanceof Array ? input : [ input ];
2670
+
2671
+ await this._invokeAllAsync( function ( ext ) {
2672
+
2673
+ ext.beforeParse && ext.beforeParse( input );
2674
+
2675
+ } );
2676
+
2677
+ const objectsWithoutScene = [];
2678
+
2679
+ for ( let i = 0; i < input.length; i ++ ) {
2680
+
2681
+ if ( input[ i ] instanceof Scene ) {
2682
+
2683
+ await this.processSceneAsync( input[ i ] );
2684
+
2685
+ } else {
2686
+
2687
+ objectsWithoutScene.push( input[ i ] );
2688
+
2689
+ }
2690
+
2691
+ }
2692
+
2693
+ if ( objectsWithoutScene.length > 0 ) {
2694
+
2695
+ await this.processObjectsAsync( objectsWithoutScene );
2696
+
2697
+ }
2698
+
2699
+ for ( let i = 0; i < this.skins.length; ++ i ) {
2700
+
2701
+ this.processSkin( this.skins[ i ] );
2702
+
2703
+ }
2704
+
2705
+ for ( let i = 0; i < options.animations.length; ++ i ) {
2706
+
2707
+ this.processAnimation( options.animations[ i ], input[ 0 ] );
2708
+
2709
+ }
2710
+
2711
+ await this._invokeAllAsync( function ( ext ) {
2712
+
2713
+ ext.afterParse && ext.afterParse( input );
2714
+
2715
+ } );
2716
+
2717
+ }
2718
+
2719
+ async _invokeAllAsync( func ) {
2720
+
2721
+ for ( let i = 0, il = this.plugins.length; i < il; i ++ ) {
2722
+
2723
+ await func( this.plugins[ i ] );
2724
+
2725
+ }
2726
+
2727
+ }
2728
+
2729
+ }
2730
+
2731
+ /**
2732
+ * Punctual Lights Extension
2733
+ *
2734
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
2735
+ *
2736
+ * @private
2737
+ */
2738
+ class GLTFLightExtension {
2739
+
2740
+ constructor( writer ) {
2741
+
2742
+ this.writer = writer;
2743
+ this.name = 'KHR_lights_punctual';
2744
+
2745
+ }
2746
+
2747
+ writeNode( light, nodeDef ) {
2748
+
2749
+ if ( ! light.isLight ) return;
2750
+
2751
+ if ( ! light.isDirectionalLight && ! light.isPointLight && ! light.isSpotLight ) {
2752
+
2753
+ console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.', light );
2754
+ return;
2755
+
2756
+ }
2757
+
2758
+ const writer = this.writer;
2759
+ const json = writer.json;
2760
+ const extensionsUsed = writer.extensionsUsed;
2761
+
2762
+ const lightDef = {};
2763
+
2764
+ if ( light.name ) lightDef.name = light.name;
2765
+
2766
+ lightDef.color = light.color.toArray();
2767
+
2768
+ lightDef.intensity = light.intensity;
2769
+
2770
+ if ( light.isDirectionalLight ) {
2771
+
2772
+ lightDef.type = 'directional';
2773
+
2774
+ } else if ( light.isPointLight ) {
2775
+
2776
+ lightDef.type = 'point';
2777
+
2778
+ if ( light.distance > 0 ) lightDef.range = light.distance;
2779
+
2780
+ } else if ( light.isSpotLight ) {
2781
+
2782
+ lightDef.type = 'spot';
2783
+
2784
+ if ( light.distance > 0 ) lightDef.range = light.distance;
2785
+
2786
+ lightDef.spot = {};
2787
+ lightDef.spot.innerConeAngle = ( 1.0 - light.penumbra ) * light.angle;
2788
+ lightDef.spot.outerConeAngle = light.angle;
2789
+
2790
+ }
2791
+
2792
+ if ( light.decay !== undefined && light.decay !== 2 ) {
2793
+
2794
+ console.warn( 'THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, '
2795
+ + 'and expects light.decay=2.' );
2796
+
2797
+ }
2798
+
2799
+ if ( light.target
2800
+ && ( light.target.parent !== light
2801
+ || light.target.position.x !== 0
2802
+ || light.target.position.y !== 0
2803
+ || light.target.position.z !== - 1 ) ) {
2804
+
2805
+ console.warn( 'THREE.GLTFExporter: Light direction may be lost. For best results, '
2806
+ + 'make light.target a child of the light with position 0,0,-1.' );
2807
+
2808
+ }
2809
+
2810
+ if ( ! extensionsUsed[ this.name ] ) {
2811
+
2812
+ json.extensions = json.extensions || {};
2813
+ json.extensions[ this.name ] = { lights: [] };
2814
+ extensionsUsed[ this.name ] = true;
2815
+
2816
+ }
2817
+
2818
+ const lights = json.extensions[ this.name ].lights;
2819
+ lights.push( lightDef );
2820
+
2821
+ nodeDef.extensions = nodeDef.extensions || {};
2822
+ nodeDef.extensions[ this.name ] = { light: lights.length - 1 };
2823
+
2824
+ }
2825
+
2826
+ }
2827
+
2828
+ /**
2829
+ * Unlit Materials Extension
2830
+ *
2831
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
2832
+ *
2833
+ * @private
2834
+ */
2835
+ class GLTFMaterialsUnlitExtension {
2836
+
2837
+ constructor( writer ) {
2838
+
2839
+ this.writer = writer;
2840
+ this.name = 'KHR_materials_unlit';
2841
+
2842
+ }
2843
+
2844
+ async writeMaterialAsync( material, materialDef ) {
2845
+
2846
+ if ( ! material.isMeshBasicMaterial ) return;
2847
+
2848
+ const writer = this.writer;
2849
+ const extensionsUsed = writer.extensionsUsed;
2850
+
2851
+ materialDef.extensions = materialDef.extensions || {};
2852
+ materialDef.extensions[ this.name ] = {};
2853
+
2854
+ extensionsUsed[ this.name ] = true;
2855
+
2856
+ materialDef.pbrMetallicRoughness.metallicFactor = 0.0;
2857
+ materialDef.pbrMetallicRoughness.roughnessFactor = 0.9;
2858
+
2859
+ }
2860
+
2861
+ }
2862
+
2863
+ /**
2864
+ * Clearcoat Materials Extension
2865
+ *
2866
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
2867
+ *
2868
+ * @private
2869
+ */
2870
+ class GLTFMaterialsClearcoatExtension {
2871
+
2872
+ constructor( writer ) {
2873
+
2874
+ this.writer = writer;
2875
+ this.name = 'KHR_materials_clearcoat';
2876
+
2877
+ }
2878
+
2879
+ async writeMaterialAsync( material, materialDef ) {
2880
+
2881
+ if ( ! material.isMeshPhysicalMaterial || material.clearcoat === 0 ) return;
2882
+
2883
+ const writer = this.writer;
2884
+ const extensionsUsed = writer.extensionsUsed;
2885
+
2886
+ const extensionDef = {};
2887
+
2888
+ extensionDef.clearcoatFactor = material.clearcoat;
2889
+
2890
+ if ( material.clearcoatMap ) {
2891
+
2892
+ const clearcoatMapDef = {
2893
+ index: await writer.processTextureAsync( material.clearcoatMap ),
2894
+ texCoord: material.clearcoatMap.channel
2895
+ };
2896
+ writer.applyTextureTransform( clearcoatMapDef, material.clearcoatMap );
2897
+ extensionDef.clearcoatTexture = clearcoatMapDef;
2898
+
2899
+ }
2900
+
2901
+ extensionDef.clearcoatRoughnessFactor = material.clearcoatRoughness;
2902
+
2903
+ if ( material.clearcoatRoughnessMap ) {
2904
+
2905
+ const clearcoatRoughnessMapDef = {
2906
+ index: await writer.processTextureAsync( material.clearcoatRoughnessMap ),
2907
+ texCoord: material.clearcoatRoughnessMap.channel
2908
+ };
2909
+ writer.applyTextureTransform( clearcoatRoughnessMapDef, material.clearcoatRoughnessMap );
2910
+ extensionDef.clearcoatRoughnessTexture = clearcoatRoughnessMapDef;
2911
+
2912
+ }
2913
+
2914
+ if ( material.clearcoatNormalMap ) {
2915
+
2916
+ const clearcoatNormalMapDef = {
2917
+ index: await writer.processTextureAsync( material.clearcoatNormalMap ),
2918
+ texCoord: material.clearcoatNormalMap.channel
2919
+ };
2920
+
2921
+ if ( material.clearcoatNormalScale.x !== 1 ) clearcoatNormalMapDef.scale = material.clearcoatNormalScale.x;
2922
+
2923
+ writer.applyTextureTransform( clearcoatNormalMapDef, material.clearcoatNormalMap );
2924
+ extensionDef.clearcoatNormalTexture = clearcoatNormalMapDef;
2925
+
2926
+ }
2927
+
2928
+ materialDef.extensions = materialDef.extensions || {};
2929
+ materialDef.extensions[ this.name ] = extensionDef;
2930
+
2931
+ extensionsUsed[ this.name ] = true;
2932
+
2933
+
2934
+ }
2935
+
2936
+ }
2937
+
2938
+ /**
2939
+ * Materials dispersion Extension
2940
+ *
2941
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_dispersion
2942
+ *
2943
+ * @private
2944
+ */
2945
+ class GLTFMaterialsDispersionExtension {
2946
+
2947
+ constructor( writer ) {
2948
+
2949
+ this.writer = writer;
2950
+ this.name = 'KHR_materials_dispersion';
2951
+
2952
+ }
2953
+
2954
+ async writeMaterialAsync( material, materialDef ) {
2955
+
2956
+ if ( ! material.isMeshPhysicalMaterial || material.dispersion === 0 ) return;
2957
+
2958
+ const writer = this.writer;
2959
+ const extensionsUsed = writer.extensionsUsed;
2960
+
2961
+ const extensionDef = {};
2962
+
2963
+ extensionDef.dispersion = material.dispersion;
2964
+
2965
+ materialDef.extensions = materialDef.extensions || {};
2966
+ materialDef.extensions[ this.name ] = extensionDef;
2967
+
2968
+ extensionsUsed[ this.name ] = true;
2969
+
2970
+ }
2971
+
2972
+ }
2973
+
2974
+ /**
2975
+ * Iridescence Materials Extension
2976
+ *
2977
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
2978
+ *
2979
+ * @private
2980
+ */
2981
+ class GLTFMaterialsIridescenceExtension {
2982
+
2983
+ constructor( writer ) {
2984
+
2985
+ this.writer = writer;
2986
+ this.name = 'KHR_materials_iridescence';
2987
+
2988
+ }
2989
+
2990
+ async writeMaterialAsync( material, materialDef ) {
2991
+
2992
+ if ( ! material.isMeshPhysicalMaterial || material.iridescence === 0 ) return;
2993
+
2994
+ const writer = this.writer;
2995
+ const extensionsUsed = writer.extensionsUsed;
2996
+
2997
+ const extensionDef = {};
2998
+
2999
+ extensionDef.iridescenceFactor = material.iridescence;
3000
+
3001
+ if ( material.iridescenceMap ) {
3002
+
3003
+ const iridescenceMapDef = {
3004
+ index: await writer.processTextureAsync( material.iridescenceMap ),
3005
+ texCoord: material.iridescenceMap.channel
3006
+ };
3007
+ writer.applyTextureTransform( iridescenceMapDef, material.iridescenceMap );
3008
+ extensionDef.iridescenceTexture = iridescenceMapDef;
3009
+
3010
+ }
3011
+
3012
+ extensionDef.iridescenceIor = material.iridescenceIOR;
3013
+ extensionDef.iridescenceThicknessMinimum = material.iridescenceThicknessRange[ 0 ];
3014
+ extensionDef.iridescenceThicknessMaximum = material.iridescenceThicknessRange[ 1 ];
3015
+
3016
+ if ( material.iridescenceThicknessMap ) {
3017
+
3018
+ const iridescenceThicknessMapDef = {
3019
+ index: await writer.processTextureAsync( material.iridescenceThicknessMap ),
3020
+ texCoord: material.iridescenceThicknessMap.channel
3021
+ };
3022
+ writer.applyTextureTransform( iridescenceThicknessMapDef, material.iridescenceThicknessMap );
3023
+ extensionDef.iridescenceThicknessTexture = iridescenceThicknessMapDef;
3024
+
3025
+ }
3026
+
3027
+ materialDef.extensions = materialDef.extensions || {};
3028
+ materialDef.extensions[ this.name ] = extensionDef;
3029
+
3030
+ extensionsUsed[ this.name ] = true;
3031
+
3032
+ }
3033
+
3034
+ }
3035
+
3036
+ /**
3037
+ * Transmission Materials Extension
3038
+ *
3039
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
3040
+ *
3041
+ * @private
3042
+ */
3043
+ class GLTFMaterialsTransmissionExtension {
3044
+
3045
+ constructor( writer ) {
3046
+
3047
+ this.writer = writer;
3048
+ this.name = 'KHR_materials_transmission';
3049
+
3050
+ }
3051
+
3052
+ async writeMaterialAsync( material, materialDef ) {
3053
+
3054
+ if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
3055
+
3056
+ const writer = this.writer;
3057
+ const extensionsUsed = writer.extensionsUsed;
3058
+
3059
+ const extensionDef = {};
3060
+
3061
+ extensionDef.transmissionFactor = material.transmission;
3062
+
3063
+ if ( material.transmissionMap ) {
3064
+
3065
+ const transmissionMapDef = {
3066
+ index: await writer.processTextureAsync( material.transmissionMap ),
3067
+ texCoord: material.transmissionMap.channel
3068
+ };
3069
+ writer.applyTextureTransform( transmissionMapDef, material.transmissionMap );
3070
+ extensionDef.transmissionTexture = transmissionMapDef;
3071
+
3072
+ }
3073
+
3074
+ materialDef.extensions = materialDef.extensions || {};
3075
+ materialDef.extensions[ this.name ] = extensionDef;
3076
+
3077
+ extensionsUsed[ this.name ] = true;
3078
+
3079
+ }
3080
+
3081
+ }
3082
+
3083
+ /**
3084
+ * Materials Volume Extension
3085
+ *
3086
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
3087
+ *
3088
+ * @private
3089
+ */
3090
+ class GLTFMaterialsVolumeExtension {
3091
+
3092
+ constructor( writer ) {
3093
+
3094
+ this.writer = writer;
3095
+ this.name = 'KHR_materials_volume';
3096
+
3097
+ }
3098
+
3099
+ async writeMaterialAsync( material, materialDef ) {
3100
+
3101
+ if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
3102
+
3103
+ const writer = this.writer;
3104
+ const extensionsUsed = writer.extensionsUsed;
3105
+
3106
+ const extensionDef = {};
3107
+
3108
+ extensionDef.thicknessFactor = material.thickness;
3109
+
3110
+ if ( material.thicknessMap ) {
3111
+
3112
+ const thicknessMapDef = {
3113
+ index: await writer.processTextureAsync( material.thicknessMap ),
3114
+ texCoord: material.thicknessMap.channel
3115
+ };
3116
+ writer.applyTextureTransform( thicknessMapDef, material.thicknessMap );
3117
+ extensionDef.thicknessTexture = thicknessMapDef;
3118
+
3119
+ }
3120
+
3121
+ if ( material.attenuationDistance !== Infinity ) {
3122
+
3123
+ extensionDef.attenuationDistance = material.attenuationDistance;
3124
+
3125
+ }
3126
+
3127
+ extensionDef.attenuationColor = material.attenuationColor.toArray();
3128
+
3129
+ materialDef.extensions = materialDef.extensions || {};
3130
+ materialDef.extensions[ this.name ] = extensionDef;
3131
+
3132
+ extensionsUsed[ this.name ] = true;
3133
+
3134
+ }
3135
+
3136
+ }
3137
+
3138
+ /**
3139
+ * Materials ior Extension
3140
+ *
3141
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
3142
+ *
3143
+ * @private
3144
+ */
3145
+ class GLTFMaterialsIorExtension {
3146
+
3147
+ constructor( writer ) {
3148
+
3149
+ this.writer = writer;
3150
+ this.name = 'KHR_materials_ior';
3151
+
3152
+ }
3153
+
3154
+ async writeMaterialAsync( material, materialDef ) {
3155
+
3156
+ if ( ! material.isMeshPhysicalMaterial || material.ior === 1.5 ) return;
3157
+
3158
+ const writer = this.writer;
3159
+ const extensionsUsed = writer.extensionsUsed;
3160
+
3161
+ const extensionDef = {};
3162
+
3163
+ extensionDef.ior = material.ior;
3164
+
3165
+ materialDef.extensions = materialDef.extensions || {};
3166
+ materialDef.extensions[ this.name ] = extensionDef;
3167
+
3168
+ extensionsUsed[ this.name ] = true;
3169
+
3170
+ }
3171
+
3172
+ }
3173
+
3174
+ /**
3175
+ * Materials specular Extension
3176
+ *
3177
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
3178
+ *
3179
+ * @private
3180
+ */
3181
+ class GLTFMaterialsSpecularExtension {
3182
+
3183
+ constructor( writer ) {
3184
+
3185
+ this.writer = writer;
3186
+ this.name = 'KHR_materials_specular';
3187
+
3188
+ }
3189
+
3190
+ async writeMaterialAsync( material, materialDef ) {
3191
+
3192
+ if ( ! material.isMeshPhysicalMaterial || ( material.specularIntensity === 1.0 &&
3193
+ material.specularColor.equals( DEFAULT_SPECULAR_COLOR ) &&
3194
+ ! material.specularIntensityMap && ! material.specularColorMap ) ) return;
3195
+
3196
+ const writer = this.writer;
3197
+ const extensionsUsed = writer.extensionsUsed;
3198
+
3199
+ const extensionDef = {};
3200
+
3201
+ if ( material.specularIntensityMap ) {
3202
+
3203
+ const specularIntensityMapDef = {
3204
+ index: await writer.processTextureAsync( material.specularIntensityMap ),
3205
+ texCoord: material.specularIntensityMap.channel
3206
+ };
3207
+ writer.applyTextureTransform( specularIntensityMapDef, material.specularIntensityMap );
3208
+ extensionDef.specularTexture = specularIntensityMapDef;
3209
+
3210
+ }
3211
+
3212
+ if ( material.specularColorMap ) {
3213
+
3214
+ const specularColorMapDef = {
3215
+ index: await writer.processTextureAsync( material.specularColorMap ),
3216
+ texCoord: material.specularColorMap.channel
3217
+ };
3218
+ writer.applyTextureTransform( specularColorMapDef, material.specularColorMap );
3219
+ extensionDef.specularColorTexture = specularColorMapDef;
3220
+
3221
+ }
3222
+
3223
+ extensionDef.specularFactor = material.specularIntensity;
3224
+ extensionDef.specularColorFactor = material.specularColor.toArray();
3225
+
3226
+ materialDef.extensions = materialDef.extensions || {};
3227
+ materialDef.extensions[ this.name ] = extensionDef;
3228
+
3229
+ extensionsUsed[ this.name ] = true;
3230
+
3231
+ }
3232
+
3233
+ }
3234
+
3235
+ /**
3236
+ * Sheen Materials Extension
3237
+ *
3238
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
3239
+ *
3240
+ * @private
3241
+ */
3242
+ class GLTFMaterialsSheenExtension {
3243
+
3244
+ constructor( writer ) {
3245
+
3246
+ this.writer = writer;
3247
+ this.name = 'KHR_materials_sheen';
3248
+
3249
+ }
3250
+
3251
+ async writeMaterialAsync( material, materialDef ) {
3252
+
3253
+ if ( ! material.isMeshPhysicalMaterial || material.sheen == 0.0 ) return;
3254
+
3255
+ const writer = this.writer;
3256
+ const extensionsUsed = writer.extensionsUsed;
3257
+
3258
+ const extensionDef = {};
3259
+
3260
+ if ( material.sheenRoughnessMap ) {
3261
+
3262
+ const sheenRoughnessMapDef = {
3263
+ index: await writer.processTextureAsync( material.sheenRoughnessMap ),
3264
+ texCoord: material.sheenRoughnessMap.channel
3265
+ };
3266
+ writer.applyTextureTransform( sheenRoughnessMapDef, material.sheenRoughnessMap );
3267
+ extensionDef.sheenRoughnessTexture = sheenRoughnessMapDef;
3268
+
3269
+ }
3270
+
3271
+ if ( material.sheenColorMap ) {
3272
+
3273
+ const sheenColorMapDef = {
3274
+ index: await writer.processTextureAsync( material.sheenColorMap ),
3275
+ texCoord: material.sheenColorMap.channel
3276
+ };
3277
+ writer.applyTextureTransform( sheenColorMapDef, material.sheenColorMap );
3278
+ extensionDef.sheenColorTexture = sheenColorMapDef;
3279
+
3280
+ }
3281
+
3282
+ extensionDef.sheenRoughnessFactor = material.sheenRoughness;
3283
+ extensionDef.sheenColorFactor = material.sheenColor.toArray();
3284
+
3285
+ materialDef.extensions = materialDef.extensions || {};
3286
+ materialDef.extensions[ this.name ] = extensionDef;
3287
+
3288
+ extensionsUsed[ this.name ] = true;
3289
+
3290
+ }
3291
+
3292
+ }
3293
+
3294
+ /**
3295
+ * Anisotropy Materials Extension
3296
+ *
3297
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy
3298
+ *
3299
+ * @private
3300
+ */
3301
+ class GLTFMaterialsAnisotropyExtension {
3302
+
3303
+ constructor( writer ) {
3304
+
3305
+ this.writer = writer;
3306
+ this.name = 'KHR_materials_anisotropy';
3307
+
3308
+ }
3309
+
3310
+ async writeMaterialAsync( material, materialDef ) {
3311
+
3312
+ if ( ! material.isMeshPhysicalMaterial || material.anisotropy == 0.0 ) return;
3313
+
3314
+ const writer = this.writer;
3315
+ const extensionsUsed = writer.extensionsUsed;
3316
+
3317
+ const extensionDef = {};
3318
+
3319
+ if ( material.anisotropyMap ) {
3320
+
3321
+ const anisotropyMapDef = { index: await writer.processTextureAsync( material.anisotropyMap ) };
3322
+ writer.applyTextureTransform( anisotropyMapDef, material.anisotropyMap );
3323
+ extensionDef.anisotropyTexture = anisotropyMapDef;
3324
+
3325
+ }
3326
+
3327
+ extensionDef.anisotropyStrength = material.anisotropy;
3328
+ extensionDef.anisotropyRotation = material.anisotropyRotation;
3329
+
3330
+ materialDef.extensions = materialDef.extensions || {};
3331
+ materialDef.extensions[ this.name ] = extensionDef;
3332
+
3333
+ extensionsUsed[ this.name ] = true;
3334
+
3335
+ }
3336
+
3337
+ }
3338
+
3339
+ /**
3340
+ * Materials Emissive Strength Extension
3341
+ *
3342
+ * Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
3343
+ *
3344
+ * @private
3345
+ */
3346
+ class GLTFMaterialsEmissiveStrengthExtension {
3347
+
3348
+ constructor( writer ) {
3349
+
3350
+ this.writer = writer;
3351
+ this.name = 'KHR_materials_emissive_strength';
3352
+
3353
+ }
3354
+
3355
+ async writeMaterialAsync( material, materialDef ) {
3356
+
3357
+ if ( ! material.isMeshStandardMaterial || material.emissiveIntensity === 1.0 ) return;
3358
+
3359
+ const writer = this.writer;
3360
+ const extensionsUsed = writer.extensionsUsed;
3361
+
3362
+ const extensionDef = {};
3363
+
3364
+ extensionDef.emissiveStrength = material.emissiveIntensity;
3365
+
3366
+ materialDef.extensions = materialDef.extensions || {};
3367
+ materialDef.extensions[ this.name ] = extensionDef;
3368
+
3369
+ extensionsUsed[ this.name ] = true;
3370
+
3371
+ }
3372
+
3373
+ }
3374
+
3375
+
3376
+ /**
3377
+ * Materials bump Extension
3378
+ *
3379
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
3380
+ *
3381
+ * @private
3382
+ */
3383
+ class GLTFMaterialsBumpExtension {
3384
+
3385
+ constructor( writer ) {
3386
+
3387
+ this.writer = writer;
3388
+ this.name = 'EXT_materials_bump';
3389
+
3390
+ }
3391
+
3392
+ async writeMaterialAsync( material, materialDef ) {
3393
+
3394
+ if ( ! material.isMeshStandardMaterial || (
3395
+ material.bumpScale === 1 &&
3396
+ ! material.bumpMap ) ) return;
3397
+
3398
+ const writer = this.writer;
3399
+ const extensionsUsed = writer.extensionsUsed;
3400
+
3401
+ const extensionDef = {};
3402
+
3403
+ if ( material.bumpMap ) {
3404
+
3405
+ const bumpMapDef = {
3406
+ index: await writer.processTextureAsync( material.bumpMap ),
3407
+ texCoord: material.bumpMap.channel
3408
+ };
3409
+ writer.applyTextureTransform( bumpMapDef, material.bumpMap );
3410
+ extensionDef.bumpTexture = bumpMapDef;
3411
+
3412
+ }
3413
+
3414
+ extensionDef.bumpFactor = material.bumpScale;
3415
+
3416
+ materialDef.extensions = materialDef.extensions || {};
3417
+ materialDef.extensions[ this.name ] = extensionDef;
3418
+
3419
+ extensionsUsed[ this.name ] = true;
3420
+
3421
+ }
3422
+
3423
+ }
3424
+
3425
+ /**
3426
+ * GPU Instancing Extension
3427
+ *
3428
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
3429
+ *
3430
+ * @private
3431
+ */
3432
+ class GLTFMeshGpuInstancing {
3433
+
3434
+ constructor( writer ) {
3435
+
3436
+ this.writer = writer;
3437
+ this.name = 'EXT_mesh_gpu_instancing';
3438
+
3439
+ }
3440
+
3441
+ writeNode( object, nodeDef ) {
3442
+
3443
+ if ( ! object.isInstancedMesh ) return;
3444
+
3445
+ const writer = this.writer;
3446
+
3447
+ const mesh = object;
3448
+
3449
+ const translationAttr = new Float32Array( mesh.count * 3 );
3450
+ const rotationAttr = new Float32Array( mesh.count * 4 );
3451
+ const scaleAttr = new Float32Array( mesh.count * 3 );
3452
+
3453
+ const matrix = new Matrix4();
3454
+ const position = new Vector3();
3455
+ const quaternion = new Quaternion();
3456
+ const scale = new Vector3();
3457
+
3458
+ for ( let i = 0; i < mesh.count; i ++ ) {
3459
+
3460
+ mesh.getMatrixAt( i, matrix );
3461
+ matrix.decompose( position, quaternion, scale );
3462
+
3463
+ position.toArray( translationAttr, i * 3 );
3464
+ quaternion.toArray( rotationAttr, i * 4 );
3465
+ scale.toArray( scaleAttr, i * 3 );
3466
+
3467
+ }
3468
+
3469
+ const attributes = {
3470
+ TRANSLATION: writer.processAccessor( new BufferAttribute( translationAttr, 3 ) ),
3471
+ ROTATION: writer.processAccessor( new BufferAttribute( rotationAttr, 4 ) ),
3472
+ SCALE: writer.processAccessor( new BufferAttribute( scaleAttr, 3 ) ),
3473
+ };
3474
+
3475
+ if ( mesh.instanceColor )
3476
+ attributes._COLOR_0 = writer.processAccessor( mesh.instanceColor );
3477
+
3478
+ nodeDef.extensions = nodeDef.extensions || {};
3479
+ nodeDef.extensions[ this.name ] = { attributes };
3480
+
3481
+ writer.extensionsUsed[ this.name ] = true;
3482
+ writer.extensionsRequired[ this.name ] = true;
3483
+
3484
+ }
3485
+
3486
+ }
3487
+
3488
+ /**
3489
+ * Static utility functions
3490
+ *
3491
+ * @private
3492
+ */
3493
+ GLTFExporter.Utils = {
3494
+
3495
+ insertKeyframe: function ( track, time ) {
3496
+
3497
+ const tolerance = 0.001; // 1ms
3498
+ const valueSize = track.getValueSize();
3499
+
3500
+ const times = new track.TimeBufferType( track.times.length + 1 );
3501
+ const values = new track.ValueBufferType( track.values.length + valueSize );
3502
+ const interpolant = track.createInterpolant( new track.ValueBufferType( valueSize ) );
3503
+
3504
+ let index;
3505
+
3506
+ if ( track.times.length === 0 ) {
3507
+
3508
+ times[ 0 ] = time;
3509
+
3510
+ for ( let i = 0; i < valueSize; i ++ ) {
3511
+
3512
+ values[ i ] = 0;
3513
+
3514
+ }
3515
+
3516
+ index = 0;
3517
+
3518
+ } else if ( time < track.times[ 0 ] ) {
3519
+
3520
+ if ( Math.abs( track.times[ 0 ] - time ) < tolerance ) return 0;
3521
+
3522
+ times[ 0 ] = time;
3523
+ times.set( track.times, 1 );
3524
+
3525
+ values.set( interpolant.evaluate( time ), 0 );
3526
+ values.set( track.values, valueSize );
3527
+
3528
+ index = 0;
3529
+
3530
+ } else if ( time > track.times[ track.times.length - 1 ] ) {
3531
+
3532
+ if ( Math.abs( track.times[ track.times.length - 1 ] - time ) < tolerance ) {
3533
+
3534
+ return track.times.length - 1;
3535
+
3536
+ }
3537
+
3538
+ times[ times.length - 1 ] = time;
3539
+ times.set( track.times, 0 );
3540
+
3541
+ values.set( track.values, 0 );
3542
+ values.set( interpolant.evaluate( time ), track.values.length );
3543
+
3544
+ index = times.length - 1;
3545
+
3546
+ } else {
3547
+
3548
+ for ( let i = 0; i < track.times.length; i ++ ) {
3549
+
3550
+ if ( Math.abs( track.times[ i ] - time ) < tolerance ) return i;
3551
+
3552
+ if ( track.times[ i ] < time && track.times[ i + 1 ] > time ) {
3553
+
3554
+ times.set( track.times.slice( 0, i + 1 ), 0 );
3555
+ times[ i + 1 ] = time;
3556
+ times.set( track.times.slice( i + 1 ), i + 2 );
3557
+
3558
+ values.set( track.values.slice( 0, ( i + 1 ) * valueSize ), 0 );
3559
+ values.set( interpolant.evaluate( time ), ( i + 1 ) * valueSize );
3560
+ values.set( track.values.slice( ( i + 1 ) * valueSize ), ( i + 2 ) * valueSize );
3561
+
3562
+ index = i + 1;
3563
+
3564
+ break;
3565
+
3566
+ }
3567
+
3568
+ }
3569
+
3570
+ }
3571
+
3572
+ track.times = times;
3573
+ track.values = values;
3574
+
3575
+ return index;
3576
+
3577
+ },
3578
+
3579
+ mergeMorphTargetTracks: function ( clip, root ) {
3580
+
3581
+ const tracks = [];
3582
+ const mergedTracks = {};
3583
+ const sourceTracks = clip.tracks;
3584
+
3585
+ for ( let i = 0; i < sourceTracks.length; ++ i ) {
3586
+
3587
+ let sourceTrack = sourceTracks[ i ];
3588
+ const sourceTrackBinding = PropertyBinding.parseTrackName( sourceTrack.name );
3589
+ const sourceTrackNode = PropertyBinding.findNode( root, sourceTrackBinding.nodeName );
3590
+
3591
+ if ( sourceTrackBinding.propertyName !== 'morphTargetInfluences' || sourceTrackBinding.propertyIndex === undefined ) {
3592
+
3593
+ // Tracks that don't affect morph targets, or that affect all morph targets together, can be left as-is.
3594
+ tracks.push( sourceTrack );
3595
+ continue;
3596
+
3597
+ }
3598
+
3599
+ if ( sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodDiscrete
3600
+ && sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodLinear ) {
3601
+
3602
+ if ( sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) {
3603
+
3604
+ // This should never happen, because glTF morph target animations
3605
+ // affect all targets already.
3606
+ throw new Error( 'THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.' );
3607
+
3608
+ }
3609
+
3610
+ console.warn( 'THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.' );
3611
+
3612
+ sourceTrack = sourceTrack.clone();
3613
+ sourceTrack.setInterpolation( InterpolateLinear );
3614
+
3615
+ }
3616
+
3617
+ const targetCount = sourceTrackNode.morphTargetInfluences.length;
3618
+ const targetIndex = sourceTrackNode.morphTargetDictionary[ sourceTrackBinding.propertyIndex ];
3619
+
3620
+ if ( targetIndex === undefined ) {
3621
+
3622
+ throw new Error( 'THREE.GLTFExporter: Morph target name not found: ' + sourceTrackBinding.propertyIndex );
3623
+
3624
+ }
3625
+
3626
+ let mergedTrack;
3627
+
3628
+ // If this is the first time we've seen this object, create a new
3629
+ // track to store merged keyframe data for each morph target.
3630
+ if ( mergedTracks[ sourceTrackNode.uuid ] === undefined ) {
3631
+
3632
+ mergedTrack = sourceTrack.clone();
3633
+
3634
+ const values = new mergedTrack.ValueBufferType( targetCount * mergedTrack.times.length );
3635
+
3636
+ for ( let j = 0; j < mergedTrack.times.length; j ++ ) {
3637
+
3638
+ values[ j * targetCount + targetIndex ] = mergedTrack.values[ j ];
3639
+
3640
+ }
3641
+
3642
+ // We need to take into consideration the intended target node
3643
+ // of our original un-merged morphTarget animation.
3644
+ mergedTrack.name = ( sourceTrackBinding.nodeName || '' ) + '.morphTargetInfluences';
3645
+ mergedTrack.values = values;
3646
+
3647
+ mergedTracks[ sourceTrackNode.uuid ] = mergedTrack;
3648
+ tracks.push( mergedTrack );
3649
+
3650
+ continue;
3651
+
3652
+ }
3653
+
3654
+ const sourceInterpolant = sourceTrack.createInterpolant( new sourceTrack.ValueBufferType( 1 ) );
3655
+
3656
+ mergedTrack = mergedTracks[ sourceTrackNode.uuid ];
3657
+
3658
+ // For every existing keyframe of the merged track, write a (possibly
3659
+ // interpolated) value from the source track.
3660
+ for ( let j = 0; j < mergedTrack.times.length; j ++ ) {
3661
+
3662
+ mergedTrack.values[ j * targetCount + targetIndex ] = sourceInterpolant.evaluate( mergedTrack.times[ j ] );
3663
+
3664
+ }
3665
+
3666
+ // For every existing keyframe of the source track, write a (possibly
3667
+ // new) keyframe to the merged track. Values from the previous loop may
3668
+ // be written again, but keyframes are de-duplicated.
3669
+ for ( let j = 0; j < sourceTrack.times.length; j ++ ) {
3670
+
3671
+ const keyframeIndex = this.insertKeyframe( mergedTrack, sourceTrack.times[ j ] );
3672
+ mergedTrack.values[ keyframeIndex * targetCount + targetIndex ] = sourceTrack.values[ j ];
3673
+
3674
+ }
3675
+
3676
+ }
3677
+
3678
+ clip.tracks = tracks;
3679
+
3680
+ return clip;
3681
+
3682
+ },
3683
+
3684
+ toTypedBufferAttribute: function ( srcAttribute, TypedArray ) {
3685
+
3686
+ const dstAttribute = new BufferAttribute( new TypedArray( srcAttribute.count * srcAttribute.itemSize ), srcAttribute.itemSize, false );
3687
+
3688
+ if ( ! srcAttribute.normalized && ! srcAttribute.isInterleavedBufferAttribute ) {
3689
+
3690
+ dstAttribute.array.set( srcAttribute.array );
3691
+
3692
+ return dstAttribute;
3693
+
3694
+ }
3695
+
3696
+ for ( let i = 0, il = srcAttribute.count; i < il; i ++ ) {
3697
+
3698
+ for ( let j = 0; j < srcAttribute.itemSize; j ++ ) {
3699
+
3700
+ dstAttribute.setComponent( i, j, srcAttribute.getComponent( i, j ) );
3701
+
3702
+ }
3703
+
3704
+ }
3705
+
3706
+ return dstAttribute;
3707
+
3708
+ }
3709
+
3710
+ };
3711
+
3712
+ /**
3713
+ * Export options of `GLTFExporter`.
3714
+ *
3715
+ * @typedef {Object} GLTFExporter~Options
3716
+ * @property {boolean} [trs=false] - Export position, rotation and scale instead of matrix per node.
3717
+ * @property {boolean} [onlyVisible=true] - Export only visible 3D objects.
3718
+ * @property {boolean} [binary=false] - Export in binary (.glb) format, returning an ArrayBuffer.
3719
+ * @property {number} [maxTextureSize=Infinity] - Restricts the image maximum size (both width and height) to the given value.
3720
+ * @property {Array<AnimationClip>} [animations=[]] - List of animations to be included in the export.
3721
+ * @property {boolean} [includeCustomExtensions=false] - Export custom glTF extensions defined on an object's `userData.gltfExtensions` property.
3722
+ **/
3723
+
3724
+ /**
3725
+ * onDone callback of `GLTFExporter`.
3726
+ *
3727
+ * @callback GLTFExporter~OnDone
3728
+ * @param {ArrayBuffer|string} result - The generated .gltf (JSON) or .glb (binary).
3729
+ */
3730
+
3731
+ /**
3732
+ * onError callback of `GLTFExporter`.
3733
+ *
3734
+ * @callback GLTFExporter~OnError
3735
+ * @param {Error} error - The error object.
3736
+ */
3737
+
3738
+ export { GLTFExporter };