@shopware-ag/dive 2.0.1-beta.1 → 2.0.1-beta.11

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 (280) hide show
  1. package/build/chunks/AssetCache-CsfCIl9J.mjs +79 -0
  2. package/build/chunks/AssetCache-DGLqbo2B.cjs +1 -0
  3. package/build/chunks/AssetExporter-DsbC2rqv.cjs +164 -0
  4. package/build/{src/modules/asset/exporter/AssetExporter.mjs → chunks/AssetExporter-brT7ogoM.mjs} +22 -21
  5. package/build/chunks/AssetLoader-DvF8gL8a.mjs +2341 -0
  6. package/build/chunks/AssetLoader-H_GSIMop.cjs +4 -0
  7. package/build/chunks/FileTypes-CHutqD19.cjs +30 -0
  8. package/build/chunks/FileTypes-IBuu9ohV.mjs +1057 -0
  9. package/build/chunks/MathUtils-CBW56ZuG.cjs +1 -0
  10. package/build/chunks/MathUtils-CFGjHuVF.mjs +159 -0
  11. package/build/chunks/OrbitController-BQ6SV1O_.mjs +1159 -0
  12. package/build/chunks/OrbitController-CpFQ3A1H.cjs +1 -0
  13. package/build/chunks/{PerspectiveCamera-sm4_81KJ.mjs → PerspectiveCamera-PMJPzAn3.mjs} +2 -2
  14. package/build/chunks/PovSchema-Co9FznEz.cjs +1 -0
  15. package/build/chunks/PovSchema-DWWvr_ED.mjs +10 -0
  16. package/build/chunks/{SelectTool-Bd8cC9nb.mjs → SelectTool-BU0vTDXg.mjs} +44 -39
  17. package/build/chunks/SelectTool-CAqDMcoM.cjs +1 -0
  18. package/build/chunks/draco_decoder-Bh9flJPu.cjs +1 -0
  19. package/build/chunks/draco_decoder-CEzwqP9o.mjs +38 -0
  20. package/build/chunks/draco_decoder-DtHHc5d0.mjs +4 -0
  21. package/build/chunks/draco_decoder-DvYjcLz_.cjs +35 -0
  22. package/build/chunks/draco_wasm_wrapper-FoEVV9af.cjs +118 -0
  23. package/build/chunks/draco_wasm_wrapper-yQy2VLhb.mjs +121 -0
  24. package/build/chunks/fflate.module-DHdJvhNh.cjs +6 -0
  25. package/build/chunks/fflate.module-xyO_T3Zm.mjs +602 -0
  26. package/build/chunks/findInterface-C6mrvf_t.cjs +1 -0
  27. package/build/chunks/findInterface-DbJ5qzbc.mjs +11 -0
  28. package/build/chunks/isFileTypeSupported-BSpswPHU.mjs +12 -0
  29. package/build/chunks/isFileTypeSupported-CrEqYiv9.cjs +1 -0
  30. package/build/chunks/network-error-BONfHWQq.mjs +14 -0
  31. package/build/chunks/network-error-CdDXil5g.cjs +1 -0
  32. package/build/chunks/package-CmvmIjT5.cjs +1 -0
  33. package/build/chunks/package-DSKqbNMb.mjs +39 -0
  34. package/build/chunks/parse-error-DfOPyLWM.mjs +14 -0
  35. package/build/chunks/parse-error-Dy_EE4rL.cjs +1 -0
  36. package/build/dive.cjs +1 -30
  37. package/build/dive.mjs +674 -1535
  38. package/build/plugins/animation/index.cjs +1 -0
  39. package/build/plugins/animation/index.d.ts +2 -0
  40. package/build/plugins/animation/index.mjs +126 -0
  41. package/build/plugins/ar/index.cjs +1 -0
  42. package/build/plugins/ar/index.d.ts +2 -0
  43. package/build/plugins/ar/index.mjs +207 -0
  44. package/build/plugins/assetcache/index.cjs +1 -0
  45. package/build/plugins/assetcache/index.d.ts +2 -0
  46. package/build/plugins/assetcache/index.mjs +5 -0
  47. package/build/plugins/assetconverter/index.d.ts +2 -0
  48. package/build/plugins/assetexporter/index.cjs +1 -0
  49. package/build/plugins/assetexporter/index.d.ts +2 -0
  50. package/build/plugins/assetexporter/index.mjs +4 -0
  51. package/build/plugins/assetloader/index.cjs +1 -0
  52. package/build/plugins/assetloader/index.d.ts +2 -0
  53. package/build/plugins/assetloader/index.mjs +6 -0
  54. package/build/plugins/mediacreator/index.cjs +1 -0
  55. package/build/plugins/mediacreator/index.d.ts +2 -0
  56. package/build/{src/modules/mediacreator/MediaCreator.mjs → plugins/mediacreator/index.mjs} +4 -4
  57. package/build/plugins/orbitcontroller/index.cjs +1 -0
  58. package/build/plugins/orbitcontroller/index.d.ts +2 -0
  59. package/build/plugins/orbitcontroller/index.mjs +5 -0
  60. package/build/plugins/orientationdisplay/index.cjs +1 -0
  61. package/build/plugins/orientationdisplay/index.d.ts +2 -0
  62. package/build/plugins/orientationdisplay/index.mjs +5 -0
  63. package/build/plugins/state/index.cjs +27 -0
  64. package/build/plugins/state/index.d.ts +2 -0
  65. package/build/plugins/state/index.mjs +4266 -0
  66. package/build/plugins/systeminfo/index.cjs +1 -0
  67. package/build/plugins/systeminfo/index.d.ts +2 -0
  68. package/build/{chunks/SystemInfo-DPAQG-S5.mjs → plugins/systeminfo/index.mjs} +48 -51
  69. package/build/plugins/toolbox/index.cjs +1 -0
  70. package/build/plugins/toolbox/index.d.ts +2 -0
  71. package/build/{src/modules/toolbox/Toolbox.mjs → plugins/toolbox/index.mjs} +29 -23
  72. package/build/src/components/boundingbox/BoundingBox.d.ts +136 -0
  73. package/build/src/components/gizmo/Gizmo.d.ts +1 -1
  74. package/build/src/components/gizmo/handles/AxisHandle.d.ts +1 -1
  75. package/build/src/components/gizmo/handles/RadialHandle.d.ts +1 -1
  76. package/build/src/components/gizmo/handles/ScaleHandle.d.ts +1 -1
  77. package/build/src/components/gizmo/rotate/RotateGizmo.d.ts +2 -2
  78. package/build/src/components/gizmo/scale/ScaleGizmo.d.ts +2 -2
  79. package/build/src/components/gizmo/translate/TranslateGizmo.d.ts +2 -2
  80. package/build/src/components/group/Group.d.ts +4 -4
  81. package/build/src/components/model/Model.d.ts +2 -2
  82. package/build/src/components/node/Node.d.ts +7 -7
  83. package/build/src/components/primitive/Primitive.d.ts +3 -3
  84. package/build/src/components/root/Root.d.ts +5 -7
  85. package/build/src/core/Dive.d.ts +5 -4
  86. package/build/src/engine/clock/Clock.d.ts +1 -0
  87. package/build/src/engine/index.d.ts +6 -0
  88. package/build/src/engine/renderer/Renderer.d.ts +47 -7
  89. package/build/src/engine/scene/xrroot/XRRoot.d.ts +2 -2
  90. package/build/src/engine/scene/xrroot/xrlightroot/XRLightRoot.d.ts +2 -2
  91. package/build/src/error/file-content/file-content-error.d.ts +4 -0
  92. package/build/src/error/index.d.ts +4 -0
  93. package/build/src/error/network/network-error.d.ts +1 -1
  94. package/build/src/error/parse/parse-error.d.ts +2 -1
  95. package/build/src/events/dispatcher/EventDispatcher.d.ts +6 -0
  96. package/build/src/events/index.d.ts +1 -0
  97. package/build/src/helpers/deepClone/deepClone.d.ts +34 -0
  98. package/build/src/helpers/index.d.ts +5 -4
  99. package/build/src/index.d.ts +5 -5
  100. package/build/src/interfaces/Draggable.d.ts +1 -1
  101. package/build/src/plugins/animation/index.d.ts +2 -0
  102. package/build/src/{modules/animation → plugins/animation/src}/animator/Animator.d.ts +2 -3
  103. package/build/src/plugins/animation/src/index.d.ts +3 -0
  104. package/build/src/plugins/animation/src/system/AnimationSystem.d.ts +23 -0
  105. package/build/src/plugins/ar/index.d.ts +4 -0
  106. package/build/src/plugins/ar/src/ARSystem.d.ts +24 -0
  107. package/build/src/plugins/ar/src/arquicklook/ARQuickLook.d.ts +15 -0
  108. package/build/src/plugins/ar/src/error/ar-errors.d.ts +24 -0
  109. package/build/src/{modules/ar → plugins/ar/src}/sceneviewer/SceneViewer.d.ts +10 -0
  110. package/build/src/{modules/ar → plugins/ar/src}/webxr/WebXR.d.ts +4 -4
  111. package/build/src/{modules/ar → plugins/ar/src}/webxr/controller/WebXRController.d.ts +5 -5
  112. package/build/src/{modules/ar → plugins/ar/src}/webxr/crosshair/WebXRCrosshair.d.ts +2 -2
  113. package/build/src/{modules/ar → plugins/ar/src}/webxr/origin/WebXROrigin.d.ts +4 -4
  114. package/build/src/{modules/ar → plugins/ar/src}/webxr/overlay/Overlay.d.ts +2 -2
  115. package/build/src/{modules/ar → plugins/ar/src}/webxr/raycaster/WebXRRaycaster.d.ts +8 -8
  116. package/build/src/{modules/ar → plugins/ar/src}/webxr/raycaster/ar/WebXRRaycasterAR.d.ts +4 -4
  117. package/build/src/{modules/ar → plugins/ar/src}/webxr/raycaster/three/WebXRRaycasterTHREE.d.ts +4 -4
  118. package/build/src/{modules/ar → plugins/ar/src}/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +3 -3
  119. package/build/src/plugins/assetcache/index.d.ts +1 -0
  120. package/build/src/plugins/assetcache/src/cache/AssetCache.d.ts +12 -0
  121. package/build/src/plugins/assetcache/src/chunk/Chunk.d.ts +16 -0
  122. package/build/src/plugins/assetcache/src/index.d.ts +2 -0
  123. package/build/src/plugins/assetconverter/index.d.ts +1 -0
  124. package/build/src/plugins/assetconverter/src/AssetConverter.d.ts +13 -0
  125. package/build/src/plugins/assetexporter/index.d.ts +1 -0
  126. package/build/src/{modules/asset/exporter → plugins/assetexporter/src}/AssetExporter.d.ts +0 -17
  127. package/build/src/plugins/assetloader/index.d.ts +3 -0
  128. package/build/src/plugins/assetloader/src/draco/DracoLoader.d.ts +10 -0
  129. package/build/src/plugins/assetloader/src/loader/AssetLoader.d.ts +14 -0
  130. package/build/src/plugins/mediacreator/index.d.ts +1 -0
  131. package/build/src/plugins/mediacreator/src/MediaCreator.d.ts +15 -0
  132. package/build/src/plugins/orbitcontroller/index.d.ts +1 -0
  133. package/build/src/plugins/orbitcontroller/src/OrbitController.d.ts +45 -0
  134. package/build/src/plugins/orientationdisplay/index.d.ts +2 -0
  135. package/build/src/plugins/orientationdisplay/src/OrientationDisplay.d.ts +18 -0
  136. package/build/src/plugins/orientationdisplay/src/axes/Axes.d.ts +6 -0
  137. package/build/src/plugins/state/index.d.ts +4 -0
  138. package/build/src/{modules/state → plugins/state/src}/State.d.ts +4 -27
  139. package/build/src/{modules/state → plugins/state/src}/actions/action.d.ts +1 -1
  140. package/build/src/{modules/state → plugins/state/src}/actions/ar/launchar.d.ts +2 -2
  141. package/build/src/{modules/state → plugins/state/src}/actions/camera/computeencompassingview.d.ts +1 -1
  142. package/build/src/{modules/state → plugins/state/src}/actions/camera/getcameratransform.d.ts +1 -1
  143. package/build/src/{modules/state → plugins/state/src}/actions/camera/lockcamera.d.ts +1 -1
  144. package/build/src/{modules/state → plugins/state/src}/actions/camera/movecamera.d.ts +3 -3
  145. package/build/src/{modules/state → plugins/state/src}/actions/camera/setcameralayer.d.ts +1 -1
  146. package/build/src/{modules/state → plugins/state/src}/actions/camera/setcameratransform.d.ts +1 -1
  147. package/build/src/{modules/state → plugins/state/src}/actions/camera/zoomcamera.d.ts +1 -1
  148. package/build/src/{modules/state → plugins/state/src}/actions/media/generatemedia.d.ts +1 -1
  149. package/build/src/plugins/state/src/actions/object/addobject.d.ts +9 -0
  150. package/build/src/plugins/state/src/actions/object/deleteobject.d.ts +13 -0
  151. package/build/src/plugins/state/src/actions/object/deselectobject.d.ts +13 -0
  152. package/build/src/{modules/state → plugins/state/src}/actions/object/dropit.d.ts +3 -3
  153. package/build/src/{modules/state → plugins/state/src}/actions/object/getallobjects.d.ts +3 -2
  154. package/build/src/plugins/state/src/actions/object/getobjects.d.ts +13 -0
  155. package/build/src/{modules/state → plugins/state/src}/actions/object/modelloaded.d.ts +1 -1
  156. package/build/src/{modules/state → plugins/state/src}/actions/object/placeonfloor.d.ts +3 -3
  157. package/build/src/plugins/state/src/actions/object/selectobject.d.ts +13 -0
  158. package/build/src/plugins/state/src/actions/object/setparent.d.ts +23 -0
  159. package/build/src/plugins/state/src/actions/object/updateobject.d.ts +13 -0
  160. package/build/src/{modules/state → plugins/state/src}/actions/renderer/startrender.d.ts +1 -1
  161. package/build/src/{modules/state → plugins/state/src}/actions/scene/exportscene.d.ts +4 -4
  162. package/build/src/plugins/state/src/actions/scene/getallscenedata.d.ts +9 -0
  163. package/build/src/{modules/state → plugins/state/src}/actions/scene/setbackground.d.ts +1 -1
  164. package/build/src/{modules/state → plugins/state/src}/actions/scene/updatescene.d.ts +1 -1
  165. package/build/src/{modules/state → plugins/state/src}/actions/toolbox/setgizmomode.d.ts +1 -1
  166. package/build/src/{modules/state → plugins/state/src}/actions/toolbox/setgizmoscalelinked.d.ts +1 -1
  167. package/build/src/plugins/state/src/actions/toolbox/setgizmovisible.d.ts +8 -0
  168. package/build/src/{modules/state → plugins/state/src}/actions/toolbox/usetool.d.ts +2 -2
  169. package/build/src/plugins/state/types/ActionTypes.d.ts +17 -0
  170. package/build/src/{types/SceneType.d.ts → plugins/state/types/StateExportFileType.d.ts} +1 -1
  171. package/build/src/plugins/state/types/StateSceneData.d.ts +19 -0
  172. package/build/src/plugins/state/types/index.d.ts +1 -0
  173. package/build/src/plugins/systeminfo/index.d.ts +2 -0
  174. package/build/src/{modules/systeminfo → plugins/systeminfo/src}/SystemInfo.d.ts +22 -32
  175. package/build/src/plugins/toolbox/index.d.ts +4 -0
  176. package/build/src/{modules/toolbox → plugins/toolbox/src}/BaseTool.d.ts +4 -6
  177. package/build/src/{modules/toolbox → plugins/toolbox/src}/Toolbox.d.ts +8 -17
  178. package/build/src/{modules/toolbox → plugins/toolbox/src}/select/SelectTool.d.ts +7 -11
  179. package/build/src/{modules/toolbox → plugins/toolbox/src}/transform/TransformTool.d.ts +6 -10
  180. package/build/src/types/components/DIVELight.d.ts +4 -0
  181. package/build/src/types/components/DIVESceneObject.d.ts +6 -0
  182. package/build/src/types/components/index.d.ts +2 -0
  183. package/build/src/types/index.d.ts +2 -5
  184. package/build/src/types/schema/BaseEntitySchema.d.ts +8 -0
  185. package/build/src/types/schema/EntitySchema.d.ts +11 -0
  186. package/build/src/types/schema/EntityTypeSchema.d.ts +1 -0
  187. package/build/src/types/schema/GeometrySchema.d.ts +7 -0
  188. package/build/src/types/schema/GeometryTypeSchema.d.ts +1 -0
  189. package/build/src/types/schema/GroupSchema.d.ts +11 -0
  190. package/build/src/types/schema/LightSchema.d.ts +28 -0
  191. package/build/src/{modules/state/types/COMMaterial.d.ts → types/schema/MaterialSchema.d.ts} +1 -1
  192. package/build/src/types/schema/ModelSchema.d.ts +14 -0
  193. package/build/src/types/schema/PovSchema.d.ts +10 -0
  194. package/build/src/types/schema/PrimitiveSchema.d.ts +14 -0
  195. package/build/src/types/schema/index.d.ts +11 -0
  196. package/package.json +59 -41
  197. package/build/chunks/FileTypes-BjZ0rrIV.cjs +0 -1
  198. package/build/chunks/FileTypes-qgYnI0Jg.mjs +0 -30
  199. package/build/chunks/ModuleRegistry-NyNtjHb2.cjs +0 -1
  200. package/build/chunks/ModuleRegistry-RSub8W0G.mjs +0 -13
  201. package/build/chunks/SelectTool-BAXTVyWs.cjs +0 -1
  202. package/build/chunks/SystemInfo-oX-NNneO.cjs +0 -1
  203. package/build/chunks/findInterface-BEdL2iUQ.cjs +0 -1
  204. package/build/chunks/findInterface-OrXgmwxj.mjs +0 -18
  205. package/build/chunks/index-C_uFFwT2.mjs +0 -5
  206. package/build/chunks/index-DAwIH9xh.cjs +0 -1
  207. package/build/chunks/package-BHjZWYD6.mjs +0 -39
  208. package/build/chunks/package-JHvTSNgQ.cjs +0 -1
  209. package/build/chunks/parse-error-2f5qpXP5.cjs +0 -6
  210. package/build/chunks/parse-error-DRBVHL9E.mjs +0 -614
  211. package/build/src/error/ar-compatibility/ar-compatibility-error.d.ts +0 -12
  212. package/build/src/modules/ModuleRegistry.d.ts +0 -19
  213. package/build/src/modules/animation/AnimationSystem.cjs +0 -1
  214. package/build/src/modules/animation/AnimationSystem.d.ts +0 -36
  215. package/build/src/modules/animation/AnimationSystem.mjs +0 -95
  216. package/build/src/modules/ar/ARSystem.cjs +0 -1
  217. package/build/src/modules/ar/ARSystem.d.ts +0 -71
  218. package/build/src/modules/ar/ARSystem.mjs +0 -163
  219. package/build/src/modules/ar/arquicklook/ARQuickLook.d.ts +0 -7
  220. package/build/src/modules/asset/converter/AssetConverter.d.ts +0 -30
  221. package/build/src/modules/asset/draco/README.md +0 -32
  222. package/build/src/modules/asset/draco/draco_decoder.js +0 -33
  223. package/build/src/modules/asset/draco/draco_decoder.wasm +0 -0
  224. package/build/src/modules/asset/draco/draco_encoder.js +0 -33
  225. package/build/src/modules/asset/draco/draco_wasm_wrapper.js +0 -116
  226. package/build/src/modules/asset/draco/gltf/draco_decoder.js +0 -33
  227. package/build/src/modules/asset/draco/gltf/draco_decoder.wasm +0 -0
  228. package/build/src/modules/asset/draco/gltf/draco_encoder.js +0 -33
  229. package/build/src/modules/asset/draco/gltf/draco_wasm_wrapper.js +0 -116
  230. package/build/src/modules/asset/exporter/AssetExporter.cjs +0 -164
  231. package/build/src/modules/asset/loader/AssetLoader.cjs +0 -3
  232. package/build/src/modules/asset/loader/AssetLoader.d.ts +0 -29
  233. package/build/src/modules/asset/loader/AssetLoader.mjs +0 -2154
  234. package/build/src/modules/axiscamera/AxisCamera.d.ts +0 -21
  235. package/build/src/modules/controller/orbit/OrbitController.d.ts +0 -30
  236. package/build/src/modules/events/EventExecutor.d.ts +0 -5
  237. package/build/src/modules/mediacreator/MediaCreator.cjs +0 -1
  238. package/build/src/modules/mediacreator/MediaCreator.d.ts +0 -44
  239. package/build/src/modules/state/State.cjs +0 -27
  240. package/build/src/modules/state/State.mjs +0 -4296
  241. package/build/src/modules/state/actions/object/addobject.d.ts +0 -8
  242. package/build/src/modules/state/actions/object/deleteobject.d.ts +0 -12
  243. package/build/src/modules/state/actions/object/deselectobject.d.ts +0 -12
  244. package/build/src/modules/state/actions/object/getobjects.d.ts +0 -12
  245. package/build/src/modules/state/actions/object/selectobject.d.ts +0 -12
  246. package/build/src/modules/state/actions/object/setparent.d.ts +0 -22
  247. package/build/src/modules/state/actions/object/updateobject.d.ts +0 -12
  248. package/build/src/modules/state/actions/scene/getallscenedata.d.ts +0 -9
  249. package/build/src/modules/state/actions/toolbox/setgizmovisible.d.ts +0 -8
  250. package/build/src/modules/state/types/ActionTypes.d.ts +0 -18
  251. package/build/src/modules/state/types/COMBaseEntity.d.ts +0 -8
  252. package/build/src/modules/state/types/COMEntity.d.ts +0 -11
  253. package/build/src/modules/state/types/COMEntityType.d.ts +0 -1
  254. package/build/src/modules/state/types/COMGeometry.d.ts +0 -7
  255. package/build/src/modules/state/types/COMGeometryType.d.ts +0 -1
  256. package/build/src/modules/state/types/COMGroup.d.ts +0 -11
  257. package/build/src/modules/state/types/COMLight.d.ts +0 -28
  258. package/build/src/modules/state/types/COMModel.d.ts +0 -14
  259. package/build/src/modules/state/types/COMPov.d.ts +0 -10
  260. package/build/src/modules/state/types/COMPrimitive.d.ts +0 -14
  261. package/build/src/modules/state/types/index.d.ts +0 -11
  262. package/build/src/modules/systeminfo/SystemInfo.cjs +0 -1
  263. package/build/src/modules/systeminfo/SystemInfo.mjs +0 -5
  264. package/build/src/modules/toolbox/Toolbox.cjs +0 -1
  265. package/build/src/types/SceneData.d.ts +0 -19
  266. package/build/src/types/SceneObjects.d.ts +0 -9
  267. package/build/src/types/UUID.d.ts +0 -1
  268. /package/build/{src/modules/asset/converter/AssetConverter.cjs → plugins/assetconverter/index.cjs} +0 -0
  269. /package/build/{src/modules/asset/converter/AssetConverter.mjs → plugins/assetconverter/index.mjs} +0 -0
  270. /package/build/src/{modules/animation → plugins/animation/src}/types/AnimatorParameters.d.ts +0 -0
  271. /package/build/src/{modules/state → plugins/state/src}/ActionRegistry.d.ts +0 -0
  272. /package/build/src/{modules/state → plugins/state/src}/actions/ar/index.d.ts +0 -0
  273. /package/build/src/{modules/state → plugins/state/src}/actions/camera/index.d.ts +0 -0
  274. /package/build/src/{modules/state → plugins/state/src}/actions/index.d.ts +0 -0
  275. /package/build/src/{modules/state → plugins/state/src}/actions/media/index.d.ts +0 -0
  276. /package/build/src/{modules/state → plugins/state/src}/actions/object/index.d.ts +0 -0
  277. /package/build/src/{modules/state → plugins/state/src}/actions/renderer/index.d.ts +0 -0
  278. /package/build/src/{modules/state → plugins/state/src}/actions/scene/index.d.ts +0 -0
  279. /package/build/src/{modules/state → plugins/state/src}/actions/toolbox/index.d.ts +0 -0
  280. /package/build/src/{types/info → plugins/systeminfo/types}/index.d.ts +0 -0
