@needle-tools/three 0.145.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 (1160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/build/three.cjs +36042 -0
  4. package/build/three.js +36048 -0
  5. package/build/three.min.js +6 -0
  6. package/build/three.module.js +49769 -0
  7. package/examples/fonts/LICENSE +13 -0
  8. package/examples/fonts/README.md +11 -0
  9. package/examples/fonts/droid/NOTICE +190 -0
  10. package/examples/fonts/droid/README.txt +18 -0
  11. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  12. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  13. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  14. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  15. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  16. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  17. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  18. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  19. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  20. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  21. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  22. package/examples/fonts/open-sans/open-sans.css +9 -0
  23. package/examples/fonts/optimer_bold.typeface.json +1 -0
  24. package/examples/fonts/optimer_regular.typeface.json +1 -0
  25. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  26. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  27. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  28. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  29. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  30. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/js/animation/AnimationClipCreator.js +97 -0
  34. package/examples/js/animation/CCDIKSolver.js +433 -0
  35. package/examples/js/animation/MMDAnimationHelper.js +1117 -0
  36. package/examples/js/animation/MMDPhysics.js +1238 -0
  37. package/examples/js/cameras/CinematicCamera.js +157 -0
  38. package/examples/js/controls/ArcballControls.js +3037 -0
  39. package/examples/js/controls/DragControls.js +230 -0
  40. package/examples/js/controls/FirstPersonControls.js +334 -0
  41. package/examples/js/controls/FlyControls.js +347 -0
  42. package/examples/js/controls/OrbitControls.js +1075 -0
  43. package/examples/js/controls/PointerLockControls.js +153 -0
  44. package/examples/js/controls/TrackballControls.js +782 -0
  45. package/examples/js/controls/TransformControls.js +1386 -0
  46. package/examples/js/csm/CSM.js +382 -0
  47. package/examples/js/csm/CSMFrustum.js +133 -0
  48. package/examples/js/csm/CSMHelper.js +145 -0
  49. package/examples/js/csm/CSMShader.js +257 -0
  50. package/examples/js/curves/CurveExtras.js +348 -0
  51. package/examples/js/curves/NURBSCurve.js +75 -0
  52. package/examples/js/curves/NURBSSurface.js +54 -0
  53. package/examples/js/curves/NURBSUtils.js +476 -0
  54. package/examples/js/effects/AnaglyphEffect.js +100 -0
  55. package/examples/js/effects/AsciiEffect.js +259 -0
  56. package/examples/js/effects/OutlineEffect.js +454 -0
  57. package/examples/js/effects/ParallaxBarrierEffect.js +75 -0
  58. package/examples/js/effects/PeppersGhostEffect.js +166 -0
  59. package/examples/js/effects/StereoEffect.js +50 -0
  60. package/examples/js/environments/DebugEnvironment.js +53 -0
  61. package/examples/js/environments/RoomEnvironment.js +122 -0
  62. package/examples/js/exporters/ColladaExporter.js +504 -0
  63. package/examples/js/exporters/DRACOExporter.js +212 -0
  64. package/examples/js/exporters/EXRExporter.js +458 -0
  65. package/examples/js/exporters/GLTFExporter.js +2543 -0
  66. package/examples/js/exporters/MMDExporter.js +194 -0
  67. package/examples/js/exporters/OBJExporter.js +251 -0
  68. package/examples/js/exporters/PLYExporter.js +422 -0
  69. package/examples/js/exporters/STLExporter.js +190 -0
  70. package/examples/js/exporters/USDZExporter.js +523 -0
  71. package/examples/js/geometries/BoxLineGeometry.js +60 -0
  72. package/examples/js/geometries/ConvexGeometry.js +48 -0
  73. package/examples/js/geometries/DecalGeometry.js +291 -0
  74. package/examples/js/geometries/LightningStrike.js +874 -0
  75. package/examples/js/geometries/ParametricGeometries.js +215 -0
  76. package/examples/js/geometries/ParametricGeometry.js +108 -0
  77. package/examples/js/geometries/RoundedBoxGeometry.js +140 -0
  78. package/examples/js/geometries/TeapotGeometry.js +331 -0
  79. package/examples/js/geometries/TextGeometry.js +51 -0
  80. package/examples/js/helpers/LightProbeHelper.js +49 -0
  81. package/examples/js/helpers/OctreeHelper.js +74 -0
  82. package/examples/js/helpers/PositionalAudioHelper.js +89 -0
  83. package/examples/js/helpers/RectAreaLightHelper.js +74 -0
  84. package/examples/js/helpers/VertexNormalsHelper.js +72 -0
  85. package/examples/js/helpers/VertexTangentsHelper.js +62 -0
  86. package/examples/js/helpers/ViewHelper.js +266 -0
  87. package/examples/js/interactive/HTMLMesh.js +508 -0
  88. package/examples/js/interactive/InteractiveGroup.js +101 -0
  89. package/examples/js/interactive/SelectionBox.js +262 -0
  90. package/examples/js/interactive/SelectionHelper.js +91 -0
  91. package/examples/js/libs/ammo.wasm.js +822 -0
  92. package/examples/js/libs/ammo.wasm.wasm +0 -0
  93. package/examples/js/libs/basis/README.md +46 -0
  94. package/examples/js/libs/basis/basis_transcoder.js +21 -0
  95. package/examples/js/libs/basis/basis_transcoder.wasm +0 -0
  96. package/examples/js/libs/chevrotain.min.js +3 -0
  97. package/examples/js/libs/draco/README.md +32 -0
  98. package/examples/js/libs/draco/draco_decoder.js +52 -0
  99. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  100. package/examples/js/libs/draco/draco_encoder.js +33 -0
  101. package/examples/js/libs/draco/draco_wasm_wrapper.js +104 -0
  102. package/examples/js/libs/draco/gltf/draco_decoder.js +48 -0
  103. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  104. package/examples/js/libs/draco/gltf/draco_encoder.js +33 -0
  105. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +104 -0
  106. package/examples/js/libs/fflate.min.js +7 -0
  107. package/examples/js/libs/ktx-parse.umd.js +1 -0
  108. package/examples/js/libs/lottie_canvas.js +12751 -0
  109. package/examples/js/libs/meshopt_decoder.js +188 -0
  110. package/examples/js/libs/opentype.min.js +1 -0
  111. package/examples/js/libs/stats.min.js +5 -0
  112. package/examples/js/lights/LightProbeGenerator.js +228 -0
  113. package/examples/js/lights/RectAreaLightUniformsLib.js +56 -0
  114. package/examples/js/lines/Line2.js +19 -0
  115. package/examples/js/lines/LineGeometry.js +71 -0
  116. package/examples/js/lines/LineMaterial.js +642 -0
  117. package/examples/js/lines/LineSegments2.js +362 -0
  118. package/examples/js/lines/LineSegmentsGeometry.js +219 -0
  119. package/examples/js/lines/Wireframe.js +52 -0
  120. package/examples/js/lines/WireframeGeometry2.js +18 -0
  121. package/examples/js/loaders/3DMLoader.js +1370 -0
  122. package/examples/js/loaders/3MFLoader.js +1340 -0
  123. package/examples/js/loaders/AMFLoader.js +529 -0
  124. package/examples/js/loaders/BVHLoader.js +394 -0
  125. package/examples/js/loaders/BasisTextureLoader.js +736 -0
  126. package/examples/js/loaders/ColladaLoader.js +3821 -0
  127. package/examples/js/loaders/DDSLoader.js +245 -0
  128. package/examples/js/loaders/DRACOLoader.js +548 -0
  129. package/examples/js/loaders/EXRLoader.js +2136 -0
  130. package/examples/js/loaders/FBXLoader.js +3835 -0
  131. package/examples/js/loaders/FontLoader.js +169 -0
  132. package/examples/js/loaders/GCodeLoader.js +256 -0
  133. package/examples/js/loaders/GLTFLoader.js +4159 -0
  134. package/examples/js/loaders/HDRCubeTextureLoader.js +93 -0
  135. package/examples/js/loaders/KMZLoader.js +125 -0
  136. package/examples/js/loaders/KTXLoader.js +177 -0
  137. package/examples/js/loaders/LDrawLoader.js +2374 -0
  138. package/examples/js/loaders/LUT3dlLoader.js +139 -0
  139. package/examples/js/loaders/LUTCubeLoader.js +140 -0
  140. package/examples/js/loaders/LWOLoader.js +966 -0
  141. package/examples/js/loaders/LogLuvLoader.js +765 -0
  142. package/examples/js/loaders/LottieLoader.js +62 -0
  143. package/examples/js/loaders/MD2Loader.js +249 -0
  144. package/examples/js/loaders/MDDLoader.js +95 -0
  145. package/examples/js/loaders/MMDLoader.js +1924 -0
  146. package/examples/js/loaders/MTLLoader.js +501 -0
  147. package/examples/js/loaders/NRRDLoader.js +649 -0
  148. package/examples/js/loaders/OBJLoader.js +804 -0
  149. package/examples/js/loaders/PCDLoader.js +408 -0
  150. package/examples/js/loaders/PDBLoader.js +313 -0
  151. package/examples/js/loaders/PLYLoader.js +562 -0
  152. package/examples/js/loaders/PRWMLoader.js +260 -0
  153. package/examples/js/loaders/PVRLoader.js +227 -0
  154. package/examples/js/loaders/RGBELoader.js +467 -0
  155. package/examples/js/loaders/RGBMLoader.js +1415 -0
  156. package/examples/js/loaders/STLLoader.js +371 -0
  157. package/examples/js/loaders/SVGLoader.js +2655 -0
  158. package/examples/js/loaders/TDSLoader.js +1029 -0
  159. package/examples/js/loaders/TGALoader.js +486 -0
  160. package/examples/js/loaders/TIFFLoader.js +31 -0
  161. package/examples/js/loaders/TTFLoader.js +211 -0
  162. package/examples/js/loaders/TiltLoader.js +460 -0
  163. package/examples/js/loaders/VOXLoader.js +248 -0
  164. package/examples/js/loaders/VRMLLoader.js +3237 -0
  165. package/examples/js/loaders/VTKLoader.js +1095 -0
  166. package/examples/js/loaders/XYZLoader.js +91 -0
  167. package/examples/js/loaders/lwo/IFFParser.js +1148 -0
  168. package/examples/js/loaders/lwo/LWO2Parser.js +448 -0
  169. package/examples/js/loaders/lwo/LWO3Parser.js +402 -0
  170. package/examples/js/materials/MeshGouraudMaterial.js +385 -0
  171. package/examples/js/math/Capsule.js +120 -0
  172. package/examples/js/math/ColorConverter.js +33 -0
  173. package/examples/js/math/ConvexHull.js +1110 -0
  174. package/examples/js/math/ImprovedNoise.js +66 -0
  175. package/examples/js/math/Lut.js +171 -0
  176. package/examples/js/math/MeshSurfaceSampler.js +193 -0
  177. package/examples/js/math/OBB.js +341 -0
  178. package/examples/js/math/Octree.js +465 -0
  179. package/examples/js/math/SimplexNoise.js +459 -0
  180. package/examples/js/misc/ConvexObjectBreaker.js +485 -0
  181. package/examples/js/misc/GPUComputationRenderer.js +397 -0
  182. package/examples/js/misc/Gyroscope.js +60 -0
  183. package/examples/js/misc/MD2Character.js +244 -0
  184. package/examples/js/misc/MD2CharacterComplex.js +494 -0
  185. package/examples/js/misc/MorphAnimMesh.js +69 -0
  186. package/examples/js/misc/MorphBlendMesh.js +292 -0
  187. package/examples/js/misc/ProgressiveLightMap.js +331 -0
  188. package/examples/js/misc/RollerCoaster.js +437 -0
  189. package/examples/js/misc/TubePainter.js +161 -0
  190. package/examples/js/misc/Volume.js +466 -0
  191. package/examples/js/misc/VolumeSlice.js +224 -0
  192. package/examples/js/modifiers/CurveModifier.js +311 -0
  193. package/examples/js/modifiers/EdgeSplitModifier.js +258 -0
  194. package/examples/js/modifiers/SimplifyModifier.js +468 -0
  195. package/examples/js/modifiers/TessellateModifier.js +283 -0
  196. package/examples/js/objects/GroundProjectedEnv.js +193 -0
  197. package/examples/js/objects/Lensflare.js +347 -0
  198. package/examples/js/objects/LightningStorm.js +209 -0
  199. package/examples/js/objects/MarchingCubes.js +738 -0
  200. package/examples/js/objects/Reflector.js +214 -0
  201. package/examples/js/objects/ReflectorForSSRPass.js +319 -0
  202. package/examples/js/objects/Refractor.js +261 -0
  203. package/examples/js/objects/ShadowMesh.js +60 -0
  204. package/examples/js/objects/Sky.js +223 -0
  205. package/examples/js/objects/Water.js +287 -0
  206. package/examples/js/objects/Water2.js +306 -0
  207. package/examples/js/physics/AmmoPhysics.js +256 -0
  208. package/examples/js/physics/OimoPhysics.js +215 -0
  209. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +342 -0
  210. package/examples/js/postprocessing/AfterimagePass.js +70 -0
  211. package/examples/js/postprocessing/BloomPass.js +114 -0
  212. package/examples/js/postprocessing/BokehPass.js +103 -0
  213. package/examples/js/postprocessing/ClearPass.js +44 -0
  214. package/examples/js/postprocessing/CubeTexturePass.js +57 -0
  215. package/examples/js/postprocessing/DotScreenPass.js +49 -0
  216. package/examples/js/postprocessing/EffectComposer.js +279 -0
  217. package/examples/js/postprocessing/FilmPass.js +50 -0
  218. package/examples/js/postprocessing/GlitchPass.js +105 -0
  219. package/examples/js/postprocessing/HalftonePass.js +75 -0
  220. package/examples/js/postprocessing/LUTPass.js +184 -0
  221. package/examples/js/postprocessing/MaskPass.js +92 -0
  222. package/examples/js/postprocessing/OutlinePass.js +589 -0
  223. package/examples/js/postprocessing/Pass.js +75 -0
  224. package/examples/js/postprocessing/RenderPass.js +74 -0
  225. package/examples/js/postprocessing/SAOPass.js +366 -0
  226. package/examples/js/postprocessing/SMAAPass.js +153 -0
  227. package/examples/js/postprocessing/SSAARenderPass.js +156 -0
  228. package/examples/js/postprocessing/SSAOPass.js +351 -0
  229. package/examples/js/postprocessing/SSRPass.js +550 -0
  230. package/examples/js/postprocessing/SavePass.js +51 -0
  231. package/examples/js/postprocessing/ShaderPass.js +63 -0
  232. package/examples/js/postprocessing/TAARenderPass.js +128 -0
  233. package/examples/js/postprocessing/TexturePass.js +46 -0
  234. package/examples/js/postprocessing/UnrealBloomPass.js +357 -0
  235. package/examples/js/renderers/CSS2DRenderer.js +197 -0
  236. package/examples/js/renderers/CSS3DRenderer.js +258 -0
  237. package/examples/js/renderers/Projector.js +874 -0
  238. package/examples/js/renderers/SVGRenderer.js +537 -0
  239. package/examples/js/shaders/ACESFilmicToneMappingShader.js +92 -0
  240. package/examples/js/shaders/AfterimageShader.js +63 -0
  241. package/examples/js/shaders/BasicShader.js +30 -0
  242. package/examples/js/shaders/BleachBypassShader.js +65 -0
  243. package/examples/js/shaders/BlendShader.js +57 -0
  244. package/examples/js/shaders/BokehShader.js +159 -0
  245. package/examples/js/shaders/BokehShader2.js +428 -0
  246. package/examples/js/shaders/BrightnessContrastShader.js +61 -0
  247. package/examples/js/shaders/ColorCorrectionShader.js +56 -0
  248. package/examples/js/shaders/ColorifyShader.js +51 -0
  249. package/examples/js/shaders/ConvolutionShader.js +97 -0
  250. package/examples/js/shaders/CopyShader.js +48 -0
  251. package/examples/js/shaders/DOFMipMapShader.js +63 -0
  252. package/examples/js/shaders/DepthLimitedBlurShader.js +180 -0
  253. package/examples/js/shaders/DigitalGlitch.js +130 -0
  254. package/examples/js/shaders/DotScreenShader.js +76 -0
  255. package/examples/js/shaders/FXAAShader.js +286 -0
  256. package/examples/js/shaders/FilmShader.js +113 -0
  257. package/examples/js/shaders/FocusShader.js +98 -0
  258. package/examples/js/shaders/FreiChenShader.js +97 -0
  259. package/examples/js/shaders/GammaCorrectionShader.js +44 -0
  260. package/examples/js/shaders/GodRaysShader.js +297 -0
  261. package/examples/js/shaders/HalftoneShader.js +339 -0
  262. package/examples/js/shaders/HorizontalBlurShader.js +62 -0
  263. package/examples/js/shaders/HorizontalTiltShiftShader.js +68 -0
  264. package/examples/js/shaders/HueSaturationShader.js +72 -0
  265. package/examples/js/shaders/KaleidoShader.js +63 -0
  266. package/examples/js/shaders/LuminosityHighPassShader.js +71 -0
  267. package/examples/js/shaders/LuminosityShader.js +49 -0
  268. package/examples/js/shaders/MMDToonShader.js +100 -0
  269. package/examples/js/shaders/MirrorShader.js +59 -0
  270. package/examples/js/shaders/NormalMapShader.js +59 -0
  271. package/examples/js/shaders/PixelShader.js +51 -0
  272. package/examples/js/shaders/RGBShiftShader.js +59 -0
  273. package/examples/js/shaders/SAOShader.js +213 -0
  274. package/examples/js/shaders/SMAAShader.js +466 -0
  275. package/examples/js/shaders/SSAOShader.js +299 -0
  276. package/examples/js/shaders/SSRShader.js +393 -0
  277. package/examples/js/shaders/SepiaShader.js +55 -0
  278. package/examples/js/shaders/SobelOperatorShader.js +92 -0
  279. package/examples/js/shaders/SubsurfaceScatteringShader.js +49 -0
  280. package/examples/js/shaders/TechnicolorShader.js +46 -0
  281. package/examples/js/shaders/ToneMapShader.js +87 -0
  282. package/examples/js/shaders/ToonShader.js +351 -0
  283. package/examples/js/shaders/TriangleBlurShader.js +74 -0
  284. package/examples/js/shaders/UnpackDepthRGBAShader.js +50 -0
  285. package/examples/js/shaders/VerticalBlurShader.js +62 -0
  286. package/examples/js/shaders/VerticalTiltShiftShader.js +68 -0
  287. package/examples/js/shaders/VignetteShader.js +56 -0
  288. package/examples/js/shaders/VolumeShader.js +300 -0
  289. package/examples/js/shaders/WaterRefractionShader.js +88 -0
  290. package/examples/js/textures/FlakesTexture.js +41 -0
  291. package/examples/js/utils/BufferGeometryUtils.js +1094 -0
  292. package/examples/js/utils/CameraUtils.js +86 -0
  293. package/examples/js/utils/GPUStatsPanel.js +134 -0
  294. package/examples/js/utils/GeometryCompressionUtils.js +574 -0
  295. package/examples/js/utils/GeometryUtils.js +173 -0
  296. package/examples/js/utils/LDrawUtils.js +182 -0
  297. package/examples/js/utils/PackedPhongMaterial.js +107 -0
  298. package/examples/js/utils/SceneUtils.js +103 -0
  299. package/examples/js/utils/ShadowMapViewer.js +180 -0
  300. package/examples/js/utils/SkeletonUtils.js +507 -0
  301. package/examples/js/utils/UVsDebug.js +135 -0
  302. package/examples/js/utils/WorkerPool.js +115 -0
  303. package/examples/jsm/animation/AnimationClipCreator.js +114 -0
  304. package/examples/jsm/animation/CCDIKSolver.js +482 -0
  305. package/examples/jsm/animation/MMDAnimationHelper.js +1207 -0
  306. package/examples/jsm/animation/MMDPhysics.js +1406 -0
  307. package/examples/jsm/cameras/CinematicCamera.js +209 -0
  308. package/examples/jsm/capabilities/WebGL.js +91 -0
  309. package/examples/jsm/capabilities/WebGPU.js +39 -0
  310. package/examples/jsm/controls/ArcballControls.js +3216 -0
  311. package/examples/jsm/controls/DragControls.js +220 -0
  312. package/examples/jsm/controls/FirstPersonControls.js +325 -0
  313. package/examples/jsm/controls/FlyControls.js +284 -0
  314. package/examples/jsm/controls/OrbitControls.js +1249 -0
  315. package/examples/jsm/controls/PointerLockControls.js +157 -0
  316. package/examples/jsm/controls/TrackballControls.js +814 -0
  317. package/examples/jsm/controls/TransformControls.js +1558 -0
  318. package/examples/jsm/csm/CSM.js +378 -0
  319. package/examples/jsm/csm/CSMFrustum.js +152 -0
  320. package/examples/jsm/csm/CSMHelper.js +193 -0
  321. package/examples/jsm/csm/CSMShader.js +251 -0
  322. package/examples/jsm/curves/CurveExtras.js +422 -0
  323. package/examples/jsm/curves/NURBSCurve.js +80 -0
  324. package/examples/jsm/curves/NURBSSurface.js +52 -0
  325. package/examples/jsm/curves/NURBSUtils.js +487 -0
  326. package/examples/jsm/effects/AnaglyphEffect.js +168 -0
  327. package/examples/jsm/effects/AsciiEffect.js +266 -0
  328. package/examples/jsm/effects/OutlineEffect.js +553 -0
  329. package/examples/jsm/effects/ParallaxBarrierEffect.js +116 -0
  330. package/examples/jsm/effects/PeppersGhostEffect.js +153 -0
  331. package/examples/jsm/effects/StereoEffect.js +55 -0
  332. package/examples/jsm/environments/DebugEnvironment.js +52 -0
  333. package/examples/jsm/environments/RoomEnvironment.js +144 -0
  334. package/examples/jsm/exporters/ColladaExporter.js +713 -0
  335. package/examples/jsm/exporters/DRACOExporter.js +225 -0
  336. package/examples/jsm/exporters/EXRExporter.js +507 -0
  337. package/examples/jsm/exporters/GLTFExporter.js +2870 -0
  338. package/examples/jsm/exporters/KTX2Exporter.js +281 -0
  339. package/examples/jsm/exporters/MMDExporter.js +217 -0
  340. package/examples/jsm/exporters/OBJExporter.js +284 -0
  341. package/examples/jsm/exporters/PLYExporter.js +521 -0
  342. package/examples/jsm/exporters/STLExporter.js +195 -0
  343. package/examples/jsm/exporters/USDZExporter.js +1112 -0
  344. package/examples/jsm/geometries/BoxLineGeometry.js +69 -0
  345. package/examples/jsm/geometries/ConvexGeometry.js +59 -0
  346. package/examples/jsm/geometries/DecalGeometry.js +356 -0
  347. package/examples/jsm/geometries/LightningStrike.js +1017 -0
  348. package/examples/jsm/geometries/ParametricGeometries.js +254 -0
  349. package/examples/jsm/geometries/ParametricGeometry.js +129 -0
  350. package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -0
  351. package/examples/jsm/geometries/TeapotGeometry.js +704 -0
  352. package/examples/jsm/geometries/TextGeometry.js +57 -0
  353. package/examples/jsm/helpers/LightProbeHelper.js +130 -0
  354. package/examples/jsm/helpers/OctreeHelper.js +72 -0
  355. package/examples/jsm/helpers/PositionalAudioHelper.js +109 -0
  356. package/examples/jsm/helpers/RectAreaLightHelper.js +85 -0
  357. package/examples/jsm/helpers/VertexNormalsHelper.js +96 -0
  358. package/examples/jsm/helpers/VertexTangentsHelper.js +88 -0
  359. package/examples/jsm/helpers/ViewHelper.js +319 -0
  360. package/examples/jsm/interactive/HTMLMesh.js +550 -0
  361. package/examples/jsm/interactive/InteractiveGroup.js +116 -0
  362. package/examples/jsm/interactive/SelectionBox.js +227 -0
  363. package/examples/jsm/interactive/SelectionHelper.js +97 -0
  364. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +37071 -0
  365. package/examples/jsm/libs/OimoPhysics/index.js +43 -0
  366. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  367. package/examples/jsm/libs/ecsy.module.js +1792 -0
  368. package/examples/jsm/libs/fflate.module.js +2474 -0
  369. package/examples/jsm/libs/flow.module.js +4552 -0
  370. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  371. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  372. package/examples/jsm/libs/meshopt_decoder.module.js +178 -0
  373. package/examples/jsm/libs/mikktspace.module.js +128 -0
  374. package/examples/jsm/libs/mmdparser.module.js +11530 -0
  375. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  376. package/examples/jsm/libs/opentype.module.js +14568 -0
  377. package/examples/jsm/libs/potpack.module.js +125 -0
  378. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  379. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  380. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  381. package/examples/jsm/libs/stats.module.js +167 -0
  382. package/examples/jsm/libs/tween.module.min.js +3 -0
  383. package/examples/jsm/libs/utif.module.js +1579 -0
  384. package/examples/jsm/libs/zstddec.module.js +1 -0
  385. package/examples/jsm/lights/LightProbeGenerator.js +250 -0
  386. package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -0
  387. package/examples/jsm/lines/Line2.js +19 -0
  388. package/examples/jsm/lines/LineGeometry.js +79 -0
  389. package/examples/jsm/lines/LineMaterial.js +702 -0
  390. package/examples/jsm/lines/LineSegments2.js +355 -0
  391. package/examples/jsm/lines/LineSegmentsGeometry.js +241 -0
  392. package/examples/jsm/lines/Wireframe.js +56 -0
  393. package/examples/jsm/lines/WireframeGeometry2.js +24 -0
  394. package/examples/jsm/loaders/3DMLoader.js +1495 -0
  395. package/examples/jsm/loaders/3MFLoader.js +1473 -0
  396. package/examples/jsm/loaders/AMFLoader.js +518 -0
  397. package/examples/jsm/loaders/BVHLoader.js +437 -0
  398. package/examples/jsm/loaders/BasisTextureLoader.js +790 -0
  399. package/examples/jsm/loaders/ColladaLoader.js +4092 -0
  400. package/examples/jsm/loaders/DDSLoader.js +274 -0
  401. package/examples/jsm/loaders/DRACOLoader.js +561 -0
  402. package/examples/jsm/loaders/EXRLoader.js +2310 -0
  403. package/examples/jsm/loaders/FBXLoader.js +4137 -0
  404. package/examples/jsm/loaders/FontLoader.js +183 -0
  405. package/examples/jsm/loaders/GCodeLoader.js +262 -0
  406. package/examples/jsm/loaders/GLTFLoader.js +5221 -0
  407. package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -0
  408. package/examples/jsm/loaders/IFCLoader.js +2431 -0
  409. package/examples/jsm/loaders/KMZLoader.js +130 -0
  410. package/examples/jsm/loaders/KTX2Loader.js +753 -0
  411. package/examples/jsm/loaders/KTXLoader.js +176 -0
  412. package/examples/jsm/loaders/LDrawLoader.js +2464 -0
  413. package/examples/jsm/loaders/LUT3dlLoader.js +151 -0
  414. package/examples/jsm/loaders/LUTCubeLoader.js +153 -0
  415. package/examples/jsm/loaders/LWOLoader.js +1069 -0
  416. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  417. package/examples/jsm/loaders/LottieLoader.js +73 -0
  418. package/examples/jsm/loaders/MD2Loader.js +399 -0
  419. package/examples/jsm/loaders/MDDLoader.js +102 -0
  420. package/examples/jsm/loaders/MMDLoader.js +2242 -0
  421. package/examples/jsm/loaders/MTLLoader.js +567 -0
  422. package/examples/jsm/loaders/NRRDLoader.js +671 -0
  423. package/examples/jsm/loaders/OBJLoader.js +905 -0
  424. package/examples/jsm/loaders/PCDLoader.js +453 -0
  425. package/examples/jsm/loaders/PDBLoader.js +227 -0
  426. package/examples/jsm/loaders/PLYLoader.js +564 -0
  427. package/examples/jsm/loaders/PRWMLoader.js +299 -0
  428. package/examples/jsm/loaders/PVRLoader.js +251 -0
  429. package/examples/jsm/loaders/RGBELoader.js +468 -0
  430. package/examples/jsm/loaders/RGBMLoader.js +1065 -0
  431. package/examples/jsm/loaders/STLLoader.js +399 -0
  432. package/examples/jsm/loaders/SVGLoader.js +2950 -0
  433. package/examples/jsm/loaders/TDSLoader.js +1124 -0
  434. package/examples/jsm/loaders/TGALoader.js +517 -0
  435. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  436. package/examples/jsm/loaders/TTFLoader.js +221 -0
  437. package/examples/jsm/loaders/TiltLoader.js +514 -0
  438. package/examples/jsm/loaders/USDZLoader.js +618 -0
  439. package/examples/jsm/loaders/VOXLoader.js +305 -0
  440. package/examples/jsm/loaders/VRMLLoader.js +3493 -0
  441. package/examples/jsm/loaders/VTKLoader.js +1154 -0
  442. package/examples/jsm/loaders/XYZLoader.js +100 -0
  443. package/examples/jsm/loaders/ifc/web-ifc-api.js +47504 -0
  444. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  445. package/examples/jsm/loaders/lwo/IFFParser.js +1218 -0
  446. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  447. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  448. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  449. package/examples/jsm/math/Capsule.js +137 -0
  450. package/examples/jsm/math/ColorConverter.js +36 -0
  451. package/examples/jsm/math/ConvexHull.js +1271 -0
  452. package/examples/jsm/math/ImprovedNoise.js +71 -0
  453. package/examples/jsm/math/Lut.js +203 -0
  454. package/examples/jsm/math/MeshSurfaceSampler.js +211 -0
  455. package/examples/jsm/math/OBB.js +423 -0
  456. package/examples/jsm/math/Octree.js +462 -0
  457. package/examples/jsm/math/SimplexNoise.js +444 -0
  458. package/examples/jsm/misc/ConvexObjectBreaker.js +525 -0
  459. package/examples/jsm/misc/GPUComputationRenderer.js +454 -0
  460. package/examples/jsm/misc/Gyroscope.js +66 -0
  461. package/examples/jsm/misc/MD2Character.js +276 -0
  462. package/examples/jsm/misc/MD2CharacterComplex.js +576 -0
  463. package/examples/jsm/misc/MorphAnimMesh.js +75 -0
  464. package/examples/jsm/misc/MorphBlendMesh.js +322 -0
  465. package/examples/jsm/misc/ProgressiveLightMap.js +321 -0
  466. package/examples/jsm/misc/RollerCoaster.js +560 -0
  467. package/examples/jsm/misc/TubePainter.js +205 -0
  468. package/examples/jsm/misc/Volume.js +460 -0
  469. package/examples/jsm/misc/VolumeSlice.js +227 -0
  470. package/examples/jsm/modifiers/CurveModifier.js +325 -0
  471. package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -0
  472. package/examples/jsm/modifiers/SimplifyModifier.js +525 -0
  473. package/examples/jsm/modifiers/TessellateModifier.js +307 -0
  474. package/examples/jsm/node-editor/NodeEditor.js +857 -0
  475. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +14 -0
  476. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  477. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  478. package/examples/jsm/node-editor/accessors/UVEditor.js +25 -0
  479. package/examples/jsm/node-editor/core/BaseNode.js +96 -0
  480. package/examples/jsm/node-editor/core/DataFile.js +59 -0
  481. package/examples/jsm/node-editor/core/FileEditor.js +20 -0
  482. package/examples/jsm/node-editor/core/FileURLEditor.js +29 -0
  483. package/examples/jsm/node-editor/display/BlendEditor.js +44 -0
  484. package/examples/jsm/node-editor/display/NormalMapEditor.js +49 -0
  485. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  486. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  487. package/examples/jsm/node-editor/examples/matcap.json +1 -0
  488. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  489. package/examples/jsm/node-editor/examples/rim.json +1 -0
  490. package/examples/jsm/node-editor/inputs/ColorEditor.js +96 -0
  491. package/examples/jsm/node-editor/inputs/FloatEditor.js +23 -0
  492. package/examples/jsm/node-editor/inputs/SliderEditor.js +67 -0
  493. package/examples/jsm/node-editor/inputs/TextureEditor.js +155 -0
  494. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  495. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  496. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  497. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +84 -0
  498. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +102 -0
  499. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +118 -0
  500. package/examples/jsm/node-editor/math/AngleEditor.js +40 -0
  501. package/examples/jsm/node-editor/math/DotEditor.js +35 -0
  502. package/examples/jsm/node-editor/math/InvertEditor.js +39 -0
  503. package/examples/jsm/node-editor/math/LimiterEditor.js +62 -0
  504. package/examples/jsm/node-editor/math/NormalizeEditor.js +28 -0
  505. package/examples/jsm/node-editor/math/OperatorEditor.js +63 -0
  506. package/examples/jsm/node-editor/math/PowerEditor.js +44 -0
  507. package/examples/jsm/node-editor/math/TrigonometryEditor.js +45 -0
  508. package/examples/jsm/node-editor/procedural/CheckerEditor.js +27 -0
  509. package/examples/jsm/node-editor/scene/MeshEditor.js +102 -0
  510. package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
  511. package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
  512. package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
  513. package/examples/jsm/node-editor/utils/OscillatorEditor.js +43 -0
  514. package/examples/jsm/node-editor/utils/PreviewEditor.js +170 -0
  515. package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
  516. package/examples/jsm/node-editor/utils/TimerEditor.js +58 -0
  517. package/examples/jsm/nodes/Nodes.js +346 -0
  518. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  519. package/examples/jsm/nodes/accessors/BufferNode.js +24 -0
  520. package/examples/jsm/nodes/accessors/CameraNode.js +67 -0
  521. package/examples/jsm/nodes/accessors/CubeTextureNode.js +107 -0
  522. package/examples/jsm/nodes/accessors/InstanceNode.js +58 -0
  523. package/examples/jsm/nodes/accessors/MaterialNode.js +152 -0
  524. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +23 -0
  525. package/examples/jsm/nodes/accessors/ModelNode.js +21 -0
  526. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +30 -0
  527. package/examples/jsm/nodes/accessors/NormalNode.js +79 -0
  528. package/examples/jsm/nodes/accessors/Object3DNode.js +122 -0
  529. package/examples/jsm/nodes/accessors/PointUVNode.js +21 -0
  530. package/examples/jsm/nodes/accessors/PositionNode.js +83 -0
  531. package/examples/jsm/nodes/accessors/ReferenceNode.js +65 -0
  532. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  533. package/examples/jsm/nodes/accessors/SkinningNode.js +109 -0
  534. package/examples/jsm/nodes/accessors/StorageBufferNode.js +21 -0
  535. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  536. package/examples/jsm/nodes/accessors/TextureNode.js +100 -0
  537. package/examples/jsm/nodes/accessors/UVNode.js +41 -0
  538. package/examples/jsm/nodes/accessors/UserDataNode.js +23 -0
  539. package/examples/jsm/nodes/core/ArrayUniformNode.js +23 -0
  540. package/examples/jsm/nodes/core/AttributeNode.js +94 -0
  541. package/examples/jsm/nodes/core/BypassNode.js +38 -0
  542. package/examples/jsm/nodes/core/CodeNode.js +50 -0
  543. package/examples/jsm/nodes/core/ConstNode.js +29 -0
  544. package/examples/jsm/nodes/core/ContextNode.js +52 -0
  545. package/examples/jsm/nodes/core/ExpressionNode.js +32 -0
  546. package/examples/jsm/nodes/core/FunctionCallNode.js +82 -0
  547. package/examples/jsm/nodes/core/FunctionNode.js +105 -0
  548. package/examples/jsm/nodes/core/InputNode.js +62 -0
  549. package/examples/jsm/nodes/core/InstanceIndexNode.js +21 -0
  550. package/examples/jsm/nodes/core/Node.js +354 -0
  551. package/examples/jsm/nodes/core/NodeAttribute.js +14 -0
  552. package/examples/jsm/nodes/core/NodeBuilder.js +815 -0
  553. package/examples/jsm/nodes/core/NodeCode.js +15 -0
  554. package/examples/jsm/nodes/core/NodeFrame.js +59 -0
  555. package/examples/jsm/nodes/core/NodeFunction.js +22 -0
  556. package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -0
  557. package/examples/jsm/nodes/core/NodeKeywords.js +80 -0
  558. package/examples/jsm/nodes/core/NodeParser.js +11 -0
  559. package/examples/jsm/nodes/core/NodeUniform.js +28 -0
  560. package/examples/jsm/nodes/core/NodeUtils.js +125 -0
  561. package/examples/jsm/nodes/core/NodeVar.js +14 -0
  562. package/examples/jsm/nodes/core/NodeVarying.js +14 -0
  563. package/examples/jsm/nodes/core/PropertyNode.js +36 -0
  564. package/examples/jsm/nodes/core/TempNode.js +50 -0
  565. package/examples/jsm/nodes/core/UniformNode.js +46 -0
  566. package/examples/jsm/nodes/core/VarNode.js +97 -0
  567. package/examples/jsm/nodes/core/VaryingNode.js +54 -0
  568. package/examples/jsm/nodes/core/constants.js +21 -0
  569. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  570. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
  571. package/examples/jsm/nodes/display/ColorSpaceNode.js +95 -0
  572. package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
  573. package/examples/jsm/nodes/display/NormalMapNode.js +93 -0
  574. package/examples/jsm/nodes/display/ToneMappingNode.js +51 -0
  575. package/examples/jsm/nodes/fog/FogNode.js +31 -0
  576. package/examples/jsm/nodes/fog/FogRangeNode.js +27 -0
  577. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +33 -0
  578. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  579. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +27 -0
  580. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
  581. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +18 -0
  582. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
  583. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +94 -0
  584. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +22 -0
  585. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +12 -0
  586. package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
  587. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  588. package/examples/jsm/nodes/gpgpu/ComputeNode.js +65 -0
  589. package/examples/jsm/nodes/lighting/AONode.js +25 -0
  590. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +37 -0
  591. package/examples/jsm/nodes/lighting/EnvironmentNode.js +66 -0
  592. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +50 -0
  593. package/examples/jsm/nodes/lighting/LightingContextNode.js +75 -0
  594. package/examples/jsm/nodes/lighting/LightingNode.js +19 -0
  595. package/examples/jsm/nodes/lighting/LightsNode.js +120 -0
  596. package/examples/jsm/nodes/lighting/PunctualLightNode.js +68 -0
  597. package/examples/jsm/nodes/loaders/NodeLoader.js +107 -0
  598. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +73 -0
  599. package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
  600. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +46 -0
  601. package/examples/jsm/nodes/materials/Materials.js +53 -0
  602. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +48 -0
  603. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  604. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +168 -0
  605. package/examples/jsm/nodes/materials/NodeMaterial.js +229 -0
  606. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +52 -0
  607. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +106 -0
  608. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
  609. package/examples/jsm/nodes/materialx/MaterialXNodes.js +55 -0
  610. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
  611. package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
  612. package/examples/jsm/nodes/math/CondNode.js +60 -0
  613. package/examples/jsm/nodes/math/MathNode.js +243 -0
  614. package/examples/jsm/nodes/math/OperatorNode.js +214 -0
  615. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -0
  616. package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -0
  617. package/examples/jsm/nodes/parsers/WGSLNodeFunction.js +104 -0
  618. package/examples/jsm/nodes/parsers/WGSLNodeParser.js +14 -0
  619. package/examples/jsm/nodes/procedural/CheckerNode.js +34 -0
  620. package/examples/jsm/nodes/shadernode/ShaderNode.js +264 -0
  621. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +299 -0
  622. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +131 -0
  623. package/examples/jsm/nodes/utils/ArrayElementNode.js +31 -0
  624. package/examples/jsm/nodes/utils/ConvertNode.js +47 -0
  625. package/examples/jsm/nodes/utils/JoinNode.js +42 -0
  626. package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
  627. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +33 -0
  628. package/examples/jsm/nodes/utils/OscNode.js +74 -0
  629. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  630. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  631. package/examples/jsm/nodes/utils/SplitNode.js +102 -0
  632. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +58 -0
  633. package/examples/jsm/nodes/utils/TimerNode.js +84 -0
  634. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  635. package/examples/jsm/objects/Lensflare.js +378 -0
  636. package/examples/jsm/objects/LightningStorm.js +245 -0
  637. package/examples/jsm/objects/MarchingCubes.js +1172 -0
  638. package/examples/jsm/objects/Reflector.js +269 -0
  639. package/examples/jsm/objects/ReflectorForSSRPass.js +349 -0
  640. package/examples/jsm/objects/Refractor.js +332 -0
  641. package/examples/jsm/objects/ShadowMesh.js +80 -0
  642. package/examples/jsm/objects/Sky.js +219 -0
  643. package/examples/jsm/objects/Water.js +329 -0
  644. package/examples/jsm/objects/Water2.js +358 -0
  645. package/examples/jsm/offscreen/jank.js +45 -0
  646. package/examples/jsm/offscreen/offscreen.js +8 -0
  647. package/examples/jsm/offscreen/scene.js +86 -0
  648. package/examples/jsm/physics/AmmoPhysics.js +286 -0
  649. package/examples/jsm/physics/OimoPhysics.js +231 -0
  650. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +369 -0
  651. package/examples/jsm/postprocessing/AfterimagePass.js +90 -0
  652. package/examples/jsm/postprocessing/BloomPass.js +150 -0
  653. package/examples/jsm/postprocessing/BokehPass.js +131 -0
  654. package/examples/jsm/postprocessing/ClearPass.js +46 -0
  655. package/examples/jsm/postprocessing/CubeTexturePass.js +78 -0
  656. package/examples/jsm/postprocessing/DotScreenPass.js +58 -0
  657. package/examples/jsm/postprocessing/EffectComposer.js +310 -0
  658. package/examples/jsm/postprocessing/FilmPass.js +59 -0
  659. package/examples/jsm/postprocessing/GlitchPass.js +118 -0
  660. package/examples/jsm/postprocessing/HalftonePass.js +77 -0
  661. package/examples/jsm/postprocessing/LUTPass.js +173 -0
  662. package/examples/jsm/postprocessing/MaskPass.js +101 -0
  663. package/examples/jsm/postprocessing/OutlinePass.js +646 -0
  664. package/examples/jsm/postprocessing/Pass.js +80 -0
  665. package/examples/jsm/postprocessing/RenderPass.js +81 -0
  666. package/examples/jsm/postprocessing/SAOPass.js +413 -0
  667. package/examples/jsm/postprocessing/SMAAPass.js +188 -0
  668. package/examples/jsm/postprocessing/SSAARenderPass.js +224 -0
  669. package/examples/jsm/postprocessing/SSAOPass.js +450 -0
  670. package/examples/jsm/postprocessing/SSRPass.js +645 -0
  671. package/examples/jsm/postprocessing/SavePass.js +62 -0
  672. package/examples/jsm/postprocessing/ShaderPass.js +68 -0
  673. package/examples/jsm/postprocessing/TAARenderPass.js +167 -0
  674. package/examples/jsm/postprocessing/TexturePass.js +60 -0
  675. package/examples/jsm/postprocessing/UnrealBloomPass.js +403 -0
  676. package/examples/jsm/renderers/CSS2DRenderer.js +210 -0
  677. package/examples/jsm/renderers/CSS3DRenderer.js +313 -0
  678. package/examples/jsm/renderers/Projector.js +918 -0
  679. package/examples/jsm/renderers/SVGRenderer.js +553 -0
  680. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +26 -0
  681. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +733 -0
  682. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +49 -0
  683. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +129 -0
  684. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +144 -0
  685. package/examples/jsm/renderers/webgpu/WebGPUBinding.js +22 -0
  686. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +255 -0
  687. package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +43 -0
  688. package/examples/jsm/renderers/webgpu/WebGPUBufferUtils.js +33 -0
  689. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +78 -0
  690. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +82 -0
  691. package/examples/jsm/renderers/webgpu/WebGPUInfo.js +74 -0
  692. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +36 -0
  693. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +22 -0
  694. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +38 -0
  695. package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +199 -0
  696. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +735 -0
  697. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +296 -0
  698. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
  699. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +969 -0
  700. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +73 -0
  701. package/examples/jsm/renderers/webgpu/WebGPUSampler.js +29 -0
  702. package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +20 -0
  703. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +40 -0
  704. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +183 -0
  705. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +794 -0
  706. package/examples/jsm/renderers/webgpu/WebGPUUniform.js +136 -0
  707. package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +18 -0
  708. package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +299 -0
  709. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  710. package/examples/jsm/renderers/webgpu/constants.js +261 -0
  711. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +801 -0
  712. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +39 -0
  713. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampler.js +21 -0
  714. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniform.js +135 -0
  715. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +83 -0
  716. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +87 -0
  717. package/examples/jsm/shaders/AfterimageShader.js +56 -0
  718. package/examples/jsm/shaders/BasicShader.js +27 -0
  719. package/examples/jsm/shaders/BleachBypassShader.js +60 -0
  720. package/examples/jsm/shaders/BlendShader.js +48 -0
  721. package/examples/jsm/shaders/BokehShader.js +143 -0
  722. package/examples/jsm/shaders/BokehShader2.js +390 -0
  723. package/examples/jsm/shaders/BrightnessContrastShader.js +54 -0
  724. package/examples/jsm/shaders/ColorCorrectionShader.js +50 -0
  725. package/examples/jsm/shaders/ColorifyShader.js +49 -0
  726. package/examples/jsm/shaders/ConvolutionShader.js +101 -0
  727. package/examples/jsm/shaders/CopyShader.js +43 -0
  728. package/examples/jsm/shaders/DOFMipMapShader.js +54 -0
  729. package/examples/jsm/shaders/DepthLimitedBlurShader.js +166 -0
  730. package/examples/jsm/shaders/DigitalGlitch.js +101 -0
  731. package/examples/jsm/shaders/DotScreenShader.js +68 -0
  732. package/examples/jsm/shaders/FXAAShader.js +286 -0
  733. package/examples/jsm/shaders/FilmShader.js +100 -0
  734. package/examples/jsm/shaders/FocusShader.js +87 -0
  735. package/examples/jsm/shaders/FreiChenShader.js +94 -0
  736. package/examples/jsm/shaders/GammaCorrectionShader.js +41 -0
  737. package/examples/jsm/shaders/GodRaysShader.js +313 -0
  738. package/examples/jsm/shaders/HalftoneShader.js +310 -0
  739. package/examples/jsm/shaders/HorizontalBlurShader.js +57 -0
  740. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +61 -0
  741. package/examples/jsm/shaders/HueSaturationShader.js +65 -0
  742. package/examples/jsm/shaders/KaleidoShader.js +56 -0
  743. package/examples/jsm/shaders/LuminosityHighPassShader.js +64 -0
  744. package/examples/jsm/shaders/LuminosityShader.js +46 -0
  745. package/examples/jsm/shaders/MMDToonShader.js +123 -0
  746. package/examples/jsm/shaders/MirrorShader.js +54 -0
  747. package/examples/jsm/shaders/NormalMapShader.js +53 -0
  748. package/examples/jsm/shaders/PixelShader.js +44 -0
  749. package/examples/jsm/shaders/RGBShiftShader.js +52 -0
  750. package/examples/jsm/shaders/SAOShader.js +188 -0
  751. package/examples/jsm/shaders/SMAAShader.js +460 -0
  752. package/examples/jsm/shaders/SSAOShader.js +288 -0
  753. package/examples/jsm/shaders/SSRShader.js +364 -0
  754. package/examples/jsm/shaders/SepiaShader.js +50 -0
  755. package/examples/jsm/shaders/SobelOperatorShader.js +90 -0
  756. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +88 -0
  757. package/examples/jsm/shaders/TechnicolorShader.js +43 -0
  758. package/examples/jsm/shaders/ToneMapShader.js +73 -0
  759. package/examples/jsm/shaders/ToonShader.js +318 -0
  760. package/examples/jsm/shaders/TriangleBlurShader.js +72 -0
  761. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +45 -0
  762. package/examples/jsm/shaders/VerticalBlurShader.js +57 -0
  763. package/examples/jsm/shaders/VerticalTiltShiftShader.js +61 -0
  764. package/examples/jsm/shaders/VignetteShader.js +49 -0
  765. package/examples/jsm/shaders/VolumeShader.js +289 -0
  766. package/examples/jsm/shaders/WaterRefractionShader.js +90 -0
  767. package/examples/jsm/textures/FlakesTexture.js +40 -0
  768. package/examples/jsm/utils/BufferGeometryUtils.js +1222 -0
  769. package/examples/jsm/utils/CameraUtils.js +73 -0
  770. package/examples/jsm/utils/GPUStatsPanel.js +128 -0
  771. package/examples/jsm/utils/GeometryCompressionUtils.js +639 -0
  772. package/examples/jsm/utils/GeometryUtils.js +221 -0
  773. package/examples/jsm/utils/LDrawUtils.js +202 -0
  774. package/examples/jsm/utils/PackedPhongMaterial.js +251 -0
  775. package/examples/jsm/utils/SceneUtils.js +125 -0
  776. package/examples/jsm/utils/ShadowMapViewer.js +210 -0
  777. package/examples/jsm/utils/SkeletonUtils.js +596 -0
  778. package/examples/jsm/utils/UVsDebug.js +165 -0
  779. package/examples/jsm/utils/WorkerPool.js +102 -0
  780. package/examples/jsm/webxr/ARButton.js +208 -0
  781. package/examples/jsm/webxr/OculusHandModel.js +108 -0
  782. package/examples/jsm/webxr/OculusHandPointerModel.js +394 -0
  783. package/examples/jsm/webxr/Text2D.js +38 -0
  784. package/examples/jsm/webxr/VRButton.js +201 -0
  785. package/examples/jsm/webxr/XRControllerModelFactory.js +310 -0
  786. package/examples/jsm/webxr/XREstimatedLight.js +223 -0
  787. package/examples/jsm/webxr/XRHandMeshModel.js +108 -0
  788. package/examples/jsm/webxr/XRHandModelFactory.js +105 -0
  789. package/examples/jsm/webxr/XRHandPrimitiveModel.js +103 -0
  790. package/package.json +179 -0
  791. package/src/Three.Legacy.js +320 -0
  792. package/src/Three.js +180 -0
  793. package/src/animation/AnimationAction.js +700 -0
  794. package/src/animation/AnimationClip.js +473 -0
  795. package/src/animation/AnimationMixer.js +770 -0
  796. package/src/animation/AnimationObjectGroup.js +387 -0
  797. package/src/animation/AnimationUtils.js +361 -0
  798. package/src/animation/KeyframeTrack.js +462 -0
  799. package/src/animation/PropertyBinding.js +719 -0
  800. package/src/animation/PropertyMixer.js +318 -0
  801. package/src/animation/tracks/BooleanKeyframeTrack.js +19 -0
  802. package/src/animation/tracks/ColorKeyframeTrack.js +15 -0
  803. package/src/animation/tracks/NumberKeyframeTrack.js +12 -0
  804. package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -0
  805. package/src/animation/tracks/StringKeyframeTrack.js +15 -0
  806. package/src/animation/tracks/VectorKeyframeTrack.js +12 -0
  807. package/src/audio/Audio.js +391 -0
  808. package/src/audio/AudioAnalyser.js +40 -0
  809. package/src/audio/AudioContext.js +25 -0
  810. package/src/audio/AudioListener.js +137 -0
  811. package/src/audio/PositionalAudio.js +138 -0
  812. package/src/cameras/ArrayCamera.js +17 -0
  813. package/src/cameras/Camera.js +68 -0
  814. package/src/cameras/CubeCamera.js +107 -0
  815. package/src/cameras/OrthographicCamera.js +136 -0
  816. package/src/cameras/PerspectiveCamera.js +233 -0
  817. package/src/cameras/StereoCamera.js +100 -0
  818. package/src/constants.js +181 -0
  819. package/src/core/BufferAttribute.js +493 -0
  820. package/src/core/BufferGeometry.js +1092 -0
  821. package/src/core/Clock.js +74 -0
  822. package/src/core/EventDispatcher.js +87 -0
  823. package/src/core/GLBufferAttribute.js +58 -0
  824. package/src/core/InstancedBufferAttribute.js +39 -0
  825. package/src/core/InstancedBufferGeometry.js +46 -0
  826. package/src/core/InstancedInterleavedBuffer.js +48 -0
  827. package/src/core/InterleavedBuffer.js +145 -0
  828. package/src/core/InterleavedBufferAttribute.js +331 -0
  829. package/src/core/Layers.js +60 -0
  830. package/src/core/Object3D.js +944 -0
  831. package/src/core/Raycaster.js +110 -0
  832. package/src/core/Uniform.js +17 -0
  833. package/src/core/UniformsGroup.js +92 -0
  834. package/src/extras/DataUtils.js +170 -0
  835. package/src/extras/Earcut.js +789 -0
  836. package/src/extras/ImageUtils.js +129 -0
  837. package/src/extras/PMREMGenerator.js +900 -0
  838. package/src/extras/ShapeUtils.js +92 -0
  839. package/src/extras/core/Curve.js +416 -0
  840. package/src/extras/core/CurvePath.js +252 -0
  841. package/src/extras/core/Interpolations.js +79 -0
  842. package/src/extras/core/Path.js +196 -0
  843. package/src/extras/core/Shape.js +102 -0
  844. package/src/extras/core/ShapePath.js +291 -0
  845. package/src/extras/curves/ArcCurve.js +17 -0
  846. package/src/extras/curves/CatmullRomCurve3.js +255 -0
  847. package/src/extras/curves/CubicBezierCurve.js +78 -0
  848. package/src/extras/curves/CubicBezierCurve3.js +79 -0
  849. package/src/extras/curves/Curves.js +10 -0
  850. package/src/extras/curves/EllipseCurve.js +156 -0
  851. package/src/extras/curves/LineCurve.js +90 -0
  852. package/src/extras/curves/LineCurve3.js +75 -0
  853. package/src/extras/curves/QuadraticBezierCurve.js +74 -0
  854. package/src/extras/curves/QuadraticBezierCurve3.js +75 -0
  855. package/src/extras/curves/SplineCurve.js +97 -0
  856. package/src/geometries/BoxGeometry.js +170 -0
  857. package/src/geometries/CapsuleGeometry.js +33 -0
  858. package/src/geometries/CircleGeometry.js +91 -0
  859. package/src/geometries/ConeGeometry.js +31 -0
  860. package/src/geometries/CylinderGeometry.js +276 -0
  861. package/src/geometries/DodecahedronGeometry.js +66 -0
  862. package/src/geometries/EdgesGeometry.js +142 -0
  863. package/src/geometries/ExtrudeGeometry.js +804 -0
  864. package/src/geometries/Geometries.js +21 -0
  865. package/src/geometries/IcosahedronGeometry.js +42 -0
  866. package/src/geometries/LatheGeometry.js +179 -0
  867. package/src/geometries/OctahedronGeometry.js +37 -0
  868. package/src/geometries/PlaneGeometry.js +88 -0
  869. package/src/geometries/PolyhedronGeometry.js +309 -0
  870. package/src/geometries/RingGeometry.js +118 -0
  871. package/src/geometries/ShapeGeometry.js +185 -0
  872. package/src/geometries/SphereGeometry.js +127 -0
  873. package/src/geometries/TetrahedronGeometry.js +34 -0
  874. package/src/geometries/TorusGeometry.js +110 -0
  875. package/src/geometries/TorusKnotGeometry.js +157 -0
  876. package/src/geometries/TubeGeometry.js +193 -0
  877. package/src/geometries/WireframeGeometry.js +137 -0
  878. package/src/helpers/ArrowHelper.js +114 -0
  879. package/src/helpers/AxesHelper.js +68 -0
  880. package/src/helpers/Box3Helper.js +56 -0
  881. package/src/helpers/BoxHelper.js +113 -0
  882. package/src/helpers/CameraHelper.js +269 -0
  883. package/src/helpers/DirectionalLightHelper.js +89 -0
  884. package/src/helpers/GridHelper.js +56 -0
  885. package/src/helpers/HemisphereLightHelper.js +85 -0
  886. package/src/helpers/PlaneHelper.js +63 -0
  887. package/src/helpers/PointLightHelper.js +91 -0
  888. package/src/helpers/PolarGridHelper.js +96 -0
  889. package/src/helpers/SkeletonHelper.js +128 -0
  890. package/src/helpers/SpotLightHelper.js +92 -0
  891. package/src/lights/AmbientLight.js +17 -0
  892. package/src/lights/AmbientLightProbe.js +21 -0
  893. package/src/lights/DirectionalLight.js +43 -0
  894. package/src/lights/DirectionalLightShadow.js +16 -0
  895. package/src/lights/HemisphereLight.js +34 -0
  896. package/src/lights/HemisphereLightProbe.js +30 -0
  897. package/src/lights/Light.js +58 -0
  898. package/src/lights/LightProbe.js +47 -0
  899. package/src/lights/LightShadow.js +147 -0
  900. package/src/lights/PointLight.js +57 -0
  901. package/src/lights/PointLightShadow.js +96 -0
  902. package/src/lights/RectAreaLight.js +56 -0
  903. package/src/lights/SpotLight.js +71 -0
  904. package/src/lights/SpotLightShadow.js +50 -0
  905. package/src/loaders/AnimationLoader.js +66 -0
  906. package/src/loaders/AudioLoader.js +60 -0
  907. package/src/loaders/BufferGeometryLoader.js +224 -0
  908. package/src/loaders/Cache.js +42 -0
  909. package/src/loaders/CompressedTextureLoader.js +134 -0
  910. package/src/loaders/CubeTextureLoader.js +56 -0
  911. package/src/loaders/DataTextureLoader.js +114 -0
  912. package/src/loaders/FileLoader.js +281 -0
  913. package/src/loaders/ImageBitmapLoader.js +99 -0
  914. package/src/loaders/ImageLoader.js +91 -0
  915. package/src/loaders/Loader.js +70 -0
  916. package/src/loaders/LoaderUtils.js +75 -0
  917. package/src/loaders/LoadingManager.js +142 -0
  918. package/src/loaders/MaterialLoader.js +355 -0
  919. package/src/loaders/ObjectLoader.js +1081 -0
  920. package/src/loaders/TextureLoader.js +41 -0
  921. package/src/materials/LineBasicMaterial.js +45 -0
  922. package/src/materials/LineDashedMaterial.js +35 -0
  923. package/src/materials/Material.js +493 -0
  924. package/src/materials/Materials.js +39 -0
  925. package/src/materials/MeshBasicMaterial.js +81 -0
  926. package/src/materials/MeshDepthMaterial.js +54 -0
  927. package/src/materials/MeshDistanceMaterial.js +52 -0
  928. package/src/materials/MeshLambertMaterial.js +116 -0
  929. package/src/materials/MeshMatcapMaterial.js +81 -0
  930. package/src/materials/MeshNormalMaterial.js +61 -0
  931. package/src/materials/MeshPhongMaterial.js +120 -0
  932. package/src/materials/MeshPhysicalMaterial.js +198 -0
  933. package/src/materials/MeshStandardMaterial.js +124 -0
  934. package/src/materials/MeshToonMaterial.js +102 -0
  935. package/src/materials/PointsMaterial.js +50 -0
  936. package/src/materials/RawShaderMaterial.js +17 -0
  937. package/src/materials/ShaderMaterial.js +182 -0
  938. package/src/materials/ShadowMaterial.js +37 -0
  939. package/src/materials/SpriteMaterial.js +54 -0
  940. package/src/math/Box2.js +203 -0
  941. package/src/math/Box3.js +532 -0
  942. package/src/math/Color.js +605 -0
  943. package/src/math/ColorManagement.js +74 -0
  944. package/src/math/Cylindrical.js +61 -0
  945. package/src/math/Euler.js +324 -0
  946. package/src/math/Frustum.js +162 -0
  947. package/src/math/Interpolant.js +241 -0
  948. package/src/math/Line3.js +115 -0
  949. package/src/math/MathUtils.js +321 -0
  950. package/src/math/Matrix3.js +333 -0
  951. package/src/math/Matrix4.js +860 -0
  952. package/src/math/Plane.js +205 -0
  953. package/src/math/Quaternion.js +678 -0
  954. package/src/math/Ray.js +496 -0
  955. package/src/math/Sphere.js +250 -0
  956. package/src/math/Spherical.js +86 -0
  957. package/src/math/SphericalHarmonics3.js +243 -0
  958. package/src/math/Triangle.js +299 -0
  959. package/src/math/Vector2.js +464 -0
  960. package/src/math/Vector3.js +715 -0
  961. package/src/math/Vector4.js +644 -0
  962. package/src/math/interpolants/CubicInterpolant.js +151 -0
  963. package/src/math/interpolants/DiscreteInterpolant.js +26 -0
  964. package/src/math/interpolants/LinearInterpolant.js +38 -0
  965. package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  966. package/src/objects/Bone.js +17 -0
  967. package/src/objects/Group.js +17 -0
  968. package/src/objects/InstancedMesh.js +126 -0
  969. package/src/objects/LOD.js +195 -0
  970. package/src/objects/Line.js +222 -0
  971. package/src/objects/LineLoop.js +17 -0
  972. package/src/objects/LineSegments.js +55 -0
  973. package/src/objects/Mesh.js +397 -0
  974. package/src/objects/Points.js +166 -0
  975. package/src/objects/Skeleton.js +281 -0
  976. package/src/objects/SkinnedMesh.js +151 -0
  977. package/src/objects/Sprite.js +181 -0
  978. package/src/renderers/WebGL1Renderer.js +7 -0
  979. package/src/renderers/WebGL3DRenderTarget.js +22 -0
  980. package/src/renderers/WebGLArrayRenderTarget.js +22 -0
  981. package/src/renderers/WebGLCubeRenderTarget.js +146 -0
  982. package/src/renderers/WebGLMultipleRenderTargets.js +82 -0
  983. package/src/renderers/WebGLRenderTarget.js +110 -0
  984. package/src/renderers/WebGLRenderer.js +2280 -0
  985. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  986. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  987. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +7 -0
  988. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  989. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +18 -0
  990. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  991. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +3 -0
  992. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  993. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +304 -0
  994. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +42 -0
  995. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  996. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +18 -0
  997. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  998. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +33 -0
  999. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  1000. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  1001. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  1002. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -0
  1003. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -0
  1004. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -0
  1005. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -0
  1006. package/src/renderers/shaders/ShaderChunk/common.glsl.js +118 -0
  1007. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +191 -0
  1008. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  1009. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1010. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +36 -0
  1011. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1012. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1013. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1014. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1015. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -0
  1016. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js +3 -0
  1018. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +11 -0
  1019. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +66 -0
  1021. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1022. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1023. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +46 -0
  1024. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1025. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1026. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1027. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1028. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1030. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +121 -0
  1031. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1032. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -0
  1033. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1034. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +199 -0
  1035. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -0
  1036. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +32 -0
  1037. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1038. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
  1039. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +223 -0
  1040. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1041. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +34 -0
  1042. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +120 -0
  1043. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +264 -0
  1044. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1045. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +28 -0
  1046. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1047. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1048. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -0
  1050. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1051. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1052. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +19 -0
  1053. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +19 -0
  1054. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1055. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1056. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1057. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -0
  1058. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -0
  1059. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -0
  1060. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +46 -0
  1061. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +41 -0
  1062. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1063. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1064. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1065. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1066. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +12 -0
  1067. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +54 -0
  1068. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -0
  1069. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +13 -0
  1070. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1071. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +321 -0
  1073. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -0
  1074. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +63 -0
  1075. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1076. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1077. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +33 -0
  1078. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1079. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1080. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1081. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1082. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1083. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +77 -0
  1084. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1085. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +116 -0
  1086. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +7 -0
  1087. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +10 -0
  1088. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +7 -0
  1089. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +7 -0
  1090. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +17 -0
  1091. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +7 -0
  1092. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +15 -0
  1093. package/src/renderers/shaders/ShaderChunk.js +265 -0
  1094. package/src/renderers/shaders/ShaderLib/background.glsl.js +35 -0
  1095. package/src/renderers/shaders/ShaderLib/cube.glsl.js +38 -0
  1096. package/src/renderers/shaders/ShaderLib/depth.glsl.js +92 -0
  1097. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +73 -0
  1098. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1099. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +70 -0
  1100. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +115 -0
  1101. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +123 -0
  1102. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +107 -0
  1103. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +82 -0
  1104. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +125 -0
  1105. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +216 -0
  1106. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +117 -0
  1107. package/src/renderers/shaders/ShaderLib/points.glsl.js +71 -0
  1108. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +49 -0
  1109. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1110. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -0
  1111. package/src/renderers/shaders/ShaderLib.js +331 -0
  1112. package/src/renderers/shaders/UniformsLib.js +218 -0
  1113. package/src/renderers/shaders/UniformsUtils.js +80 -0
  1114. package/src/renderers/webgl/WebGLAnimation.js +53 -0
  1115. package/src/renderers/webgl/WebGLAttributes.js +193 -0
  1116. package/src/renderers/webgl/WebGLBackground.js +228 -0
  1117. package/src/renderers/webgl/WebGLBindingStates.js +623 -0
  1118. package/src/renderers/webgl/WebGLBufferRenderer.js +61 -0
  1119. package/src/renderers/webgl/WebGLCapabilities.js +121 -0
  1120. package/src/renderers/webgl/WebGLClipping.js +167 -0
  1121. package/src/renderers/webgl/WebGLCubeMaps.js +99 -0
  1122. package/src/renderers/webgl/WebGLCubeUVMaps.js +130 -0
  1123. package/src/renderers/webgl/WebGLExtensions.js +96 -0
  1124. package/src/renderers/webgl/WebGLGeometries.js +195 -0
  1125. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +71 -0
  1126. package/src/renderers/webgl/WebGLInfo.js +72 -0
  1127. package/src/renderers/webgl/WebGLLights.js +574 -0
  1128. package/src/renderers/webgl/WebGLMaterials.js +677 -0
  1129. package/src/renderers/webgl/WebGLMorphtargets.js +300 -0
  1130. package/src/renderers/webgl/WebGLObjects.js +72 -0
  1131. package/src/renderers/webgl/WebGLProgram.js +901 -0
  1132. package/src/renderers/webgl/WebGLPrograms.js +542 -0
  1133. package/src/renderers/webgl/WebGLProperties.js +48 -0
  1134. package/src/renderers/webgl/WebGLRenderLists.js +238 -0
  1135. package/src/renderers/webgl/WebGLRenderStates.js +107 -0
  1136. package/src/renderers/webgl/WebGLShader.js +12 -0
  1137. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1138. package/src/renderers/webgl/WebGLShadowMap.js +374 -0
  1139. package/src/renderers/webgl/WebGLState.js +1263 -0
  1140. package/src/renderers/webgl/WebGLTextures.js +1944 -0
  1141. package/src/renderers/webgl/WebGLUniforms.js +1050 -0
  1142. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  1143. package/src/renderers/webgl/WebGLUtils.js +266 -0
  1144. package/src/renderers/webxr/WebXRController.js +307 -0
  1145. package/src/renderers/webxr/WebXRManager.js +731 -0
  1146. package/src/scenes/Fog.js +37 -0
  1147. package/src/scenes/FogExp2.js +34 -0
  1148. package/src/scenes/Scene.js +71 -0
  1149. package/src/textures/CanvasTexture.js +17 -0
  1150. package/src/textures/CompressedTexture.js +28 -0
  1151. package/src/textures/CubeTexture.js +33 -0
  1152. package/src/textures/Data3DTexture.js +35 -0
  1153. package/src/textures/DataArrayTexture.js +27 -0
  1154. package/src/textures/DataTexture.js +22 -0
  1155. package/src/textures/DepthTexture.js +36 -0
  1156. package/src/textures/FramebufferTexture.js +25 -0
  1157. package/src/textures/Source.js +123 -0
  1158. package/src/textures/Texture.js +308 -0
  1159. package/src/textures/VideoTexture.js +55 -0
  1160. package/src/utils.js +71 -0
@@ -0,0 +1,4159 @@
1
+ ( function () {
2
+
3
+ class GLTFLoader extends THREE.Loader {
4
+
5
+ constructor( manager ) {
6
+
7
+ super( manager );
8
+ this.dracoLoader = null;
9
+ this.ktx2Loader = null;
10
+ this.meshoptDecoder = null;
11
+ this.pluginCallbacks = [];
12
+ this.register( function ( parser ) {
13
+
14
+ return new GLTFMaterialsClearcoatExtension( parser );
15
+
16
+ } );
17
+ this.register( function ( parser ) {
18
+
19
+ return new GLTFTextureBasisUExtension( parser );
20
+
21
+ } );
22
+ this.register( function ( parser ) {
23
+
24
+ return new GLTFTextureWebPExtension( parser );
25
+
26
+ } );
27
+ this.register( function ( parser ) {
28
+
29
+ return new GLTFMaterialsSheenExtension( parser );
30
+
31
+ } );
32
+ this.register( function ( parser ) {
33
+
34
+ return new GLTFMaterialsTransmissionExtension( parser );
35
+
36
+ } );
37
+ this.register( function ( parser ) {
38
+
39
+ return new GLTFMaterialsVolumeExtension( parser );
40
+
41
+ } );
42
+ this.register( function ( parser ) {
43
+
44
+ return new GLTFMaterialsIorExtension( parser );
45
+
46
+ } );
47
+ this.register( function ( parser ) {
48
+
49
+ return new GLTFMaterialsEmissiveStrengthExtension( parser );
50
+
51
+ } );
52
+ this.register( function ( parser ) {
53
+
54
+ return new GLTFMaterialsSpecularExtension( parser );
55
+
56
+ } );
57
+ this.register( function ( parser ) {
58
+
59
+ return new GLTFMaterialsIridescenceExtension( parser );
60
+
61
+ } );
62
+ this.register( function ( parser ) {
63
+
64
+ return new GLTFLightsExtension( parser );
65
+
66
+ } );
67
+ this.register( function ( parser ) {
68
+
69
+ return new GLTFMeshoptCompression( parser );
70
+
71
+ } );
72
+
73
+ }
74
+
75
+ load( url, onLoad, onProgress, onError ) {
76
+
77
+ const scope = this;
78
+ let resourcePath;
79
+
80
+ if ( this.resourcePath !== '' ) {
81
+
82
+ resourcePath = this.resourcePath;
83
+
84
+ } else if ( this.path !== '' ) {
85
+
86
+ resourcePath = this.path;
87
+
88
+ } else {
89
+
90
+ resourcePath = THREE.LoaderUtils.extractUrlBase( url );
91
+
92
+ } // Tells the LoadingManager to track an extra item, which resolves after
93
+ // the model is fully loaded. This means the count of items loaded will
94
+ // be incorrect, but ensures manager.onLoad() does not fire early.
95
+
96
+
97
+ this.manager.itemStart( url );
98
+
99
+ const _onError = function ( e ) {
100
+
101
+ if ( onError ) {
102
+
103
+ onError( e );
104
+
105
+ } else {
106
+
107
+ console.error( e );
108
+
109
+ }
110
+
111
+ scope.manager.itemError( url );
112
+ scope.manager.itemEnd( url );
113
+
114
+ };
115
+
116
+ const loader = new THREE.FileLoader( this.manager );
117
+ loader.setPath( this.path );
118
+ loader.setResponseType( 'arraybuffer' );
119
+ loader.setRequestHeader( this.requestHeader );
120
+ loader.setWithCredentials( this.withCredentials );
121
+ loader.load( url, function ( data ) {
122
+
123
+ try {
124
+
125
+ scope.parse( data, resourcePath, function ( gltf ) {
126
+
127
+ onLoad( gltf );
128
+ scope.manager.itemEnd( url );
129
+
130
+ }, _onError );
131
+
132
+ } catch ( e ) {
133
+
134
+ _onError( e );
135
+
136
+ }
137
+
138
+ }, onProgress, _onError );
139
+
140
+ }
141
+
142
+ setDRACOLoader( dracoLoader ) {
143
+
144
+ this.dracoLoader = dracoLoader;
145
+ return this;
146
+
147
+ }
148
+
149
+ setDDSLoader() {
150
+
151
+ throw new Error( 'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".' );
152
+
153
+ }
154
+
155
+ setKTX2Loader( ktx2Loader ) {
156
+
157
+ this.ktx2Loader = ktx2Loader;
158
+ return this;
159
+
160
+ }
161
+
162
+ setMeshoptDecoder( meshoptDecoder ) {
163
+
164
+ this.meshoptDecoder = meshoptDecoder;
165
+ return this;
166
+
167
+ }
168
+
169
+ register( callback ) {
170
+
171
+ if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
172
+
173
+ this.pluginCallbacks.push( callback );
174
+
175
+ }
176
+
177
+ return this;
178
+
179
+ }
180
+
181
+ unregister( callback ) {
182
+
183
+ if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
184
+
185
+ this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 );
186
+
187
+ }
188
+
189
+ return this;
190
+
191
+ }
192
+
193
+ parse( data, path, onLoad, onError ) {
194
+
195
+ let content;
196
+ const extensions = {};
197
+ const plugins = {};
198
+
199
+ if ( typeof data === 'string' ) {
200
+
201
+ content = data;
202
+
203
+ } else {
204
+
205
+ const magic = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
206
+
207
+ if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
208
+
209
+ try {
210
+
211
+ extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
212
+
213
+ } catch ( error ) {
214
+
215
+ if ( onError ) onError( error );
216
+ return;
217
+
218
+ }
219
+
220
+ content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
221
+
222
+ } else {
223
+
224
+ content = THREE.LoaderUtils.decodeText( new Uint8Array( data ) );
225
+
226
+ }
227
+
228
+ }
229
+
230
+ const json = JSON.parse( content );
231
+
232
+ if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
233
+
234
+ if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
235
+ return;
236
+
237
+ }
238
+
239
+ const parser = new GLTFParser( json, {
240
+ path: path || this.resourcePath || '',
241
+ crossOrigin: this.crossOrigin,
242
+ requestHeader: this.requestHeader,
243
+ manager: this.manager,
244
+ ktx2Loader: this.ktx2Loader,
245
+ meshoptDecoder: this.meshoptDecoder
246
+ } );
247
+ parser.fileLoader.setRequestHeader( this.requestHeader );
248
+
249
+ for ( let i = 0; i < this.pluginCallbacks.length; i ++ ) {
250
+
251
+ const plugin = this.pluginCallbacks[ i ]( parser );
252
+ plugins[ plugin.name ] = plugin; // Workaround to avoid determining as unknown extension
253
+ // in addUnknownExtensionsToUserData().
254
+ // Remove this workaround if we move all the existing
255
+ // extension handlers to plugin system
256
+
257
+ extensions[ plugin.name ] = true;
258
+
259
+ }
260
+
261
+ if ( json.extensionsUsed ) {
262
+
263
+ for ( let i = 0; i < json.extensionsUsed.length; ++ i ) {
264
+
265
+ const extensionName = json.extensionsUsed[ i ];
266
+ const extensionsRequired = json.extensionsRequired || [];
267
+
268
+ switch ( extensionName ) {
269
+
270
+ case EXTENSIONS.KHR_MATERIALS_UNLIT:
271
+ extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
272
+ break;
273
+
274
+ case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
275
+ extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
276
+ break;
277
+
278
+ case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
279
+ extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
280
+ break;
281
+
282
+ case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
283
+ extensions[ extensionName ] = new GLTFTextureTransformExtension();
284
+ break;
285
+
286
+ case EXTENSIONS.KHR_MESH_QUANTIZATION:
287
+ extensions[ extensionName ] = new GLTFMeshQuantizationExtension();
288
+ break;
289
+
290
+ default:
291
+ if ( extensionsRequired.indexOf( extensionName ) >= 0 && plugins[ extensionName ] === undefined ) {
292
+
293
+ console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' );
294
+
295
+ }
296
+
297
+ }
298
+
299
+ }
300
+
301
+ }
302
+
303
+ parser.setExtensions( extensions );
304
+ parser.setPlugins( plugins );
305
+ parser.parse( onLoad, onError );
306
+
307
+ }
308
+
309
+ parseAsync( data, path ) {
310
+
311
+ const scope = this;
312
+ return new Promise( function ( resolve, reject ) {
313
+
314
+ scope.parse( data, path, resolve, reject );
315
+
316
+ } );
317
+
318
+ }
319
+
320
+ }
321
+ /* GLTFREGISTRY */
322
+
323
+
324
+ function GLTFRegistry() {
325
+
326
+ let objects = {};
327
+ return {
328
+ get: function ( key ) {
329
+
330
+ return objects[ key ];
331
+
332
+ },
333
+ add: function ( key, object ) {
334
+
335
+ objects[ key ] = object;
336
+
337
+ },
338
+ remove: function ( key ) {
339
+
340
+ delete objects[ key ];
341
+
342
+ },
343
+ removeAll: function () {
344
+
345
+ objects = {};
346
+
347
+ }
348
+ };
349
+
350
+ }
351
+ /*********************************/
352
+
353
+ /********** EXTENSIONS ***********/
354
+
355
+ /*********************************/
356
+
357
+
358
+ const EXTENSIONS = {
359
+ KHR_BINARY_GLTF: 'KHR_binary_glTF',
360
+ KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
361
+ KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
362
+ KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
363
+ KHR_MATERIALS_IOR: 'KHR_materials_ior',
364
+ KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
365
+ KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
366
+ KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
367
+ KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
368
+ KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
369
+ KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
370
+ KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
371
+ KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
372
+ KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
373
+ KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
374
+ KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
375
+ EXT_TEXTURE_WEBP: 'EXT_texture_webp',
376
+ EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression'
377
+ };
378
+ /**
379
+ * Punctual Lights Extension
380
+ *
381
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
382
+ */
383
+
384
+ class GLTFLightsExtension {
385
+
386
+ constructor( parser ) {
387
+
388
+ this.parser = parser;
389
+ this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL; // THREE.Object3D instance caches
390
+
391
+ this.cache = {
392
+ refs: {},
393
+ uses: {}
394
+ };
395
+
396
+ }
397
+
398
+ _markDefs() {
399
+
400
+ const parser = this.parser;
401
+ const nodeDefs = this.parser.json.nodes || [];
402
+
403
+ for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
404
+
405
+ const nodeDef = nodeDefs[ nodeIndex ];
406
+
407
+ if ( nodeDef.extensions && nodeDef.extensions[ this.name ] && nodeDef.extensions[ this.name ].light !== undefined ) {
408
+
409
+ parser._addNodeRef( this.cache, nodeDef.extensions[ this.name ].light );
410
+
411
+ }
412
+
413
+ }
414
+
415
+ }
416
+
417
+ _loadLight( lightIndex ) {
418
+
419
+ const parser = this.parser;
420
+ const cacheKey = 'light:' + lightIndex;
421
+ let dependency = parser.cache.get( cacheKey );
422
+ if ( dependency ) return dependency;
423
+ const json = parser.json;
424
+ const extensions = json.extensions && json.extensions[ this.name ] || {};
425
+ const lightDefs = extensions.lights || [];
426
+ const lightDef = lightDefs[ lightIndex ];
427
+ let lightNode;
428
+ const color = new THREE.Color( 0xffffff );
429
+ if ( lightDef.color !== undefined ) color.fromArray( lightDef.color );
430
+ const range = lightDef.range !== undefined ? lightDef.range : 0;
431
+
432
+ switch ( lightDef.type ) {
433
+
434
+ case 'directional':
435
+ lightNode = new THREE.DirectionalLight( color );
436
+ lightNode.target.position.set( 0, 0, - 1 );
437
+ lightNode.add( lightNode.target );
438
+ break;
439
+
440
+ case 'point':
441
+ lightNode = new THREE.PointLight( color );
442
+ lightNode.distance = range;
443
+ break;
444
+
445
+ case 'spot':
446
+ lightNode = new THREE.SpotLight( color );
447
+ lightNode.distance = range; // Handle spotlight properties.
448
+
449
+ lightDef.spot = lightDef.spot || {};
450
+ lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;
451
+ lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;
452
+ lightNode.angle = lightDef.spot.outerConeAngle;
453
+ lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
454
+ lightNode.target.position.set( 0, 0, - 1 );
455
+ lightNode.add( lightNode.target );
456
+ break;
457
+
458
+ default:
459
+ throw new Error( 'THREE.GLTFLoader: Unexpected light type: ' + lightDef.type );
460
+
461
+ } // Some lights (e.g. spot) default to a position other than the origin. Reset the position
462
+ // here, because node-level parsing will only override position if explicitly specified.
463
+
464
+
465
+ lightNode.position.set( 0, 0, 0 );
466
+ lightNode.decay = 2;
467
+ if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
468
+ lightNode.name = parser.createUniqueName( lightDef.name || 'light_' + lightIndex );
469
+ dependency = Promise.resolve( lightNode );
470
+ parser.cache.add( cacheKey, dependency );
471
+ return dependency;
472
+
473
+ }
474
+
475
+ createNodeAttachment( nodeIndex ) {
476
+
477
+ const self = this;
478
+ const parser = this.parser;
479
+ const json = parser.json;
480
+ const nodeDef = json.nodes[ nodeIndex ];
481
+ const lightDef = nodeDef.extensions && nodeDef.extensions[ this.name ] || {};
482
+ const lightIndex = lightDef.light;
483
+ if ( lightIndex === undefined ) return null;
484
+ return this._loadLight( lightIndex ).then( function ( light ) {
485
+
486
+ return parser._getNodeRef( self.cache, lightIndex, light );
487
+
488
+ } );
489
+
490
+ }
491
+
492
+ }
493
+ /**
494
+ * Unlit Materials Extension
495
+ *
496
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
497
+ */
498
+
499
+
500
+ class GLTFMaterialsUnlitExtension {
501
+
502
+ constructor() {
503
+
504
+ this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
505
+
506
+ }
507
+
508
+ getMaterialType() {
509
+
510
+ return THREE.MeshBasicMaterial;
511
+
512
+ }
513
+
514
+ extendParams( materialParams, materialDef, parser ) {
515
+
516
+ const pending = [];
517
+ materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
518
+ materialParams.opacity = 1.0;
519
+ const metallicRoughness = materialDef.pbrMetallicRoughness;
520
+
521
+ if ( metallicRoughness ) {
522
+
523
+ if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
524
+
525
+ const array = metallicRoughness.baseColorFactor;
526
+ materialParams.color.fromArray( array );
527
+ materialParams.opacity = array[ 3 ];
528
+
529
+ }
530
+
531
+ if ( metallicRoughness.baseColorTexture !== undefined ) {
532
+
533
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, THREE.sRGBEncoding ) );
534
+
535
+ }
536
+
537
+ }
538
+
539
+ return Promise.all( pending );
540
+
541
+ }
542
+
543
+ }
544
+ /**
545
+ * Materials Emissive Strength Extension
546
+ *
547
+ * Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
548
+ */
549
+
550
+
551
+ class GLTFMaterialsEmissiveStrengthExtension {
552
+
553
+ constructor( parser ) {
554
+
555
+ this.parser = parser;
556
+ this.name = EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH;
557
+
558
+ }
559
+
560
+ extendMaterialParams( materialIndex, materialParams ) {
561
+
562
+ const parser = this.parser;
563
+ const materialDef = parser.json.materials[ materialIndex ];
564
+
565
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
566
+
567
+ return Promise.resolve();
568
+
569
+ }
570
+
571
+ const emissiveStrength = materialDef.extensions[ this.name ].emissiveStrength;
572
+
573
+ if ( emissiveStrength !== undefined ) {
574
+
575
+ materialParams.emissiveIntensity = emissiveStrength;
576
+
577
+ }
578
+
579
+ return Promise.resolve();
580
+
581
+ }
582
+
583
+ }
584
+ /**
585
+ * Clearcoat Materials Extension
586
+ *
587
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
588
+ */
589
+
590
+
591
+ class GLTFMaterialsClearcoatExtension {
592
+
593
+ constructor( parser ) {
594
+
595
+ this.parser = parser;
596
+ this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
597
+
598
+ }
599
+
600
+ getMaterialType( materialIndex ) {
601
+
602
+ const parser = this.parser;
603
+ const materialDef = parser.json.materials[ materialIndex ];
604
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
605
+ return THREE.MeshPhysicalMaterial;
606
+
607
+ }
608
+
609
+ extendMaterialParams( materialIndex, materialParams ) {
610
+
611
+ const parser = this.parser;
612
+ const materialDef = parser.json.materials[ materialIndex ];
613
+
614
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
615
+
616
+ return Promise.resolve();
617
+
618
+ }
619
+
620
+ const pending = [];
621
+ const extension = materialDef.extensions[ this.name ];
622
+
623
+ if ( extension.clearcoatFactor !== undefined ) {
624
+
625
+ materialParams.clearcoat = extension.clearcoatFactor;
626
+
627
+ }
628
+
629
+ if ( extension.clearcoatTexture !== undefined ) {
630
+
631
+ pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
632
+
633
+ }
634
+
635
+ if ( extension.clearcoatRoughnessFactor !== undefined ) {
636
+
637
+ materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
638
+
639
+ }
640
+
641
+ if ( extension.clearcoatRoughnessTexture !== undefined ) {
642
+
643
+ pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
644
+
645
+ }
646
+
647
+ if ( extension.clearcoatNormalTexture !== undefined ) {
648
+
649
+ pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
650
+
651
+ if ( extension.clearcoatNormalTexture.scale !== undefined ) {
652
+
653
+ const scale = extension.clearcoatNormalTexture.scale;
654
+ materialParams.clearcoatNormalScale = new THREE.Vector2( scale, scale );
655
+
656
+ }
657
+
658
+ }
659
+
660
+ return Promise.all( pending );
661
+
662
+ }
663
+
664
+ }
665
+ /**
666
+ * Iridescence Materials Extension
667
+ *
668
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
669
+ */
670
+
671
+
672
+ class GLTFMaterialsIridescenceExtension {
673
+
674
+ constructor( parser ) {
675
+
676
+ this.parser = parser;
677
+ this.name = EXTENSIONS.KHR_MATERIALS_IRIDESCENCE;
678
+
679
+ }
680
+
681
+ getMaterialType( materialIndex ) {
682
+
683
+ const parser = this.parser;
684
+ const materialDef = parser.json.materials[ materialIndex ];
685
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
686
+ return THREE.MeshPhysicalMaterial;
687
+
688
+ }
689
+
690
+ extendMaterialParams( materialIndex, materialParams ) {
691
+
692
+ const parser = this.parser;
693
+ const materialDef = parser.json.materials[ materialIndex ];
694
+
695
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
696
+
697
+ return Promise.resolve();
698
+
699
+ }
700
+
701
+ const pending = [];
702
+ const extension = materialDef.extensions[ this.name ];
703
+
704
+ if ( extension.iridescenceFactor !== undefined ) {
705
+
706
+ materialParams.iridescence = extension.iridescenceFactor;
707
+
708
+ }
709
+
710
+ if ( extension.iridescenceTexture !== undefined ) {
711
+
712
+ pending.push( parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
713
+
714
+ }
715
+
716
+ if ( extension.iridescenceIor !== undefined ) {
717
+
718
+ materialParams.iridescenceIOR = extension.iridescenceIor;
719
+
720
+ }
721
+
722
+ if ( materialParams.iridescenceThicknessRange === undefined ) {
723
+
724
+ materialParams.iridescenceThicknessRange = [ 100, 400 ];
725
+
726
+ }
727
+
728
+ if ( extension.iridescenceThicknessMinimum !== undefined ) {
729
+
730
+ materialParams.iridescenceThicknessRange[ 0 ] = extension.iridescenceThicknessMinimum;
731
+
732
+ }
733
+
734
+ if ( extension.iridescenceThicknessMaximum !== undefined ) {
735
+
736
+ materialParams.iridescenceThicknessRange[ 1 ] = extension.iridescenceThicknessMaximum;
737
+
738
+ }
739
+
740
+ if ( extension.iridescenceThicknessTexture !== undefined ) {
741
+
742
+ pending.push( parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
743
+
744
+ }
745
+
746
+ return Promise.all( pending );
747
+
748
+ }
749
+
750
+ }
751
+ /**
752
+ * Sheen Materials Extension
753
+ *
754
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
755
+ */
756
+
757
+
758
+ class GLTFMaterialsSheenExtension {
759
+
760
+ constructor( parser ) {
761
+
762
+ this.parser = parser;
763
+ this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
764
+
765
+ }
766
+
767
+ getMaterialType( materialIndex ) {
768
+
769
+ const parser = this.parser;
770
+ const materialDef = parser.json.materials[ materialIndex ];
771
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
772
+ return THREE.MeshPhysicalMaterial;
773
+
774
+ }
775
+
776
+ extendMaterialParams( materialIndex, materialParams ) {
777
+
778
+ const parser = this.parser;
779
+ const materialDef = parser.json.materials[ materialIndex ];
780
+
781
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
782
+
783
+ return Promise.resolve();
784
+
785
+ }
786
+
787
+ const pending = [];
788
+ materialParams.sheenColor = new THREE.Color( 0, 0, 0 );
789
+ materialParams.sheenRoughness = 0;
790
+ materialParams.sheen = 1;
791
+ const extension = materialDef.extensions[ this.name ];
792
+
793
+ if ( extension.sheenColorFactor !== undefined ) {
794
+
795
+ materialParams.sheenColor.fromArray( extension.sheenColorFactor );
796
+
797
+ }
798
+
799
+ if ( extension.sheenRoughnessFactor !== undefined ) {
800
+
801
+ materialParams.sheenRoughness = extension.sheenRoughnessFactor;
802
+
803
+ }
804
+
805
+ if ( extension.sheenColorTexture !== undefined ) {
806
+
807
+ pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, THREE.sRGBEncoding ) );
808
+
809
+ }
810
+
811
+ if ( extension.sheenRoughnessTexture !== undefined ) {
812
+
813
+ pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
814
+
815
+ }
816
+
817
+ return Promise.all( pending );
818
+
819
+ }
820
+
821
+ }
822
+ /**
823
+ * Transmission Materials Extension
824
+ *
825
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
826
+ * Draft: https://github.com/KhronosGroup/glTF/pull/1698
827
+ */
828
+
829
+
830
+ class GLTFMaterialsTransmissionExtension {
831
+
832
+ constructor( parser ) {
833
+
834
+ this.parser = parser;
835
+ this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
836
+
837
+ }
838
+
839
+ getMaterialType( materialIndex ) {
840
+
841
+ const parser = this.parser;
842
+ const materialDef = parser.json.materials[ materialIndex ];
843
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
844
+ return THREE.MeshPhysicalMaterial;
845
+
846
+ }
847
+
848
+ extendMaterialParams( materialIndex, materialParams ) {
849
+
850
+ const parser = this.parser;
851
+ const materialDef = parser.json.materials[ materialIndex ];
852
+
853
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
854
+
855
+ return Promise.resolve();
856
+
857
+ }
858
+
859
+ const pending = [];
860
+ const extension = materialDef.extensions[ this.name ];
861
+
862
+ if ( extension.transmissionFactor !== undefined ) {
863
+
864
+ materialParams.transmission = extension.transmissionFactor;
865
+
866
+ }
867
+
868
+ if ( extension.transmissionTexture !== undefined ) {
869
+
870
+ pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
871
+
872
+ }
873
+
874
+ return Promise.all( pending );
875
+
876
+ }
877
+
878
+ }
879
+ /**
880
+ * Materials Volume Extension
881
+ *
882
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
883
+ */
884
+
885
+
886
+ class GLTFMaterialsVolumeExtension {
887
+
888
+ constructor( parser ) {
889
+
890
+ this.parser = parser;
891
+ this.name = EXTENSIONS.KHR_MATERIALS_VOLUME;
892
+
893
+ }
894
+
895
+ getMaterialType( materialIndex ) {
896
+
897
+ const parser = this.parser;
898
+ const materialDef = parser.json.materials[ materialIndex ];
899
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
900
+ return THREE.MeshPhysicalMaterial;
901
+
902
+ }
903
+
904
+ extendMaterialParams( materialIndex, materialParams ) {
905
+
906
+ const parser = this.parser;
907
+ const materialDef = parser.json.materials[ materialIndex ];
908
+
909
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
910
+
911
+ return Promise.resolve();
912
+
913
+ }
914
+
915
+ const pending = [];
916
+ const extension = materialDef.extensions[ this.name ];
917
+ materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0;
918
+
919
+ if ( extension.thicknessTexture !== undefined ) {
920
+
921
+ pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
922
+
923
+ }
924
+
925
+ materialParams.attenuationDistance = extension.attenuationDistance || 0;
926
+ const colorArray = extension.attenuationColor || [ 1, 1, 1 ];
927
+ materialParams.attenuationColor = new THREE.Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] );
928
+ return Promise.all( pending );
929
+
930
+ }
931
+
932
+ }
933
+ /**
934
+ * Materials ior Extension
935
+ *
936
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
937
+ */
938
+
939
+
940
+ class GLTFMaterialsIorExtension {
941
+
942
+ constructor( parser ) {
943
+
944
+ this.parser = parser;
945
+ this.name = EXTENSIONS.KHR_MATERIALS_IOR;
946
+
947
+ }
948
+
949
+ getMaterialType( materialIndex ) {
950
+
951
+ const parser = this.parser;
952
+ const materialDef = parser.json.materials[ materialIndex ];
953
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
954
+ return THREE.MeshPhysicalMaterial;
955
+
956
+ }
957
+
958
+ extendMaterialParams( materialIndex, materialParams ) {
959
+
960
+ const parser = this.parser;
961
+ const materialDef = parser.json.materials[ materialIndex ];
962
+
963
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
964
+
965
+ return Promise.resolve();
966
+
967
+ }
968
+
969
+ const extension = materialDef.extensions[ this.name ];
970
+ materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5;
971
+ return Promise.resolve();
972
+
973
+ }
974
+
975
+ }
976
+ /**
977
+ * Materials specular Extension
978
+ *
979
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
980
+ */
981
+
982
+
983
+ class GLTFMaterialsSpecularExtension {
984
+
985
+ constructor( parser ) {
986
+
987
+ this.parser = parser;
988
+ this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR;
989
+
990
+ }
991
+
992
+ getMaterialType( materialIndex ) {
993
+
994
+ const parser = this.parser;
995
+ const materialDef = parser.json.materials[ materialIndex ];
996
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
997
+ return THREE.MeshPhysicalMaterial;
998
+
999
+ }
1000
+
1001
+ extendMaterialParams( materialIndex, materialParams ) {
1002
+
1003
+ const parser = this.parser;
1004
+ const materialDef = parser.json.materials[ materialIndex ];
1005
+
1006
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1007
+
1008
+ return Promise.resolve();
1009
+
1010
+ }
1011
+
1012
+ const pending = [];
1013
+ const extension = materialDef.extensions[ this.name ];
1014
+ materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;
1015
+
1016
+ if ( extension.specularTexture !== undefined ) {
1017
+
1018
+ pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
1019
+
1020
+ }
1021
+
1022
+ const colorArray = extension.specularColorFactor || [ 1, 1, 1 ];
1023
+ materialParams.specularColor = new THREE.Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] );
1024
+
1025
+ if ( extension.specularColorTexture !== undefined ) {
1026
+
1027
+ pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, THREE.sRGBEncoding ) );
1028
+
1029
+ }
1030
+
1031
+ return Promise.all( pending );
1032
+
1033
+ }
1034
+
1035
+ }
1036
+ /**
1037
+ * BasisU THREE.Texture Extension
1038
+ *
1039
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
1040
+ */
1041
+
1042
+
1043
+ class GLTFTextureBasisUExtension {
1044
+
1045
+ constructor( parser ) {
1046
+
1047
+ this.parser = parser;
1048
+ this.name = EXTENSIONS.KHR_TEXTURE_BASISU;
1049
+
1050
+ }
1051
+
1052
+ loadTexture( textureIndex ) {
1053
+
1054
+ const parser = this.parser;
1055
+ const json = parser.json;
1056
+ const textureDef = json.textures[ textureIndex ];
1057
+
1058
+ if ( ! textureDef.extensions || ! textureDef.extensions[ this.name ] ) {
1059
+
1060
+ return null;
1061
+
1062
+ }
1063
+
1064
+ const extension = textureDef.extensions[ this.name ];
1065
+ const loader = parser.options.ktx2Loader;
1066
+
1067
+ if ( ! loader ) {
1068
+
1069
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
1070
+
1071
+ throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
1072
+
1073
+ } else {
1074
+
1075
+ // Assumes that the extension is optional and that a fallback texture is present
1076
+ return null;
1077
+
1078
+ }
1079
+
1080
+ }
1081
+
1082
+ return parser.loadTextureImage( textureIndex, extension.source, loader );
1083
+
1084
+ }
1085
+
1086
+ }
1087
+ /**
1088
+ * WebP THREE.Texture Extension
1089
+ *
1090
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
1091
+ */
1092
+
1093
+
1094
+ class GLTFTextureWebPExtension {
1095
+
1096
+ constructor( parser ) {
1097
+
1098
+ this.parser = parser;
1099
+ this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
1100
+ this.isSupported = null;
1101
+
1102
+ }
1103
+
1104
+ loadTexture( textureIndex ) {
1105
+
1106
+ const name = this.name;
1107
+ const parser = this.parser;
1108
+ const json = parser.json;
1109
+ const textureDef = json.textures[ textureIndex ];
1110
+
1111
+ if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
1112
+
1113
+ return null;
1114
+
1115
+ }
1116
+
1117
+ const extension = textureDef.extensions[ name ];
1118
+ const source = json.images[ extension.source ];
1119
+ let loader = parser.textureLoader;
1120
+
1121
+ if ( source.uri ) {
1122
+
1123
+ const handler = parser.options.manager.getHandler( source.uri );
1124
+ if ( handler !== null ) loader = handler;
1125
+
1126
+ }
1127
+
1128
+ return this.detectSupport().then( function ( isSupported ) {
1129
+
1130
+ if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );
1131
+
1132
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
1133
+
1134
+ throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' );
1135
+
1136
+ } // Fall back to PNG or JPEG.
1137
+
1138
+
1139
+ return parser.loadTexture( textureIndex );
1140
+
1141
+ } );
1142
+
1143
+ }
1144
+
1145
+ detectSupport() {
1146
+
1147
+ if ( ! this.isSupported ) {
1148
+
1149
+ this.isSupported = new Promise( function ( resolve ) {
1150
+
1151
+ const image = new Image(); // Lossy test image. Support for lossy images doesn't guarantee support for all
1152
+ // WebP images, unfortunately.
1153
+
1154
+ image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
1155
+
1156
+ image.onload = image.onerror = function () {
1157
+
1158
+ resolve( image.height === 1 );
1159
+
1160
+ };
1161
+
1162
+ } );
1163
+
1164
+ }
1165
+
1166
+ return this.isSupported;
1167
+
1168
+ }
1169
+
1170
+ }
1171
+ /**
1172
+ * meshopt BufferView Compression Extension
1173
+ *
1174
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
1175
+ */
1176
+
1177
+
1178
+ class GLTFMeshoptCompression {
1179
+
1180
+ constructor( parser ) {
1181
+
1182
+ this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION;
1183
+ this.parser = parser;
1184
+
1185
+ }
1186
+
1187
+ loadBufferView( index ) {
1188
+
1189
+ const json = this.parser.json;
1190
+ const bufferView = json.bufferViews[ index ];
1191
+
1192
+ if ( bufferView.extensions && bufferView.extensions[ this.name ] ) {
1193
+
1194
+ const extensionDef = bufferView.extensions[ this.name ];
1195
+ const buffer = this.parser.getDependency( 'buffer', extensionDef.buffer );
1196
+ const decoder = this.parser.options.meshoptDecoder;
1197
+
1198
+ if ( ! decoder || ! decoder.supported ) {
1199
+
1200
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
1201
+
1202
+ throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' );
1203
+
1204
+ } else {
1205
+
1206
+ // Assumes that the extension is optional and that fallback buffer data is present
1207
+ return null;
1208
+
1209
+ }
1210
+
1211
+ }
1212
+
1213
+ return buffer.then( function ( res ) {
1214
+
1215
+ const byteOffset = extensionDef.byteOffset || 0;
1216
+ const byteLength = extensionDef.byteLength || 0;
1217
+ const count = extensionDef.count;
1218
+ const stride = extensionDef.byteStride;
1219
+ const source = new Uint8Array( res, byteOffset, byteLength );
1220
+
1221
+ if ( decoder.decodeGltfBufferAsync ) {
1222
+
1223
+ return decoder.decodeGltfBufferAsync( count, stride, source, extensionDef.mode, extensionDef.filter ).then( function ( res ) {
1224
+
1225
+ return res.buffer;
1226
+
1227
+ } );
1228
+
1229
+ } else {
1230
+
1231
+ // Support for MeshoptDecoder 0.18 or earlier, without decodeGltfBufferAsync
1232
+ return decoder.ready.then( function () {
1233
+
1234
+ const result = new ArrayBuffer( count * stride );
1235
+ decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter );
1236
+ return result;
1237
+
1238
+ } );
1239
+
1240
+ }
1241
+
1242
+ } );
1243
+
1244
+ } else {
1245
+
1246
+ return null;
1247
+
1248
+ }
1249
+
1250
+ }
1251
+
1252
+ }
1253
+ /* BINARY EXTENSION */
1254
+
1255
+
1256
+ const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
1257
+ const BINARY_EXTENSION_HEADER_LENGTH = 12;
1258
+ const BINARY_EXTENSION_CHUNK_TYPES = {
1259
+ JSON: 0x4E4F534A,
1260
+ BIN: 0x004E4942
1261
+ };
1262
+
1263
+ class GLTFBinaryExtension {
1264
+
1265
+ constructor( data ) {
1266
+
1267
+ this.name = EXTENSIONS.KHR_BINARY_GLTF;
1268
+ this.content = null;
1269
+ this.body = null;
1270
+ const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
1271
+ this.header = {
1272
+ magic: THREE.LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ),
1273
+ version: headerView.getUint32( 4, true ),
1274
+ length: headerView.getUint32( 8, true )
1275
+ };
1276
+
1277
+ if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) {
1278
+
1279
+ throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' );
1280
+
1281
+ } else if ( this.header.version < 2.0 ) {
1282
+
1283
+ throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
1284
+
1285
+ }
1286
+
1287
+ const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH;
1288
+ const chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH );
1289
+ let chunkIndex = 0;
1290
+
1291
+ while ( chunkIndex < chunkContentsLength ) {
1292
+
1293
+ const chunkLength = chunkView.getUint32( chunkIndex, true );
1294
+ chunkIndex += 4;
1295
+ const chunkType = chunkView.getUint32( chunkIndex, true );
1296
+ chunkIndex += 4;
1297
+
1298
+ if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
1299
+
1300
+ const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
1301
+ this.content = THREE.LoaderUtils.decodeText( contentArray );
1302
+
1303
+ } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
1304
+
1305
+ const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
1306
+ this.body = data.slice( byteOffset, byteOffset + chunkLength );
1307
+
1308
+ } // Clients must ignore chunks with unknown types.
1309
+
1310
+
1311
+ chunkIndex += chunkLength;
1312
+
1313
+ }
1314
+
1315
+ if ( this.content === null ) {
1316
+
1317
+ throw new Error( 'THREE.GLTFLoader: JSON content not found.' );
1318
+
1319
+ }
1320
+
1321
+ }
1322
+
1323
+ }
1324
+ /**
1325
+ * DRACO THREE.Mesh Compression Extension
1326
+ *
1327
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
1328
+ */
1329
+
1330
+
1331
+ class GLTFDracoMeshCompressionExtension {
1332
+
1333
+ constructor( json, dracoLoader ) {
1334
+
1335
+ if ( ! dracoLoader ) {
1336
+
1337
+ throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' );
1338
+
1339
+ }
1340
+
1341
+ this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
1342
+ this.json = json;
1343
+ this.dracoLoader = dracoLoader;
1344
+ this.dracoLoader.preload();
1345
+
1346
+ }
1347
+
1348
+ decodePrimitive( primitive, parser ) {
1349
+
1350
+ const json = this.json;
1351
+ const dracoLoader = this.dracoLoader;
1352
+ const bufferViewIndex = primitive.extensions[ this.name ].bufferView;
1353
+ const gltfAttributeMap = primitive.extensions[ this.name ].attributes;
1354
+ const threeAttributeMap = {};
1355
+ const attributeNormalizedMap = {};
1356
+ const attributeTypeMap = {};
1357
+
1358
+ for ( const attributeName in gltfAttributeMap ) {
1359
+
1360
+ const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
1361
+ threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ];
1362
+
1363
+ }
1364
+
1365
+ for ( const attributeName in primitive.attributes ) {
1366
+
1367
+ const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
1368
+
1369
+ if ( gltfAttributeMap[ attributeName ] !== undefined ) {
1370
+
1371
+ const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
1372
+ const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
1373
+ attributeTypeMap[ threeAttributeName ] = componentType.name;
1374
+ attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
1375
+
1376
+ }
1377
+
1378
+ }
1379
+
1380
+ return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) {
1381
+
1382
+ return new Promise( function ( resolve ) {
1383
+
1384
+ dracoLoader.decodeDracoFile( bufferView, function ( geometry ) {
1385
+
1386
+ for ( const attributeName in geometry.attributes ) {
1387
+
1388
+ const attribute = geometry.attributes[ attributeName ];
1389
+ const normalized = attributeNormalizedMap[ attributeName ];
1390
+ if ( normalized !== undefined ) attribute.normalized = normalized;
1391
+
1392
+ }
1393
+
1394
+ resolve( geometry );
1395
+
1396
+ }, threeAttributeMap, attributeTypeMap );
1397
+
1398
+ } );
1399
+
1400
+ } );
1401
+
1402
+ }
1403
+
1404
+ }
1405
+ /**
1406
+ * THREE.Texture Transform Extension
1407
+ *
1408
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
1409
+ */
1410
+
1411
+
1412
+ class GLTFTextureTransformExtension {
1413
+
1414
+ constructor() {
1415
+
1416
+ this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
1417
+
1418
+ }
1419
+
1420
+ extendTexture( texture, transform ) {
1421
+
1422
+ if ( transform.texCoord !== undefined ) {
1423
+
1424
+ console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
1425
+
1426
+ }
1427
+
1428
+ if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) {
1429
+
1430
+ // See https://github.com/mrdoob/three.js/issues/21819.
1431
+ return texture;
1432
+
1433
+ }
1434
+
1435
+ texture = texture.clone();
1436
+
1437
+ if ( transform.offset !== undefined ) {
1438
+
1439
+ texture.offset.fromArray( transform.offset );
1440
+
1441
+ }
1442
+
1443
+ if ( transform.rotation !== undefined ) {
1444
+
1445
+ texture.rotation = transform.rotation;
1446
+
1447
+ }
1448
+
1449
+ if ( transform.scale !== undefined ) {
1450
+
1451
+ texture.repeat.fromArray( transform.scale );
1452
+
1453
+ }
1454
+
1455
+ texture.needsUpdate = true;
1456
+ return texture;
1457
+
1458
+ }
1459
+
1460
+ }
1461
+ /**
1462
+ * Specular-Glossiness Extension
1463
+ *
1464
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness
1465
+ */
1466
+
1467
+ /**
1468
+ * A sub class of StandardMaterial with some of the functionality
1469
+ * changed via the `onBeforeCompile` callback
1470
+ * @pailhead
1471
+ */
1472
+
1473
+
1474
+ class GLTFMeshStandardSGMaterial extends THREE.MeshStandardMaterial {
1475
+
1476
+ constructor( params ) {
1477
+
1478
+ super();
1479
+ this.isGLTFSpecularGlossinessMaterial = true; //various chunks that need replacing
1480
+
1481
+ const specularMapParsFragmentChunk = [ '#ifdef USE_SPECULARMAP', ' uniform sampler2D specularMap;', '#endif' ].join( '\n' );
1482
+ const glossinessMapParsFragmentChunk = [ '#ifdef USE_GLOSSINESSMAP', ' uniform sampler2D glossinessMap;', '#endif' ].join( '\n' );
1483
+ const specularMapFragmentChunk = [ 'vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', ' vec4 texelSpecular = texture2D( specularMap, vUv );', ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', ' specularFactor *= texelSpecular.rgb;', '#endif' ].join( '\n' );
1484
+ const glossinessMapFragmentChunk = [ 'float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );', ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', ' glossinessFactor *= texelGlossiness.a;', '#endif' ].join( '\n' );
1485
+ const lightPhysicalFragmentChunk = [ 'PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', 'material.roughness += geometryRoughness;', 'material.roughness = min( material.roughness, 1.0 );', 'material.specularColor = specularFactor;' ].join( '\n' );
1486
+ const uniforms = {
1487
+ specular: {
1488
+ value: new THREE.Color().setHex( 0xffffff )
1489
+ },
1490
+ glossiness: {
1491
+ value: 1
1492
+ },
1493
+ specularMap: {
1494
+ value: null
1495
+ },
1496
+ glossinessMap: {
1497
+ value: null
1498
+ }
1499
+ };
1500
+ this._extraUniforms = uniforms;
1501
+
1502
+ this.onBeforeCompile = function ( shader ) {
1503
+
1504
+ for ( const uniformName in uniforms ) {
1505
+
1506
+ shader.uniforms[ uniformName ] = uniforms[ uniformName ];
1507
+
1508
+ }
1509
+
1510
+ shader.fragmentShader = shader.fragmentShader.replace( 'uniform float roughness;', 'uniform vec3 specular;' ).replace( 'uniform float metalness;', 'uniform float glossiness;' ).replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk ).replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk ).replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk ).replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk ).replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
1511
+
1512
+ };
1513
+
1514
+ Object.defineProperties( this, {
1515
+ specular: {
1516
+ get: function () {
1517
+
1518
+ return uniforms.specular.value;
1519
+
1520
+ },
1521
+ set: function ( v ) {
1522
+
1523
+ uniforms.specular.value = v;
1524
+
1525
+ }
1526
+ },
1527
+ specularMap: {
1528
+ get: function () {
1529
+
1530
+ return uniforms.specularMap.value;
1531
+
1532
+ },
1533
+ set: function ( v ) {
1534
+
1535
+ uniforms.specularMap.value = v;
1536
+
1537
+ if ( v ) {
1538
+
1539
+ this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps
1540
+
1541
+ } else {
1542
+
1543
+ delete this.defines.USE_SPECULARMAP;
1544
+
1545
+ }
1546
+
1547
+ }
1548
+ },
1549
+ glossiness: {
1550
+ get: function () {
1551
+
1552
+ return uniforms.glossiness.value;
1553
+
1554
+ },
1555
+ set: function ( v ) {
1556
+
1557
+ uniforms.glossiness.value = v;
1558
+
1559
+ }
1560
+ },
1561
+ glossinessMap: {
1562
+ get: function () {
1563
+
1564
+ return uniforms.glossinessMap.value;
1565
+
1566
+ },
1567
+ set: function ( v ) {
1568
+
1569
+ uniforms.glossinessMap.value = v;
1570
+
1571
+ if ( v ) {
1572
+
1573
+ this.defines.USE_GLOSSINESSMAP = '';
1574
+ this.defines.USE_UV = '';
1575
+
1576
+ } else {
1577
+
1578
+ delete this.defines.USE_GLOSSINESSMAP;
1579
+ delete this.defines.USE_UV;
1580
+
1581
+ }
1582
+
1583
+ }
1584
+ }
1585
+ } );
1586
+ delete this.metalness;
1587
+ delete this.roughness;
1588
+ delete this.metalnessMap;
1589
+ delete this.roughnessMap;
1590
+ this.setValues( params );
1591
+
1592
+ }
1593
+
1594
+ copy( source ) {
1595
+
1596
+ super.copy( source );
1597
+ this.specularMap = source.specularMap;
1598
+ this.specular.copy( source.specular );
1599
+ this.glossinessMap = source.glossinessMap;
1600
+ this.glossiness = source.glossiness;
1601
+ delete this.metalness;
1602
+ delete this.roughness;
1603
+ delete this.metalnessMap;
1604
+ delete this.roughnessMap;
1605
+ return this;
1606
+
1607
+ }
1608
+
1609
+ }
1610
+
1611
+ class GLTFMaterialsPbrSpecularGlossinessExtension {
1612
+
1613
+ constructor() {
1614
+
1615
+ this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS;
1616
+ this.specularGlossinessParams = [ 'color', 'map', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveIntensity', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'normalMapType', 'displacementMap', 'displacementScale', 'displacementBias', 'specularMap', 'specular', 'glossinessMap', 'glossiness', 'alphaMap', 'envMap', 'envMapIntensity' ];
1617
+
1618
+ }
1619
+
1620
+ getMaterialType() {
1621
+
1622
+ return GLTFMeshStandardSGMaterial;
1623
+
1624
+ }
1625
+
1626
+ extendParams( materialParams, materialDef, parser ) {
1627
+
1628
+ const pbrSpecularGlossiness = materialDef.extensions[ this.name ];
1629
+ materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
1630
+ materialParams.opacity = 1.0;
1631
+ const pending = [];
1632
+
1633
+ if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) {
1634
+
1635
+ const array = pbrSpecularGlossiness.diffuseFactor;
1636
+ materialParams.color.fromArray( array );
1637
+ materialParams.opacity = array[ 3 ];
1638
+
1639
+ }
1640
+
1641
+ if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
1642
+
1643
+ pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture, THREE.sRGBEncoding ) );
1644
+
1645
+ }
1646
+
1647
+ materialParams.emissive = new THREE.Color( 0.0, 0.0, 0.0 );
1648
+ materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
1649
+ materialParams.specular = new THREE.Color( 1.0, 1.0, 1.0 );
1650
+
1651
+ if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
1652
+
1653
+ materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor );
1654
+
1655
+ }
1656
+
1657
+ if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
1658
+
1659
+ const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
1660
+ pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) );
1661
+ pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef, THREE.sRGBEncoding ) );
1662
+
1663
+ }
1664
+
1665
+ return Promise.all( pending );
1666
+
1667
+ }
1668
+
1669
+ createMaterial( materialParams ) {
1670
+
1671
+ const material = new GLTFMeshStandardSGMaterial( materialParams );
1672
+ material.fog = true;
1673
+ material.color = materialParams.color;
1674
+ material.map = materialParams.map === undefined ? null : materialParams.map;
1675
+ material.lightMap = null;
1676
+ material.lightMapIntensity = 1.0;
1677
+ material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;
1678
+ material.aoMapIntensity = 1.0;
1679
+ material.emissive = materialParams.emissive;
1680
+ material.emissiveIntensity = materialParams.emissiveIntensity === undefined ? 1.0 : materialParams.emissiveIntensity;
1681
+ material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;
1682
+ material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;
1683
+ material.bumpScale = 1;
1684
+ material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap;
1685
+ material.normalMapType = THREE.TangentSpaceNormalMap;
1686
+ if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale;
1687
+ material.displacementMap = null;
1688
+ material.displacementScale = 1;
1689
+ material.displacementBias = 0;
1690
+ material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap;
1691
+ material.specular = materialParams.specular;
1692
+ material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;
1693
+ material.glossiness = materialParams.glossiness;
1694
+ material.alphaMap = null;
1695
+ material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;
1696
+ material.envMapIntensity = 1.0;
1697
+ return material;
1698
+
1699
+ }
1700
+
1701
+ }
1702
+ /**
1703
+ * THREE.Mesh Quantization Extension
1704
+ *
1705
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
1706
+ */
1707
+
1708
+
1709
+ class GLTFMeshQuantizationExtension {
1710
+
1711
+ constructor() {
1712
+
1713
+ this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
1714
+
1715
+ }
1716
+
1717
+ }
1718
+ /*********************************/
1719
+
1720
+ /********** INTERPOLATION ********/
1721
+
1722
+ /*********************************/
1723
+ // Spline Interpolation
1724
+ // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
1725
+
1726
+
1727
+ class GLTFCubicSplineInterpolant extends THREE.Interpolant {
1728
+
1729
+ constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
1730
+
1731
+ super( parameterPositions, sampleValues, sampleSize, resultBuffer );
1732
+
1733
+ }
1734
+
1735
+ copySampleValue_( index ) {
1736
+
1737
+ // Copies a sample value to the result buffer. See description of glTF
1738
+ // CUBICSPLINE values layout in interpolate_() function below.
1739
+ const result = this.resultBuffer,
1740
+ values = this.sampleValues,
1741
+ valueSize = this.valueSize,
1742
+ offset = index * valueSize * 3 + valueSize;
1743
+
1744
+ for ( let i = 0; i !== valueSize; i ++ ) {
1745
+
1746
+ result[ i ] = values[ offset + i ];
1747
+
1748
+ }
1749
+
1750
+ return result;
1751
+
1752
+ }
1753
+
1754
+ interpolate_( i1, t0, t, t1 ) {
1755
+
1756
+ const result = this.resultBuffer;
1757
+ const values = this.sampleValues;
1758
+ const stride = this.valueSize;
1759
+ const stride2 = stride * 2;
1760
+ const stride3 = stride * 3;
1761
+ const td = t1 - t0;
1762
+ const p = ( t - t0 ) / td;
1763
+ const pp = p * p;
1764
+ const ppp = pp * p;
1765
+ const offset1 = i1 * stride3;
1766
+ const offset0 = offset1 - stride3;
1767
+ const s2 = - 2 * ppp + 3 * pp;
1768
+ const s3 = ppp - pp;
1769
+ const s0 = 1 - s2;
1770
+ const s1 = s3 - pp + p; // Layout of keyframe output values for CUBICSPLINE animations:
1771
+ // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
1772
+
1773
+ for ( let i = 0; i !== stride; i ++ ) {
1774
+
1775
+ const p0 = values[ offset0 + i + stride ]; // splineVertex_k
1776
+
1777
+ const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
1778
+
1779
+ const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
1780
+
1781
+ const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
1782
+
1783
+ result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
1784
+
1785
+ }
1786
+
1787
+ return result;
1788
+
1789
+ }
1790
+
1791
+ }
1792
+
1793
+ const _q = new THREE.Quaternion();
1794
+
1795
+ class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
1796
+
1797
+ interpolate_( i1, t0, t, t1 ) {
1798
+
1799
+ const result = super.interpolate_( i1, t0, t, t1 );
1800
+
1801
+ _q.fromArray( result ).normalize().toArray( result );
1802
+
1803
+ return result;
1804
+
1805
+ }
1806
+
1807
+ }
1808
+ /*********************************/
1809
+
1810
+ /********** INTERNALS ************/
1811
+
1812
+ /*********************************/
1813
+
1814
+ /* CONSTANTS */
1815
+
1816
+
1817
+ const WEBGL_CONSTANTS = {
1818
+ FLOAT: 5126,
1819
+ //FLOAT_MAT2: 35674,
1820
+ FLOAT_MAT3: 35675,
1821
+ FLOAT_MAT4: 35676,
1822
+ FLOAT_VEC2: 35664,
1823
+ FLOAT_VEC3: 35665,
1824
+ FLOAT_VEC4: 35666,
1825
+ LINEAR: 9729,
1826
+ REPEAT: 10497,
1827
+ SAMPLER_2D: 35678,
1828
+ POINTS: 0,
1829
+ LINES: 1,
1830
+ LINE_LOOP: 2,
1831
+ LINE_STRIP: 3,
1832
+ TRIANGLES: 4,
1833
+ TRIANGLE_STRIP: 5,
1834
+ TRIANGLE_FAN: 6,
1835
+ UNSIGNED_BYTE: 5121,
1836
+ UNSIGNED_SHORT: 5123
1837
+ };
1838
+ const WEBGL_COMPONENT_TYPES = {
1839
+ 5120: Int8Array,
1840
+ 5121: Uint8Array,
1841
+ 5122: Int16Array,
1842
+ 5123: Uint16Array,
1843
+ 5125: Uint32Array,
1844
+ 5126: Float32Array
1845
+ };
1846
+ const WEBGL_FILTERS = {
1847
+ 9728: THREE.NearestFilter,
1848
+ 9729: THREE.LinearFilter,
1849
+ 9984: THREE.NearestMipmapNearestFilter,
1850
+ 9985: THREE.LinearMipmapNearestFilter,
1851
+ 9986: THREE.NearestMipmapLinearFilter,
1852
+ 9987: THREE.LinearMipmapLinearFilter
1853
+ };
1854
+ const WEBGL_WRAPPINGS = {
1855
+ 33071: THREE.ClampToEdgeWrapping,
1856
+ 33648: THREE.MirroredRepeatWrapping,
1857
+ 10497: THREE.RepeatWrapping
1858
+ };
1859
+ const WEBGL_TYPE_SIZES = {
1860
+ 'SCALAR': 1,
1861
+ 'VEC2': 2,
1862
+ 'VEC3': 3,
1863
+ 'VEC4': 4,
1864
+ 'MAT2': 4,
1865
+ 'MAT3': 9,
1866
+ 'MAT4': 16
1867
+ };
1868
+ const ATTRIBUTES = {
1869
+ POSITION: 'position',
1870
+ NORMAL: 'normal',
1871
+ TANGENT: 'tangent',
1872
+ TEXCOORD_0: 'uv',
1873
+ TEXCOORD_1: 'uv2',
1874
+ COLOR_0: 'color',
1875
+ WEIGHTS_0: 'skinWeight',
1876
+ JOINTS_0: 'skinIndex'
1877
+ };
1878
+ const PATH_PROPERTIES = {
1879
+ scale: 'scale',
1880
+ translation: 'position',
1881
+ rotation: 'quaternion',
1882
+ weights: 'morphTargetInfluences'
1883
+ };
1884
+ const INTERPOLATION = {
1885
+ CUBICSPLINE: undefined,
1886
+ // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
1887
+ // keyframe track will be initialized with a default interpolation type, then modified.
1888
+ LINEAR: THREE.InterpolateLinear,
1889
+ STEP: THREE.InterpolateDiscrete
1890
+ };
1891
+ const ALPHA_MODES = {
1892
+ OPAQUE: 'OPAQUE',
1893
+ MASK: 'MASK',
1894
+ BLEND: 'BLEND'
1895
+ };
1896
+ /**
1897
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
1898
+ */
1899
+
1900
+ function createDefaultMaterial( cache ) {
1901
+
1902
+ if ( cache[ 'DefaultMaterial' ] === undefined ) {
1903
+
1904
+ cache[ 'DefaultMaterial' ] = new THREE.MeshStandardMaterial( {
1905
+ color: 0xFFFFFF,
1906
+ emissive: 0x000000,
1907
+ metalness: 1,
1908
+ roughness: 1,
1909
+ transparent: false,
1910
+ depthTest: true,
1911
+ side: THREE.FrontSide
1912
+ } );
1913
+
1914
+ }
1915
+
1916
+ return cache[ 'DefaultMaterial' ];
1917
+
1918
+ }
1919
+
1920
+ function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
1921
+
1922
+ // Add unknown glTF extensions to an object's userData.
1923
+ for ( const name in objectDef.extensions ) {
1924
+
1925
+ if ( knownExtensions[ name ] === undefined ) {
1926
+
1927
+ object.userData.gltfExtensions = object.userData.gltfExtensions || {};
1928
+ object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ];
1929
+
1930
+ }
1931
+
1932
+ }
1933
+
1934
+ }
1935
+ /**
1936
+ * @param {Object3D|Material|BufferGeometry} object
1937
+ * @param {GLTF.definition} gltfDef
1938
+ */
1939
+
1940
+
1941
+ function assignExtrasToUserData( object, gltfDef ) {
1942
+
1943
+ if ( gltfDef.extras !== undefined ) {
1944
+
1945
+ if ( typeof gltfDef.extras === 'object' ) {
1946
+
1947
+ Object.assign( object.userData, gltfDef.extras );
1948
+
1949
+ } else {
1950
+
1951
+ console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras );
1952
+
1953
+ }
1954
+
1955
+ }
1956
+
1957
+ }
1958
+ /**
1959
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
1960
+ *
1961
+ * @param {BufferGeometry} geometry
1962
+ * @param {Array<GLTF.Target>} targets
1963
+ * @param {GLTFParser} parser
1964
+ * @return {Promise<BufferGeometry>}
1965
+ */
1966
+
1967
+
1968
+ function addMorphTargets( geometry, targets, parser ) {
1969
+
1970
+ let hasMorphPosition = false;
1971
+ let hasMorphNormal = false;
1972
+ let hasMorphColor = false;
1973
+
1974
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
1975
+
1976
+ const target = targets[ i ];
1977
+ if ( target.POSITION !== undefined ) hasMorphPosition = true;
1978
+ if ( target.NORMAL !== undefined ) hasMorphNormal = true;
1979
+ if ( target.COLOR_0 !== undefined ) hasMorphColor = true;
1980
+ if ( hasMorphPosition && hasMorphNormal && hasMorphColor ) break;
1981
+
1982
+ }
1983
+
1984
+ if ( ! hasMorphPosition && ! hasMorphNormal && ! hasMorphColor ) return Promise.resolve( geometry );
1985
+ const pendingPositionAccessors = [];
1986
+ const pendingNormalAccessors = [];
1987
+ const pendingColorAccessors = [];
1988
+
1989
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
1990
+
1991
+ const target = targets[ i ];
1992
+
1993
+ if ( hasMorphPosition ) {
1994
+
1995
+ const pendingAccessor = target.POSITION !== undefined ? parser.getDependency( 'accessor', target.POSITION ) : geometry.attributes.position;
1996
+ pendingPositionAccessors.push( pendingAccessor );
1997
+
1998
+ }
1999
+
2000
+ if ( hasMorphNormal ) {
2001
+
2002
+ const pendingAccessor = target.NORMAL !== undefined ? parser.getDependency( 'accessor', target.NORMAL ) : geometry.attributes.normal;
2003
+ pendingNormalAccessors.push( pendingAccessor );
2004
+
2005
+ }
2006
+
2007
+ if ( hasMorphColor ) {
2008
+
2009
+ const pendingAccessor = target.COLOR_0 !== undefined ? parser.getDependency( 'accessor', target.COLOR_0 ) : geometry.attributes.color;
2010
+ pendingColorAccessors.push( pendingAccessor );
2011
+
2012
+ }
2013
+
2014
+ }
2015
+
2016
+ return Promise.all( [ Promise.all( pendingPositionAccessors ), Promise.all( pendingNormalAccessors ), Promise.all( pendingColorAccessors ) ] ).then( function ( accessors ) {
2017
+
2018
+ const morphPositions = accessors[ 0 ];
2019
+ const morphNormals = accessors[ 1 ];
2020
+ const morphColors = accessors[ 2 ];
2021
+ if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
2022
+ if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;
2023
+ if ( hasMorphColor ) geometry.morphAttributes.color = morphColors;
2024
+ geometry.morphTargetsRelative = true;
2025
+ return geometry;
2026
+
2027
+ } );
2028
+
2029
+ }
2030
+ /**
2031
+ * @param {Mesh} mesh
2032
+ * @param {GLTF.Mesh} meshDef
2033
+ */
2034
+
2035
+
2036
+ function updateMorphTargets( mesh, meshDef ) {
2037
+
2038
+ mesh.updateMorphTargets();
2039
+
2040
+ if ( meshDef.weights !== undefined ) {
2041
+
2042
+ for ( let i = 0, il = meshDef.weights.length; i < il; i ++ ) {
2043
+
2044
+ mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ];
2045
+
2046
+ }
2047
+
2048
+ } // .extras has user-defined data, so check that .extras.targetNames is an array.
2049
+
2050
+
2051
+ if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
2052
+
2053
+ const targetNames = meshDef.extras.targetNames;
2054
+
2055
+ if ( mesh.morphTargetInfluences.length === targetNames.length ) {
2056
+
2057
+ mesh.morphTargetDictionary = {};
2058
+
2059
+ for ( let i = 0, il = targetNames.length; i < il; i ++ ) {
2060
+
2061
+ mesh.morphTargetDictionary[ targetNames[ i ] ] = i;
2062
+
2063
+ }
2064
+
2065
+ } else {
2066
+
2067
+ console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' );
2068
+
2069
+ }
2070
+
2071
+ }
2072
+
2073
+ }
2074
+
2075
+ function createPrimitiveKey( primitiveDef ) {
2076
+
2077
+ const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
2078
+ let geometryKey;
2079
+
2080
+ if ( dracoExtension ) {
2081
+
2082
+ geometryKey = 'draco:' + dracoExtension.bufferView + ':' + dracoExtension.indices + ':' + createAttributesKey( dracoExtension.attributes );
2083
+
2084
+ } else {
2085
+
2086
+ geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
2087
+
2088
+ }
2089
+
2090
+ return geometryKey;
2091
+
2092
+ }
2093
+
2094
+ function createAttributesKey( attributes ) {
2095
+
2096
+ let attributesKey = '';
2097
+ const keys = Object.keys( attributes ).sort();
2098
+
2099
+ for ( let i = 0, il = keys.length; i < il; i ++ ) {
2100
+
2101
+ attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';';
2102
+
2103
+ }
2104
+
2105
+ return attributesKey;
2106
+
2107
+ }
2108
+
2109
+ function getNormalizedComponentScale( constructor ) {
2110
+
2111
+ // Reference:
2112
+ // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
2113
+ switch ( constructor ) {
2114
+
2115
+ case Int8Array:
2116
+ return 1 / 127;
2117
+
2118
+ case Uint8Array:
2119
+ return 1 / 255;
2120
+
2121
+ case Int16Array:
2122
+ return 1 / 32767;
2123
+
2124
+ case Uint16Array:
2125
+ return 1 / 65535;
2126
+
2127
+ default:
2128
+ throw new Error( 'THREE.GLTFLoader: Unsupported normalized accessor component type.' );
2129
+
2130
+ }
2131
+
2132
+ }
2133
+
2134
+ function getImageURIMimeType( uri ) {
2135
+
2136
+ if ( uri.search( /\.jpe?g($|\?)/i ) > 0 || uri.search( /^data\:image\/jpeg/ ) === 0 ) return 'image/jpeg';
2137
+ if ( uri.search( /\.webp($|\?)/i ) > 0 || uri.search( /^data\:image\/webp/ ) === 0 ) return 'image/webp';
2138
+ return 'image/png';
2139
+
2140
+ }
2141
+ /* GLTF PARSER */
2142
+
2143
+
2144
+ class GLTFParser {
2145
+
2146
+ constructor( json = {}, options = {} ) {
2147
+
2148
+ this.json = json;
2149
+ this.extensions = {};
2150
+ this.plugins = {};
2151
+ this.options = options; // loader object cache
2152
+
2153
+ this.cache = new GLTFRegistry(); // associations between Three.js objects and glTF elements
2154
+
2155
+ this.associations = new Map(); // THREE.BufferGeometry caching
2156
+
2157
+ this.primitiveCache = {}; // THREE.Object3D instance caches
2158
+
2159
+ this.meshCache = {
2160
+ refs: {},
2161
+ uses: {}
2162
+ };
2163
+ this.cameraCache = {
2164
+ refs: {},
2165
+ uses: {}
2166
+ };
2167
+ this.lightCache = {
2168
+ refs: {},
2169
+ uses: {}
2170
+ };
2171
+ this.sourceCache = {};
2172
+ this.textureCache = {}; // Track node names, to ensure no duplicates
2173
+
2174
+ this.nodeNamesUsed = {}; // Use an THREE.ImageBitmapLoader if imageBitmaps are supported. Moves much of the
2175
+ // expensive work of uploading a texture to the GPU off the main thread.
2176
+
2177
+ const isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
2178
+ const isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
2179
+ const firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
2180
+
2181
+ if ( typeof createImageBitmap === 'undefined' || isSafari || isFirefox && firefoxVersion < 98 ) {
2182
+
2183
+ this.textureLoader = new THREE.TextureLoader( this.options.manager );
2184
+
2185
+ } else {
2186
+
2187
+ this.textureLoader = new THREE.ImageBitmapLoader( this.options.manager );
2188
+
2189
+ }
2190
+
2191
+ this.textureLoader.setCrossOrigin( this.options.crossOrigin );
2192
+ this.textureLoader.setRequestHeader( this.options.requestHeader );
2193
+ this.fileLoader = new THREE.FileLoader( this.options.manager );
2194
+ this.fileLoader.setResponseType( 'arraybuffer' );
2195
+
2196
+ if ( this.options.crossOrigin === 'use-credentials' ) {
2197
+
2198
+ this.fileLoader.setWithCredentials( true );
2199
+
2200
+ }
2201
+
2202
+ }
2203
+
2204
+ setExtensions( extensions ) {
2205
+
2206
+ this.extensions = extensions;
2207
+
2208
+ }
2209
+
2210
+ setPlugins( plugins ) {
2211
+
2212
+ this.plugins = plugins;
2213
+
2214
+ }
2215
+
2216
+ parse( onLoad, onError ) {
2217
+
2218
+ const parser = this;
2219
+ const json = this.json;
2220
+ const extensions = this.extensions; // Clear the loader cache
2221
+
2222
+ this.cache.removeAll(); // Mark the special nodes/meshes in json for efficient parse
2223
+
2224
+ this._invokeAll( function ( ext ) {
2225
+
2226
+ return ext._markDefs && ext._markDefs();
2227
+
2228
+ } );
2229
+
2230
+ Promise.all( this._invokeAll( function ( ext ) {
2231
+
2232
+ return ext.beforeRoot && ext.beforeRoot();
2233
+
2234
+ } ) ).then( function () {
2235
+
2236
+ return Promise.all( [ parser.getDependencies( 'scene' ), parser.getDependencies( 'animation' ), parser.getDependencies( 'camera' ) ] );
2237
+
2238
+ } ).then( function ( dependencies ) {
2239
+
2240
+ const result = {
2241
+ scene: dependencies[ 0 ][ json.scene || 0 ],
2242
+ scenes: dependencies[ 0 ],
2243
+ animations: dependencies[ 1 ],
2244
+ cameras: dependencies[ 2 ],
2245
+ asset: json.asset,
2246
+ parser: parser,
2247
+ userData: {}
2248
+ };
2249
+ addUnknownExtensionsToUserData( extensions, result, json );
2250
+ assignExtrasToUserData( result, json );
2251
+ Promise.all( parser._invokeAll( function ( ext ) {
2252
+
2253
+ return ext.afterRoot && ext.afterRoot( result );
2254
+
2255
+ } ) ).then( function () {
2256
+
2257
+ onLoad( result );
2258
+
2259
+ } );
2260
+
2261
+ } ).catch( onError );
2262
+
2263
+ }
2264
+ /**
2265
+ * Marks the special nodes/meshes in json for efficient parse.
2266
+ */
2267
+
2268
+
2269
+ _markDefs() {
2270
+
2271
+ const nodeDefs = this.json.nodes || [];
2272
+ const skinDefs = this.json.skins || [];
2273
+ const meshDefs = this.json.meshes || []; // Nothing in the node definition indicates whether it is a THREE.Bone or an
2274
+ // THREE.Object3D. Use the skins' joint references to mark bones.
2275
+
2276
+ for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) {
2277
+
2278
+ const joints = skinDefs[ skinIndex ].joints;
2279
+
2280
+ for ( let i = 0, il = joints.length; i < il; i ++ ) {
2281
+
2282
+ nodeDefs[ joints[ i ] ].isBone = true;
2283
+
2284
+ }
2285
+
2286
+ } // Iterate over all nodes, marking references to shared resources,
2287
+ // as well as skeleton joints.
2288
+
2289
+
2290
+ for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
2291
+
2292
+ const nodeDef = nodeDefs[ nodeIndex ];
2293
+
2294
+ if ( nodeDef.mesh !== undefined ) {
2295
+
2296
+ this._addNodeRef( this.meshCache, nodeDef.mesh ); // Nothing in the mesh definition indicates whether it is
2297
+ // a THREE.SkinnedMesh or THREE.Mesh. Use the node's mesh reference
2298
+ // to mark THREE.SkinnedMesh if node has skin.
2299
+
2300
+
2301
+ if ( nodeDef.skin !== undefined ) {
2302
+
2303
+ meshDefs[ nodeDef.mesh ].isSkinnedMesh = true;
2304
+
2305
+ }
2306
+
2307
+ }
2308
+
2309
+ if ( nodeDef.camera !== undefined ) {
2310
+
2311
+ this._addNodeRef( this.cameraCache, nodeDef.camera );
2312
+
2313
+ }
2314
+
2315
+ }
2316
+
2317
+ }
2318
+ /**
2319
+ * Counts references to shared node / THREE.Object3D resources. These resources
2320
+ * can be reused, or "instantiated", at multiple nodes in the scene
2321
+ * hierarchy. THREE.Mesh, Camera, and Light instances are instantiated and must
2322
+ * be marked. Non-scenegraph resources (like Materials, Geometries, and
2323
+ * Textures) can be reused directly and are not marked here.
2324
+ *
2325
+ * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
2326
+ */
2327
+
2328
+
2329
+ _addNodeRef( cache, index ) {
2330
+
2331
+ if ( index === undefined ) return;
2332
+
2333
+ if ( cache.refs[ index ] === undefined ) {
2334
+
2335
+ cache.refs[ index ] = cache.uses[ index ] = 0;
2336
+
2337
+ }
2338
+
2339
+ cache.refs[ index ] ++;
2340
+
2341
+ }
2342
+ /** Returns a reference to a shared resource, cloning it if necessary. */
2343
+
2344
+
2345
+ _getNodeRef( cache, index, object ) {
2346
+
2347
+ if ( cache.refs[ index ] <= 1 ) return object;
2348
+ const ref = object.clone(); // Propagates mappings to the cloned object, prevents mappings on the
2349
+ // original object from being lost.
2350
+
2351
+ const updateMappings = ( original, clone ) => {
2352
+
2353
+ const mappings = this.associations.get( original );
2354
+
2355
+ if ( mappings != null ) {
2356
+
2357
+ this.associations.set( clone, mappings );
2358
+
2359
+ }
2360
+
2361
+ for ( const [ i, child ] of original.children.entries() ) {
2362
+
2363
+ updateMappings( child, clone.children[ i ] );
2364
+
2365
+ }
2366
+
2367
+ };
2368
+
2369
+ updateMappings( object, ref );
2370
+ ref.name += '_instance_' + cache.uses[ index ] ++;
2371
+ return ref;
2372
+
2373
+ }
2374
+
2375
+ _invokeOne( func ) {
2376
+
2377
+ const extensions = Object.values( this.plugins );
2378
+ extensions.push( this );
2379
+
2380
+ for ( let i = 0; i < extensions.length; i ++ ) {
2381
+
2382
+ const result = func( extensions[ i ] );
2383
+ if ( result ) return result;
2384
+
2385
+ }
2386
+
2387
+ return null;
2388
+
2389
+ }
2390
+
2391
+ _invokeAll( func ) {
2392
+
2393
+ const extensions = Object.values( this.plugins );
2394
+ extensions.unshift( this );
2395
+ const pending = [];
2396
+
2397
+ for ( let i = 0; i < extensions.length; i ++ ) {
2398
+
2399
+ const result = func( extensions[ i ] );
2400
+ if ( result ) pending.push( result );
2401
+
2402
+ }
2403
+
2404
+ return pending;
2405
+
2406
+ }
2407
+ /**
2408
+ * Requests the specified dependency asynchronously, with caching.
2409
+ * @param {string} type
2410
+ * @param {number} index
2411
+ * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
2412
+ */
2413
+
2414
+
2415
+ getDependency( type, index ) {
2416
+
2417
+ const cacheKey = type + ':' + index;
2418
+ let dependency = this.cache.get( cacheKey );
2419
+
2420
+ if ( ! dependency ) {
2421
+
2422
+ switch ( type ) {
2423
+
2424
+ case 'scene':
2425
+ dependency = this.loadScene( index );
2426
+ break;
2427
+
2428
+ case 'node':
2429
+ dependency = this.loadNode( index );
2430
+ break;
2431
+
2432
+ case 'mesh':
2433
+ dependency = this._invokeOne( function ( ext ) {
2434
+
2435
+ return ext.loadMesh && ext.loadMesh( index );
2436
+
2437
+ } );
2438
+ break;
2439
+
2440
+ case 'accessor':
2441
+ dependency = this.loadAccessor( index );
2442
+ break;
2443
+
2444
+ case 'bufferView':
2445
+ dependency = this._invokeOne( function ( ext ) {
2446
+
2447
+ return ext.loadBufferView && ext.loadBufferView( index );
2448
+
2449
+ } );
2450
+ break;
2451
+
2452
+ case 'buffer':
2453
+ dependency = this.loadBuffer( index );
2454
+ break;
2455
+
2456
+ case 'material':
2457
+ dependency = this._invokeOne( function ( ext ) {
2458
+
2459
+ return ext.loadMaterial && ext.loadMaterial( index );
2460
+
2461
+ } );
2462
+ break;
2463
+
2464
+ case 'texture':
2465
+ dependency = this._invokeOne( function ( ext ) {
2466
+
2467
+ return ext.loadTexture && ext.loadTexture( index );
2468
+
2469
+ } );
2470
+ break;
2471
+
2472
+ case 'skin':
2473
+ dependency = this.loadSkin( index );
2474
+ break;
2475
+
2476
+ case 'animation':
2477
+ dependency = this._invokeOne( function ( ext ) {
2478
+
2479
+ return ext.loadAnimation && ext.loadAnimation( index );
2480
+
2481
+ } );
2482
+ break;
2483
+
2484
+ case 'camera':
2485
+ dependency = this.loadCamera( index );
2486
+ break;
2487
+
2488
+ default:
2489
+ throw new Error( 'Unknown type: ' + type );
2490
+
2491
+ }
2492
+
2493
+ this.cache.add( cacheKey, dependency );
2494
+
2495
+ }
2496
+
2497
+ return dependency;
2498
+
2499
+ }
2500
+ /**
2501
+ * Requests all dependencies of the specified type asynchronously, with caching.
2502
+ * @param {string} type
2503
+ * @return {Promise<Array<Object>>}
2504
+ */
2505
+
2506
+
2507
+ getDependencies( type ) {
2508
+
2509
+ let dependencies = this.cache.get( type );
2510
+
2511
+ if ( ! dependencies ) {
2512
+
2513
+ const parser = this;
2514
+ const defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || [];
2515
+ dependencies = Promise.all( defs.map( function ( def, index ) {
2516
+
2517
+ return parser.getDependency( type, index );
2518
+
2519
+ } ) );
2520
+ this.cache.add( type, dependencies );
2521
+
2522
+ }
2523
+
2524
+ return dependencies;
2525
+
2526
+ }
2527
+ /**
2528
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
2529
+ * @param {number} bufferIndex
2530
+ * @return {Promise<ArrayBuffer>}
2531
+ */
2532
+
2533
+
2534
+ loadBuffer( bufferIndex ) {
2535
+
2536
+ const bufferDef = this.json.buffers[ bufferIndex ];
2537
+ const loader = this.fileLoader;
2538
+
2539
+ if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) {
2540
+
2541
+ throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' );
2542
+
2543
+ } // If present, GLB container is required to be the first buffer.
2544
+
2545
+
2546
+ if ( bufferDef.uri === undefined && bufferIndex === 0 ) {
2547
+
2548
+ return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body );
2549
+
2550
+ }
2551
+
2552
+ const options = this.options;
2553
+ return new Promise( function ( resolve, reject ) {
2554
+
2555
+ loader.load( THREE.LoaderUtils.resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () {
2556
+
2557
+ reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) );
2558
+
2559
+ } );
2560
+
2561
+ } );
2562
+
2563
+ }
2564
+ /**
2565
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
2566
+ * @param {number} bufferViewIndex
2567
+ * @return {Promise<ArrayBuffer>}
2568
+ */
2569
+
2570
+
2571
+ loadBufferView( bufferViewIndex ) {
2572
+
2573
+ const bufferViewDef = this.json.bufferViews[ bufferViewIndex ];
2574
+ return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) {
2575
+
2576
+ const byteLength = bufferViewDef.byteLength || 0;
2577
+ const byteOffset = bufferViewDef.byteOffset || 0;
2578
+ return buffer.slice( byteOffset, byteOffset + byteLength );
2579
+
2580
+ } );
2581
+
2582
+ }
2583
+ /**
2584
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
2585
+ * @param {number} accessorIndex
2586
+ * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
2587
+ */
2588
+
2589
+
2590
+ loadAccessor( accessorIndex ) {
2591
+
2592
+ const parser = this;
2593
+ const json = this.json;
2594
+ const accessorDef = this.json.accessors[ accessorIndex ];
2595
+
2596
+ if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
2597
+
2598
+ // Ignore empty accessors, which may be used to declare runtime
2599
+ // information about attributes coming from another source (e.g. Draco
2600
+ // compression extension).
2601
+ return Promise.resolve( null );
2602
+
2603
+ }
2604
+
2605
+ const pendingBufferViews = [];
2606
+
2607
+ if ( accessorDef.bufferView !== undefined ) {
2608
+
2609
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) );
2610
+
2611
+ } else {
2612
+
2613
+ pendingBufferViews.push( null );
2614
+
2615
+ }
2616
+
2617
+ if ( accessorDef.sparse !== undefined ) {
2618
+
2619
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) );
2620
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) );
2621
+
2622
+ }
2623
+
2624
+ return Promise.all( pendingBufferViews ).then( function ( bufferViews ) {
2625
+
2626
+ const bufferView = bufferViews[ 0 ];
2627
+ const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
2628
+ const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
2629
+
2630
+ const elementBytes = TypedArray.BYTES_PER_ELEMENT;
2631
+ const itemBytes = elementBytes * itemSize;
2632
+ const byteOffset = accessorDef.byteOffset || 0;
2633
+ const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined;
2634
+ const normalized = accessorDef.normalized === true;
2635
+ let array, bufferAttribute; // The buffer is not interleaved if the stride is the item size in bytes.
2636
+
2637
+ if ( byteStride && byteStride !== itemBytes ) {
2638
+
2639
+ // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own THREE.InterleavedBuffer
2640
+ // This makes sure that IBA.count reflects accessor.count properly
2641
+ const ibSlice = Math.floor( byteOffset / byteStride );
2642
+ const ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
2643
+ let ib = parser.cache.get( ibCacheKey );
2644
+
2645
+ if ( ! ib ) {
2646
+
2647
+ array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes ); // Integer parameters to IB/IBA are in array elements, not bytes.
2648
+
2649
+ ib = new THREE.InterleavedBuffer( array, byteStride / elementBytes );
2650
+ parser.cache.add( ibCacheKey, ib );
2651
+
2652
+ }
2653
+
2654
+ bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, byteOffset % byteStride / elementBytes, normalized );
2655
+
2656
+ } else {
2657
+
2658
+ if ( bufferView === null ) {
2659
+
2660
+ array = new TypedArray( accessorDef.count * itemSize );
2661
+
2662
+ } else {
2663
+
2664
+ array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize );
2665
+
2666
+ }
2667
+
2668
+ bufferAttribute = new THREE.BufferAttribute( array, itemSize, normalized );
2669
+
2670
+ } // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
2671
+
2672
+
2673
+ if ( accessorDef.sparse !== undefined ) {
2674
+
2675
+ const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
2676
+ const TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ];
2677
+ const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
2678
+ const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
2679
+ const sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices );
2680
+ const sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize );
2681
+
2682
+ if ( bufferView !== null ) {
2683
+
2684
+ // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
2685
+ bufferAttribute = new THREE.BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized );
2686
+
2687
+ }
2688
+
2689
+ for ( let i = 0, il = sparseIndices.length; i < il; i ++ ) {
2690
+
2691
+ const index = sparseIndices[ i ];
2692
+ bufferAttribute.setX( index, sparseValues[ i * itemSize ] );
2693
+ if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] );
2694
+ if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] );
2695
+ if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] );
2696
+ if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.' );
2697
+
2698
+ }
2699
+
2700
+ }
2701
+
2702
+ return bufferAttribute;
2703
+
2704
+ } );
2705
+
2706
+ }
2707
+ /**
2708
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
2709
+ * @param {number} textureIndex
2710
+ * @return {Promise<THREE.Texture>}
2711
+ */
2712
+
2713
+
2714
+ loadTexture( textureIndex ) {
2715
+
2716
+ const json = this.json;
2717
+ const options = this.options;
2718
+ const textureDef = json.textures[ textureIndex ];
2719
+ const sourceIndex = textureDef.source;
2720
+ const sourceDef = json.images[ sourceIndex ];
2721
+ let loader = this.textureLoader;
2722
+
2723
+ if ( sourceDef.uri ) {
2724
+
2725
+ const handler = options.manager.getHandler( sourceDef.uri );
2726
+ if ( handler !== null ) loader = handler;
2727
+
2728
+ }
2729
+
2730
+ return this.loadTextureImage( textureIndex, sourceIndex, loader );
2731
+
2732
+ }
2733
+
2734
+ loadTextureImage( textureIndex, sourceIndex, loader ) {
2735
+
2736
+ const parser = this;
2737
+ const json = this.json;
2738
+ const textureDef = json.textures[ textureIndex ];
2739
+ const sourceDef = json.images[ sourceIndex ];
2740
+ const cacheKey = ( sourceDef.uri || sourceDef.bufferView ) + ':' + textureDef.sampler;
2741
+
2742
+ if ( this.textureCache[ cacheKey ] ) {
2743
+
2744
+ // See https://github.com/mrdoob/three.js/issues/21559.
2745
+ return this.textureCache[ cacheKey ];
2746
+
2747
+ }
2748
+
2749
+ const promise = this.loadImageSource( sourceIndex, loader ).then( function ( texture ) {
2750
+
2751
+ texture.flipY = false;
2752
+ if ( textureDef.name ) texture.name = textureDef.name;
2753
+ const samplers = json.samplers || {};
2754
+ const sampler = samplers[ textureDef.sampler ] || {};
2755
+ texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter;
2756
+ texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.LinearMipmapLinearFilter;
2757
+ texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping;
2758
+ texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping;
2759
+ parser.associations.set( texture, {
2760
+ textures: textureIndex
2761
+ } );
2762
+ return texture;
2763
+
2764
+ } ).catch( function () {
2765
+
2766
+ return null;
2767
+
2768
+ } );
2769
+ this.textureCache[ cacheKey ] = promise;
2770
+ return promise;
2771
+
2772
+ }
2773
+
2774
+ loadImageSource( sourceIndex, loader ) {
2775
+
2776
+ const parser = this;
2777
+ const json = this.json;
2778
+ const options = this.options;
2779
+
2780
+ if ( this.sourceCache[ sourceIndex ] !== undefined ) {
2781
+
2782
+ return this.sourceCache[ sourceIndex ].then( texture => texture.clone() );
2783
+
2784
+ }
2785
+
2786
+ const sourceDef = json.images[ sourceIndex ];
2787
+ const URL = self.URL || self.webkitURL;
2788
+ let sourceURI = sourceDef.uri || '';
2789
+ let isObjectURL = false;
2790
+
2791
+ if ( sourceDef.bufferView !== undefined ) {
2792
+
2793
+ // Load binary image data from bufferView, if provided.
2794
+ sourceURI = parser.getDependency( 'bufferView', sourceDef.bufferView ).then( function ( bufferView ) {
2795
+
2796
+ isObjectURL = true;
2797
+ const blob = new Blob( [ bufferView ], {
2798
+ type: sourceDef.mimeType
2799
+ } );
2800
+ sourceURI = URL.createObjectURL( blob );
2801
+ return sourceURI;
2802
+
2803
+ } );
2804
+
2805
+ } else if ( sourceDef.uri === undefined ) {
2806
+
2807
+ throw new Error( 'THREE.GLTFLoader: Image ' + sourceIndex + ' is missing URI and bufferView' );
2808
+
2809
+ }
2810
+
2811
+ const promise = Promise.resolve( sourceURI ).then( function ( sourceURI ) {
2812
+
2813
+ return new Promise( function ( resolve, reject ) {
2814
+
2815
+ let onLoad = resolve;
2816
+
2817
+ if ( loader.isImageBitmapLoader === true ) {
2818
+
2819
+ onLoad = function ( imageBitmap ) {
2820
+
2821
+ const texture = new THREE.Texture( imageBitmap );
2822
+ texture.needsUpdate = true;
2823
+ resolve( texture );
2824
+
2825
+ };
2826
+
2827
+ }
2828
+
2829
+ loader.load( THREE.LoaderUtils.resolveURL( sourceURI, options.path ), onLoad, undefined, reject );
2830
+
2831
+ } );
2832
+
2833
+ } ).then( function ( texture ) {
2834
+
2835
+ // Clean up resources and configure THREE.Texture.
2836
+ if ( isObjectURL === true ) {
2837
+
2838
+ URL.revokeObjectURL( sourceURI );
2839
+
2840
+ }
2841
+
2842
+ texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri );
2843
+ return texture;
2844
+
2845
+ } ).catch( function ( error ) {
2846
+
2847
+ console.error( 'THREE.GLTFLoader: Couldn\'t load texture', sourceURI );
2848
+ throw error;
2849
+
2850
+ } );
2851
+ this.sourceCache[ sourceIndex ] = promise;
2852
+ return promise;
2853
+
2854
+ }
2855
+ /**
2856
+ * Asynchronously assigns a texture to the given material parameters.
2857
+ * @param {Object} materialParams
2858
+ * @param {string} mapName
2859
+ * @param {Object} mapDef
2860
+ * @return {Promise<Texture>}
2861
+ */
2862
+
2863
+
2864
+ assignTexture( materialParams, mapName, mapDef, encoding ) {
2865
+
2866
+ const parser = this;
2867
+ return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
2868
+
2869
+ // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
2870
+ // However, we will copy UV set 0 to UV set 1 on demand for aoMap
2871
+ if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
2872
+
2873
+ console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' );
2874
+
2875
+ }
2876
+
2877
+ if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) {
2878
+
2879
+ const transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined;
2880
+
2881
+ if ( transform ) {
2882
+
2883
+ const gltfReference = parser.associations.get( texture );
2884
+ texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform );
2885
+ parser.associations.set( texture, gltfReference );
2886
+
2887
+ }
2888
+
2889
+ }
2890
+
2891
+ if ( encoding !== undefined ) {
2892
+
2893
+ texture.encoding = encoding;
2894
+
2895
+ }
2896
+
2897
+ materialParams[ mapName ] = texture;
2898
+ return texture;
2899
+
2900
+ } );
2901
+
2902
+ }
2903
+ /**
2904
+ * Assigns final material to a THREE.Mesh, THREE.Line, or THREE.Points instance. The instance
2905
+ * already has a material (generated from the glTF material options alone)
2906
+ * but reuse of the same glTF material may require multiple threejs materials
2907
+ * to accommodate different primitive types, defines, etc. New materials will
2908
+ * be created if necessary, and reused from a cache.
2909
+ * @param {Object3D} mesh THREE.Mesh, THREE.Line, or THREE.Points instance.
2910
+ */
2911
+
2912
+
2913
+ assignFinalMaterial( mesh ) {
2914
+
2915
+ const geometry = mesh.geometry;
2916
+ let material = mesh.material;
2917
+ const useDerivativeTangents = geometry.attributes.tangent === undefined;
2918
+ const useVertexColors = geometry.attributes.color !== undefined;
2919
+ const useFlatShading = geometry.attributes.normal === undefined;
2920
+
2921
+ if ( mesh.isPoints ) {
2922
+
2923
+ const cacheKey = 'PointsMaterial:' + material.uuid;
2924
+ let pointsMaterial = this.cache.get( cacheKey );
2925
+
2926
+ if ( ! pointsMaterial ) {
2927
+
2928
+ pointsMaterial = new THREE.PointsMaterial();
2929
+ THREE.Material.prototype.copy.call( pointsMaterial, material );
2930
+ pointsMaterial.color.copy( material.color );
2931
+ pointsMaterial.map = material.map;
2932
+ pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
2933
+
2934
+ this.cache.add( cacheKey, pointsMaterial );
2935
+
2936
+ }
2937
+
2938
+ material = pointsMaterial;
2939
+
2940
+ } else if ( mesh.isLine ) {
2941
+
2942
+ const cacheKey = 'LineBasicMaterial:' + material.uuid;
2943
+ let lineMaterial = this.cache.get( cacheKey );
2944
+
2945
+ if ( ! lineMaterial ) {
2946
+
2947
+ lineMaterial = new THREE.LineBasicMaterial();
2948
+ THREE.Material.prototype.copy.call( lineMaterial, material );
2949
+ lineMaterial.color.copy( material.color );
2950
+ this.cache.add( cacheKey, lineMaterial );
2951
+
2952
+ }
2953
+
2954
+ material = lineMaterial;
2955
+
2956
+ } // Clone the material if it will be modified
2957
+
2958
+
2959
+ if ( useDerivativeTangents || useVertexColors || useFlatShading ) {
2960
+
2961
+ let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
2962
+ if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:';
2963
+ if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:';
2964
+ if ( useVertexColors ) cacheKey += 'vertex-colors:';
2965
+ if ( useFlatShading ) cacheKey += 'flat-shading:';
2966
+ let cachedMaterial = this.cache.get( cacheKey );
2967
+
2968
+ if ( ! cachedMaterial ) {
2969
+
2970
+ cachedMaterial = material.clone();
2971
+ if ( useVertexColors ) cachedMaterial.vertexColors = true;
2972
+ if ( useFlatShading ) cachedMaterial.flatShading = true;
2973
+
2974
+ if ( useDerivativeTangents ) {
2975
+
2976
+ // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
2977
+ if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1;
2978
+ if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1;
2979
+
2980
+ }
2981
+
2982
+ this.cache.add( cacheKey, cachedMaterial );
2983
+ this.associations.set( cachedMaterial, this.associations.get( material ) );
2984
+
2985
+ }
2986
+
2987
+ material = cachedMaterial;
2988
+
2989
+ } // workarounds for mesh and geometry
2990
+
2991
+
2992
+ if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {
2993
+
2994
+ geometry.setAttribute( 'uv2', geometry.attributes.uv );
2995
+
2996
+ }
2997
+
2998
+ mesh.material = material;
2999
+
3000
+ }
3001
+
3002
+ getMaterialType() {
3003
+
3004
+ return THREE.MeshStandardMaterial;
3005
+
3006
+ }
3007
+ /**
3008
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
3009
+ * @param {number} materialIndex
3010
+ * @return {Promise<Material>}
3011
+ */
3012
+
3013
+
3014
+ loadMaterial( materialIndex ) {
3015
+
3016
+ const parser = this;
3017
+ const json = this.json;
3018
+ const extensions = this.extensions;
3019
+ const materialDef = json.materials[ materialIndex ];
3020
+ let materialType;
3021
+ const materialParams = {};
3022
+ const materialExtensions = materialDef.extensions || {};
3023
+ const pending = [];
3024
+
3025
+ if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
3026
+
3027
+ const sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
3028
+ materialType = sgExtension.getMaterialType();
3029
+ pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
3030
+
3031
+ } else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
3032
+
3033
+ const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
3034
+ materialType = kmuExtension.getMaterialType();
3035
+ pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
3036
+
3037
+ } else {
3038
+
3039
+ // Specification:
3040
+ // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
3041
+ const metallicRoughness = materialDef.pbrMetallicRoughness || {};
3042
+ materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
3043
+ materialParams.opacity = 1.0;
3044
+
3045
+ if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
3046
+
3047
+ const array = metallicRoughness.baseColorFactor;
3048
+ materialParams.color.fromArray( array );
3049
+ materialParams.opacity = array[ 3 ];
3050
+
3051
+ }
3052
+
3053
+ if ( metallicRoughness.baseColorTexture !== undefined ) {
3054
+
3055
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, THREE.sRGBEncoding ) );
3056
+
3057
+ }
3058
+
3059
+ materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
3060
+ materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
3061
+
3062
+ if ( metallicRoughness.metallicRoughnessTexture !== undefined ) {
3063
+
3064
+ pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) );
3065
+ pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) );
3066
+
3067
+ }
3068
+
3069
+ materialType = this._invokeOne( function ( ext ) {
3070
+
3071
+ return ext.getMaterialType && ext.getMaterialType( materialIndex );
3072
+
3073
+ } );
3074
+ pending.push( Promise.all( this._invokeAll( function ( ext ) {
3075
+
3076
+ return ext.extendMaterialParams && ext.extendMaterialParams( materialIndex, materialParams );
3077
+
3078
+ } ) ) );
3079
+
3080
+ }
3081
+
3082
+ if ( materialDef.doubleSided === true ) {
3083
+
3084
+ materialParams.side = THREE.DoubleSide;
3085
+
3086
+ }
3087
+
3088
+ const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
3089
+
3090
+ if ( alphaMode === ALPHA_MODES.BLEND ) {
3091
+
3092
+ materialParams.transparent = true; // See: https://github.com/mrdoob/three.js/issues/17706
3093
+
3094
+ materialParams.depthWrite = false;
3095
+
3096
+ } else {
3097
+
3098
+ materialParams.transparent = false;
3099
+
3100
+ if ( alphaMode === ALPHA_MODES.MASK ) {
3101
+
3102
+ materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
3103
+
3104
+ }
3105
+
3106
+ }
3107
+
3108
+ if ( materialDef.normalTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3109
+
3110
+ pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) );
3111
+ materialParams.normalScale = new THREE.Vector2( 1, 1 );
3112
+
3113
+ if ( materialDef.normalTexture.scale !== undefined ) {
3114
+
3115
+ const scale = materialDef.normalTexture.scale;
3116
+ materialParams.normalScale.set( scale, scale );
3117
+
3118
+ }
3119
+
3120
+ }
3121
+
3122
+ if ( materialDef.occlusionTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3123
+
3124
+ pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) );
3125
+
3126
+ if ( materialDef.occlusionTexture.strength !== undefined ) {
3127
+
3128
+ materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
3129
+
3130
+ }
3131
+
3132
+ }
3133
+
3134
+ if ( materialDef.emissiveFactor !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3135
+
3136
+ materialParams.emissive = new THREE.Color().fromArray( materialDef.emissiveFactor );
3137
+
3138
+ }
3139
+
3140
+ if ( materialDef.emissiveTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3141
+
3142
+ pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, THREE.sRGBEncoding ) );
3143
+
3144
+ }
3145
+
3146
+ return Promise.all( pending ).then( function () {
3147
+
3148
+ let material;
3149
+
3150
+ if ( materialType === GLTFMeshStandardSGMaterial ) {
3151
+
3152
+ material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams );
3153
+
3154
+ } else {
3155
+
3156
+ material = new materialType( materialParams );
3157
+
3158
+ }
3159
+
3160
+ if ( materialDef.name ) material.name = materialDef.name;
3161
+ assignExtrasToUserData( material, materialDef );
3162
+ parser.associations.set( material, {
3163
+ materials: materialIndex
3164
+ } );
3165
+ if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef );
3166
+ return material;
3167
+
3168
+ } );
3169
+
3170
+ }
3171
+ /** When THREE.Object3D instances are targeted by animation, they need unique names. */
3172
+
3173
+
3174
+ createUniqueName( originalName ) {
3175
+
3176
+ const sanitizedName = THREE.PropertyBinding.sanitizeNodeName( originalName || '' );
3177
+ let name = sanitizedName;
3178
+
3179
+ for ( let i = 1; this.nodeNamesUsed[ name ]; ++ i ) {
3180
+
3181
+ name = sanitizedName + '_' + i;
3182
+
3183
+ }
3184
+
3185
+ this.nodeNamesUsed[ name ] = true;
3186
+ return name;
3187
+
3188
+ }
3189
+ /**
3190
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
3191
+ *
3192
+ * Creates BufferGeometries from primitives.
3193
+ *
3194
+ * @param {Array<GLTF.Primitive>} primitives
3195
+ * @return {Promise<Array<BufferGeometry>>}
3196
+ */
3197
+
3198
+
3199
+ loadGeometries( primitives ) {
3200
+
3201
+ const parser = this;
3202
+ const extensions = this.extensions;
3203
+ const cache = this.primitiveCache;
3204
+
3205
+ function createDracoPrimitive( primitive ) {
3206
+
3207
+ return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ].decodePrimitive( primitive, parser ).then( function ( geometry ) {
3208
+
3209
+ return addPrimitiveAttributes( geometry, primitive, parser );
3210
+
3211
+ } );
3212
+
3213
+ }
3214
+
3215
+ const pending = [];
3216
+
3217
+ for ( let i = 0, il = primitives.length; i < il; i ++ ) {
3218
+
3219
+ const primitive = primitives[ i ];
3220
+ const cacheKey = createPrimitiveKey( primitive ); // See if we've already created this geometry
3221
+
3222
+ const cached = cache[ cacheKey ];
3223
+
3224
+ if ( cached ) {
3225
+
3226
+ // Use the cached geometry if it exists
3227
+ pending.push( cached.promise );
3228
+
3229
+ } else {
3230
+
3231
+ let geometryPromise;
3232
+
3233
+ if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) {
3234
+
3235
+ // Use DRACO geometry if available
3236
+ geometryPromise = createDracoPrimitive( primitive );
3237
+
3238
+ } else {
3239
+
3240
+ // Otherwise create a new geometry
3241
+ geometryPromise = addPrimitiveAttributes( new THREE.BufferGeometry(), primitive, parser );
3242
+
3243
+ } // Cache this geometry
3244
+
3245
+
3246
+ cache[ cacheKey ] = {
3247
+ primitive: primitive,
3248
+ promise: geometryPromise
3249
+ };
3250
+ pending.push( geometryPromise );
3251
+
3252
+ }
3253
+
3254
+ }
3255
+
3256
+ return Promise.all( pending );
3257
+
3258
+ }
3259
+ /**
3260
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
3261
+ * @param {number} meshIndex
3262
+ * @return {Promise<Group|Mesh|SkinnedMesh>}
3263
+ */
3264
+
3265
+
3266
+ loadMesh( meshIndex ) {
3267
+
3268
+ const parser = this;
3269
+ const json = this.json;
3270
+ const extensions = this.extensions;
3271
+ const meshDef = json.meshes[ meshIndex ];
3272
+ const primitives = meshDef.primitives;
3273
+ const pending = [];
3274
+
3275
+ for ( let i = 0, il = primitives.length; i < il; i ++ ) {
3276
+
3277
+ const material = primitives[ i ].material === undefined ? createDefaultMaterial( this.cache ) : this.getDependency( 'material', primitives[ i ].material );
3278
+ pending.push( material );
3279
+
3280
+ }
3281
+
3282
+ pending.push( parser.loadGeometries( primitives ) );
3283
+ return Promise.all( pending ).then( function ( results ) {
3284
+
3285
+ const materials = results.slice( 0, results.length - 1 );
3286
+ const geometries = results[ results.length - 1 ];
3287
+ const meshes = [];
3288
+
3289
+ for ( let i = 0, il = geometries.length; i < il; i ++ ) {
3290
+
3291
+ const geometry = geometries[ i ];
3292
+ const primitive = primitives[ i ]; // 1. create THREE.Mesh
3293
+
3294
+ let mesh;
3295
+ const material = materials[ i ];
3296
+
3297
+ if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === undefined ) {
3298
+
3299
+ // .isSkinnedMesh isn't in glTF spec. See ._markDefs()
3300
+ mesh = meshDef.isSkinnedMesh === true ? new THREE.SkinnedMesh( geometry, material ) : new THREE.Mesh( geometry, material );
3301
+
3302
+ if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
3303
+
3304
+ // we normalize floating point skin weight array to fix malformed assets (see #15319)
3305
+ // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
3306
+ mesh.normalizeSkinWeights();
3307
+
3308
+ }
3309
+
3310
+ if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) {
3311
+
3312
+ mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleStripDrawMode );
3313
+
3314
+ } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) {
3315
+
3316
+ mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleFanDrawMode );
3317
+
3318
+ }
3319
+
3320
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
3321
+
3322
+ mesh = new THREE.LineSegments( geometry, material );
3323
+
3324
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) {
3325
+
3326
+ mesh = new THREE.Line( geometry, material );
3327
+
3328
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) {
3329
+
3330
+ mesh = new THREE.LineLoop( geometry, material );
3331
+
3332
+ } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) {
3333
+
3334
+ mesh = new THREE.Points( geometry, material );
3335
+
3336
+ } else {
3337
+
3338
+ throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode );
3339
+
3340
+ }
3341
+
3342
+ if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) {
3343
+
3344
+ updateMorphTargets( mesh, meshDef );
3345
+
3346
+ }
3347
+
3348
+ mesh.name = parser.createUniqueName( meshDef.name || 'mesh_' + meshIndex );
3349
+ assignExtrasToUserData( mesh, meshDef );
3350
+ if ( primitive.extensions ) addUnknownExtensionsToUserData( extensions, mesh, primitive );
3351
+ parser.assignFinalMaterial( mesh );
3352
+ meshes.push( mesh );
3353
+
3354
+ }
3355
+
3356
+ for ( let i = 0, il = meshes.length; i < il; i ++ ) {
3357
+
3358
+ parser.associations.set( meshes[ i ], {
3359
+ meshes: meshIndex,
3360
+ primitives: i
3361
+ } );
3362
+
3363
+ }
3364
+
3365
+ if ( meshes.length === 1 ) {
3366
+
3367
+ return meshes[ 0 ];
3368
+
3369
+ }
3370
+
3371
+ const group = new THREE.Group();
3372
+ parser.associations.set( group, {
3373
+ meshes: meshIndex
3374
+ } );
3375
+
3376
+ for ( let i = 0, il = meshes.length; i < il; i ++ ) {
3377
+
3378
+ group.add( meshes[ i ] );
3379
+
3380
+ }
3381
+
3382
+ return group;
3383
+
3384
+ } );
3385
+
3386
+ }
3387
+ /**
3388
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
3389
+ * @param {number} cameraIndex
3390
+ * @return {Promise<THREE.Camera>}
3391
+ */
3392
+
3393
+
3394
+ loadCamera( cameraIndex ) {
3395
+
3396
+ let camera;
3397
+ const cameraDef = this.json.cameras[ cameraIndex ];
3398
+ const params = cameraDef[ cameraDef.type ];
3399
+
3400
+ if ( ! params ) {
3401
+
3402
+ console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
3403
+ return;
3404
+
3405
+ }
3406
+
3407
+ if ( cameraDef.type === 'perspective' ) {
3408
+
3409
+ camera = new THREE.PerspectiveCamera( THREE.MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 );
3410
+
3411
+ } else if ( cameraDef.type === 'orthographic' ) {
3412
+
3413
+ camera = new THREE.OrthographicCamera( - params.xmag, params.xmag, params.ymag, - params.ymag, params.znear, params.zfar );
3414
+
3415
+ }
3416
+
3417
+ if ( cameraDef.name ) camera.name = this.createUniqueName( cameraDef.name );
3418
+ assignExtrasToUserData( camera, cameraDef );
3419
+ return Promise.resolve( camera );
3420
+
3421
+ }
3422
+ /**
3423
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
3424
+ * @param {number} skinIndex
3425
+ * @return {Promise<Object>}
3426
+ */
3427
+
3428
+
3429
+ loadSkin( skinIndex ) {
3430
+
3431
+ const skinDef = this.json.skins[ skinIndex ];
3432
+ const skinEntry = {
3433
+ joints: skinDef.joints
3434
+ };
3435
+
3436
+ if ( skinDef.inverseBindMatrices === undefined ) {
3437
+
3438
+ return Promise.resolve( skinEntry );
3439
+
3440
+ }
3441
+
3442
+ return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) {
3443
+
3444
+ skinEntry.inverseBindMatrices = accessor;
3445
+ return skinEntry;
3446
+
3447
+ } );
3448
+
3449
+ }
3450
+ /**
3451
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
3452
+ * @param {number} animationIndex
3453
+ * @return {Promise<AnimationClip>}
3454
+ */
3455
+
3456
+
3457
+ loadAnimation( animationIndex ) {
3458
+
3459
+ const json = this.json;
3460
+ const animationDef = json.animations[ animationIndex ];
3461
+ const pendingNodes = [];
3462
+ const pendingInputAccessors = [];
3463
+ const pendingOutputAccessors = [];
3464
+ const pendingSamplers = [];
3465
+ const pendingTargets = [];
3466
+
3467
+ for ( let i = 0, il = animationDef.channels.length; i < il; i ++ ) {
3468
+
3469
+ const channel = animationDef.channels[ i ];
3470
+ const sampler = animationDef.samplers[ channel.sampler ];
3471
+ const target = channel.target;
3472
+ const name = target.node;
3473
+ const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
3474
+ const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
3475
+ pendingNodes.push( this.getDependency( 'node', name ) );
3476
+ pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
3477
+ pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
3478
+ pendingSamplers.push( sampler );
3479
+ pendingTargets.push( target );
3480
+
3481
+ }
3482
+
3483
+ return Promise.all( [ Promise.all( pendingNodes ), Promise.all( pendingInputAccessors ), Promise.all( pendingOutputAccessors ), Promise.all( pendingSamplers ), Promise.all( pendingTargets ) ] ).then( function ( dependencies ) {
3484
+
3485
+ const nodes = dependencies[ 0 ];
3486
+ const inputAccessors = dependencies[ 1 ];
3487
+ const outputAccessors = dependencies[ 2 ];
3488
+ const samplers = dependencies[ 3 ];
3489
+ const targets = dependencies[ 4 ];
3490
+ const tracks = [];
3491
+
3492
+ for ( let i = 0, il = nodes.length; i < il; i ++ ) {
3493
+
3494
+ const node = nodes[ i ];
3495
+ const inputAccessor = inputAccessors[ i ];
3496
+ const outputAccessor = outputAccessors[ i ];
3497
+ const sampler = samplers[ i ];
3498
+ const target = targets[ i ];
3499
+ if ( node === undefined ) continue;
3500
+ node.updateMatrix();
3501
+ let TypedKeyframeTrack;
3502
+
3503
+ switch ( PATH_PROPERTIES[ target.path ] ) {
3504
+
3505
+ case PATH_PROPERTIES.weights:
3506
+ TypedKeyframeTrack = THREE.NumberKeyframeTrack;
3507
+ break;
3508
+
3509
+ case PATH_PROPERTIES.rotation:
3510
+ TypedKeyframeTrack = THREE.QuaternionKeyframeTrack;
3511
+ break;
3512
+
3513
+ case PATH_PROPERTIES.position:
3514
+ case PATH_PROPERTIES.scale:
3515
+ default:
3516
+ TypedKeyframeTrack = THREE.VectorKeyframeTrack;
3517
+ break;
3518
+
3519
+ }
3520
+
3521
+ const targetName = node.name ? node.name : node.uuid;
3522
+ const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;
3523
+ const targetNames = [];
3524
+
3525
+ if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) {
3526
+
3527
+ node.traverse( function ( object ) {
3528
+
3529
+ if ( object.morphTargetInfluences ) {
3530
+
3531
+ targetNames.push( object.name ? object.name : object.uuid );
3532
+
3533
+ }
3534
+
3535
+ } );
3536
+
3537
+ } else {
3538
+
3539
+ targetNames.push( targetName );
3540
+
3541
+ }
3542
+
3543
+ let outputArray = outputAccessor.array;
3544
+
3545
+ if ( outputAccessor.normalized ) {
3546
+
3547
+ const scale = getNormalizedComponentScale( outputArray.constructor );
3548
+ const scaled = new Float32Array( outputArray.length );
3549
+
3550
+ for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
3551
+
3552
+ scaled[ j ] = outputArray[ j ] * scale;
3553
+
3554
+ }
3555
+
3556
+ outputArray = scaled;
3557
+
3558
+ }
3559
+
3560
+ for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) {
3561
+
3562
+ const track = new TypedKeyframeTrack( targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ], inputAccessor.array, outputArray, interpolation ); // Override interpolation with custom factory method.
3563
+
3564
+ if ( sampler.interpolation === 'CUBICSPLINE' ) {
3565
+
3566
+ track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
3567
+
3568
+ // A CUBICSPLINE keyframe in glTF has three output values for each input value,
3569
+ // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
3570
+ // must be divided by three to get the interpolant's sampleSize argument.
3571
+ const interpolantType = this instanceof THREE.QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
3572
+ return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
3573
+
3574
+ }; // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
3575
+
3576
+
3577
+ track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
3578
+
3579
+ }
3580
+
3581
+ tracks.push( track );
3582
+
3583
+ }
3584
+
3585
+ }
3586
+
3587
+ const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
3588
+ return new THREE.AnimationClip( name, undefined, tracks );
3589
+
3590
+ } );
3591
+
3592
+ }
3593
+
3594
+ createNodeMesh( nodeIndex ) {
3595
+
3596
+ const json = this.json;
3597
+ const parser = this;
3598
+ const nodeDef = json.nodes[ nodeIndex ];
3599
+ if ( nodeDef.mesh === undefined ) return null;
3600
+ return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
3601
+
3602
+ const node = parser._getNodeRef( parser.meshCache, nodeDef.mesh, mesh ); // if weights are provided on the node, override weights on the mesh.
3603
+
3604
+
3605
+ if ( nodeDef.weights !== undefined ) {
3606
+
3607
+ node.traverse( function ( o ) {
3608
+
3609
+ if ( ! o.isMesh ) return;
3610
+
3611
+ for ( let i = 0, il = nodeDef.weights.length; i < il; i ++ ) {
3612
+
3613
+ o.morphTargetInfluences[ i ] = nodeDef.weights[ i ];
3614
+
3615
+ }
3616
+
3617
+ } );
3618
+
3619
+ }
3620
+
3621
+ return node;
3622
+
3623
+ } );
3624
+
3625
+ }
3626
+ /**
3627
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
3628
+ * @param {number} nodeIndex
3629
+ * @return {Promise<Object3D>}
3630
+ */
3631
+
3632
+
3633
+ loadNode( nodeIndex ) {
3634
+
3635
+ const json = this.json;
3636
+ const extensions = this.extensions;
3637
+ const parser = this;
3638
+ const nodeDef = json.nodes[ nodeIndex ]; // reserve node's name before its dependencies, so the root has the intended name.
3639
+
3640
+ const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
3641
+ return function () {
3642
+
3643
+ const pending = [];
3644
+
3645
+ const meshPromise = parser._invokeOne( function ( ext ) {
3646
+
3647
+ return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
3648
+
3649
+ } );
3650
+
3651
+ if ( meshPromise ) {
3652
+
3653
+ pending.push( meshPromise );
3654
+
3655
+ }
3656
+
3657
+ if ( nodeDef.camera !== undefined ) {
3658
+
3659
+ pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
3660
+
3661
+ return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
3662
+
3663
+ } ) );
3664
+
3665
+ }
3666
+
3667
+ parser._invokeAll( function ( ext ) {
3668
+
3669
+ return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
3670
+
3671
+ } ).forEach( function ( promise ) {
3672
+
3673
+ pending.push( promise );
3674
+
3675
+ } );
3676
+
3677
+ return Promise.all( pending );
3678
+
3679
+ }().then( function ( objects ) {
3680
+
3681
+ let node; // .isBone isn't in glTF spec. See ._markDefs
3682
+
3683
+ if ( nodeDef.isBone === true ) {
3684
+
3685
+ node = new THREE.Bone();
3686
+
3687
+ } else if ( objects.length > 1 ) {
3688
+
3689
+ node = new THREE.Group();
3690
+
3691
+ } else if ( objects.length === 1 ) {
3692
+
3693
+ node = objects[ 0 ];
3694
+
3695
+ } else {
3696
+
3697
+ node = new THREE.Object3D();
3698
+
3699
+ }
3700
+
3701
+ if ( node !== objects[ 0 ] ) {
3702
+
3703
+ for ( let i = 0, il = objects.length; i < il; i ++ ) {
3704
+
3705
+ node.add( objects[ i ] );
3706
+
3707
+ }
3708
+
3709
+ }
3710
+
3711
+ if ( nodeDef.name ) {
3712
+
3713
+ node.userData.name = nodeDef.name;
3714
+ node.name = nodeName;
3715
+
3716
+ }
3717
+
3718
+ assignExtrasToUserData( node, nodeDef );
3719
+ if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef );
3720
+
3721
+ if ( nodeDef.matrix !== undefined ) {
3722
+
3723
+ const matrix = new THREE.Matrix4();
3724
+ matrix.fromArray( nodeDef.matrix );
3725
+ node.applyMatrix4( matrix );
3726
+
3727
+ } else {
3728
+
3729
+ if ( nodeDef.translation !== undefined ) {
3730
+
3731
+ node.position.fromArray( nodeDef.translation );
3732
+
3733
+ }
3734
+
3735
+ if ( nodeDef.rotation !== undefined ) {
3736
+
3737
+ node.quaternion.fromArray( nodeDef.rotation );
3738
+
3739
+ }
3740
+
3741
+ if ( nodeDef.scale !== undefined ) {
3742
+
3743
+ node.scale.fromArray( nodeDef.scale );
3744
+
3745
+ }
3746
+
3747
+ }
3748
+
3749
+ if ( ! parser.associations.has( node ) ) {
3750
+
3751
+ parser.associations.set( node, {} );
3752
+
3753
+ }
3754
+
3755
+ parser.associations.get( node ).nodes = nodeIndex;
3756
+ return node;
3757
+
3758
+ } );
3759
+
3760
+ }
3761
+ /**
3762
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
3763
+ * @param {number} sceneIndex
3764
+ * @return {Promise<Group>}
3765
+ */
3766
+
3767
+
3768
+ loadScene( sceneIndex ) {
3769
+
3770
+ const json = this.json;
3771
+ const extensions = this.extensions;
3772
+ const sceneDef = this.json.scenes[ sceneIndex ];
3773
+ const parser = this; // THREE.Loader returns THREE.Group, not Scene.
3774
+ // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
3775
+
3776
+ const scene = new THREE.Group();
3777
+ if ( sceneDef.name ) scene.name = parser.createUniqueName( sceneDef.name );
3778
+ assignExtrasToUserData( scene, sceneDef );
3779
+ if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef );
3780
+ const nodeIds = sceneDef.nodes || [];
3781
+ const pending = [];
3782
+
3783
+ for ( let i = 0, il = nodeIds.length; i < il; i ++ ) {
3784
+
3785
+ pending.push( buildNodeHierarchy( nodeIds[ i ], scene, json, parser ) );
3786
+
3787
+ }
3788
+
3789
+ return Promise.all( pending ).then( function () {
3790
+
3791
+ // Removes dangling associations, associations that reference a node that
3792
+ // didn't make it into the scene.
3793
+ const reduceAssociations = node => {
3794
+
3795
+ const reducedAssociations = new Map();
3796
+
3797
+ for ( const [ key, value ] of parser.associations ) {
3798
+
3799
+ if ( key instanceof THREE.Material || key instanceof THREE.Texture ) {
3800
+
3801
+ reducedAssociations.set( key, value );
3802
+
3803
+ }
3804
+
3805
+ }
3806
+
3807
+ node.traverse( node => {
3808
+
3809
+ const mappings = parser.associations.get( node );
3810
+
3811
+ if ( mappings != null ) {
3812
+
3813
+ reducedAssociations.set( node, mappings );
3814
+
3815
+ }
3816
+
3817
+ } );
3818
+ return reducedAssociations;
3819
+
3820
+ };
3821
+
3822
+ parser.associations = reduceAssociations( scene );
3823
+ return scene;
3824
+
3825
+ } );
3826
+
3827
+ }
3828
+
3829
+ }
3830
+
3831
+ function buildNodeHierarchy( nodeId, parentObject, json, parser ) {
3832
+
3833
+ const nodeDef = json.nodes[ nodeId ];
3834
+ return parser.getDependency( 'node', nodeId ).then( function ( node ) {
3835
+
3836
+ if ( nodeDef.skin === undefined ) return node; // build skeleton here as well
3837
+
3838
+ let skinEntry;
3839
+ return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) {
3840
+
3841
+ skinEntry = skin;
3842
+ const pendingJoints = [];
3843
+
3844
+ for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) {
3845
+
3846
+ pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) );
3847
+
3848
+ }
3849
+
3850
+ return Promise.all( pendingJoints );
3851
+
3852
+ } ).then( function ( jointNodes ) {
3853
+
3854
+ node.traverse( function ( mesh ) {
3855
+
3856
+ if ( ! mesh.isMesh ) return;
3857
+ const bones = [];
3858
+ const boneInverses = [];
3859
+
3860
+ for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) {
3861
+
3862
+ const jointNode = jointNodes[ j ];
3863
+
3864
+ if ( jointNode ) {
3865
+
3866
+ bones.push( jointNode );
3867
+ const mat = new THREE.Matrix4();
3868
+
3869
+ if ( skinEntry.inverseBindMatrices !== undefined ) {
3870
+
3871
+ mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 );
3872
+
3873
+ }
3874
+
3875
+ boneInverses.push( mat );
3876
+
3877
+ } else {
3878
+
3879
+ console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] );
3880
+
3881
+ }
3882
+
3883
+ }
3884
+
3885
+ mesh.bind( new THREE.Skeleton( bones, boneInverses ), mesh.matrixWorld );
3886
+
3887
+ } );
3888
+ return node;
3889
+
3890
+ } );
3891
+
3892
+ } ).then( function ( node ) {
3893
+
3894
+ // build node hierachy
3895
+ parentObject.add( node );
3896
+ const pending = [];
3897
+
3898
+ if ( nodeDef.children ) {
3899
+
3900
+ const children = nodeDef.children;
3901
+
3902
+ for ( let i = 0, il = children.length; i < il; i ++ ) {
3903
+
3904
+ const child = children[ i ];
3905
+ pending.push( buildNodeHierarchy( child, node, json, parser ) );
3906
+
3907
+ }
3908
+
3909
+ }
3910
+
3911
+ return Promise.all( pending );
3912
+
3913
+ } );
3914
+
3915
+ }
3916
+ /**
3917
+ * @param {BufferGeometry} geometry
3918
+ * @param {GLTF.Primitive} primitiveDef
3919
+ * @param {GLTFParser} parser
3920
+ */
3921
+
3922
+
3923
+ function computeBounds( geometry, primitiveDef, parser ) {
3924
+
3925
+ const attributes = primitiveDef.attributes;
3926
+ const box = new THREE.Box3();
3927
+
3928
+ if ( attributes.POSITION !== undefined ) {
3929
+
3930
+ const accessor = parser.json.accessors[ attributes.POSITION ];
3931
+ const min = accessor.min;
3932
+ const max = accessor.max; // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
3933
+
3934
+ if ( min !== undefined && max !== undefined ) {
3935
+
3936
+ box.set( new THREE.Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ), new THREE.Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) );
3937
+
3938
+ if ( accessor.normalized ) {
3939
+
3940
+ const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
3941
+ box.min.multiplyScalar( boxScale );
3942
+ box.max.multiplyScalar( boxScale );
3943
+
3944
+ }
3945
+
3946
+ } else {
3947
+
3948
+ console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
3949
+ return;
3950
+
3951
+ }
3952
+
3953
+ } else {
3954
+
3955
+ return;
3956
+
3957
+ }
3958
+
3959
+ const targets = primitiveDef.targets;
3960
+
3961
+ if ( targets !== undefined ) {
3962
+
3963
+ const maxDisplacement = new THREE.Vector3();
3964
+ const vector = new THREE.Vector3();
3965
+
3966
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
3967
+
3968
+ const target = targets[ i ];
3969
+
3970
+ if ( target.POSITION !== undefined ) {
3971
+
3972
+ const accessor = parser.json.accessors[ target.POSITION ];
3973
+ const min = accessor.min;
3974
+ const max = accessor.max; // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
3975
+
3976
+ if ( min !== undefined && max !== undefined ) {
3977
+
3978
+ // we need to get max of absolute components because target weight is [-1,1]
3979
+ vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
3980
+ vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
3981
+ vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
3982
+
3983
+ if ( accessor.normalized ) {
3984
+
3985
+ const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
3986
+ vector.multiplyScalar( boxScale );
3987
+
3988
+ } // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative
3989
+ // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets
3990
+ // are used to implement key-frame animations and as such only two are active at a time - this results in very large
3991
+ // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.
3992
+
3993
+
3994
+ maxDisplacement.max( vector );
3995
+
3996
+ } else {
3997
+
3998
+ console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
3999
+
4000
+ }
4001
+
4002
+ }
4003
+
4004
+ } // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.
4005
+
4006
+
4007
+ box.expandByVector( maxDisplacement );
4008
+
4009
+ }
4010
+
4011
+ geometry.boundingBox = box;
4012
+ const sphere = new THREE.Sphere();
4013
+ box.getCenter( sphere.center );
4014
+ sphere.radius = box.min.distanceTo( box.max ) / 2;
4015
+ geometry.boundingSphere = sphere;
4016
+
4017
+ }
4018
+ /**
4019
+ * @param {BufferGeometry} geometry
4020
+ * @param {GLTF.Primitive} primitiveDef
4021
+ * @param {GLTFParser} parser
4022
+ * @return {Promise<BufferGeometry>}
4023
+ */
4024
+
4025
+
4026
+ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
4027
+
4028
+ const attributes = primitiveDef.attributes;
4029
+ const pending = [];
4030
+
4031
+ function assignAttributeAccessor( accessorIndex, attributeName ) {
4032
+
4033
+ return parser.getDependency( 'accessor', accessorIndex ).then( function ( accessor ) {
4034
+
4035
+ geometry.setAttribute( attributeName, accessor );
4036
+
4037
+ } );
4038
+
4039
+ }
4040
+
4041
+ for ( const gltfAttributeName in attributes ) {
4042
+
4043
+ const threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase(); // Skip attributes already provided by e.g. Draco extension.
4044
+
4045
+ if ( threeAttributeName in geometry.attributes ) continue;
4046
+ pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) );
4047
+
4048
+ }
4049
+
4050
+ if ( primitiveDef.indices !== undefined && ! geometry.index ) {
4051
+
4052
+ const accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) {
4053
+
4054
+ geometry.setIndex( accessor );
4055
+
4056
+ } );
4057
+ pending.push( accessor );
4058
+
4059
+ }
4060
+
4061
+ assignExtrasToUserData( geometry, primitiveDef );
4062
+ computeBounds( geometry, primitiveDef, parser );
4063
+ return Promise.all( pending ).then( function () {
4064
+
4065
+ return primitiveDef.targets !== undefined ? addMorphTargets( geometry, primitiveDef.targets, parser ) : geometry;
4066
+
4067
+ } );
4068
+
4069
+ }
4070
+ /**
4071
+ * @param {BufferGeometry} geometry
4072
+ * @param {Number} drawMode
4073
+ * @return {BufferGeometry}
4074
+ */
4075
+
4076
+
4077
+ function toTrianglesDrawMode( geometry, drawMode ) {
4078
+
4079
+ let index = geometry.getIndex(); // generate index if not present
4080
+
4081
+ if ( index === null ) {
4082
+
4083
+ const indices = [];
4084
+ const position = geometry.getAttribute( 'position' );
4085
+
4086
+ if ( position !== undefined ) {
4087
+
4088
+ for ( let i = 0; i < position.count; i ++ ) {
4089
+
4090
+ indices.push( i );
4091
+
4092
+ }
4093
+
4094
+ geometry.setIndex( indices );
4095
+ index = geometry.getIndex();
4096
+
4097
+ } else {
4098
+
4099
+ console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
4100
+ return geometry;
4101
+
4102
+ }
4103
+
4104
+ } //
4105
+
4106
+
4107
+ const numberOfTriangles = index.count - 2;
4108
+ const newIndices = [];
4109
+
4110
+ if ( drawMode === THREE.TriangleFanDrawMode ) {
4111
+
4112
+ // gl.TRIANGLE_FAN
4113
+ for ( let i = 1; i <= numberOfTriangles; i ++ ) {
4114
+
4115
+ newIndices.push( index.getX( 0 ) );
4116
+ newIndices.push( index.getX( i ) );
4117
+ newIndices.push( index.getX( i + 1 ) );
4118
+
4119
+ }
4120
+
4121
+ } else {
4122
+
4123
+ // gl.TRIANGLE_STRIP
4124
+ for ( let i = 0; i < numberOfTriangles; i ++ ) {
4125
+
4126
+ if ( i % 2 === 0 ) {
4127
+
4128
+ newIndices.push( index.getX( i ) );
4129
+ newIndices.push( index.getX( i + 1 ) );
4130
+ newIndices.push( index.getX( i + 2 ) );
4131
+
4132
+ } else {
4133
+
4134
+ newIndices.push( index.getX( i + 2 ) );
4135
+ newIndices.push( index.getX( i + 1 ) );
4136
+ newIndices.push( index.getX( i ) );
4137
+
4138
+ }
4139
+
4140
+ }
4141
+
4142
+ }
4143
+
4144
+ if ( newIndices.length / 3 !== numberOfTriangles ) {
4145
+
4146
+ console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
4147
+
4148
+ } // build final geometry
4149
+
4150
+
4151
+ const newGeometry = geometry.clone();
4152
+ newGeometry.setIndex( newIndices );
4153
+ return newGeometry;
4154
+
4155
+ }
4156
+
4157
+ THREE.GLTFLoader = GLTFLoader;
4158
+
4159
+ } )();