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