@@ -1,2154 +0,0 @@
1
- var Ge = Object.defineProperty;
2
- var ve = (h, e, t) => e in h ? Ge(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
- var Q = (h, e, t) => ve(h, typeof e != "symbol" ? e + "" : e, t);
4
- import { TrianglesDrawMode as Be, TriangleFanDrawMode as se, TriangleStripDrawMode as Se, Loader as ie, LoaderUtils as X, FileLoader as j, MeshPhysicalMaterial as k, Vector2 as z, Color as H, LinearSRGBColorSpace as O, SRGBColorSpace as C, SpotLight as je, PointLight as Ke, DirectionalLight as Ve, Matrix4 as q, Vector3 as v, Quaternion as Le, InstancedMesh as Xe, InstancedBufferAttribute as We, Object3D as ae, TextureLoader as be, ImageBitmapLoader as ze, BufferAttribute as D, InterleavedBuffer as qe, InterleavedBufferAttribute as Ye, LinearMipmapLinearFilter as Me, NearestMipmapLinearFilter as Je, LinearMipmapNearestFilter as Qe, NearestMipmapNearestFilter as Ze, LinearFilter as Ne, NearestFilter as $e, RepeatWrapping as Y, MirroredRepeatWrapping as Ie, ClampToEdgeWrapping as Ce, PointsMaterial as et, Material as Z, LineBasicMaterial as tt, MeshStandardMaterial as Oe, DoubleSide as nt, MeshBasicMaterial as V, PropertyBinding as st, BufferGeometry as ce, SkinnedMesh as rt, Mesh as ke, LineSegments as ot, Line as it, LineLoop as at, Points as ct, Group as W, PerspectiveCamera as lt, MathUtils as ut, OrthographicCamera as ft, Skeleton as dt, AnimationClip as ht, Bone as pt, InterpolateDiscrete as mt, InterpolateLinear as De, Texture as fe, VectorKeyframeTrack as de, NumberKeyframeTrack as he, QuaternionKeyframeTrack as pe, ColorManagement as me, FrontSide as gt, Interpolant as At, Box3 as Tt, Sphere as xt, NoColorSpace as U } from "three";
5
- import { u as Rt, a as ge, F as Ae, P as Te } from "../../../../chunks/parse-error-DRBVHL9E.mjs";
6
- import { g as yt, i as wt, S as _t } from "../../../../chunks/FileTypes-qgYnI0Jg.mjs";
7
- function xe(h, e) {
8
- if (e === Be)
9
- return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), h;
10
- if (e === se || e === Se) {
11
- let t = h.getIndex();
12
- if (t === null) {
13
- const s = [], a = h.getAttribute("position");
14
- if (a !== void 0) {
15
- for (let i = 0; i < a.count; i++)
16
- s.push(i);
17
- h.setIndex(s), t = h.getIndex();
18
- } else
19
- return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), h;
20
- }
21
- const o = t.count - 2, n = [];
22
- if (e === se)
23
- for (let s = 1; s <= o; s++)
24
- n.push(t.getX(0)), n.push(t.getX(s)), n.push(t.getX(s + 1));
25
- else
26
- for (let s = 0; s < o; s++)
27
- s % 2 === 0 ? (n.push(t.getX(s)), n.push(t.getX(s + 1)), n.push(t.getX(s + 2))) : (n.push(t.getX(s + 2)), n.push(t.getX(s + 1)), n.push(t.getX(s)));
28
- n.length / 3 !== o && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
29
- const r = h.clone();
30
- return r.setIndex(n), r.clearGroups(), r;
31
- } else
32
- return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), h;
33
- }
34
- class Et extends ie {
35
- constructor(e) {
36
- super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
37
- return new Nt(t);
38
- }), this.register(function(t) {
39
- return new Ut(t);
40
- }), this.register(function(t) {
41
- return new Gt(t);
42
- }), this.register(function(t) {
43
- return new vt(t);
44
- }), this.register(function(t) {
45
- return new Ct(t);
46
- }), this.register(function(t) {
47
- return new Ot(t);
48
- }), this.register(function(t) {
49
- return new kt(t);
50
- }), this.register(function(t) {
51
- return new Dt(t);
52
- }), this.register(function(t) {
53
- return new Mt(t);
54
- }), this.register(function(t) {
55
- return new Ft(t);
56
- }), this.register(function(t) {
57
- return new It(t);
58
- }), this.register(function(t) {
59
- return new Ht(t);
60
- }), this.register(function(t) {
61
- return new Pt(t);
62
- }), this.register(function(t) {
63
- return new Lt(t);
64
- }), this.register(function(t) {
65
- return new Bt(t);
66
- }), this.register(function(t) {
67
- return new jt(t);
68
- });
69
- }
70
- load(e, t, o, n) {
71
- const r = this;
72
- let s;
73
- if (this.resourcePath !== "")
74
- s = this.resourcePath;
75
- else if (this.path !== "") {
76
- const c = X.extractUrlBase(e);
77
- s = X.resolveURL(c, this.path);
78
- } else
79
- s = X.extractUrlBase(e);
80
- this.manager.itemStart(e);
81
- const a = function(c) {
82
- n ? n(c) : console.error(c), r.manager.itemError(e), r.manager.itemEnd(e);
83
- }, i = new j(this.manager);
84
- i.setPath(this.path), i.setResponseType("arraybuffer"), i.setRequestHeader(this.requestHeader), i.setWithCredentials(this.withCredentials), i.load(e, function(c) {
85
- try {
86
- r.parse(c, s, function(l) {
87
- t(l), r.manager.itemEnd(e);
88
- }, a);
89
- } catch (l) {
90
- a(l);
91
- }
92
- }, o, a);
93
- }
94
- setDRACOLoader(e) {
95
- return this.dracoLoader = e, this;
96
- }
97
- setDDSLoader() {
98
- throw new Error(
99
- 'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".'
100
- );
101
- }
102
- setKTX2Loader(e) {
103
- return this.ktx2Loader = e, this;
104
- }
105
- setMeshoptDecoder(e) {
106
- return this.meshoptDecoder = e, this;
107
- }
108
- register(e) {
109
- return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
110
- }
111
- unregister(e) {
112
- return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
113
- }
114
- parse(e, t, o, n) {
115
- let r;
116
- const s = {}, a = {}, i = new TextDecoder();
117
- if (typeof e == "string")
118
- r = JSON.parse(e);
119
- else if (e instanceof ArrayBuffer)
120
- if (i.decode(new Uint8Array(e, 0, 4)) === Fe) {
121
- try {
122
- s[E.KHR_BINARY_GLTF] = new Kt(e);
123
- } catch (u) {
124
- n && n(u);
125
- return;
126
- }
127
- r = JSON.parse(s[E.KHR_BINARY_GLTF].content);
128
- } else
129
- r = JSON.parse(i.decode(e));
130
- else
131
- r = e;
132
- if (r.asset === void 0 || r.asset.version[0] < 2) {
133
- n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
134
- return;
135
- }
136
- const c = new nn(r, {
137
- path: t || this.resourcePath || "",
138
- crossOrigin: this.crossOrigin,
139
- requestHeader: this.requestHeader,
140
- manager: this.manager,
141
- ktx2Loader: this.ktx2Loader,
142
- meshoptDecoder: this.meshoptDecoder
143
- });
144
- c.fileLoader.setRequestHeader(this.requestHeader);
145
- for (let l = 0; l < this.pluginCallbacks.length; l++) {
146
- const u = this.pluginCallbacks[l](c);
147
- u.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[u.name] = u, s[u.name] = !0;
148
- }
149
- if (r.extensionsUsed)
150
- for (let l = 0; l < r.extensionsUsed.length; ++l) {
151
- const u = r.extensionsUsed[l], f = r.extensionsRequired || [];
152
- switch (u) {
153
- case E.KHR_MATERIALS_UNLIT:
154
- s[u] = new bt();
155
- break;
156
- case E.KHR_DRACO_MESH_COMPRESSION:
157
- s[u] = new Vt(r, this.dracoLoader);
158
- break;
159
- case E.KHR_TEXTURE_TRANSFORM:
160
- s[u] = new Xt();
161
- break;
162
- case E.KHR_MESH_QUANTIZATION:
163
- s[u] = new Wt();
164
- break;
165
- default:
166
- f.indexOf(u) >= 0 && a[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".');
167
- }
168
- }
169
- c.setExtensions(s), c.setPlugins(a), c.parse(o, n);
170
- }
171
- parseAsync(e, t) {
172
- const o = this;
173
- return new Promise(function(n, r) {
174
- o.parse(e, t, n, r);
175
- });
176
- }
177
- }
178
- function St() {
179
- let h = {};
180
- return {
181
- get: function(e) {
182
- return h[e];
183
- },
184
- add: function(e, t) {
185
- h[e] = t;
186
- },
187
- remove: function(e) {
188
- delete h[e];
189
- },
190
- removeAll: function() {
191
- h = {};
192
- }
193
- };
194
- }
195
- const E = {
196
- KHR_BINARY_GLTF: "KHR_binary_glTF",
197
- KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
198
- KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
199
- KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
200
- KHR_MATERIALS_IOR: "KHR_materials_ior",
201
- KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
202
- KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
203
- KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
204
- KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
205
- KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
206
- KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
207
- KHR_MATERIALS_VOLUME: "KHR_materials_volume",
208
- KHR_TEXTURE_BASISU: "KHR_texture_basisu",
209
- KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
210
- KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
211
- KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
212
- EXT_MATERIALS_BUMP: "EXT_materials_bump",
213
- EXT_TEXTURE_WEBP: "EXT_texture_webp",
214
- EXT_TEXTURE_AVIF: "EXT_texture_avif",
215
- EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
216
- EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
217
- };
218
- class Lt {
219
- constructor(e) {
220
- this.parser = e, this.name = E.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
221
- }
222
- _markDefs() {
223
- const e = this.parser, t = this.parser.json.nodes || [];
224
- for (let o = 0, n = t.length; o < n; o++) {
225
- const r = t[o];
226
- r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
227
- }
228
- }
229
- _loadLight(e) {
230
- const t = this.parser, o = "light:" + e;
231
- let n = t.cache.get(o);
232
- if (n) return n;
233
- const r = t.json, i = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e];
234
- let c;
235
- const l = new H(16777215);
236
- i.color !== void 0 && l.setRGB(i.color[0], i.color[1], i.color[2], O);
237
- const u = i.range !== void 0 ? i.range : 0;
238
- switch (i.type) {
239
- case "directional":
240
- c = new Ve(l), c.target.position.set(0, 0, -1), c.add(c.target);
241
- break;
242
- case "point":
243
- c = new Ke(l), c.distance = u;
244
- break;
245
- case "spot":
246
- c = new je(l), c.distance = u, i.spot = i.spot || {}, i.spot.innerConeAngle = i.spot.innerConeAngle !== void 0 ? i.spot.innerConeAngle : 0, i.spot.outerConeAngle = i.spot.outerConeAngle !== void 0 ? i.spot.outerConeAngle : Math.PI / 4, c.angle = i.spot.outerConeAngle, c.penumbra = 1 - i.spot.innerConeAngle / i.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
247
- break;
248
- default:
249
- throw new Error("THREE.GLTFLoader: Unexpected light type: " + i.type);
250
- }
251
- return c.position.set(0, 0, 0), c.decay = 2, P(c, i), i.intensity !== void 0 && (c.intensity = i.intensity), c.name = t.createUniqueName(i.name || "light_" + e), n = Promise.resolve(c), t.cache.add(o, n), n;
252
- }
253
- getDependency(e, t) {
254
- if (e === "light")
255
- return this._loadLight(t);
256
- }
257
- createNodeAttachment(e) {
258
- const t = this, o = this.parser, r = o.json.nodes[e], a = (r.extensions && r.extensions[this.name] || {}).light;
259
- return a === void 0 ? null : this._loadLight(a).then(function(i) {
260
- return o._getNodeRef(t.cache, a, i);
261
- });
262
- }
263
- }
264
- class bt {
265
- constructor() {
266
- this.name = E.KHR_MATERIALS_UNLIT;
267
- }
268
- getMaterialType() {
269
- return V;
270
- }
271
- extendParams(e, t, o) {
272
- const n = [];
273
- e.color = new H(1, 1, 1), e.opacity = 1;
274
- const r = t.pbrMetallicRoughness;
275
- if (r) {
276
- if (Array.isArray(r.baseColorFactor)) {
277
- const s = r.baseColorFactor;
278
- e.color.setRGB(s[0], s[1], s[2], O), e.opacity = s[3];
279
- }
280
- r.baseColorTexture !== void 0 && n.push(o.assignTexture(e, "map", r.baseColorTexture, C));
281
- }
282
- return Promise.all(n);
283
- }
284
- }
285
- class Mt {
286
- constructor(e) {
287
- this.parser = e, this.name = E.KHR_MATERIALS_EMISSIVE_STRENGTH;
288
- }
289
- extendMaterialParams(e, t) {
290
- const n = this.parser.json.materials[e];
291
- if (!n.extensions || !n.extensions[this.name])
292
- return Promise.resolve();
293
- const r = n.extensions[this.name].emissiveStrength;
294
- return r !== void 0 && (t.emissiveIntensity = r), Promise.resolve();
295
- }
296
- }
297
- class Nt {
298
- constructor(e) {
299
- this.parser = e, this.name = E.KHR_MATERIALS_CLEARCOAT;
300
- }
301
- getMaterialType(e) {
302
- const o = this.parser.json.materials[e];
303
- return !o.extensions || !o.extensions[this.name] ? null : k;
304
- }
305
- extendMaterialParams(e, t) {
306
- const o = this.parser, n = o.json.materials[e];
307
- if (!n.extensions || !n.extensions[this.name])
308
- return Promise.resolve();
309
- const r = [], s = n.extensions[this.name];
310
- if (s.clearcoatFactor !== void 0 && (t.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && r.push(o.assignTexture(t, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && r.push(o.assignTexture(t, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (r.push(o.assignTexture(t, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
311
- const a = s.clearcoatNormalTexture.scale;
312
- t.clearcoatNormalScale = new z(a, a);
313
- }
314
- return Promise.all(r);
315
- }
316
- }
317
- class It {
318
- constructor(e) {
319
- this.parser = e, this.name = E.KHR_MATERIALS_IRIDESCENCE;
320
- }
321
- getMaterialType(e) {
322
- const o = this.parser.json.materials[e];
323
- return !o.extensions || !o.extensions[this.name] ? null : k;
324
- }
325
- extendMaterialParams(e, t) {
326
- const o = this.parser, n = o.json.materials[e];
327
- if (!n.extensions || !n.extensions[this.name])
328
- return Promise.resolve();
329
- const r = [], s = n.extensions[this.name];
330
- return s.iridescenceFactor !== void 0 && (t.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && r.push(o.assignTexture(t, "iridescenceMap", s.iridescenceTexture)), s.iridescenceIor !== void 0 && (t.iridescenceIOR = s.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), s.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = s.iridescenceThicknessMinimum), s.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = s.iridescenceThicknessMaximum), s.iridescenceThicknessTexture !== void 0 && r.push(o.assignTexture(t, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(r);
331
- }
332
- }
333
- class Ct {
334
- constructor(e) {
335
- this.parser = e, this.name = E.KHR_MATERIALS_SHEEN;
336
- }
337
- getMaterialType(e) {
338
- const o = this.parser.json.materials[e];
339
- return !o.extensions || !o.extensions[this.name] ? null : k;
340
- }
341
- extendMaterialParams(e, t) {
342
- const o = this.parser, n = o.json.materials[e];
343
- if (!n.extensions || !n.extensions[this.name])
344
- return Promise.resolve();
345
- const r = [];
346
- t.sheenColor = new H(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
347
- const s = n.extensions[this.name];
348
- if (s.sheenColorFactor !== void 0) {
349
- const a = s.sheenColorFactor;
350
- t.sheenColor.setRGB(a[0], a[1], a[2], O);
351
- }
352
- return s.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && r.push(o.assignTexture(t, "sheenColorMap", s.sheenColorTexture, C)), s.sheenRoughnessTexture !== void 0 && r.push(o.assignTexture(t, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(r);
353
- }
354
- }
355
- class Ot {
356
- constructor(e) {
357
- this.parser = e, this.name = E.KHR_MATERIALS_TRANSMISSION;
358
- }
359
- getMaterialType(e) {
360
- const o = this.parser.json.materials[e];
361
- return !o.extensions || !o.extensions[this.name] ? null : k;
362
- }
363
- extendMaterialParams(e, t) {
364
- const o = this.parser, n = o.json.materials[e];
365
- if (!n.extensions || !n.extensions[this.name])
366
- return Promise.resolve();
367
- const r = [], s = n.extensions[this.name];
368
- return s.transmissionFactor !== void 0 && (t.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && r.push(o.assignTexture(t, "transmissionMap", s.transmissionTexture)), Promise.all(r);
369
- }
370
- }
371
- class kt {
372
- constructor(e) {
373
- this.parser = e, this.name = E.KHR_MATERIALS_VOLUME;
374
- }
375
- getMaterialType(e) {
376
- const o = this.parser.json.materials[e];
377
- return !o.extensions || !o.extensions[this.name] ? null : k;
378
- }
379
- extendMaterialParams(e, t) {
380
- const o = this.parser, n = o.json.materials[e];
381
- if (!n.extensions || !n.extensions[this.name])
382
- return Promise.resolve();
383
- const r = [], s = n.extensions[this.name];
384
- t.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && r.push(o.assignTexture(t, "thicknessMap", s.thicknessTexture)), t.attenuationDistance = s.attenuationDistance || 1 / 0;
385
- const a = s.attenuationColor || [1, 1, 1];
386
- return t.attenuationColor = new H().setRGB(a[0], a[1], a[2], O), Promise.all(r);
387
- }
388
- }
389
- class Dt {
390
- constructor(e) {
391
- this.parser = e, this.name = E.KHR_MATERIALS_IOR;
392
- }
393
- getMaterialType(e) {
394
- const o = this.parser.json.materials[e];
395
- return !o.extensions || !o.extensions[this.name] ? null : k;
396
- }
397
- extendMaterialParams(e, t) {
398
- const n = this.parser.json.materials[e];
399
- if (!n.extensions || !n.extensions[this.name])
400
- return Promise.resolve();
401
- const r = n.extensions[this.name];
402
- return t.ior = r.ior !== void 0 ? r.ior : 1.5, Promise.resolve();
403
- }
404
- }
405
- class Ft {
406
- constructor(e) {
407
- this.parser = e, this.name = E.KHR_MATERIALS_SPECULAR;
408
- }
409
- getMaterialType(e) {
410
- const o = this.parser.json.materials[e];
411
- return !o.extensions || !o.extensions[this.name] ? null : k;
412
- }
413
- extendMaterialParams(e, t) {
414
- const o = this.parser, n = o.json.materials[e];
415
- if (!n.extensions || !n.extensions[this.name])
416
- return Promise.resolve();
417
- const r = [], s = n.extensions[this.name];
418
- t.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && r.push(o.assignTexture(t, "specularIntensityMap", s.specularTexture));
419
- const a = s.specularColorFactor || [1, 1, 1];
420
- return t.specularColor = new H().setRGB(a[0], a[1], a[2], O), s.specularColorTexture !== void 0 && r.push(o.assignTexture(t, "specularColorMap", s.specularColorTexture, C)), Promise.all(r);
421
- }
422
- }
423
- class Pt {
424
- constructor(e) {
425
- this.parser = e, this.name = E.EXT_MATERIALS_BUMP;
426
- }
427
- getMaterialType(e) {
428
- const o = this.parser.json.materials[e];
429
- return !o.extensions || !o.extensions[this.name] ? null : k;
430
- }
431
- extendMaterialParams(e, t) {
432
- const o = this.parser, n = o.json.materials[e];
433
- if (!n.extensions || !n.extensions[this.name])
434
- return Promise.resolve();
435
- const r = [], s = n.extensions[this.name];
436
- return t.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && r.push(o.assignTexture(t, "bumpMap", s.bumpTexture)), Promise.all(r);
437
- }
438
- }
439
- class Ht {
440
- constructor(e) {
441
- this.parser = e, this.name = E.KHR_MATERIALS_ANISOTROPY;
442
- }
443
- getMaterialType(e) {
444
- const o = this.parser.json.materials[e];
445
- return !o.extensions || !o.extensions[this.name] ? null : k;
446
- }
447
- extendMaterialParams(e, t) {
448
- const o = this.parser, n = o.json.materials[e];
449
- if (!n.extensions || !n.extensions[this.name])
450
- return Promise.resolve();
451
- const r = [], s = n.extensions[this.name];
452
- return s.anisotropyStrength !== void 0 && (t.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (t.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && r.push(o.assignTexture(t, "anisotropyMap", s.anisotropyTexture)), Promise.all(r);
453
- }
454
- }
455
- class Ut {
456
- constructor(e) {
457
- this.parser = e, this.name = E.KHR_TEXTURE_BASISU;
458
- }
459
- loadTexture(e) {
460
- const t = this.parser, o = t.json, n = o.textures[e];
461
- if (!n.extensions || !n.extensions[this.name])
462
- return null;
463
- const r = n.extensions[this.name], s = t.options.ktx2Loader;
464
- if (!s) {
465
- if (o.extensionsRequired && o.extensionsRequired.indexOf(this.name) >= 0)
466
- throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
467
- return null;
468
- }
469
- return t.loadTextureImage(e, r.source, s);
470
- }
471
- }
472
- class Gt {
473
- constructor(e) {
474
- this.parser = e, this.name = E.EXT_TEXTURE_WEBP, this.isSupported = null;
475
- }
476
- loadTexture(e) {
477
- const t = this.name, o = this.parser, n = o.json, r = n.textures[e];
478
- if (!r.extensions || !r.extensions[t])
479
- return null;
480
- const s = r.extensions[t], a = n.images[s.source];
481
- let i = o.textureLoader;
482
- if (a.uri) {
483
- const c = o.options.manager.getHandler(a.uri);
484
- c !== null && (i = c);
485
- }
486
- return this.detectSupport().then(function(c) {
487
- if (c) return o.loadTextureImage(e, s.source, i);
488
- if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
489
- throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
490
- return o.loadTexture(e);
491
- });
492
- }
493
- detectSupport() {
494
- return this.isSupported || (this.isSupported = new Promise(function(e) {
495
- const t = new Image();
496
- t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() {
497
- e(t.height === 1);
498
- };
499
- })), this.isSupported;
500
- }
501
- }
502
- class vt {
503
- constructor(e) {
504
- this.parser = e, this.name = E.EXT_TEXTURE_AVIF, this.isSupported = null;
505
- }
506
- loadTexture(e) {
507
- const t = this.name, o = this.parser, n = o.json, r = n.textures[e];
508
- if (!r.extensions || !r.extensions[t])
509
- return null;
510
- const s = r.extensions[t], a = n.images[s.source];
511
- let i = o.textureLoader;
512
- if (a.uri) {
513
- const c = o.options.manager.getHandler(a.uri);
514
- c !== null && (i = c);
515
- }
516
- return this.detectSupport().then(function(c) {
517
- if (c) return o.loadTextureImage(e, s.source, i);
518
- if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
519
- throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
520
- return o.loadTexture(e);
521
- });
522
- }
523
- detectSupport() {
524
- return this.isSupported || (this.isSupported = new Promise(function(e) {
525
- const t = new Image();
526
- t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() {
527
- e(t.height === 1);
528
- };
529
- })), this.isSupported;
530
- }
531
- }
532
- class Bt {
533
- constructor(e) {
534
- this.name = E.EXT_MESHOPT_COMPRESSION, this.parser = e;
535
- }
536
- loadBufferView(e) {
537
- const t = this.parser.json, o = t.bufferViews[e];
538
- if (o.extensions && o.extensions[this.name]) {
539
- const n = o.extensions[this.name], r = this.parser.getDependency("buffer", n.buffer), s = this.parser.options.meshoptDecoder;
540
- if (!s || !s.supported) {
541
- if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
542
- throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
543
- return null;
544
- }
545
- return r.then(function(a) {
546
- const i = n.byteOffset || 0, c = n.byteLength || 0, l = n.count, u = n.byteStride, f = new Uint8Array(a, i, c);
547
- return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(l, u, f, n.mode, n.filter).then(function(m) {
548
- return m.buffer;
549
- }) : s.ready.then(function() {
550
- const m = new ArrayBuffer(l * u);
551
- return s.decodeGltfBuffer(new Uint8Array(m), l, u, f, n.mode, n.filter), m;
552
- });
553
- });
554
- } else
555
- return null;
556
- }
557
- }
558
- class jt {
559
- constructor(e) {
560
- this.name = E.EXT_MESH_GPU_INSTANCING, this.parser = e;
561
- }
562
- createNodeMesh(e) {
563
- const t = this.parser.json, o = t.nodes[e];
564
- if (!o.extensions || !o.extensions[this.name] || o.mesh === void 0)
565
- return null;
566
- const n = t.meshes[o.mesh];
567
- for (const c of n.primitives)
568
- if (c.mode !== I.TRIANGLES && c.mode !== I.TRIANGLE_STRIP && c.mode !== I.TRIANGLE_FAN && c.mode !== void 0)
569
- return null;
570
- const s = o.extensions[this.name].attributes, a = [], i = {};
571
- for (const c in s)
572
- a.push(this.parser.getDependency("accessor", s[c]).then((l) => (i[c] = l, i[c])));
573
- return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((c) => {
574
- const l = c.pop(), u = l.isGroup ? l.children : [l], f = c[0].count, m = [];
575
- for (const T of u) {
576
- const _ = new q(), x = new v(), R = new Le(), S = new v(1, 1, 1), L = new Xe(T.geometry, T.material, f);
577
- for (let y = 0; y < f; y++)
578
- i.TRANSLATION && x.fromBufferAttribute(i.TRANSLATION, y), i.ROTATION && R.fromBufferAttribute(i.ROTATION, y), i.SCALE && S.fromBufferAttribute(i.SCALE, y), L.setMatrixAt(y, _.compose(x, R, S));
579
- for (const y in i)
580
- if (y === "_COLOR_0") {
581
- const M = i[y];
582
- L.instanceColor = new We(M.array, M.itemSize, M.normalized);
583
- } else y !== "TRANSLATION" && y !== "ROTATION" && y !== "SCALE" && T.geometry.setAttribute(y, i[y]);
584
- ae.prototype.copy.call(L, T), this.parser.assignFinalMaterial(L), m.push(L);
585
- }
586
- return l.isGroup ? (l.clear(), l.add(...m), l) : m[0];
587
- }));
588
- }
589
- }
590
- const Fe = "glTF", K = 12, Re = { JSON: 1313821514, BIN: 5130562 };
591
- class Kt {
592
- constructor(e) {
593
- this.name = E.KHR_BINARY_GLTF, this.content = null, this.body = null;
594
- const t = new DataView(e, 0, K), o = new TextDecoder();
595
- if (this.header = {
596
- magic: o.decode(new Uint8Array(e.slice(0, 4))),
597
- version: t.getUint32(4, !0),
598
- length: t.getUint32(8, !0)
599
- }, this.header.magic !== Fe)
600
- throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
601
- if (this.header.version < 2)
602
- throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
603
- const n = this.header.length - K, r = new DataView(e, K);
604
- let s = 0;
605
- for (; s < n; ) {
606
- const a = r.getUint32(s, !0);
607
- s += 4;
608
- const i = r.getUint32(s, !0);
609
- if (s += 4, i === Re.JSON) {
610
- const c = new Uint8Array(e, K + s, a);
611
- this.content = o.decode(c);
612
- } else if (i === Re.BIN) {
613
- const c = K + s;
614
- this.body = e.slice(c, c + a);
615
- }
616
- s += a;
617
- }
618
- if (this.content === null)
619
- throw new Error("THREE.GLTFLoader: JSON content not found.");
620
- }
621
- }
622
- class Vt {
623
- constructor(e, t) {
624
- if (!t)
625
- throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
626
- this.name = E.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
627
- }
628
- decodePrimitive(e, t) {
629
- const o = this.json, n = this.dracoLoader, r = e.extensions[this.name].bufferView, s = e.extensions[this.name].attributes, a = {}, i = {}, c = {};
630
- for (const l in s) {
631
- const u = re[l] || l.toLowerCase();
632
- a[u] = s[l];
633
- }
634
- for (const l in e.attributes) {
635
- const u = re[l] || l.toLowerCase();
636
- if (s[l] !== void 0) {
637
- const f = o.accessors[e.attributes[l]], m = B[f.componentType];
638
- c[u] = m.name, i[u] = f.normalized === !0;
639
- }
640
- }
641
- return t.getDependency("bufferView", r).then(function(l) {
642
- return new Promise(function(u, f) {
643
- n.decodeDracoFile(l, function(m) {
644
- for (const T in m.attributes) {
645
- const _ = m.attributes[T], x = i[T];
646
- x !== void 0 && (_.normalized = x);
647
- }
648
- u(m);
649
- }, a, c, O, f);
650
- });
651
- });
652
- }
653
- }
654
- class Xt {
655
- constructor() {
656
- this.name = E.KHR_TEXTURE_TRANSFORM;
657
- }
658
- extendTexture(e, t) {
659
- return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
660
- }
661
- }
662
- class Wt {
663
- constructor() {
664
- this.name = E.KHR_MESH_QUANTIZATION;
665
- }
666
- }
667
- class Pe extends At {
668
- constructor(e, t, o, n) {
669
- super(e, t, o, n);
670
- }
671
- copySampleValue_(e) {
672
- const t = this.resultBuffer, o = this.sampleValues, n = this.valueSize, r = e * n * 3 + n;
673
- for (let s = 0; s !== n; s++)
674
- t[s] = o[r + s];
675
- return t;
676
- }
677
- interpolate_(e, t, o, n) {
678
- const r = this.resultBuffer, s = this.sampleValues, a = this.valueSize, i = a * 2, c = a * 3, l = n - t, u = (o - t) / l, f = u * u, m = f * u, T = e * c, _ = T - c, x = -2 * m + 3 * f, R = m - f, S = 1 - x, L = R - f + u;
679
- for (let y = 0; y !== a; y++) {
680
- const M = s[_ + y + a], N = s[_ + y + i] * l, b = s[T + y + a], d = s[T + y] * l;
681
- r[y] = S * M + L * N + x * b + R * d;
682
- }
683
- return r;
684
- }
685
- }
686
- const zt = new Le();
687
- class qt extends Pe {
688
- interpolate_(e, t, o, n) {
689
- const r = super.interpolate_(e, t, o, n);
690
- return zt.fromArray(r).normalize().toArray(r), r;
691
- }
692
- }
693
- const I = {
694
- POINTS: 0,
695
- LINES: 1,
696
- LINE_LOOP: 2,
697
- LINE_STRIP: 3,
698
- TRIANGLES: 4,
699
- TRIANGLE_STRIP: 5,
700
- TRIANGLE_FAN: 6
701
- }, B = {
702
- 5120: Int8Array,
703
- 5121: Uint8Array,
704
- 5122: Int16Array,
705
- 5123: Uint16Array,
706
- 5125: Uint32Array,
707
- 5126: Float32Array
708
- }, ye = {
709
- 9728: $e,
710
- 9729: Ne,
711
- 9984: Ze,
712
- 9985: Qe,
713
- 9986: Je,
714
- 9987: Me
715
- }, we = {
716
- 33071: Ce,
717
- 33648: Ie,
718
- 10497: Y
719
- }, $ = {
720
- SCALAR: 1,
721
- VEC2: 2,
722
- VEC3: 3,
723
- VEC4: 4,
724
- MAT2: 4,
725
- MAT3: 9,
726
- MAT4: 16
727
- }, re = {
728
- POSITION: "position",
729
- NORMAL: "normal",
730
- TANGENT: "tangent",
731
- TEXCOORD_0: "uv",
732
- TEXCOORD_1: "uv1",
733
- TEXCOORD_2: "uv2",
734
- TEXCOORD_3: "uv3",
735
- COLOR_0: "color",
736
- WEIGHTS_0: "skinWeight",
737
- JOINTS_0: "skinIndex"
738
- }, F = {
739
- scale: "scale",
740
- translation: "position",
741
- rotation: "quaternion",
742
- weights: "morphTargetInfluences"
743
- }, Yt = {
744
- CUBICSPLINE: void 0,
745
- // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
746
- // keyframe track will be initialized with a default interpolation type, then modified.
747
- LINEAR: De,
748
- STEP: mt
749
- }, ee = {
750
- OPAQUE: "OPAQUE",
751
- MASK: "MASK",
752
- BLEND: "BLEND"
753
- };
754
- function Jt(h) {
755
- return h.DefaultMaterial === void 0 && (h.DefaultMaterial = new Oe({
756
- color: 16777215,
757
- emissive: 0,
758
- metalness: 1,
759
- roughness: 1,
760
- transparent: !1,
761
- depthTest: !0,
762
- side: gt
763
- })), h.DefaultMaterial;
764
- }
765
- function G(h, e, t) {
766
- for (const o in t.extensions)
767
- h[o] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[o] = t.extensions[o]);
768
- }
769
- function P(h, e) {
770
- e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(h.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
771
- }
772
- function Qt(h, e, t) {
773
- let o = !1, n = !1, r = !1;
774
- for (let c = 0, l = e.length; c < l; c++) {
775
- const u = e[c];
776
- if (u.POSITION !== void 0 && (o = !0), u.NORMAL !== void 0 && (n = !0), u.COLOR_0 !== void 0 && (r = !0), o && n && r) break;
777
- }
778
- if (!o && !n && !r) return Promise.resolve(h);
779
- const s = [], a = [], i = [];
780
- for (let c = 0, l = e.length; c < l; c++) {
781
- const u = e[c];
782
- if (o) {
783
- const f = u.POSITION !== void 0 ? t.getDependency("accessor", u.POSITION) : h.attributes.position;
784
- s.push(f);
785
- }
786
- if (n) {
787
- const f = u.NORMAL !== void 0 ? t.getDependency("accessor", u.NORMAL) : h.attributes.normal;
788
- a.push(f);
789
- }
790
- if (r) {
791
- const f = u.COLOR_0 !== void 0 ? t.getDependency("accessor", u.COLOR_0) : h.attributes.color;
792
- i.push(f);
793
- }
794
- }
795
- return Promise.all([
796
- Promise.all(s),
797
- Promise.all(a),
798
- Promise.all(i)
799
- ]).then(function(c) {
800
- const l = c[0], u = c[1], f = c[2];
801
- return o && (h.morphAttributes.position = l), n && (h.morphAttributes.normal = u), r && (h.morphAttributes.color = f), h.morphTargetsRelative = !0, h;
802
- });
803
- }
804
- function Zt(h, e) {
805
- if (h.updateMorphTargets(), e.weights !== void 0)
806
- for (let t = 0, o = e.weights.length; t < o; t++)
807
- h.morphTargetInfluences[t] = e.weights[t];
808
- if (e.extras && Array.isArray(e.extras.targetNames)) {
809
- const t = e.extras.targetNames;
810
- if (h.morphTargetInfluences.length === t.length) {
811
- h.morphTargetDictionary = {};
812
- for (let o = 0, n = t.length; o < n; o++)
813
- h.morphTargetDictionary[t[o]] = o;
814
- } else
815
- console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
816
- }
817
- }
818
- function $t(h) {
819
- let e;
820
- const t = h.extensions && h.extensions[E.KHR_DRACO_MESH_COMPRESSION];
821
- if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + te(t.attributes) : e = h.indices + ":" + te(h.attributes) + ":" + h.mode, h.targets !== void 0)
822
- for (let o = 0, n = h.targets.length; o < n; o++)
823
- e += ":" + te(h.targets[o]);
824
- return e;
825
- }
826
- function te(h) {
827
- let e = "";
828
- const t = Object.keys(h).sort();
829
- for (let o = 0, n = t.length; o < n; o++)
830
- e += t[o] + ":" + h[t[o]] + ";";
831
- return e;
832
- }
833
- function oe(h) {
834
- switch (h) {
835
- case Int8Array:
836
- return 1 / 127;
837
- case Uint8Array:
838
- return 1 / 255;
839
- case Int16Array:
840
- return 1 / 32767;
841
- case Uint16Array:
842
- return 1 / 65535;
843
- default:
844
- throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
845
- }
846
- }
847
- function en(h) {
848
- return h.search(/\.jpe?g($|\?)/i) > 0 || h.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : h.search(/\.webp($|\?)/i) > 0 || h.search(/^data\:image\/webp/) === 0 ? "image/webp" : "image/png";
849
- }
850
- const tn = new q();
851
- class nn {
852
- constructor(e = {}, t = {}) {
853
- this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new St(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
854
- let o = !1, n = !1, r = -1;
855
- typeof navigator < "u" && (o = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === !0, n = navigator.userAgent.indexOf("Firefox") > -1, r = n ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1), typeof createImageBitmap > "u" || o || n && r < 98 ? this.textureLoader = new be(this.options.manager) : this.textureLoader = new ze(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new j(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
856
- }
857
- setExtensions(e) {
858
- this.extensions = e;
859
- }
860
- setPlugins(e) {
861
- this.plugins = e;
862
- }
863
- parse(e, t) {
864
- const o = this, n = this.json, r = this.extensions;
865
- this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(s) {
866
- return s._markDefs && s._markDefs();
867
- }), Promise.all(this._invokeAll(function(s) {
868
- return s.beforeRoot && s.beforeRoot();
869
- })).then(function() {
870
- return Promise.all([
871
- o.getDependencies("scene"),
872
- o.getDependencies("animation"),
873
- o.getDependencies("camera")
874
- ]);
875
- }).then(function(s) {
876
- const a = {
877
- scene: s[0][n.scene || 0],
878
- scenes: s[0],
879
- animations: s[1],
880
- cameras: s[2],
881
- asset: n.asset,
882
- parser: o,
883
- userData: {}
884
- };
885
- return G(r, a, n), P(a, n), Promise.all(o._invokeAll(function(i) {
886
- return i.afterRoot && i.afterRoot(a);
887
- })).then(function() {
888
- for (const i of a.scenes)
889
- i.updateMatrixWorld();
890
- e(a);
891
- });
892
- }).catch(t);
893
- }
894
- /**
895
- * Marks the special nodes/meshes in json for efficient parse.
896
- */
897
- _markDefs() {
898
- const e = this.json.nodes || [], t = this.json.skins || [], o = this.json.meshes || [];
899
- for (let n = 0, r = t.length; n < r; n++) {
900
- const s = t[n].joints;
901
- for (let a = 0, i = s.length; a < i; a++)
902
- e[s[a]].isBone = !0;
903
- }
904
- for (let n = 0, r = e.length; n < r; n++) {
905
- const s = e[n];
906
- s.mesh !== void 0 && (this._addNodeRef(this.meshCache, s.mesh), s.skin !== void 0 && (o[s.mesh].isSkinnedMesh = !0)), s.camera !== void 0 && this._addNodeRef(this.cameraCache, s.camera);
907
- }
908
- }
909
- /**
910
- * Counts references to shared node / Object3D resources. These resources
911
- * can be reused, or "instantiated", at multiple nodes in the scene
912
- * hierarchy. Mesh, Camera, and Light instances are instantiated and must
913
- * be marked. Non-scenegraph resources (like Materials, Geometries, and
914
- * Textures) can be reused directly and are not marked here.
915
- *
916
- * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
917
- */
918
- _addNodeRef(e, t) {
919
- t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
920
- }
921
- /** Returns a reference to a shared resource, cloning it if necessary. */
922
- _getNodeRef(e, t, o) {
923
- if (e.refs[t] <= 1) return o;
924
- const n = o.clone(), r = (s, a) => {
925
- const i = this.associations.get(s);
926
- i != null && this.associations.set(a, i);
927
- for (const [c, l] of s.children.entries())
928
- r(l, a.children[c]);
929
- };
930
- return r(o, n), n.name += "_instance_" + e.uses[t]++, n;
931
- }
932
- _invokeOne(e) {
933
- const t = Object.values(this.plugins);
934
- t.push(this);
935
- for (let o = 0; o < t.length; o++) {
936
- const n = e(t[o]);
937
- if (n) return n;
938
- }
939
- return null;
940
- }
941
- _invokeAll(e) {
942
- const t = Object.values(this.plugins);
943
- t.unshift(this);
944
- const o = [];
945
- for (let n = 0; n < t.length; n++) {
946
- const r = e(t[n]);
947
- r && o.push(r);
948
- }
949
- return o;
950
- }
951
- /**
952
- * Requests the specified dependency asynchronously, with caching.
953
- * @param {string} type
954
- * @param {number} index
955
- * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
956
- */
957
- getDependency(e, t) {
958
- const o = e + ":" + t;
959
- let n = this.cache.get(o);
960
- if (!n) {
961
- switch (e) {
962
- case "scene":
963
- n = this.loadScene(t);
964
- break;
965
- case "node":
966
- n = this._invokeOne(function(r) {
967
- return r.loadNode && r.loadNode(t);
968
- });
969
- break;
970
- case "mesh":
971
- n = this._invokeOne(function(r) {
972
- return r.loadMesh && r.loadMesh(t);
973
- });
974
- break;
975
- case "accessor":
976
- n = this.loadAccessor(t);
977
- break;
978
- case "bufferView":
979
- n = this._invokeOne(function(r) {
980
- return r.loadBufferView && r.loadBufferView(t);
981
- });
982
- break;
983
- case "buffer":
984
- n = this.loadBuffer(t);
985
- break;
986
- case "material":
987
- n = this._invokeOne(function(r) {
988
- return r.loadMaterial && r.loadMaterial(t);
989
- });
990
- break;
991
- case "texture":
992
- n = this._invokeOne(function(r) {
993
- return r.loadTexture && r.loadTexture(t);
994
- });
995
- break;
996
- case "skin":
997
- n = this.loadSkin(t);
998
- break;
999
- case "animation":
1000
- n = this._invokeOne(function(r) {
1001
- return r.loadAnimation && r.loadAnimation(t);
1002
- });
1003
- break;
1004
- case "camera":
1005
- n = this.loadCamera(t);
1006
- break;
1007
- default:
1008
- if (n = this._invokeOne(function(r) {
1009
- return r != this && r.getDependency && r.getDependency(e, t);
1010
- }), !n)
1011
- throw new Error("Unknown type: " + e);
1012
- break;
1013
- }
1014
- this.cache.add(o, n);
1015
- }
1016
- return n;
1017
- }
1018
- /**
1019
- * Requests all dependencies of the specified type asynchronously, with caching.
1020
- * @param {string} type
1021
- * @return {Promise<Array<Object>>}
1022
- */
1023
- getDependencies(e) {
1024
- let t = this.cache.get(e);
1025
- if (!t) {
1026
- const o = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
1027
- t = Promise.all(n.map(function(r, s) {
1028
- return o.getDependency(e, s);
1029
- })), this.cache.add(e, t);
1030
- }
1031
- return t;
1032
- }
1033
- /**
1034
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1035
- * @param {number} bufferIndex
1036
- * @return {Promise<ArrayBuffer>}
1037
- */
1038
- loadBuffer(e) {
1039
- const t = this.json.buffers[e], o = this.fileLoader;
1040
- if (t.type && t.type !== "arraybuffer")
1041
- throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
1042
- if (t.uri === void 0 && e === 0)
1043
- return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);
1044
- const n = this.options;
1045
- return new Promise(function(r, s) {
1046
- o.load(X.resolveURL(t.uri, n.path), r, void 0, function() {
1047
- s(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
1048
- });
1049
- });
1050
- }
1051
- /**
1052
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1053
- * @param {number} bufferViewIndex
1054
- * @return {Promise<ArrayBuffer>}
1055
- */
1056
- loadBufferView(e) {
1057
- const t = this.json.bufferViews[e];
1058
- return this.getDependency("buffer", t.buffer).then(function(o) {
1059
- const n = t.byteLength || 0, r = t.byteOffset || 0;
1060
- return o.slice(r, r + n);
1061
- });
1062
- }
1063
- /**
1064
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
1065
- * @param {number} accessorIndex
1066
- * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
1067
- */
1068
- loadAccessor(e) {
1069
- const t = this, o = this.json, n = this.json.accessors[e];
1070
- if (n.bufferView === void 0 && n.sparse === void 0) {
1071
- const s = $[n.type], a = B[n.componentType], i = n.normalized === !0, c = new a(n.count * s);
1072
- return Promise.resolve(new D(c, s, i));
1073
- }
1074
- const r = [];
1075
- return n.bufferView !== void 0 ? r.push(this.getDependency("bufferView", n.bufferView)) : r.push(null), n.sparse !== void 0 && (r.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(r).then(function(s) {
1076
- const a = s[0], i = $[n.type], c = B[n.componentType], l = c.BYTES_PER_ELEMENT, u = l * i, f = n.byteOffset || 0, m = n.bufferView !== void 0 ? o.bufferViews[n.bufferView].byteStride : void 0, T = n.normalized === !0;
1077
- let _, x;
1078
- if (m && m !== u) {
1079
- const R = Math.floor(f / m), S = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + R + ":" + n.count;
1080
- let L = t.cache.get(S);
1081
- L || (_ = new c(a, R * m, n.count * m / l), L = new qe(_, m / l), t.cache.add(S, L)), x = new Ye(L, i, f % m / l, T);
1082
- } else
1083
- a === null ? _ = new c(n.count * i) : _ = new c(a, f, n.count * i), x = new D(_, i, T);
1084
- if (n.sparse !== void 0) {
1085
- const R = $.SCALAR, S = B[n.sparse.indices.componentType], L = n.sparse.indices.byteOffset || 0, y = n.sparse.values.byteOffset || 0, M = new S(s[1], L, n.sparse.count * R), N = new c(s[2], y, n.sparse.count * i);
1086
- a !== null && (x = new D(x.array.slice(), x.itemSize, x.normalized));
1087
- for (let b = 0, d = M.length; b < d; b++) {
1088
- const p = M[b];
1089
- if (x.setX(p, N[b * i]), i >= 2 && x.setY(p, N[b * i + 1]), i >= 3 && x.setZ(p, N[b * i + 2]), i >= 4 && x.setW(p, N[b * i + 3]), i >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
1090
- }
1091
- }
1092
- return x;
1093
- });
1094
- }
1095
- /**
1096
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
1097
- * @param {number} textureIndex
1098
- * @return {Promise<THREE.Texture|null>}
1099
- */
1100
- loadTexture(e) {
1101
- const t = this.json, o = this.options, r = t.textures[e].source, s = t.images[r];
1102
- let a = this.textureLoader;
1103
- if (s.uri) {
1104
- const i = o.manager.getHandler(s.uri);
1105
- i !== null && (a = i);
1106
- }
1107
- return this.loadTextureImage(e, r, a);
1108
- }
1109
- loadTextureImage(e, t, o) {
1110
- const n = this, r = this.json, s = r.textures[e], a = r.images[t], i = (a.uri || a.bufferView) + ":" + s.sampler;
1111
- if (this.textureCache[i])
1112
- return this.textureCache[i];
1113
- const c = this.loadImageSource(t, o).then(function(l) {
1114
- l.flipY = !1, l.name = s.name || a.name || "", l.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (l.name = a.uri);
1115
- const f = (r.samplers || {})[s.sampler] || {};
1116
- return l.magFilter = ye[f.magFilter] || Ne, l.minFilter = ye[f.minFilter] || Me, l.wrapS = we[f.wrapS] || Y, l.wrapT = we[f.wrapT] || Y, n.associations.set(l, { textures: e }), l;
1117
- }).catch(function() {
1118
- return null;
1119
- });
1120
- return this.textureCache[i] = c, c;
1121
- }
1122
- loadImageSource(e, t) {
1123
- const o = this, n = this.json, r = this.options;
1124
- if (this.sourceCache[e] !== void 0)
1125
- return this.sourceCache[e].then((u) => u.clone());
1126
- const s = n.images[e], a = self.URL || self.webkitURL;
1127
- let i = s.uri || "", c = !1;
1128
- if (s.bufferView !== void 0)
1129
- i = o.getDependency("bufferView", s.bufferView).then(function(u) {
1130
- c = !0;
1131
- const f = new Blob([u], { type: s.mimeType });
1132
- return i = a.createObjectURL(f), i;
1133
- });
1134
- else if (s.uri === void 0)
1135
- throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
1136
- const l = Promise.resolve(i).then(function(u) {
1137
- return new Promise(function(f, m) {
1138
- let T = f;
1139
- t.isImageBitmapLoader === !0 && (T = function(_) {
1140
- const x = new fe(_);
1141
- x.needsUpdate = !0, f(x);
1142
- }), t.load(X.resolveURL(u, r.path), T, void 0, m);
1143
- });
1144
- }).then(function(u) {
1145
- return c === !0 && a.revokeObjectURL(i), u.userData.mimeType = s.mimeType || en(s.uri), u;
1146
- }).catch(function(u) {
1147
- throw console.error("THREE.GLTFLoader: Couldn't load texture", i), u;
1148
- });
1149
- return this.sourceCache[e] = l, l;
1150
- }
1151
- /**
1152
- * Asynchronously assigns a texture to the given material parameters.
1153
- * @param {Object} materialParams
1154
- * @param {string} mapName
1155
- * @param {Object} mapDef
1156
- * @return {Promise<Texture>}
1157
- */
1158
- assignTexture(e, t, o, n) {
1159
- const r = this;
1160
- return this.getDependency("texture", o.index).then(function(s) {
1161
- if (!s) return null;
1162
- if (o.texCoord !== void 0 && o.texCoord > 0 && (s = s.clone(), s.channel = o.texCoord), r.extensions[E.KHR_TEXTURE_TRANSFORM]) {
1163
- const a = o.extensions !== void 0 ? o.extensions[E.KHR_TEXTURE_TRANSFORM] : void 0;
1164
- if (a) {
1165
- const i = r.associations.get(s);
1166
- s = r.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(s, a), r.associations.set(s, i);
1167
- }
1168
- }
1169
- return n !== void 0 && (s.colorSpace = n), e[t] = s, s;
1170
- });
1171
- }
1172
- /**
1173
- * Assigns final material to a Mesh, Line, or Points instance. The instance
1174
- * already has a material (generated from the glTF material options alone)
1175
- * but reuse of the same glTF material may require multiple threejs materials
1176
- * to accommodate different primitive types, defines, etc. New materials will
1177
- * be created if necessary, and reused from a cache.
1178
- * @param {Object3D} mesh Mesh, Line, or Points instance.
1179
- */
1180
- assignFinalMaterial(e) {
1181
- const t = e.geometry;
1182
- let o = e.material;
1183
- const n = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, s = t.attributes.normal === void 0;
1184
- if (e.isPoints) {
1185
- const a = "PointsMaterial:" + o.uuid;
1186
- let i = this.cache.get(a);
1187
- i || (i = new et(), Z.prototype.copy.call(i, o), i.color.copy(o.color), i.map = o.map, i.sizeAttenuation = !1, this.cache.add(a, i)), o = i;
1188
- } else if (e.isLine) {
1189
- const a = "LineBasicMaterial:" + o.uuid;
1190
- let i = this.cache.get(a);
1191
- i || (i = new tt(), Z.prototype.copy.call(i, o), i.color.copy(o.color), i.map = o.map, this.cache.add(a, i)), o = i;
1192
- }
1193
- if (n || r || s) {
1194
- let a = "ClonedMaterial:" + o.uuid + ":";
1195
- n && (a += "derivative-tangents:"), r && (a += "vertex-colors:"), s && (a += "flat-shading:");
1196
- let i = this.cache.get(a);
1197
- i || (i = o.clone(), r && (i.vertexColors = !0), s && (i.flatShading = !0), n && (i.normalScale && (i.normalScale.y *= -1), i.clearcoatNormalScale && (i.clearcoatNormalScale.y *= -1)), this.cache.add(a, i), this.associations.set(i, this.associations.get(o))), o = i;
1198
- }
1199
- e.material = o;
1200
- }
1201
- getMaterialType() {
1202
- return Oe;
1203
- }
1204
- /**
1205
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
1206
- * @param {number} materialIndex
1207
- * @return {Promise<Material>}
1208
- */
1209
- loadMaterial(e) {
1210
- const t = this, o = this.json, n = this.extensions, r = o.materials[e];
1211
- let s;
1212
- const a = {}, i = r.extensions || {}, c = [];
1213
- if (i[E.KHR_MATERIALS_UNLIT]) {
1214
- const u = n[E.KHR_MATERIALS_UNLIT];
1215
- s = u.getMaterialType(), c.push(u.extendParams(a, r, t));
1216
- } else {
1217
- const u = r.pbrMetallicRoughness || {};
1218
- if (a.color = new H(1, 1, 1), a.opacity = 1, Array.isArray(u.baseColorFactor)) {
1219
- const f = u.baseColorFactor;
1220
- a.color.setRGB(f[0], f[1], f[2], O), a.opacity = f[3];
1221
- }
1222
- u.baseColorTexture !== void 0 && c.push(t.assignTexture(a, "map", u.baseColorTexture, C)), a.metalness = u.metallicFactor !== void 0 ? u.metallicFactor : 1, a.roughness = u.roughnessFactor !== void 0 ? u.roughnessFactor : 1, u.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(a, "metalnessMap", u.metallicRoughnessTexture)), c.push(t.assignTexture(a, "roughnessMap", u.metallicRoughnessTexture))), s = this._invokeOne(function(f) {
1223
- return f.getMaterialType && f.getMaterialType(e);
1224
- }), c.push(Promise.all(this._invokeAll(function(f) {
1225
- return f.extendMaterialParams && f.extendMaterialParams(e, a);
1226
- })));
1227
- }
1228
- r.doubleSided === !0 && (a.side = nt);
1229
- const l = r.alphaMode || ee.OPAQUE;
1230
- if (l === ee.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, l === ee.MASK && (a.alphaTest = r.alphaCutoff !== void 0 ? r.alphaCutoff : 0.5)), r.normalTexture !== void 0 && s !== V && (c.push(t.assignTexture(a, "normalMap", r.normalTexture)), a.normalScale = new z(1, 1), r.normalTexture.scale !== void 0)) {
1231
- const u = r.normalTexture.scale;
1232
- a.normalScale.set(u, u);
1233
- }
1234
- if (r.occlusionTexture !== void 0 && s !== V && (c.push(t.assignTexture(a, "aoMap", r.occlusionTexture)), r.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = r.occlusionTexture.strength)), r.emissiveFactor !== void 0 && s !== V) {
1235
- const u = r.emissiveFactor;
1236
- a.emissive = new H().setRGB(u[0], u[1], u[2], O);
1237
- }
1238
- return r.emissiveTexture !== void 0 && s !== V && c.push(t.assignTexture(a, "emissiveMap", r.emissiveTexture, C)), Promise.all(c).then(function() {
1239
- const u = new s(a);
1240
- return r.name && (u.name = r.name), P(u, r), t.associations.set(u, { materials: e }), r.extensions && G(n, u, r), u;
1241
- });
1242
- }
1243
- /** When Object3D instances are targeted by animation, they need unique names. */
1244
- createUniqueName(e) {
1245
- const t = st.sanitizeNodeName(e || "");
1246
- return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
1247
- }
1248
- /**
1249
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
1250
- *
1251
- * Creates BufferGeometries from primitives.
1252
- *
1253
- * @param {Array<GLTF.Primitive>} primitives
1254
- * @return {Promise<Array<BufferGeometry>>}
1255
- */
1256
- loadGeometries(e) {
1257
- const t = this, o = this.extensions, n = this.primitiveCache;
1258
- function r(a) {
1259
- return o[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, t).then(function(i) {
1260
- return _e(i, a, t);
1261
- });
1262
- }
1263
- const s = [];
1264
- for (let a = 0, i = e.length; a < i; a++) {
1265
- const c = e[a], l = $t(c), u = n[l];
1266
- if (u)
1267
- s.push(u.promise);
1268
- else {
1269
- let f;
1270
- c.extensions && c.extensions[E.KHR_DRACO_MESH_COMPRESSION] ? f = r(c) : f = _e(new ce(), c, t), n[l] = { primitive: c, promise: f }, s.push(f);
1271
- }
1272
- }
1273
- return Promise.all(s);
1274
- }
1275
- /**
1276
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
1277
- * @param {number} meshIndex
1278
- * @return {Promise<Group|Mesh|SkinnedMesh>}
1279
- */
1280
- loadMesh(e) {
1281
- const t = this, o = this.json, n = this.extensions, r = o.meshes[e], s = r.primitives, a = [];
1282
- for (let i = 0, c = s.length; i < c; i++) {
1283
- const l = s[i].material === void 0 ? Jt(this.cache) : this.getDependency("material", s[i].material);
1284
- a.push(l);
1285
- }
1286
- return a.push(t.loadGeometries(s)), Promise.all(a).then(function(i) {
1287
- const c = i.slice(0, i.length - 1), l = i[i.length - 1], u = [];
1288
- for (let m = 0, T = l.length; m < T; m++) {
1289
- const _ = l[m], x = s[m];
1290
- let R;
1291
- const S = c[m];
1292
- if (x.mode === I.TRIANGLES || x.mode === I.TRIANGLE_STRIP || x.mode === I.TRIANGLE_FAN || x.mode === void 0)
1293
- R = r.isSkinnedMesh === !0 ? new rt(_, S) : new ke(_, S), R.isSkinnedMesh === !0 && R.normalizeSkinWeights(), x.mode === I.TRIANGLE_STRIP ? R.geometry = xe(R.geometry, Se) : x.mode === I.TRIANGLE_FAN && (R.geometry = xe(R.geometry, se));
1294
- else if (x.mode === I.LINES)
1295
- R = new ot(_, S);
1296
- else if (x.mode === I.LINE_STRIP)
1297
- R = new it(_, S);
1298
- else if (x.mode === I.LINE_LOOP)
1299
- R = new at(_, S);
1300
- else if (x.mode === I.POINTS)
1301
- R = new ct(_, S);
1302
- else
1303
- throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + x.mode);
1304
- Object.keys(R.geometry.morphAttributes).length > 0 && Zt(R, r), R.name = t.createUniqueName(r.name || "mesh_" + e), P(R, r), x.extensions && G(n, R, x), t.assignFinalMaterial(R), u.push(R);
1305
- }
1306
- for (let m = 0, T = u.length; m < T; m++)
1307
- t.associations.set(u[m], {
1308
- meshes: e,
1309
- primitives: m
1310
- });
1311
- if (u.length === 1)
1312
- return r.extensions && G(n, u[0], r), u[0];
1313
- const f = new W();
1314
- r.extensions && G(n, f, r), t.associations.set(f, { meshes: e });
1315
- for (let m = 0, T = u.length; m < T; m++)
1316
- f.add(u[m]);
1317
- return f;
1318
- });
1319
- }
1320
- /**
1321
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
1322
- * @param {number} cameraIndex
1323
- * @return {Promise<THREE.Camera>}
1324
- */
1325
- loadCamera(e) {
1326
- let t;
1327
- const o = this.json.cameras[e], n = o[o.type];
1328
- if (!n) {
1329
- console.warn("THREE.GLTFLoader: Missing camera parameters.");
1330
- return;
1331
- }
1332
- return o.type === "perspective" ? t = new lt(ut.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : o.type === "orthographic" && (t = new ft(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), o.name && (t.name = this.createUniqueName(o.name)), P(t, o), Promise.resolve(t);
1333
- }
1334
- /**
1335
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
1336
- * @param {number} skinIndex
1337
- * @return {Promise<Skeleton>}
1338
- */
1339
- loadSkin(e) {
1340
- const t = this.json.skins[e], o = [];
1341
- for (let n = 0, r = t.joints.length; n < r; n++)
1342
- o.push(this._loadNodeShallow(t.joints[n]));
1343
- return t.inverseBindMatrices !== void 0 ? o.push(this.getDependency("accessor", t.inverseBindMatrices)) : o.push(null), Promise.all(o).then(function(n) {
1344
- const r = n.pop(), s = n, a = [], i = [];
1345
- for (let c = 0, l = s.length; c < l; c++) {
1346
- const u = s[c];
1347
- if (u) {
1348
- a.push(u);
1349
- const f = new q();
1350
- r !== null && f.fromArray(r.array, c * 16), i.push(f);
1351
- } else
1352
- console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]);
1353
- }
1354
- return new dt(a, i);
1355
- });
1356
- }
1357
- /**
1358
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
1359
- * @param {number} animationIndex
1360
- * @return {Promise<AnimationClip>}
1361
- */
1362
- loadAnimation(e) {
1363
- const t = this.json, o = this, n = t.animations[e], r = n.name ? n.name : "animation_" + e, s = [], a = [], i = [], c = [], l = [];
1364
- for (let u = 0, f = n.channels.length; u < f; u++) {
1365
- const m = n.channels[u], T = n.samplers[m.sampler], _ = m.target, x = _.node, R = n.parameters !== void 0 ? n.parameters[T.input] : T.input, S = n.parameters !== void 0 ? n.parameters[T.output] : T.output;
1366
- _.node !== void 0 && (s.push(this.getDependency("node", x)), a.push(this.getDependency("accessor", R)), i.push(this.getDependency("accessor", S)), c.push(T), l.push(_));
1367
- }
1368
- return Promise.all([
1369
- Promise.all(s),
1370
- Promise.all(a),
1371
- Promise.all(i),
1372
- Promise.all(c),
1373
- Promise.all(l)
1374
- ]).then(function(u) {
1375
- const f = u[0], m = u[1], T = u[2], _ = u[3], x = u[4], R = [];
1376
- for (let S = 0, L = f.length; S < L; S++) {
1377
- const y = f[S], M = m[S], N = T[S], b = _[S], d = x[S];
1378
- if (y === void 0) continue;
1379
- y.updateMatrix && y.updateMatrix();
1380
- const p = o._createAnimationTracks(y, M, N, b, d);
1381
- if (p)
1382
- for (let g = 0; g < p.length; g++)
1383
- R.push(p[g]);
1384
- }
1385
- return new ht(r, void 0, R);
1386
- });
1387
- }
1388
- createNodeMesh(e) {
1389
- const t = this.json, o = this, n = t.nodes[e];
1390
- return n.mesh === void 0 ? null : o.getDependency("mesh", n.mesh).then(function(r) {
1391
- const s = o._getNodeRef(o.meshCache, n.mesh, r);
1392
- return n.weights !== void 0 && s.traverse(function(a) {
1393
- if (a.isMesh)
1394
- for (let i = 0, c = n.weights.length; i < c; i++)
1395
- a.morphTargetInfluences[i] = n.weights[i];
1396
- }), s;
1397
- });
1398
- }
1399
- /**
1400
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
1401
- * @param {number} nodeIndex
1402
- * @return {Promise<Object3D>}
1403
- */
1404
- loadNode(e) {
1405
- const t = this.json, o = this, n = t.nodes[e], r = o._loadNodeShallow(e), s = [], a = n.children || [];
1406
- for (let c = 0, l = a.length; c < l; c++)
1407
- s.push(o.getDependency("node", a[c]));
1408
- const i = n.skin === void 0 ? Promise.resolve(null) : o.getDependency("skin", n.skin);
1409
- return Promise.all([
1410
- r,
1411
- Promise.all(s),
1412
- i
1413
- ]).then(function(c) {
1414
- const l = c[0], u = c[1], f = c[2];
1415
- f !== null && l.traverse(function(m) {
1416
- m.isSkinnedMesh && m.bind(f, tn);
1417
- });
1418
- for (let m = 0, T = u.length; m < T; m++)
1419
- l.add(u[m]);
1420
- return l;
1421
- });
1422
- }
1423
- // ._loadNodeShallow() parses a single node.
1424
- // skin and child nodes are created and added in .loadNode() (no '_' prefix).
1425
- _loadNodeShallow(e) {
1426
- const t = this.json, o = this.extensions, n = this;
1427
- if (this.nodeCache[e] !== void 0)
1428
- return this.nodeCache[e];
1429
- const r = t.nodes[e], s = r.name ? n.createUniqueName(r.name) : "", a = [], i = n._invokeOne(function(c) {
1430
- return c.createNodeMesh && c.createNodeMesh(e);
1431
- });
1432
- return i && a.push(i), r.camera !== void 0 && a.push(n.getDependency("camera", r.camera).then(function(c) {
1433
- return n._getNodeRef(n.cameraCache, r.camera, c);
1434
- })), n._invokeAll(function(c) {
1435
- return c.createNodeAttachment && c.createNodeAttachment(e);
1436
- }).forEach(function(c) {
1437
- a.push(c);
1438
- }), this.nodeCache[e] = Promise.all(a).then(function(c) {
1439
- let l;
1440
- if (r.isBone === !0 ? l = new pt() : c.length > 1 ? l = new W() : c.length === 1 ? l = c[0] : l = new ae(), l !== c[0])
1441
- for (let u = 0, f = c.length; u < f; u++)
1442
- l.add(c[u]);
1443
- if (r.name && (l.userData.name = r.name, l.name = s), P(l, r), r.extensions && G(o, l, r), r.matrix !== void 0) {
1444
- const u = new q();
1445
- u.fromArray(r.matrix), l.applyMatrix4(u);
1446
- } else
1447
- r.translation !== void 0 && l.position.fromArray(r.translation), r.rotation !== void 0 && l.quaternion.fromArray(r.rotation), r.scale !== void 0 && l.scale.fromArray(r.scale);
1448
- return n.associations.has(l) || n.associations.set(l, {}), n.associations.get(l).nodes = e, l;
1449
- }), this.nodeCache[e];
1450
- }
1451
- /**
1452
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
1453
- * @param {number} sceneIndex
1454
- * @return {Promise<Group>}
1455
- */
1456
- loadScene(e) {
1457
- const t = this.extensions, o = this.json.scenes[e], n = this, r = new W();
1458
- o.name && (r.name = n.createUniqueName(o.name)), P(r, o), o.extensions && G(t, r, o);
1459
- const s = o.nodes || [], a = [];
1460
- for (let i = 0, c = s.length; i < c; i++)
1461
- a.push(n.getDependency("node", s[i]));
1462
- return Promise.all(a).then(function(i) {
1463
- for (let l = 0, u = i.length; l < u; l++)
1464
- r.add(i[l]);
1465
- const c = (l) => {
1466
- const u = /* @__PURE__ */ new Map();
1467
- for (const [f, m] of n.associations)
1468
- (f instanceof Z || f instanceof fe) && u.set(f, m);
1469
- return l.traverse((f) => {
1470
- const m = n.associations.get(f);
1471
- m != null && u.set(f, m);
1472
- }), u;
1473
- };
1474
- return n.associations = c(r), r;
1475
- });
1476
- }
1477
- _createAnimationTracks(e, t, o, n, r) {
1478
- const s = [], a = e.name ? e.name : e.uuid, i = [];
1479
- F[r.path] === F.weights ? e.traverse(function(f) {
1480
- f.morphTargetInfluences && i.push(f.name ? f.name : f.uuid);
1481
- }) : i.push(a);
1482
- let c;
1483
- switch (F[r.path]) {
1484
- case F.weights:
1485
- c = he;
1486
- break;
1487
- case F.rotation:
1488
- c = pe;
1489
- break;
1490
- case F.position:
1491
- case F.scale:
1492
- c = de;
1493
- break;
1494
- default:
1495
- switch (o.itemSize) {
1496
- case 1:
1497
- c = he;
1498
- break;
1499
- case 2:
1500
- case 3:
1501
- default:
1502
- c = de;
1503
- break;
1504
- }
1505
- break;
1506
- }
1507
- const l = n.interpolation !== void 0 ? Yt[n.interpolation] : De, u = this._getArrayFromAccessor(o);
1508
- for (let f = 0, m = i.length; f < m; f++) {
1509
- const T = new c(
1510
- i[f] + "." + F[r.path],
1511
- t.array,
1512
- u,
1513
- l
1514
- );
1515
- n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(T), s.push(T);
1516
- }
1517
- return s;
1518
- }
1519
- _getArrayFromAccessor(e) {
1520
- let t = e.array;
1521
- if (e.normalized) {
1522
- const o = oe(t.constructor), n = new Float32Array(t.length);
1523
- for (let r = 0, s = t.length; r < s; r++)
1524
- n[r] = t[r] * o;
1525
- t = n;
1526
- }
1527
- return t;
1528
- }
1529
- _createCubicSplineTrackInterpolant(e) {
1530
- e.createInterpolant = function(o) {
1531
- const n = this instanceof pe ? qt : Pe;
1532
- return new n(this.times, this.values, this.getValueSize() / 3, o);
1533
- }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
1534
- }
1535
- }
1536
- function sn(h, e, t) {
1537
- const o = e.attributes, n = new Tt();
1538
- if (o.POSITION !== void 0) {
1539
- const a = t.json.accessors[o.POSITION], i = a.min, c = a.max;
1540
- if (i !== void 0 && c !== void 0) {
1541
- if (n.set(
1542
- new v(i[0], i[1], i[2]),
1543
- new v(c[0], c[1], c[2])
1544
- ), a.normalized) {
1545
- const l = oe(B[a.componentType]);
1546
- n.min.multiplyScalar(l), n.max.multiplyScalar(l);
1547
- }
1548
- } else {
1549
- console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
1550
- return;
1551
- }
1552
- } else
1553
- return;
1554
- const r = e.targets;
1555
- if (r !== void 0) {
1556
- const a = new v(), i = new v();
1557
- for (let c = 0, l = r.length; c < l; c++) {
1558
- const u = r[c];
1559
- if (u.POSITION !== void 0) {
1560
- const f = t.json.accessors[u.POSITION], m = f.min, T = f.max;
1561
- if (m !== void 0 && T !== void 0) {
1562
- if (i.setX(Math.max(Math.abs(m[0]), Math.abs(T[0]))), i.setY(Math.max(Math.abs(m[1]), Math.abs(T[1]))), i.setZ(Math.max(Math.abs(m[2]), Math.abs(T[2]))), f.normalized) {
1563
- const _ = oe(B[f.componentType]);
1564
- i.multiplyScalar(_);
1565
- }
1566
- a.max(i);
1567
- } else
1568
- console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
1569
- }
1570
- }
1571
- n.expandByVector(a);
1572
- }
1573
- h.boundingBox = n;
1574
- const s = new xt();
1575
- n.getCenter(s.center), s.radius = n.min.distanceTo(n.max) / 2, h.boundingSphere = s;
1576
- }
1577
- function _e(h, e, t) {
1578
- const o = e.attributes, n = [];
1579
- function r(s, a) {
1580
- return t.getDependency("accessor", s).then(function(i) {
1581
- h.setAttribute(a, i);
1582
- });
1583
- }
1584
- for (const s in o) {
1585
- const a = re[s] || s.toLowerCase();
1586
- a in h.attributes || n.push(r(o[s], a));
1587
- }
1588
- if (e.indices !== void 0 && !h.index) {
1589
- const s = t.getDependency("accessor", e.indices).then(function(a) {
1590
- h.setIndex(a);
1591
- });
1592
- n.push(s);
1593
- }
1594
- return me.workingColorSpace !== O && "COLOR_0" in o && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${me.workingColorSpace}" not supported.`), P(h, e), sn(h, e, t), Promise.all(n).then(function() {
1595
- return e.targets !== void 0 ? Qt(h, e.targets, t) : h;
1596
- });
1597
- }
1598
- class rn {
1599
- parse(e) {
1600
- const t = {}, o = e.split(`
1601
- `);
1602
- let n = null, r = t;
1603
- const s = [t];
1604
- for (const a of o)
1605
- if (a.includes("=")) {
1606
- const i = a.split("="), c = i[0].trim(), l = i[1].trim();
1607
- if (l.endsWith("{")) {
1608
- const u = {};
1609
- s.push(u), r[c] = u, r = u;
1610
- } else
1611
- r[c] = l;
1612
- } else if (a.endsWith("{")) {
1613
- const i = r[n] || {};
1614
- s.push(i), r[n] = i, r = i;
1615
- } else if (a.endsWith("}")) {
1616
- if (s.pop(), s.length === 0) continue;
1617
- r = s[s.length - 1];
1618
- } else if (a.endsWith("(")) {
1619
- const i = {};
1620
- s.push(i), n = a.split("(")[0].trim() || n, r[n] = i, r = i;
1621
- } else a.endsWith(")") ? (s.pop(), r = s[s.length - 1]) : n = a.trim();
1622
- return t;
1623
- }
1624
- }
1625
- class on extends ie {
1626
- constructor(e) {
1627
- super(e);
1628
- }
1629
- load(e, t, o, n) {
1630
- const r = this, s = new j(r.manager);
1631
- s.setPath(r.path), s.setResponseType("arraybuffer"), s.setRequestHeader(r.requestHeader), s.setWithCredentials(r.withCredentials), s.load(e, function(a) {
1632
- try {
1633
- t(r.parse(a));
1634
- } catch (i) {
1635
- n ? n(i) : console.error(i), r.manager.itemError(e);
1636
- }
1637
- }, o, n);
1638
- }
1639
- parse(e) {
1640
- const t = new rn();
1641
- function o(d) {
1642
- const p = {};
1643
- new j().setResponseType("arraybuffer");
1644
- for (const A in d) {
1645
- if (A.endsWith("png")) {
1646
- const w = new Blob([d[A]], { type: { type: "image/png" } });
1647
- p[A] = URL.createObjectURL(w);
1648
- }
1649
- if (A.endsWith("usd") || A.endsWith("usda")) {
1650
- if (n(d[A])) {
1651
- console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.");
1652
- continue;
1653
- }
1654
- const w = ge(d[A]);
1655
- p[A] = t.parse(w);
1656
- }
1657
- }
1658
- return p;
1659
- }
1660
- function n(d) {
1661
- const p = d.slice(0, 7), g = new Uint8Array([80, 88, 82, 45, 85, 83, 68, 67]);
1662
- return p.every((A, w) => A === g[w]);
1663
- }
1664
- function r(d) {
1665
- if (d.length < 1) return;
1666
- const p = Object.keys(d)[0];
1667
- let g = !1;
1668
- if (p.endsWith("usda")) return d[p];
1669
- if (p.endsWith("usdc"))
1670
- g = !0;
1671
- else if (p.endsWith("usd"))
1672
- if (n(d[p]))
1673
- g = !0;
1674
- else
1675
- return d[p];
1676
- g && console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.");
1677
- }
1678
- const s = Rt(new Uint8Array(e)), a = o(s), i = r(s);
1679
- if (i === void 0)
1680
- return console.warn("THREE.USDZLoader: No usda file found."), new W();
1681
- const c = ge(i), l = t.parse(c);
1682
- function u(d) {
1683
- if (d) {
1684
- if ("prepend references" in d) {
1685
- const g = d["prepend references"].split("@"), A = g[1].replace(/^.\//, ""), w = g[2].replace(/^<\//, "").replace(/>$/, "");
1686
- return f(a[A], w);
1687
- }
1688
- return f(d);
1689
- }
1690
- }
1691
- function f(d, p) {
1692
- if (d) {
1693
- if (p !== void 0) {
1694
- const g = `def Mesh "${p}"`;
1695
- if (g in d)
1696
- return d[g];
1697
- }
1698
- for (const g in d) {
1699
- const A = d[g];
1700
- if (g.startsWith("def Mesh"))
1701
- return "point3f[] points" in d && (A["point3f[] points"] = d["point3f[] points"]), "texCoord2f[] primvars:st" in d && (A["texCoord2f[] primvars:st"] = d["texCoord2f[] primvars:st"]), "int[] primvars:st:indices" in d && (A["int[] primvars:st:indices"] = d["int[] primvars:st:indices"]), A;
1702
- if (typeof A == "object") {
1703
- const w = f(A);
1704
- if (w) return w;
1705
- }
1706
- }
1707
- }
1708
- }
1709
- function m(d) {
1710
- if (!d) return;
1711
- let p = new ce();
1712
- if ("int[] faceVertexIndices" in d) {
1713
- const g = JSON.parse(d["int[] faceVertexIndices"]);
1714
- p.setIndex(g);
1715
- }
1716
- if ("point3f[] points" in d) {
1717
- const g = JSON.parse(d["point3f[] points"].replace(/[()]*/g, "")), A = new D(new Float32Array(g), 3);
1718
- p.setAttribute("position", A);
1719
- }
1720
- if ("normal3f[] normals" in d) {
1721
- const g = JSON.parse(d["normal3f[] normals"].replace(/[()]*/g, "")), A = new D(new Float32Array(g), 3);
1722
- p.setAttribute("normal", A);
1723
- } else
1724
- p.computeVertexNormals();
1725
- if ("float2[] primvars:st" in d && (d["texCoord2f[] primvars:st"] = d["float2[] primvars:st"]), "texCoord2f[] primvars:st" in d) {
1726
- const g = JSON.parse(d["texCoord2f[] primvars:st"].replace(/[()]*/g, "")), A = new D(new Float32Array(g), 2);
1727
- if ("int[] primvars:st:indices" in d) {
1728
- p = p.toNonIndexed();
1729
- const w = JSON.parse(d["int[] primvars:st:indices"]);
1730
- p.setAttribute("uv", T(A, w));
1731
- } else
1732
- p.setAttribute("uv", A);
1733
- }
1734
- return p;
1735
- }
1736
- function T(d, p) {
1737
- const g = d.array, A = d.itemSize, w = new g.constructor(p.length * A);
1738
- let le = 0, He = 0;
1739
- for (let J = 0, Ue = p.length; J < Ue; J++) {
1740
- le = p[J] * A;
1741
- for (let ue = 0; ue < A; ue++)
1742
- w[He++] = g[le++];
1743
- }
1744
- return new D(w, A);
1745
- }
1746
- function _(d) {
1747
- if (d) {
1748
- if ("rel material:binding" in d) {
1749
- const A = d["rel material:binding"].replace(/^<\//, "").replace(/>$/, "").split("/");
1750
- return x(l, ` "${A[1]}"`);
1751
- }
1752
- return x(d);
1753
- }
1754
- }
1755
- function x(d, p = "") {
1756
- for (const g in d) {
1757
- const A = d[g];
1758
- if (g.startsWith("def Material" + p))
1759
- return A;
1760
- if (typeof A == "object") {
1761
- const w = x(A, p);
1762
- if (w) return w;
1763
- }
1764
- }
1765
- }
1766
- function R(d, p) {
1767
- p["float inputs:rotation"] && (d.rotation = parseFloat(p["float inputs:rotation"])), p["float2 inputs:scale"] && (d.repeat = new z().fromArray(JSON.parse("[" + p["float2 inputs:scale"].replace(/[()]*/g, "") + "]"))), p["float2 inputs:translation"] && (d.offset = new z().fromArray(JSON.parse("[" + p["float2 inputs:translation"].replace(/[()]*/g, "") + "]")));
1768
- }
1769
- function S(d) {
1770
- const p = new k();
1771
- if (d !== void 0) {
1772
- if ('def Shader "PreviewSurface"' in d) {
1773
- const g = d['def Shader "PreviewSurface"'];
1774
- if ("color3f inputs:diffuseColor.connect" in g) {
1775
- const A = g["color3f inputs:diffuseColor.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1776
- p.map = y(w), p.map.colorSpace = C, 'def Shader "Transform2d_diffuse"' in d && R(p.map, d['def Shader "Transform2d_diffuse"']);
1777
- } else if ("color3f inputs:diffuseColor" in g) {
1778
- const A = g["color3f inputs:diffuseColor"].replace(/[()]*/g, "");
1779
- p.color.fromArray(JSON.parse("[" + A + "]"));
1780
- }
1781
- if ("color3f inputs:emissiveColor.connect" in g) {
1782
- const A = g["color3f inputs:emissiveColor.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1783
- p.emissiveMap = y(w), p.emissiveMap.colorSpace = C, p.emissive.set(16777215), 'def Shader "Transform2d_emissive"' in d && R(p.emissiveMap, d['def Shader "Transform2d_emissive"']);
1784
- } else if ("color3f inputs:emissiveColor" in g) {
1785
- const A = g["color3f inputs:emissiveColor"].replace(/[()]*/g, "");
1786
- p.emissive.fromArray(JSON.parse("[" + A + "]"));
1787
- }
1788
- if ("normal3f inputs:normal.connect" in g) {
1789
- const A = g["normal3f inputs:normal.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1790
- p.normalMap = y(w), p.normalMap.colorSpace = U, 'def Shader "Transform2d_normal"' in d && R(p.normalMap, d['def Shader "Transform2d_normal"']);
1791
- }
1792
- if ("float inputs:roughness.connect" in g) {
1793
- const A = g["float inputs:roughness.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1794
- p.roughness = 1, p.roughnessMap = y(w), p.roughnessMap.colorSpace = U, 'def Shader "Transform2d_roughness"' in d && R(p.roughnessMap, d['def Shader "Transform2d_roughness"']);
1795
- } else "float inputs:roughness" in g && (p.roughness = parseFloat(g["float inputs:roughness"]));
1796
- if ("float inputs:metallic.connect" in g) {
1797
- const A = g["float inputs:metallic.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1798
- p.metalness = 1, p.metalnessMap = y(w), p.metalnessMap.colorSpace = U, 'def Shader "Transform2d_metallic"' in d && R(p.metalnessMap, d['def Shader "Transform2d_metallic"']);
1799
- } else "float inputs:metallic" in g && (p.metalness = parseFloat(g["float inputs:metallic"]));
1800
- if ("float inputs:clearcoat.connect" in g) {
1801
- const A = g["float inputs:clearcoat.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1802
- p.clearcoat = 1, p.clearcoatMap = y(w), p.clearcoatMap.colorSpace = U, 'def Shader "Transform2d_clearcoat"' in d && R(p.clearcoatMap, d['def Shader "Transform2d_clearcoat"']);
1803
- } else "float inputs:clearcoat" in g && (p.clearcoat = parseFloat(g["float inputs:clearcoat"]));
1804
- if ("float inputs:clearcoatRoughness.connect" in g) {
1805
- const A = g["float inputs:clearcoatRoughness.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1806
- p.clearcoatRoughness = 1, p.clearcoatRoughnessMap = y(w), p.clearcoatRoughnessMap.colorSpace = U, 'def Shader "Transform2d_clearcoatRoughness"' in d && R(p.clearcoatRoughnessMap, d['def Shader "Transform2d_clearcoatRoughness"']);
1807
- } else "float inputs:clearcoatRoughness" in g && (p.clearcoatRoughness = parseFloat(g["float inputs:clearcoatRoughness"]));
1808
- if ("float inputs:ior" in g && (p.ior = parseFloat(g["float inputs:ior"])), "float inputs:occlusion.connect" in g) {
1809
- const A = g["float inputs:occlusion.connect"], w = L(l, /(\w+).output/.exec(A)[1]);
1810
- p.aoMap = y(w), p.aoMap.colorSpace = U, 'def Shader "Transform2d_occlusion"' in d && R(p.aoMap, d['def Shader "Transform2d_occlusion"']);
1811
- }
1812
- }
1813
- if ('def Shader "diffuseColor_texture"' in d) {
1814
- const g = d['def Shader "diffuseColor_texture"'];
1815
- p.map = y(g), p.map.colorSpace = C;
1816
- }
1817
- if ('def Shader "normal_texture"' in d) {
1818
- const g = d['def Shader "normal_texture"'];
1819
- p.normalMap = y(g), p.normalMap.colorSpace = U;
1820
- }
1821
- }
1822
- return p;
1823
- }
1824
- function L(d, p) {
1825
- for (const g in d) {
1826
- const A = d[g];
1827
- if (g.startsWith(`def Shader "${p}"`))
1828
- return A;
1829
- if (typeof A == "object") {
1830
- const w = L(A, p);
1831
- if (w) return w;
1832
- }
1833
- }
1834
- }
1835
- function y(d) {
1836
- if ("asset inputs:file" in d) {
1837
- const p = d["asset inputs:file"].replace(/@*/g, ""), A = new be().load(a[p]), w = {
1838
- '"clamp"': Ce,
1839
- '"mirror"': Ie,
1840
- '"repeat"': Y
1841
- };
1842
- return "token inputs:wrapS" in d && (A.wrapS = w[d["token inputs:wrapS"]]), "token inputs:wrapT" in d && (A.wrapT = w[d["token inputs:wrapT"]]), A;
1843
- }
1844
- return null;
1845
- }
1846
- function M(d) {
1847
- const p = m(u(d)), g = S(_(d)), A = p ? new ke(p, g) : new ae();
1848
- if ("matrix4d xformOp:transform" in d) {
1849
- const w = JSON.parse("[" + d["matrix4d xformOp:transform"].replace(/[()]*/g, "") + "]");
1850
- A.matrix.fromArray(w), A.matrix.decompose(A.position, A.quaternion, A.scale);
1851
- }
1852
- return A;
1853
- }
1854
- function N(d, p) {
1855
- for (const g in d)
1856
- if (g.startsWith("def Scope"))
1857
- N(d[g], p);
1858
- else if (g.startsWith("def Xform")) {
1859
- const A = M(d[g]);
1860
- /def Xform "(\w+)"/.test(g) && (A.name = /def Xform "(\w+)"/.exec(g)[1]), p.add(A), N(d[g], A);
1861
- }
1862
- }
1863
- const b = new W();
1864
- return N(l, b), b;
1865
- }
1866
- }
1867
- const ne = /* @__PURE__ */ new WeakMap();
1868
- class an extends ie {
1869
- constructor(e) {
1870
- super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
1871
- position: "POSITION",
1872
- normal: "NORMAL",
1873
- color: "COLOR",
1874
- uv: "TEX_COORD"
1875
- }, this.defaultAttributeTypes = {
1876
- position: "Float32Array",
1877
- normal: "Float32Array",
1878
- color: "Float32Array",
1879
- uv: "Float32Array"
1880
- };
1881
- }
1882
- setDecoderPath(e) {
1883
- return this.decoderPath = e, this;
1884
- }
1885
- setDecoderConfig(e) {
1886
- return this.decoderConfig = e, this;
1887
- }
1888
- setWorkerLimit(e) {
1889
- return this.workerLimit = e, this;
1890
- }
1891
- load(e, t, o, n) {
1892
- const r = new j(this.manager);
1893
- r.setPath(this.path), r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials), r.load(e, (s) => {
1894
- this.parse(s, t, n);
1895
- }, o, n);
1896
- }
1897
- parse(e, t, o = () => {
1898
- }) {
1899
- this.decodeDracoFile(e, t, null, null, C).catch(o);
1900
- }
1901
- decodeDracoFile(e, t, o, n, r = O, s = () => {
1902
- }) {
1903
- const a = {
1904
- attributeIDs: o || this.defaultAttributeIDs,
1905
- attributeTypes: n || this.defaultAttributeTypes,
1906
- useUniqueIDs: !!o,
1907
- vertexColorSpace: r
1908
- };
1909
- return this.decodeGeometry(e, a).then(t).catch(s);
1910
- }
1911
- decodeGeometry(e, t) {
1912
- const o = JSON.stringify(t);
1913
- if (ne.has(e)) {
1914
- const i = ne.get(e);
1915
- if (i.key === o)
1916
- return i.promise;
1917
- if (e.byteLength === 0)
1918
- throw new Error(
1919
- "THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."
1920
- );
1921
- }
1922
- let n;
1923
- const r = this.workerNextTaskID++, s = e.byteLength, a = this._getWorker(r, s).then((i) => (n = i, new Promise((c, l) => {
1924
- n._callbacks[r] = { resolve: c, reject: l }, n.postMessage({ type: "decode", id: r, taskConfig: t, buffer: e }, [e]);
1925
- }))).then((i) => this._createGeometry(i.geometry));
1926
- return a.catch(() => !0).then(() => {
1927
- n && r && this._releaseTask(n, r);
1928
- }), ne.set(e, {
1929
- key: o,
1930
- promise: a
1931
- }), a;
1932
- }
1933
- _createGeometry(e) {
1934
- const t = new ce();
1935
- e.index && t.setIndex(new D(e.index.array, 1));
1936
- for (let o = 0; o < e.attributes.length; o++) {
1937
- const n = e.attributes[o], r = n.name, s = n.array, a = n.itemSize, i = new D(s, a);
1938
- r === "color" && (this._assignVertexColorSpace(i, n.vertexColorSpace), i.normalized = !(s instanceof Float32Array)), t.setAttribute(r, i);
1939
- }
1940
- return t;
1941
- }
1942
- _assignVertexColorSpace(e, t) {
1943
- if (t !== C) return;
1944
- const o = new H();
1945
- for (let n = 0, r = e.count; n < r; n++)
1946
- o.fromBufferAttribute(e, n).convertSRGBToLinear(), e.setXYZ(n, o.r, o.g, o.b);
1947
- }
1948
- _loadLibrary(e, t) {
1949
- const o = new j(this.manager);
1950
- return o.setPath(this.decoderPath), o.setResponseType(t), o.setWithCredentials(this.withCredentials), new Promise((n, r) => {
1951
- o.load(e, n, void 0, r);
1952
- });
1953
- }
1954
- preload() {
1955
- return this._initDecoder(), this;
1956
- }
1957
- _initDecoder() {
1958
- if (this.decoderPending) return this.decoderPending;
1959
- const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
1960
- return e ? t.push(this._loadLibrary("draco_decoder.js", "text")) : (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(t).then((o) => {
1961
- const n = o[0];
1962
- e || (this.decoderConfig.wasmBinary = o[1]);
1963
- const r = cn.toString(), s = [
1964
- "/* draco decoder */",
1965
- n,
1966
- "",
1967
- "/* worker */",
1968
- r.substring(r.indexOf("{") + 1, r.lastIndexOf("}"))
1969
- ].join(`
1970
- `);
1971
- this.workerSourceURL = URL.createObjectURL(new Blob([s]));
1972
- }), this.decoderPending;
1973
- }
1974
- _getWorker(e, t) {
1975
- return this._initDecoder().then(() => {
1976
- if (this.workerPool.length < this.workerLimit) {
1977
- const n = new Worker(this.workerSourceURL);
1978
- n._callbacks = {}, n._taskCosts = {}, n._taskLoad = 0, n.postMessage({ type: "init", decoderConfig: this.decoderConfig }), n.onmessage = function(r) {
1979
- const s = r.data;
1980
- switch (s.type) {
1981
- case "decode":
1982
- n._callbacks[s.id].resolve(s);
1983
- break;
1984
- case "error":
1985
- n._callbacks[s.id].reject(s);
1986
- break;
1987
- default:
1988
- console.error('THREE.DRACOLoader: Unexpected message, "' + s.type + '"');
1989
- }
1990
- }, this.workerPool.push(n);
1991
- } else
1992
- this.workerPool.sort(function(n, r) {
1993
- return n._taskLoad > r._taskLoad ? -1 : 1;
1994
- });
1995
- const o = this.workerPool[this.workerPool.length - 1];
1996
- return o._taskCosts[e] = t, o._taskLoad += t, o;
1997
- });
1998
- }
1999
- _releaseTask(e, t) {
2000
- e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t];
2001
- }
2002
- debug() {
2003
- console.log("Task load: ", this.workerPool.map((e) => e._taskLoad));
2004
- }
2005
- dispose() {
2006
- for (let e = 0; e < this.workerPool.length; ++e)
2007
- this.workerPool[e].terminate();
2008
- return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
2009
- }
2010
- }
2011
- function cn() {
2012
- let h, e;
2013
- onmessage = function(s) {
2014
- const a = s.data;
2015
- switch (a.type) {
2016
- case "init":
2017
- h = a.decoderConfig, e = new Promise(function(l) {
2018
- h.onModuleLoaded = function(u) {
2019
- l({ draco: u });
2020
- }, DracoDecoderModule(h);
2021
- });
2022
- break;
2023
- case "decode":
2024
- const i = a.buffer, c = a.taskConfig;
2025
- e.then((l) => {
2026
- const u = l.draco, f = new u.Decoder();
2027
- try {
2028
- const m = t(u, f, new Int8Array(i), c), T = m.attributes.map((_) => _.array.buffer);
2029
- m.index && T.push(m.index.array.buffer), self.postMessage({ type: "decode", id: a.id, geometry: m }, T);
2030
- } catch (m) {
2031
- console.error(m), self.postMessage({ type: "error", id: a.id, error: m.message });
2032
- } finally {
2033
- u.destroy(f);
2034
- }
2035
- });
2036
- break;
2037
- }
2038
- };
2039
- function t(s, a, i, c) {
2040
- const l = c.attributeIDs, u = c.attributeTypes;
2041
- let f, m;
2042
- const T = a.GetEncodedGeometryType(i);
2043
- if (T === s.TRIANGULAR_MESH)
2044
- f = new s.Mesh(), m = a.DecodeArrayToMesh(i, i.byteLength, f);
2045
- else if (T === s.POINT_CLOUD)
2046
- f = new s.PointCloud(), m = a.DecodeArrayToPointCloud(i, i.byteLength, f);
2047
- else
2048
- throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
2049
- if (!m.ok() || f.ptr === 0)
2050
- throw new Error("THREE.DRACOLoader: Decoding failed: " + m.error_msg());
2051
- const _ = { index: null, attributes: [] };
2052
- for (const x in l) {
2053
- const R = self[u[x]];
2054
- let S, L;
2055
- if (c.useUniqueIDs)
2056
- L = l[x], S = a.GetAttributeByUniqueId(f, L);
2057
- else {
2058
- if (L = a.GetAttributeId(f, s[l[x]]), L === -1) continue;
2059
- S = a.GetAttribute(f, L);
2060
- }
2061
- const y = n(s, a, f, x, R, S);
2062
- x === "color" && (y.vertexColorSpace = c.vertexColorSpace), _.attributes.push(y);
2063
- }
2064
- return T === s.TRIANGULAR_MESH && (_.index = o(s, a, f)), s.destroy(f), _;
2065
- }
2066
- function o(s, a, i) {
2067
- const l = i.num_faces() * 3, u = l * 4, f = s._malloc(u);
2068
- a.GetTrianglesUInt32Array(i, u, f);
2069
- const m = new Uint32Array(s.HEAPF32.buffer, f, l).slice();
2070
- return s._free(f), { array: m, itemSize: 1 };
2071
- }
2072
- function n(s, a, i, c, l, u) {
2073
- const f = u.num_components(), T = i.num_points() * f, _ = T * l.BYTES_PER_ELEMENT, x = r(s, l), R = s._malloc(_);
2074
- a.GetAttributeDataArrayForAllPoints(i, u, x, _, R);
2075
- const S = new l(s.HEAPF32.buffer, R, T).slice();
2076
- return s._free(R), {
2077
- name: c,
2078
- array: S,
2079
- itemSize: f
2080
- };
2081
- }
2082
- function r(s, a) {
2083
- switch (a) {
2084
- case Float32Array:
2085
- return s.DT_FLOAT32;
2086
- case Int8Array:
2087
- return s.DT_INT8;
2088
- case Int16Array:
2089
- return s.DT_INT16;
2090
- case Int32Array:
2091
- return s.DT_INT32;
2092
- case Uint8Array:
2093
- return s.DT_UINT8;
2094
- case Uint16Array:
2095
- return s.DT_UINT16;
2096
- case Uint32Array:
2097
- return s.DT_UINT32;
2098
- }
2099
- }
2100
- }
2101
- class Ee extends Error {
2102
- constructor(e, t, o) {
2103
- super(t), this.url = e, this.cause = o, this.name = "NetworkError";
2104
- }
2105
- }
2106
- class hn {
2107
- constructor() {
2108
- Q(this, "_gltfLoader");
2109
- Q(this, "_usdzLoader");
2110
- const e = new an();
2111
- e.setDecoderPath("../draco/"), this._gltfLoader = new Et(), this._gltfLoader.setDRACOLoader(e), this._usdzLoader = new on();
2112
- }
2113
- async _loadFile(e) {
2114
- const t = await fetch(e);
2115
- if (!t.ok)
2116
- throw new Ee(e, `Failed to fetch file from ${e}`);
2117
- try {
2118
- return await t.arrayBuffer();
2119
- } catch {
2120
- throw new Ee(e, `Failed to fetch file from ${e}`);
2121
- }
2122
- }
2123
- async load(e) {
2124
- const t = yt(e);
2125
- if (t.length === 0)
2126
- throw new Ae("No file extension found in URI", "");
2127
- if (!wt(t))
2128
- throw new Ae(
2129
- `Unsupported file type: ${t}. Supported types: ${_t.join(", ")}`,
2130
- t
2131
- );
2132
- const o = await this._loadFile(e);
2133
- try {
2134
- switch (t) {
2135
- case "glb":
2136
- case "gltf":
2137
- return (await this._gltfLoader.parseAsync(
2138
- o,
2139
- ""
2140
- )).scene;
2141
- case "usdz":
2142
- return await this._usdzLoader.parse(o);
2143
- }
2144
- } catch (n) {
2145
- throw n instanceof Error ? new Te(
2146
- `Failed to parse ${t} file: ${n.message}`,
2147
- n
2148
- ) : new Te(`Failed to parse ${t} file`);
2149
- }
2150
- }
2151
- }
2152
- export {
2153
- hn as AssetLoader
2154
- };