@shopware-ag/dive 1.19.1-beta.9 → 2.0.1-beta.1

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