@7niao/doc-previewer 0.0.0-stage → 0.1.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/LICENSE +15 -0
- package/README.md +219 -2
- package/dist/assets/ArchiveRenderer-BZsm87A2.js +514 -0
- package/dist/assets/CadRenderer-DQiBmk71.js +1838 -0
- package/dist/assets/DocxRenderer-6BCR0R9L.js +3173 -0
- package/dist/assets/GisRenderer-BQ_T-z1A.js +9758 -0
- package/dist/assets/ImageRenderer-D1SFZkV3.js +24 -0
- package/dist/assets/MediaRenderer-DKj0V7cL.js +66 -0
- package/dist/assets/Model3dRenderer-DDk-HsYP.js +1966 -0
- package/dist/assets/OfdRenderer-1kDqHPDa.js +67 -0
- package/dist/assets/PdfRenderer-DqOFKG_L.js +16321 -0
- package/dist/assets/PptxRenderer-BSoVSGOz.js +48492 -0
- package/dist/assets/TextRenderer-pKpgA2wF.js +38 -0
- package/dist/assets/UnsupportedRenderer-CnjuGXg3.js +29 -0
- package/dist/assets/XlsxRenderer-Bohk5iIA.js +16257 -0
- package/dist/assets/_plugin-vue_export-helper-Djzt4Yr7.js +7 -0
- package/dist/assets/createLucideIcon-C_l8giLP.js +91 -0
- package/dist/assets/dom-Ba50_9e0.js +93 -0
- package/dist/assets/dwg2dxf-wasm-DO6Y5cnM.js +2148 -0
- package/dist/assets/file-question-mark-D7iJe3UN.js +21 -0
- package/dist/assets/jszip.min-OjSHaKmg.js +3039 -0
- package/dist/assets/ofd.es-CauEO04U.js +24255 -0
- package/dist/assets/rolldown-runtime-CwxnZyOB.js +22 -0
- package/dist/assets/three.module-B04XcvCz.js +12454 -0
- package/dist/assets/types-CVtHVd2P.js +168 -0
- package/dist/index.js +725 -0
- package/dist/libarchive/libarchive.wasm +0 -0
- package/dist/libarchive/worker-bundle.js +6 -0
- package/dist/style.css +2 -0
- package/dist/types/FileViewer.vue.d.ts +48 -0
- package/dist/types/components/PreviewToolbar.vue.d.ts +33 -0
- package/dist/types/composables/useFullscreen.d.ts +6 -0
- package/dist/types/composables/usePreviewSource.d.ts +14 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/renderers/ArchiveRenderer.vue.d.ts +18 -0
- package/dist/types/renderers/CadRenderer.vue.d.ts +29 -0
- package/dist/types/renderers/DocxRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/GisRenderer.vue.d.ts +26 -0
- package/dist/types/renderers/ImageRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/MediaRenderer.vue.d.ts +17 -0
- package/dist/types/renderers/Model3dRenderer.vue.d.ts +29 -0
- package/dist/types/renderers/OfdRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/PdfRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/PptxRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/TextRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/UnsupportedRenderer.vue.d.ts +14 -0
- package/dist/types/renderers/XlsxRenderer.vue.d.ts +16 -0
- package/dist/types/types.d.ts +53 -0
- package/dist/types/utils/detect.d.ts +10 -0
- package/dist/types/utils/dom.d.ts +13 -0
- package/dist/types/vendor/asn1js-stub.d.ts +10 -0
- package/package.json +77 -3
|
@@ -0,0 +1,1966 @@
|
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as ee, St as y, T as te, U as b, V as ne, W as x, X as S, Y as re, Z as ie, _ as C, _t as w, a as T, at as ae, b as oe, bt as E, ct as D, d as O, dt as se, et as ce, f as le, ft as ue, h as de, i as fe, it as k, j as pe, k as me, lt as he, m as ge, mt as _e, n as ve, nt as ye, o as A, ot as be, p as xe, pt as j, q as Se, r as Ce, rt as we, s as Te, st as Ee, t as De, tt as Oe, u as ke, ut as Ae, v as je, vt as Me, w as Ne, x as Pe, xt as M, y as Fe, yt as Ie, z as Le } from "./three.module-B04XcvCz.js";
|
|
2
|
+
import { i as Re } from "./dom-Ba50_9e0.js";
|
|
3
|
+
import { t as ze } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
|
|
4
|
+
import { createCommentVNode as Be, createElementBlock as Ve, createElementVNode as N, defineComponent as He, onBeforeUnmount as Ue, onMounted as We, openBlock as Ge, ref as Ke, toDisplayString as qe } from "vue";
|
|
5
|
+
// node_modules/.pnpm/three@0.187.0/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js
|
|
6
|
+
function Je(e, t) {
|
|
7
|
+
if (t === 0) return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), e;
|
|
8
|
+
if (t === 2 || t === 1) {
|
|
9
|
+
let n = e.getIndex();
|
|
10
|
+
if (n === null) {
|
|
11
|
+
let t = [], r = e.getAttribute("position");
|
|
12
|
+
if (r !== void 0) {
|
|
13
|
+
for (let e = 0; e < r.count; e++) t.push(e);
|
|
14
|
+
e.setIndex(t), n = e.getIndex();
|
|
15
|
+
} else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), e;
|
|
16
|
+
}
|
|
17
|
+
let r = n.count - 2, i = [];
|
|
18
|
+
if (t === 2) for (let e = 1; e <= r; e++) i.push(n.getX(0)), i.push(n.getX(e)), i.push(n.getX(e + 1));
|
|
19
|
+
else for (let e = 0; e < r; e++) e % 2 == 0 ? (i.push(n.getX(e)), i.push(n.getX(e + 1)), i.push(n.getX(e + 2))) : (i.push(n.getX(e + 2)), i.push(n.getX(e + 1)), i.push(n.getX(e)));
|
|
20
|
+
return i.length / 3 !== r && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."), e.setIndex(i), e.clearGroups(), e;
|
|
21
|
+
}
|
|
22
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", t), e;
|
|
23
|
+
}
|
|
24
|
+
// node_modules/.pnpm/three@0.187.0/node_modules/three/examples/jsm/utils/SkeletonUtils.js
|
|
25
|
+
function Ye(e) {
|
|
26
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = e.clone();
|
|
27
|
+
return Xe(e, r, function(e, r) {
|
|
28
|
+
t.set(r, e), n.set(e, r);
|
|
29
|
+
}), r.traverse(function(e) {
|
|
30
|
+
if (!e.isSkinnedMesh) return;
|
|
31
|
+
let r = e, i = t.get(e), a = i.skeleton.bones;
|
|
32
|
+
r.skeleton = i.skeleton.clone(), r.bindMatrix.copy(i.bindMatrix), r.skeleton.bones = a.map(function(e) {
|
|
33
|
+
return n.get(e);
|
|
34
|
+
}), r.bind(r.skeleton, r.bindMatrix);
|
|
35
|
+
}), r;
|
|
36
|
+
}
|
|
37
|
+
function Xe(e, t, n) {
|
|
38
|
+
n(e, t);
|
|
39
|
+
for (let r = 0; r < e.children.length; r++) Xe(e.children[r], t.children[r], n);
|
|
40
|
+
}
|
|
41
|
+
// node_modules/.pnpm/three@0.187.0/node_modules/three/examples/jsm/loaders/GLTFLoader.js
|
|
42
|
+
var Ze = class extends o {
|
|
43
|
+
constructor(e) {
|
|
44
|
+
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
45
|
+
return new nt(e);
|
|
46
|
+
}), this.register(function(e) {
|
|
47
|
+
return new rt(e);
|
|
48
|
+
}), this.register(function(e) {
|
|
49
|
+
return new it(e);
|
|
50
|
+
}), this.register(function(e) {
|
|
51
|
+
return new pt(e);
|
|
52
|
+
}), this.register(function(e) {
|
|
53
|
+
return new mt(e);
|
|
54
|
+
}), this.register(function(e) {
|
|
55
|
+
return new ht(e);
|
|
56
|
+
}), this.register(function(e) {
|
|
57
|
+
return new ot(e);
|
|
58
|
+
}), this.register(function(e) {
|
|
59
|
+
return new st(e);
|
|
60
|
+
}), this.register(function(e) {
|
|
61
|
+
return new ct(e);
|
|
62
|
+
}), this.register(function(e) {
|
|
63
|
+
return new lt(e);
|
|
64
|
+
}), this.register(function(e) {
|
|
65
|
+
return new tt(e);
|
|
66
|
+
}), this.register(function(e) {
|
|
67
|
+
return new ut(e);
|
|
68
|
+
}), this.register(function(e) {
|
|
69
|
+
return new at(e);
|
|
70
|
+
}), this.register(function(e) {
|
|
71
|
+
return new ft(e);
|
|
72
|
+
}), this.register(function(e) {
|
|
73
|
+
return new dt(e);
|
|
74
|
+
}), this.register(function(e) {
|
|
75
|
+
return new $e(e);
|
|
76
|
+
}), this.register(function(e) {
|
|
77
|
+
return new gt(e, F.EXT_MESHOPT_COMPRESSION);
|
|
78
|
+
}), this.register(function(e) {
|
|
79
|
+
return new gt(e, F.KHR_MESHOPT_COMPRESSION);
|
|
80
|
+
}), this.register(function(e) {
|
|
81
|
+
return new _t(e);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
load(e, t, n, r) {
|
|
85
|
+
let i = this, a;
|
|
86
|
+
if (this.resourcePath !== "") a = this.resourcePath;
|
|
87
|
+
else if (this.path !== "") {
|
|
88
|
+
let t = l.extractUrlBase(e);
|
|
89
|
+
a = l.resolveURL(t, this.path);
|
|
90
|
+
} else a = l.extractUrlBase(e);
|
|
91
|
+
this.manager.itemStart(e);
|
|
92
|
+
let o = function(t) {
|
|
93
|
+
r ? r(t) : console.error(t), i.manager.itemError(e), i.manager.itemEnd(e);
|
|
94
|
+
}, s = new de(this.manager);
|
|
95
|
+
s.setPriority(this.priority), s.setCache(this.cache), s.setPath(this.path), s.setResponseType("arraybuffer"), s.setRequestHeader(this.requestHeader), s.setWithCredentials(this.withCredentials), s.load(e, function(n) {
|
|
96
|
+
try {
|
|
97
|
+
i.parse(n, a, function(n) {
|
|
98
|
+
t(n), i.manager.itemEnd(e);
|
|
99
|
+
}, o);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
o(e);
|
|
102
|
+
}
|
|
103
|
+
}, n, o);
|
|
104
|
+
}
|
|
105
|
+
setDRACOLoader(e) {
|
|
106
|
+
return this.dracoLoader = e, this;
|
|
107
|
+
}
|
|
108
|
+
setKTX2Loader(e) {
|
|
109
|
+
return this.ktx2Loader = e, this;
|
|
110
|
+
}
|
|
111
|
+
setMeshoptDecoder(e) {
|
|
112
|
+
return this.meshoptDecoder = e, this;
|
|
113
|
+
}
|
|
114
|
+
register(e) {
|
|
115
|
+
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
|
|
116
|
+
}
|
|
117
|
+
unregister(e) {
|
|
118
|
+
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
|
|
119
|
+
}
|
|
120
|
+
parse(e, t, n, r) {
|
|
121
|
+
let i, a = {}, o = {}, s = new TextDecoder();
|
|
122
|
+
if (typeof e == "string") i = JSON.parse(e);
|
|
123
|
+
else if (e instanceof ArrayBuffer) {
|
|
124
|
+
if (s.decode(new Uint8Array(e, 0, 4)) === vt) {
|
|
125
|
+
try {
|
|
126
|
+
a[F.KHR_BINARY_GLTF] = new bt(e);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
r && r(e);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
i = JSON.parse(a[F.KHR_BINARY_GLTF].content);
|
|
132
|
+
} else i = JSON.parse(s.decode(e));
|
|
133
|
+
} else i = e;
|
|
134
|
+
if (i.asset === void 0 || i.asset.version[0] < 2) {
|
|
135
|
+
r && r(/* @__PURE__ */ Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
let c = new It(i, {
|
|
139
|
+
path: t || this.resourcePath || "",
|
|
140
|
+
crossOrigin: this.crossOrigin,
|
|
141
|
+
priority: this.priority,
|
|
142
|
+
cache: this.cache,
|
|
143
|
+
withCredentials: this.withCredentials,
|
|
144
|
+
requestHeader: this.requestHeader,
|
|
145
|
+
manager: this.manager,
|
|
146
|
+
ktx2Loader: this.ktx2Loader,
|
|
147
|
+
meshoptDecoder: this.meshoptDecoder
|
|
148
|
+
});
|
|
149
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
150
|
+
for (let e = 0; e < this.pluginCallbacks.length; e++) {
|
|
151
|
+
let t = this.pluginCallbacks[e](c);
|
|
152
|
+
t.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), o[t.name] = t, a[t.name] = !0;
|
|
153
|
+
}
|
|
154
|
+
if (i.extensionsUsed) for (let e = 0; e < i.extensionsUsed.length; ++e) {
|
|
155
|
+
let t = i.extensionsUsed[e], n = i.extensionsRequired || [];
|
|
156
|
+
switch (t) {
|
|
157
|
+
case F.KHR_MATERIALS_UNLIT:
|
|
158
|
+
a[t] = new et();
|
|
159
|
+
break;
|
|
160
|
+
case F.KHR_DRACO_MESH_COMPRESSION:
|
|
161
|
+
a[t] = new xt(i, this.dracoLoader);
|
|
162
|
+
break;
|
|
163
|
+
case F.KHR_TEXTURE_TRANSFORM:
|
|
164
|
+
a[t] = new St();
|
|
165
|
+
break;
|
|
166
|
+
case F.KHR_MESH_QUANTIZATION:
|
|
167
|
+
a[t] = new Ct();
|
|
168
|
+
break;
|
|
169
|
+
default: n.indexOf(t) >= 0 && o[t] === void 0 && console.warn("THREE.GLTFLoader: Unknown extension \"" + t + "\".");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
c.setExtensions(a), c.setPlugins(o), c.parse(n, r);
|
|
173
|
+
}
|
|
174
|
+
parseAsync(e, t) {
|
|
175
|
+
let n = this;
|
|
176
|
+
return new Promise(function(r, i) {
|
|
177
|
+
n.parse(e, t, r, i);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
function Qe() {
|
|
182
|
+
let e = {};
|
|
183
|
+
return {
|
|
184
|
+
get: function(t) {
|
|
185
|
+
return e[t];
|
|
186
|
+
},
|
|
187
|
+
add: function(t, n) {
|
|
188
|
+
e[t] = n;
|
|
189
|
+
},
|
|
190
|
+
remove: function(t) {
|
|
191
|
+
delete e[t];
|
|
192
|
+
},
|
|
193
|
+
removeAll: function() {
|
|
194
|
+
e = {};
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function P(e, t, n) {
|
|
199
|
+
let r = e.json.materials[t];
|
|
200
|
+
return r.extensions && r.extensions[n] ? r.extensions[n] : null;
|
|
201
|
+
}
|
|
202
|
+
var F = {
|
|
203
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
204
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
205
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
206
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
207
|
+
KHR_MATERIALS_DIFFUSE_ROUGHNESS: "KHR_materials_diffuse_roughness",
|
|
208
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
209
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
210
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
211
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
212
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
213
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
214
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
215
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
216
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
217
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
218
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
219
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
220
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
221
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
222
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
223
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
224
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
225
|
+
KHR_MESHOPT_COMPRESSION: "KHR_meshopt_compression",
|
|
226
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
227
|
+
}, $e = class {
|
|
228
|
+
constructor(e) {
|
|
229
|
+
this.parser = e, this.name = F.KHR_LIGHTS_PUNCTUAL, this.cache = {
|
|
230
|
+
refs: {},
|
|
231
|
+
uses: {}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
_markDefs() {
|
|
235
|
+
let e = this.parser, t = this.parser.json.nodes || [];
|
|
236
|
+
for (let n = 0, r = t.length; n < r; n++) {
|
|
237
|
+
let r = t[n];
|
|
238
|
+
r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
_loadLight(e) {
|
|
242
|
+
let t = this.parser, n = "light:" + e, r = t.cache.get(n);
|
|
243
|
+
if (r) return r;
|
|
244
|
+
let i = t.json, a = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e], o, s = new O(16777215);
|
|
245
|
+
a.color !== void 0 && s.setRGB(a.color[0], a.color[1], a.color[2], g);
|
|
246
|
+
let c = a.range === void 0 ? 0 : a.range;
|
|
247
|
+
switch (a.type) {
|
|
248
|
+
case "directional":
|
|
249
|
+
o = new ge(s), o.target.position.set(0, 0, -1), o.add(o.target);
|
|
250
|
+
break;
|
|
251
|
+
case "point":
|
|
252
|
+
o = new ce(s), o.distance = c;
|
|
253
|
+
break;
|
|
254
|
+
case "spot":
|
|
255
|
+
o = new _e(s), o.distance = c, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle === void 0 ? 0 : a.spot.innerConeAngle, a.spot.outerConeAngle = a.spot.outerConeAngle === void 0 ? Math.PI / 4 : a.spot.outerConeAngle, o.angle = a.spot.outerConeAngle, o.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, o.target.position.set(0, 0, -1), o.add(o.target);
|
|
256
|
+
break;
|
|
257
|
+
default: throw Error("THREE.GLTFLoader: Unexpected light type: " + a.type);
|
|
258
|
+
}
|
|
259
|
+
return o.position.set(0, 0, 0), W(o, a), a.intensity !== void 0 && (o.intensity = a.intensity), o.name = t.createUniqueName(a.name || "light_" + e), r = Promise.resolve(o), t.cache.add(n, r), r;
|
|
260
|
+
}
|
|
261
|
+
getDependency(e, t) {
|
|
262
|
+
if (e === "light") return this._loadLight(t);
|
|
263
|
+
}
|
|
264
|
+
createNodeAttachment(e) {
|
|
265
|
+
let t = this, n = this.parser, r = n.json.nodes[e], i = (r.extensions && r.extensions[this.name] || {}).light;
|
|
266
|
+
return i === void 0 ? null : this._loadLight(i).then(function(e) {
|
|
267
|
+
return n._getNodeRef(t.cache, i, e);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}, et = class {
|
|
271
|
+
constructor() {
|
|
272
|
+
this.name = F.KHR_MATERIALS_UNLIT;
|
|
273
|
+
}
|
|
274
|
+
getMaterialType() {
|
|
275
|
+
return c;
|
|
276
|
+
}
|
|
277
|
+
extendParams(e, t, n) {
|
|
278
|
+
let r = [];
|
|
279
|
+
e.color = new O(1, 1, 1), e.opacity = 1;
|
|
280
|
+
let i = t.pbrMetallicRoughness;
|
|
281
|
+
if (i) {
|
|
282
|
+
if (Array.isArray(i.baseColorFactor)) {
|
|
283
|
+
let t = i.baseColorFactor;
|
|
284
|
+
e.color.setRGB(t[0], t[1], t[2], g), e.opacity = t[3];
|
|
285
|
+
}
|
|
286
|
+
i.baseColorTexture !== void 0 && r.push(n.assignTexture(e, "map", i.baseColorTexture, D));
|
|
287
|
+
}
|
|
288
|
+
return Promise.all(r);
|
|
289
|
+
}
|
|
290
|
+
}, tt = class {
|
|
291
|
+
constructor(e) {
|
|
292
|
+
this.parser = e, this.name = F.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
293
|
+
}
|
|
294
|
+
extendMaterialParams(e, t) {
|
|
295
|
+
let n = P(this.parser, e, this.name);
|
|
296
|
+
return n === null || n.emissiveStrength !== void 0 && (t.emissiveIntensity = n.emissiveStrength), Promise.resolve();
|
|
297
|
+
}
|
|
298
|
+
}, nt = class {
|
|
299
|
+
constructor(e) {
|
|
300
|
+
this.parser = e, this.name = F.KHR_MATERIALS_CLEARCOAT;
|
|
301
|
+
}
|
|
302
|
+
getMaterialType(e) {
|
|
303
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
304
|
+
}
|
|
305
|
+
extendMaterialParams(e, t) {
|
|
306
|
+
let n = P(this.parser, e, this.name);
|
|
307
|
+
if (n === null) return Promise.resolve();
|
|
308
|
+
let r = [];
|
|
309
|
+
if (n.clearcoatFactor !== void 0 && (t.clearcoat = n.clearcoatFactor), n.clearcoatTexture !== void 0 && r.push(this.parser.assignTexture(t, "clearcoatMap", n.clearcoatTexture)), n.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = n.clearcoatRoughnessFactor), n.clearcoatRoughnessTexture !== void 0 && r.push(this.parser.assignTexture(t, "clearcoatRoughnessMap", n.clearcoatRoughnessTexture)), n.clearcoatNormalTexture !== void 0 && (r.push(this.parser.assignTexture(t, "clearcoatNormalMap", n.clearcoatNormalTexture)), n.clearcoatNormalTexture.scale !== void 0)) {
|
|
310
|
+
let e = n.clearcoatNormalTexture.scale;
|
|
311
|
+
t.clearcoatNormalScale = new E(e, e);
|
|
312
|
+
}
|
|
313
|
+
return Promise.all(r);
|
|
314
|
+
}
|
|
315
|
+
}, rt = class {
|
|
316
|
+
constructor(e) {
|
|
317
|
+
this.parser = e, this.name = F.KHR_MATERIALS_DIFFUSE_ROUGHNESS;
|
|
318
|
+
}
|
|
319
|
+
getMaterialType(e) {
|
|
320
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
321
|
+
}
|
|
322
|
+
extendMaterialParams(e, t) {
|
|
323
|
+
let n = P(this.parser, e, this.name);
|
|
324
|
+
if (n === null) return Promise.resolve();
|
|
325
|
+
let r = [];
|
|
326
|
+
return t.diffuseRoughness = n.diffuseRoughnessFactor === void 0 ? 0 : n.diffuseRoughnessFactor, n.diffuseRoughnessTexture !== void 0 && r.push(this.parser.assignTexture(t, "diffuseRoughnessMap", n.diffuseRoughnessTexture)), Promise.all(r);
|
|
327
|
+
}
|
|
328
|
+
}, it = class {
|
|
329
|
+
constructor(e) {
|
|
330
|
+
this.parser = e, this.name = F.KHR_MATERIALS_DISPERSION;
|
|
331
|
+
}
|
|
332
|
+
getMaterialType(e) {
|
|
333
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
334
|
+
}
|
|
335
|
+
extendMaterialParams(e, t) {
|
|
336
|
+
let n = P(this.parser, e, this.name);
|
|
337
|
+
return n === null || (t.dispersion = n.dispersion === void 0 ? 0 : n.dispersion), Promise.resolve();
|
|
338
|
+
}
|
|
339
|
+
}, at = class {
|
|
340
|
+
constructor(e) {
|
|
341
|
+
this.parser = e, this.name = F.KHR_MATERIALS_IRIDESCENCE;
|
|
342
|
+
}
|
|
343
|
+
getMaterialType(e) {
|
|
344
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
345
|
+
}
|
|
346
|
+
extendMaterialParams(e, t) {
|
|
347
|
+
let n = P(this.parser, e, this.name);
|
|
348
|
+
if (n === null) return Promise.resolve();
|
|
349
|
+
let r = [];
|
|
350
|
+
return n.iridescenceFactor !== void 0 && (t.iridescence = n.iridescenceFactor), n.iridescenceTexture !== void 0 && r.push(this.parser.assignTexture(t, "iridescenceMap", n.iridescenceTexture)), n.iridescenceIor !== void 0 && (t.iridescenceIOR = n.iridescenceIor), n.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessMinimum = n.iridescenceThicknessMinimum), n.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessMaximum = n.iridescenceThicknessMaximum), n.iridescenceThicknessTexture !== void 0 && r.push(this.parser.assignTexture(t, "iridescenceThicknessMap", n.iridescenceThicknessTexture)), Promise.all(r);
|
|
351
|
+
}
|
|
352
|
+
}, ot = class {
|
|
353
|
+
constructor(e) {
|
|
354
|
+
this.parser = e, this.name = F.KHR_MATERIALS_SHEEN;
|
|
355
|
+
}
|
|
356
|
+
getMaterialType(e) {
|
|
357
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
358
|
+
}
|
|
359
|
+
extendMaterialParams(e, t) {
|
|
360
|
+
let n = P(this.parser, e, this.name);
|
|
361
|
+
if (n === null) return Promise.resolve();
|
|
362
|
+
let r = [];
|
|
363
|
+
if (t.sheenColor = new O(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1, n.sheenColorFactor !== void 0) {
|
|
364
|
+
let e = n.sheenColorFactor;
|
|
365
|
+
t.sheenColor.setRGB(e[0], e[1], e[2], g);
|
|
366
|
+
}
|
|
367
|
+
return n.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = n.sheenRoughnessFactor), n.sheenColorTexture !== void 0 && r.push(this.parser.assignTexture(t, "sheenColorMap", n.sheenColorTexture, D)), n.sheenRoughnessTexture !== void 0 && r.push(this.parser.assignTexture(t, "sheenRoughnessMap", n.sheenRoughnessTexture)), Promise.all(r);
|
|
368
|
+
}
|
|
369
|
+
}, st = class {
|
|
370
|
+
constructor(e) {
|
|
371
|
+
this.parser = e, this.name = F.KHR_MATERIALS_TRANSMISSION;
|
|
372
|
+
}
|
|
373
|
+
getMaterialType(e) {
|
|
374
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
375
|
+
}
|
|
376
|
+
extendMaterialParams(e, t) {
|
|
377
|
+
let n = P(this.parser, e, this.name);
|
|
378
|
+
if (n === null) return Promise.resolve();
|
|
379
|
+
let r = [];
|
|
380
|
+
return n.transmissionFactor !== void 0 && (t.transmission = n.transmissionFactor), n.transmissionTexture !== void 0 && r.push(this.parser.assignTexture(t, "transmissionMap", n.transmissionTexture)), Promise.all(r);
|
|
381
|
+
}
|
|
382
|
+
}, ct = class {
|
|
383
|
+
constructor(e) {
|
|
384
|
+
this.parser = e, this.name = F.KHR_MATERIALS_VOLUME;
|
|
385
|
+
}
|
|
386
|
+
getMaterialType(e) {
|
|
387
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
388
|
+
}
|
|
389
|
+
extendMaterialParams(e, t) {
|
|
390
|
+
let n = P(this.parser, e, this.name);
|
|
391
|
+
if (n === null) return Promise.resolve();
|
|
392
|
+
let r = [];
|
|
393
|
+
t.thickness = n.thicknessFactor === void 0 ? 0 : n.thicknessFactor, n.thicknessTexture !== void 0 && r.push(this.parser.assignTexture(t, "thicknessMap", n.thicknessTexture)), t.attenuationDistance = n.attenuationDistance || Infinity;
|
|
394
|
+
let i = n.attenuationColor || [
|
|
395
|
+
1,
|
|
396
|
+
1,
|
|
397
|
+
1
|
|
398
|
+
];
|
|
399
|
+
return t.attenuationColor = new O().setRGB(i[0], i[1], i[2], g), Promise.all(r);
|
|
400
|
+
}
|
|
401
|
+
}, lt = class {
|
|
402
|
+
constructor(e) {
|
|
403
|
+
this.parser = e, this.name = F.KHR_MATERIALS_IOR;
|
|
404
|
+
}
|
|
405
|
+
getMaterialType(e) {
|
|
406
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
407
|
+
}
|
|
408
|
+
extendMaterialParams(e, t) {
|
|
409
|
+
let n = P(this.parser, e, this.name);
|
|
410
|
+
return n === null || (t.ior = n.ior === void 0 ? 1.5 : n.ior, t.ior === 0 && (t.ior = 1e3)), Promise.resolve();
|
|
411
|
+
}
|
|
412
|
+
}, ut = class {
|
|
413
|
+
constructor(e) {
|
|
414
|
+
this.parser = e, this.name = F.KHR_MATERIALS_SPECULAR;
|
|
415
|
+
}
|
|
416
|
+
getMaterialType(e) {
|
|
417
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
418
|
+
}
|
|
419
|
+
extendMaterialParams(e, t) {
|
|
420
|
+
let n = P(this.parser, e, this.name);
|
|
421
|
+
if (n === null) return Promise.resolve();
|
|
422
|
+
let r = [];
|
|
423
|
+
t.specularIntensity = n.specularFactor === void 0 ? 1 : n.specularFactor, n.specularTexture !== void 0 && r.push(this.parser.assignTexture(t, "specularIntensityMap", n.specularTexture));
|
|
424
|
+
let i = n.specularColorFactor || [
|
|
425
|
+
1,
|
|
426
|
+
1,
|
|
427
|
+
1
|
|
428
|
+
];
|
|
429
|
+
return t.specularColor = new O().setRGB(i[0], i[1], i[2], g), n.specularColorTexture !== void 0 && r.push(this.parser.assignTexture(t, "specularColorMap", n.specularColorTexture, D)), Promise.all(r);
|
|
430
|
+
}
|
|
431
|
+
}, dt = class {
|
|
432
|
+
constructor(e) {
|
|
433
|
+
this.parser = e, this.name = F.EXT_MATERIALS_BUMP;
|
|
434
|
+
}
|
|
435
|
+
getMaterialType(e) {
|
|
436
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
437
|
+
}
|
|
438
|
+
extendMaterialParams(e, t) {
|
|
439
|
+
let n = P(this.parser, e, this.name);
|
|
440
|
+
if (n === null) return Promise.resolve();
|
|
441
|
+
let r = [];
|
|
442
|
+
return t.bumpScale = n.bumpFactor === void 0 ? 1 : n.bumpFactor, n.bumpTexture !== void 0 && r.push(this.parser.assignTexture(t, "bumpMap", n.bumpTexture)), Promise.all(r);
|
|
443
|
+
}
|
|
444
|
+
}, ft = class {
|
|
445
|
+
constructor(e) {
|
|
446
|
+
this.parser = e, this.name = F.KHR_MATERIALS_ANISOTROPY;
|
|
447
|
+
}
|
|
448
|
+
getMaterialType(e) {
|
|
449
|
+
return P(this.parser, e, this.name) === null ? null : b;
|
|
450
|
+
}
|
|
451
|
+
extendMaterialParams(e, t) {
|
|
452
|
+
let n = P(this.parser, e, this.name);
|
|
453
|
+
if (n === null) return Promise.resolve();
|
|
454
|
+
let r = [];
|
|
455
|
+
return n.anisotropyStrength !== void 0 && (t.anisotropy = n.anisotropyStrength), n.anisotropyRotation !== void 0 && (t.anisotropyRotation = n.anisotropyRotation), n.anisotropyTexture !== void 0 && r.push(this.parser.assignTexture(t, "anisotropyMap", n.anisotropyTexture)), Promise.all(r);
|
|
456
|
+
}
|
|
457
|
+
}, pt = class {
|
|
458
|
+
constructor(e) {
|
|
459
|
+
this.parser = e, this.name = F.KHR_TEXTURE_BASISU;
|
|
460
|
+
}
|
|
461
|
+
loadTexture(e) {
|
|
462
|
+
let t = this.parser, n = t.json, r = n.textures[e];
|
|
463
|
+
if (!r.extensions || !r.extensions[this.name]) return null;
|
|
464
|
+
let i = r.extensions[this.name], a = t.options.ktx2Loader;
|
|
465
|
+
if (!a) {
|
|
466
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0) throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
return t.loadTextureImage(e, i.source, a);
|
|
470
|
+
}
|
|
471
|
+
}, mt = class {
|
|
472
|
+
constructor(e) {
|
|
473
|
+
this.parser = e, this.name = F.EXT_TEXTURE_WEBP;
|
|
474
|
+
}
|
|
475
|
+
loadTexture(e) {
|
|
476
|
+
let t = this.name, n = this.parser, r = n.json, i = r.textures[e];
|
|
477
|
+
if (!i.extensions || !i.extensions[t]) return null;
|
|
478
|
+
let a = i.extensions[t], o = r.images[a.source], s = n.textureLoader;
|
|
479
|
+
if (o.uri) {
|
|
480
|
+
let e = n.options.manager.getHandler(o.uri);
|
|
481
|
+
e !== null && (s = e);
|
|
482
|
+
}
|
|
483
|
+
return n.loadTextureImage(e, a.source, s);
|
|
484
|
+
}
|
|
485
|
+
}, ht = class {
|
|
486
|
+
constructor(e) {
|
|
487
|
+
this.parser = e, this.name = F.EXT_TEXTURE_AVIF;
|
|
488
|
+
}
|
|
489
|
+
loadTexture(e) {
|
|
490
|
+
let t = this.name, n = this.parser, r = n.json, i = r.textures[e];
|
|
491
|
+
if (!i.extensions || !i.extensions[t]) return null;
|
|
492
|
+
let a = i.extensions[t], o = r.images[a.source], s = n.textureLoader;
|
|
493
|
+
if (o.uri) {
|
|
494
|
+
let e = n.options.manager.getHandler(o.uri);
|
|
495
|
+
e !== null && (s = e);
|
|
496
|
+
}
|
|
497
|
+
return n.loadTextureImage(e, a.source, s);
|
|
498
|
+
}
|
|
499
|
+
}, gt = class {
|
|
500
|
+
constructor(e, t) {
|
|
501
|
+
this.name = t, this.parser = e;
|
|
502
|
+
}
|
|
503
|
+
loadBufferView(e) {
|
|
504
|
+
let t = this.parser.json, n = t.bufferViews[e];
|
|
505
|
+
if (n.extensions && n.extensions[this.name]) {
|
|
506
|
+
let e = n.extensions[this.name], r = this.parser.getDependency("buffer", e.buffer), i = this.parser.options.meshoptDecoder;
|
|
507
|
+
if (!i || !i.supported) {
|
|
508
|
+
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0) throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
return r.then(function(t) {
|
|
512
|
+
let n = e.byteOffset || 0, r = e.byteLength || 0, a = e.count, o = e.byteStride, s = new Uint8Array(t, n, r);
|
|
513
|
+
return i.decodeGltfBufferAsync ? i.decodeGltfBufferAsync(a, o, s, e.mode, e.filter).then(function(e) {
|
|
514
|
+
return e.buffer;
|
|
515
|
+
}) : i.ready.then(function() {
|
|
516
|
+
let t = new ArrayBuffer(a * o);
|
|
517
|
+
return i.decodeGltfBuffer(new Uint8Array(t), a, o, s, e.mode, e.filter), t;
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
}, _t = class {
|
|
524
|
+
constructor(e) {
|
|
525
|
+
this.name = F.EXT_MESH_GPU_INSTANCING, this.parser = e;
|
|
526
|
+
}
|
|
527
|
+
createNodeMesh(e) {
|
|
528
|
+
let t = this.parser.json, r = t.nodes[e];
|
|
529
|
+
if (!r.extensions || !r.extensions[this.name] || r.mesh === void 0) return null;
|
|
530
|
+
let i = t.meshes[r.mesh];
|
|
531
|
+
for (let e of i.primitives) if (e.mode !== L.TRIANGLES && e.mode !== L.TRIANGLE_STRIP && e.mode !== L.TRIANGLE_FAN && e.mode !== void 0) return null;
|
|
532
|
+
let a = r.extensions[this.name].attributes, o = [], s = {};
|
|
533
|
+
for (let e in a) o.push(this.parser.getDependency("accessor", a[e]).then((t) => (s[e] = t, s[e])));
|
|
534
|
+
return o.length < 1 ? null : (o.push(this.parser.createNodeMesh(e)), Promise.all(o).then((e) => {
|
|
535
|
+
let t = e.pop(), r = t.isGroup ? t.children : [t], i = e[0].count, a = [];
|
|
536
|
+
for (let e of r) {
|
|
537
|
+
let t = new n(), r = new M(), o = new k(), c = new M(1, 1, 1), l = new Pe(e.geometry, e.material, i);
|
|
538
|
+
for (let e = 0; e < i; e++) s.TRANSLATION && r.fromBufferAttribute(s.TRANSLATION, e), s.ROTATION && o.fromBufferAttribute(s.ROTATION, e), s.SCALE && c.fromBufferAttribute(s.SCALE, e), l.setMatrixAt(e, t.compose(r, o, c));
|
|
539
|
+
let u = null;
|
|
540
|
+
for (let e in s) if (e === "_COLOR_0") {
|
|
541
|
+
let t = s[e];
|
|
542
|
+
l.instanceColor = new oe(t.array, t.itemSize, t.normalized);
|
|
543
|
+
} else if (e !== "TRANSLATION" && e !== "ROTATION" && e !== "SCALE") {
|
|
544
|
+
if (u === null) {
|
|
545
|
+
let e = l.geometry;
|
|
546
|
+
u = new Te(), u.name = e.name;
|
|
547
|
+
for (let t in e.attributes) u.setAttribute(t, e.attributes[t]);
|
|
548
|
+
for (let t in e.morphAttributes) u.morphAttributes[t] = e.morphAttributes[t];
|
|
549
|
+
e.index !== null && u.setIndex(e.index), u.morphTargetsRelative = e.morphTargetsRelative;
|
|
550
|
+
for (let t of e.groups) u.addGroup(t.start, t.count, t.materialIndex);
|
|
551
|
+
e.boundingBox !== null && (u.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (u.boundingSphere = e.boundingSphere.clone()), u.drawRange.start = e.drawRange.start, u.drawRange.count = e.drawRange.count, u.userData = Object.assign({}, e.userData), l.geometry = u;
|
|
552
|
+
}
|
|
553
|
+
let t = s[e];
|
|
554
|
+
u.setAttribute(e, new oe(t.array, t.itemSize, t.normalized));
|
|
555
|
+
}
|
|
556
|
+
S.prototype.copy.call(l, e), this.parser.assignFinalMaterial(l), a.push(l);
|
|
557
|
+
}
|
|
558
|
+
return t.isGroup ? (t.clear(), t.add(...a), t) : a[0];
|
|
559
|
+
}));
|
|
560
|
+
}
|
|
561
|
+
}, vt = "glTF", I = 12, yt = {
|
|
562
|
+
JSON: 1313821514,
|
|
563
|
+
BIN: 5130562
|
|
564
|
+
}, bt = class {
|
|
565
|
+
constructor(e) {
|
|
566
|
+
this.name = F.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
567
|
+
let t = new DataView(e, 0, I), n = new TextDecoder();
|
|
568
|
+
if (this.header = {
|
|
569
|
+
magic: n.decode(new Uint8Array(e.slice(0, 4))),
|
|
570
|
+
version: t.getUint32(4, !0),
|
|
571
|
+
length: t.getUint32(8, !0)
|
|
572
|
+
}, this.header.magic !== vt) throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
573
|
+
if (this.header.version < 2) throw Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
574
|
+
let r = this.header.length - I, i = new DataView(e, I), a = 0;
|
|
575
|
+
for (; a < r;) {
|
|
576
|
+
let t = i.getUint32(a, !0);
|
|
577
|
+
a += 4;
|
|
578
|
+
let r = i.getUint32(a, !0);
|
|
579
|
+
if (a += 4, r === yt.JSON) {
|
|
580
|
+
let r = new Uint8Array(e, I + a, t);
|
|
581
|
+
this.content = n.decode(r);
|
|
582
|
+
} else if (r === yt.BIN) {
|
|
583
|
+
let n = I + a;
|
|
584
|
+
this.body = e.slice(n, n + t);
|
|
585
|
+
}
|
|
586
|
+
a += t;
|
|
587
|
+
}
|
|
588
|
+
if (this.content === null) throw Error("THREE.GLTFLoader: JSON content not found.");
|
|
589
|
+
}
|
|
590
|
+
}, xt = class {
|
|
591
|
+
constructor(e, t) {
|
|
592
|
+
if (!t) throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
593
|
+
this.name = F.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
|
|
594
|
+
}
|
|
595
|
+
decodePrimitive(e, t) {
|
|
596
|
+
let n = this.json, r = this.dracoLoader, i = e.extensions[this.name].bufferView, a = e.extensions[this.name].attributes, o = {}, s = {}, c = {};
|
|
597
|
+
for (let e in a) {
|
|
598
|
+
let t = B[e] || e.toLowerCase();
|
|
599
|
+
o[t] = a[e];
|
|
600
|
+
}
|
|
601
|
+
for (let t in e.attributes) {
|
|
602
|
+
let r = B[t] || t.toLowerCase();
|
|
603
|
+
if (a[t] !== void 0) {
|
|
604
|
+
let i = n.accessors[e.attributes[t]];
|
|
605
|
+
c[r] = R[i.componentType].name, s[r] = i.normalized === !0;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return t.getDependency("bufferView", i).then(function(e) {
|
|
609
|
+
return new Promise(function(t, n) {
|
|
610
|
+
r.decodeDracoFile(e, function(e) {
|
|
611
|
+
for (let t in e.attributes) {
|
|
612
|
+
let n = e.attributes[t], r = s[t];
|
|
613
|
+
r !== void 0 && (n.normalized = r);
|
|
614
|
+
}
|
|
615
|
+
t(e);
|
|
616
|
+
}, o, c, g, n);
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
}, St = class {
|
|
621
|
+
constructor() {
|
|
622
|
+
this.name = F.KHR_TEXTURE_TRANSFORM;
|
|
623
|
+
}
|
|
624
|
+
extendTexture(e, t) {
|
|
625
|
+
if ((t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0) return e;
|
|
626
|
+
if (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), t.rotation !== void 0) {
|
|
627
|
+
let t = Math.cos(e.rotation), n = Math.sin(e.rotation);
|
|
628
|
+
e.matrix.set(e.repeat.x * t, e.repeat.y * n, e.offset.x, -e.repeat.x * n, e.repeat.y * t, e.offset.y, 0, 0, 1), e.matrixAutoUpdate = !1;
|
|
629
|
+
}
|
|
630
|
+
return e.needsUpdate = !0, e;
|
|
631
|
+
}
|
|
632
|
+
}, Ct = class {
|
|
633
|
+
constructor() {
|
|
634
|
+
this.name = F.KHR_MESH_QUANTIZATION;
|
|
635
|
+
}
|
|
636
|
+
}, wt = class extends Ne {
|
|
637
|
+
constructor(e, t, n, r) {
|
|
638
|
+
super(e, t, n, r);
|
|
639
|
+
}
|
|
640
|
+
copySampleValue_(e) {
|
|
641
|
+
let t = this.resultBuffer, n = this.sampleValues, r = this.valueSize, i = e * r * 3 + r;
|
|
642
|
+
for (let e = 0; e !== r; e++) t[e] = n[i + e];
|
|
643
|
+
return t;
|
|
644
|
+
}
|
|
645
|
+
interpolate_(e, t, n, r) {
|
|
646
|
+
let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = o * 2, c = o * 3, l = r - t, u = (n - t) / l, d = u * u, f = d * u, p = e * c, m = p - c, h = -2 * f + 3 * d, g = f - d, _ = 1 - h, v = g - d + u;
|
|
647
|
+
for (let e = 0; e !== o; e++) {
|
|
648
|
+
let t = a[m + e + o], n = a[m + e + s] * l, r = a[p + e + o], c = a[p + e] * l;
|
|
649
|
+
i[e] = _ * t + v * n + h * r + g * c;
|
|
650
|
+
}
|
|
651
|
+
return i;
|
|
652
|
+
}
|
|
653
|
+
}, Tt = new k(), Et = class extends wt {
|
|
654
|
+
interpolate_(e, t, n, r) {
|
|
655
|
+
let i = super.interpolate_(e, t, n, r);
|
|
656
|
+
return Tt.fromArray(i).normalize().toArray(i), i;
|
|
657
|
+
}
|
|
658
|
+
}, L = {
|
|
659
|
+
FLOAT: 5126,
|
|
660
|
+
FLOAT_MAT3: 35675,
|
|
661
|
+
FLOAT_MAT4: 35676,
|
|
662
|
+
FLOAT_VEC2: 35664,
|
|
663
|
+
FLOAT_VEC3: 35665,
|
|
664
|
+
FLOAT_VEC4: 35666,
|
|
665
|
+
LINEAR: 9729,
|
|
666
|
+
REPEAT: 10497,
|
|
667
|
+
SAMPLER_2D: 35678,
|
|
668
|
+
POINTS: 0,
|
|
669
|
+
LINES: 1,
|
|
670
|
+
LINE_LOOP: 2,
|
|
671
|
+
LINE_STRIP: 3,
|
|
672
|
+
TRIANGLES: 4,
|
|
673
|
+
TRIANGLE_STRIP: 5,
|
|
674
|
+
TRIANGLE_FAN: 6,
|
|
675
|
+
UNSIGNED_BYTE: 5121,
|
|
676
|
+
UNSIGNED_SHORT: 5123
|
|
677
|
+
}, R = {
|
|
678
|
+
5120: Int8Array,
|
|
679
|
+
5121: Uint8Array,
|
|
680
|
+
5122: Int16Array,
|
|
681
|
+
5123: Uint16Array,
|
|
682
|
+
5125: Uint32Array,
|
|
683
|
+
5126: Float32Array
|
|
684
|
+
}, Dt = {
|
|
685
|
+
9728: d,
|
|
686
|
+
9729: pe,
|
|
687
|
+
9984: u,
|
|
688
|
+
9985: m,
|
|
689
|
+
9986: Se,
|
|
690
|
+
9987: p
|
|
691
|
+
}, Ot = {
|
|
692
|
+
33071: ke,
|
|
693
|
+
33648: s,
|
|
694
|
+
10497: Ee
|
|
695
|
+
}, z = {
|
|
696
|
+
SCALAR: 1,
|
|
697
|
+
VEC2: 2,
|
|
698
|
+
VEC3: 3,
|
|
699
|
+
VEC4: 4,
|
|
700
|
+
MAT2: 4,
|
|
701
|
+
MAT3: 9,
|
|
702
|
+
MAT4: 16
|
|
703
|
+
}, B = {
|
|
704
|
+
POSITION: "position",
|
|
705
|
+
NORMAL: "normal",
|
|
706
|
+
TANGENT: "tangent",
|
|
707
|
+
TEXCOORD_0: "uv",
|
|
708
|
+
TEXCOORD_1: "uv1",
|
|
709
|
+
TEXCOORD_2: "uv2",
|
|
710
|
+
TEXCOORD_3: "uv3",
|
|
711
|
+
COLOR_0: "color",
|
|
712
|
+
WEIGHTS_0: "skinWeight",
|
|
713
|
+
JOINTS_0: "skinIndex"
|
|
714
|
+
}, V = {
|
|
715
|
+
scale: "scale",
|
|
716
|
+
translation: "position",
|
|
717
|
+
rotation: "quaternion",
|
|
718
|
+
weights: "morphTargetInfluences"
|
|
719
|
+
}, kt = {
|
|
720
|
+
CUBICSPLINE: void 0,
|
|
721
|
+
LINEAR: a,
|
|
722
|
+
STEP: te
|
|
723
|
+
}, H = {
|
|
724
|
+
OPAQUE: "OPAQUE",
|
|
725
|
+
MASK: "MASK",
|
|
726
|
+
BLEND: "BLEND"
|
|
727
|
+
};
|
|
728
|
+
function At(e) {
|
|
729
|
+
return e.DefaultMaterial === void 0 && (e.DefaultMaterial = new x({
|
|
730
|
+
color: 16777215,
|
|
731
|
+
emissive: 0,
|
|
732
|
+
metalness: 1,
|
|
733
|
+
roughness: 1,
|
|
734
|
+
transparent: !1,
|
|
735
|
+
depthTest: !0,
|
|
736
|
+
side: 0
|
|
737
|
+
})), e.DefaultMaterial;
|
|
738
|
+
}
|
|
739
|
+
function U(e, t, n) {
|
|
740
|
+
for (let r in n.extensions) e[r] === void 0 && (t.userData.gltfExtensions = t.userData.gltfExtensions || {}, t.userData.gltfExtensions[r] = n.extensions[r]);
|
|
741
|
+
}
|
|
742
|
+
function W(e, t) {
|
|
743
|
+
t.extras !== void 0 && (typeof t.extras == "object" ? Object.assign(e.userData, t.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + t.extras));
|
|
744
|
+
}
|
|
745
|
+
function jt(e, t, n) {
|
|
746
|
+
let r = !1, i = !1, a = !1;
|
|
747
|
+
for (let e = 0, n = t.length; e < n; e++) {
|
|
748
|
+
let n = t[e];
|
|
749
|
+
if (n.POSITION !== void 0 && (r = !0), n.NORMAL !== void 0 && (i = !0), n.COLOR_0 !== void 0 && (a = !0), r && i && a) break;
|
|
750
|
+
}
|
|
751
|
+
if (!r && !i && !a) return Promise.resolve(e);
|
|
752
|
+
let o = [], s = [], c = [];
|
|
753
|
+
for (let l = 0, u = t.length; l < u; l++) {
|
|
754
|
+
let u = t[l];
|
|
755
|
+
if (r) {
|
|
756
|
+
let t = u.POSITION === void 0 ? e.attributes.position : n.getDependency("accessor", u.POSITION);
|
|
757
|
+
o.push(t);
|
|
758
|
+
}
|
|
759
|
+
if (i) {
|
|
760
|
+
let t = u.NORMAL === void 0 ? e.attributes.normal : n.getDependency("accessor", u.NORMAL);
|
|
761
|
+
s.push(t);
|
|
762
|
+
}
|
|
763
|
+
if (a) {
|
|
764
|
+
let t = u.COLOR_0 === void 0 ? e.attributes.color : n.getDependency("accessor", u.COLOR_0);
|
|
765
|
+
c.push(t);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return Promise.all([
|
|
769
|
+
Promise.all(o),
|
|
770
|
+
Promise.all(s),
|
|
771
|
+
Promise.all(c)
|
|
772
|
+
]).then(function(t) {
|
|
773
|
+
let n = t[0], o = t[1], s = t[2];
|
|
774
|
+
return r && (e.morphAttributes.position = n), i && (e.morphAttributes.normal = o), a && (e.morphAttributes.color = s), e.morphTargetsRelative = !0, e;
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
function Mt(e, t) {
|
|
778
|
+
if (e.updateMorphTargets(), t.weights !== void 0) for (let n = 0, r = t.weights.length; n < r; n++) e.morphTargetInfluences[n] = t.weights[n];
|
|
779
|
+
if (t.extras && Array.isArray(t.extras.targetNames)) {
|
|
780
|
+
let n = t.extras.targetNames;
|
|
781
|
+
if (e.morphTargetInfluences.length === n.length) {
|
|
782
|
+
e.morphTargetDictionary = {};
|
|
783
|
+
for (let t = 0, r = n.length; t < r; t++) e.morphTargetDictionary[n[t]] = t;
|
|
784
|
+
} else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function Nt(e) {
|
|
788
|
+
let t, n = e.extensions && e.extensions[F.KHR_DRACO_MESH_COMPRESSION];
|
|
789
|
+
if (t = n ? "draco:" + n.bufferView + ":" + n.indices + ":" + G(n.attributes) : e.indices + ":" + G(e.attributes) + ":" + e.mode, e.targets !== void 0) for (let n = 0, r = e.targets.length; n < r; n++) t += ":" + G(e.targets[n]);
|
|
790
|
+
return t;
|
|
791
|
+
}
|
|
792
|
+
function G(e) {
|
|
793
|
+
let t = "", n = Object.keys(e).sort();
|
|
794
|
+
for (let r = 0, i = n.length; r < i; r++) t += n[r] + ":" + e[n[r]] + ";";
|
|
795
|
+
return t;
|
|
796
|
+
}
|
|
797
|
+
function K(e) {
|
|
798
|
+
switch (e) {
|
|
799
|
+
case Int8Array: return 1 / 127;
|
|
800
|
+
case Uint8Array: return 1 / 255;
|
|
801
|
+
case Int16Array: return 1 / 32767;
|
|
802
|
+
case Uint16Array: return 1 / 65535;
|
|
803
|
+
default: throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function Pt(e) {
|
|
807
|
+
return e.search(/\.jpe?g($|\?)/i) > 0 || e.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : e.search(/\.webp($|\?)/i) > 0 || e.search(/^data\:image\/webp/) === 0 ? "image/webp" : e.search(/\.ktx2($|\?)/i) > 0 || e.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
808
|
+
}
|
|
809
|
+
var Ft = new n(), It = class {
|
|
810
|
+
constructor(e = {}, t = {}) {
|
|
811
|
+
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new Qe(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = {
|
|
812
|
+
refs: {},
|
|
813
|
+
uses: {}
|
|
814
|
+
}, this.cameraCache = {
|
|
815
|
+
refs: {},
|
|
816
|
+
uses: {}
|
|
817
|
+
}, this.lightCache = {
|
|
818
|
+
refs: {},
|
|
819
|
+
uses: {}
|
|
820
|
+
}, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
821
|
+
let n = !1, r = -1, i = !1, a = -1;
|
|
822
|
+
if (typeof navigator < "u" && navigator.userAgent !== void 0) {
|
|
823
|
+
let e = navigator.userAgent;
|
|
824
|
+
n = /^((?!chrome|android).)*safari/i.test(e) === !0;
|
|
825
|
+
let t = e.match(/Version\/(\d+)/);
|
|
826
|
+
r = n && t ? parseInt(t[1], 10) : -1, i = e.indexOf("Firefox") > -1, a = i ? e.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
827
|
+
}
|
|
828
|
+
typeof createImageBitmap > "u" || n && r < 17 || i && a < 98 ? (this.textureLoader = new Ie(this.options.manager), this.textureLoader.setPriority(this.options.priority), this.textureLoader.setCache(this.options.cache)) : (this.textureLoader = new Fe(this.options.manager), this.textureLoader.setPriority(this.options.priority), this.textureLoader.setCache(this.options.cache)), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setWithCredentials(this.options.withCredentials), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new de(this.options.manager), this.fileLoader.setPriority(this.options.priority), this.fileLoader.setCache(this.options.cache), this.fileLoader.setResponseType("arraybuffer"), (this.options.withCredentials || this.options.crossOrigin === "use-credentials") && this.fileLoader.setWithCredentials(!0);
|
|
829
|
+
}
|
|
830
|
+
setExtensions(e) {
|
|
831
|
+
this.extensions = e;
|
|
832
|
+
}
|
|
833
|
+
setPlugins(e) {
|
|
834
|
+
this.plugins = e;
|
|
835
|
+
}
|
|
836
|
+
parse(e, t) {
|
|
837
|
+
let n = this, r = this.json, i = this.extensions;
|
|
838
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(e) {
|
|
839
|
+
return e._markDefs && e._markDefs();
|
|
840
|
+
}), Promise.all(this._invokeAll(function(e) {
|
|
841
|
+
return e.beforeRoot && e.beforeRoot();
|
|
842
|
+
})).then(function() {
|
|
843
|
+
return Promise.all([
|
|
844
|
+
n.getDependencies("scene"),
|
|
845
|
+
n.getDependencies("animation"),
|
|
846
|
+
n.getDependencies("camera")
|
|
847
|
+
]);
|
|
848
|
+
}).then(function(t) {
|
|
849
|
+
let a = {
|
|
850
|
+
scene: t[0][r.scene || 0],
|
|
851
|
+
scenes: t[0],
|
|
852
|
+
animations: t[1],
|
|
853
|
+
cameras: t[2],
|
|
854
|
+
asset: r.asset,
|
|
855
|
+
parser: n,
|
|
856
|
+
userData: {}
|
|
857
|
+
};
|
|
858
|
+
return U(i, a, r), W(a, r), Promise.all(n._invokeAll(function(e) {
|
|
859
|
+
return e.afterRoot && e.afterRoot(a);
|
|
860
|
+
})).then(function() {
|
|
861
|
+
for (let e of a.scenes) e.updateMatrixWorld();
|
|
862
|
+
e(a);
|
|
863
|
+
});
|
|
864
|
+
}).catch(t);
|
|
865
|
+
}
|
|
866
|
+
_markDefs() {
|
|
867
|
+
let e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];
|
|
868
|
+
for (let n = 0, r = t.length; n < r; n++) {
|
|
869
|
+
let r = t[n].joints;
|
|
870
|
+
for (let t = 0, n = r.length; t < n; t++) e[r[t]].isBone = !0;
|
|
871
|
+
}
|
|
872
|
+
for (let t = 0, r = e.length; t < r; t++) {
|
|
873
|
+
let r = e[t];
|
|
874
|
+
r.mesh !== void 0 && (this._addNodeRef(this.meshCache, r.mesh), r.skin !== void 0 && (n[r.mesh].isSkinnedMesh = !0)), r.camera !== void 0 && this._addNodeRef(this.cameraCache, r.camera);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
_addNodeRef(e, t) {
|
|
878
|
+
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
|
|
879
|
+
}
|
|
880
|
+
_getNodeRef(e, t, n) {
|
|
881
|
+
if (e.refs[t] <= 1) return n;
|
|
882
|
+
let r = n.clone(), i = (e, t) => {
|
|
883
|
+
let n = this.associations.get(e);
|
|
884
|
+
n != null && this.associations.set(t, n);
|
|
885
|
+
for (let [n, r] of e.children.entries()) i(r, t.children[n]);
|
|
886
|
+
};
|
|
887
|
+
return i(n, r), r.name += "_instance_" + e.uses[t]++, r;
|
|
888
|
+
}
|
|
889
|
+
_invokeOne(e) {
|
|
890
|
+
let t = Object.values(this.plugins);
|
|
891
|
+
t.push(this);
|
|
892
|
+
for (let n = 0; n < t.length; n++) {
|
|
893
|
+
let r = e(t[n]);
|
|
894
|
+
if (r) return r;
|
|
895
|
+
}
|
|
896
|
+
return null;
|
|
897
|
+
}
|
|
898
|
+
_invokeAll(e) {
|
|
899
|
+
let t = Object.values(this.plugins);
|
|
900
|
+
t.unshift(this);
|
|
901
|
+
let n = [];
|
|
902
|
+
for (let r = 0; r < t.length; r++) {
|
|
903
|
+
let i = e(t[r]);
|
|
904
|
+
i && n.push(i);
|
|
905
|
+
}
|
|
906
|
+
return n;
|
|
907
|
+
}
|
|
908
|
+
getDependency(e, t) {
|
|
909
|
+
let n = e + ":" + t, r = this.cache.get(n);
|
|
910
|
+
if (!r) {
|
|
911
|
+
switch (e) {
|
|
912
|
+
case "scene":
|
|
913
|
+
r = this.loadScene(t);
|
|
914
|
+
break;
|
|
915
|
+
case "node":
|
|
916
|
+
r = this._invokeOne(function(e) {
|
|
917
|
+
return e.loadNode && e.loadNode(t);
|
|
918
|
+
});
|
|
919
|
+
break;
|
|
920
|
+
case "mesh":
|
|
921
|
+
r = this._invokeOne(function(e) {
|
|
922
|
+
return e.loadMesh && e.loadMesh(t);
|
|
923
|
+
});
|
|
924
|
+
break;
|
|
925
|
+
case "accessor":
|
|
926
|
+
r = this.loadAccessor(t);
|
|
927
|
+
break;
|
|
928
|
+
case "bufferView":
|
|
929
|
+
r = this._invokeOne(function(e) {
|
|
930
|
+
return e.loadBufferView && e.loadBufferView(t);
|
|
931
|
+
});
|
|
932
|
+
break;
|
|
933
|
+
case "buffer":
|
|
934
|
+
r = this.loadBuffer(t);
|
|
935
|
+
break;
|
|
936
|
+
case "material":
|
|
937
|
+
r = this._invokeOne(function(e) {
|
|
938
|
+
return e.loadMaterial && e.loadMaterial(t);
|
|
939
|
+
});
|
|
940
|
+
break;
|
|
941
|
+
case "texture":
|
|
942
|
+
r = this._invokeOne(function(e) {
|
|
943
|
+
return e.loadTexture && e.loadTexture(t);
|
|
944
|
+
});
|
|
945
|
+
break;
|
|
946
|
+
case "skin":
|
|
947
|
+
r = this.loadSkin(t);
|
|
948
|
+
break;
|
|
949
|
+
case "animation":
|
|
950
|
+
r = this._invokeOne(function(e) {
|
|
951
|
+
return e.loadAnimation && e.loadAnimation(t);
|
|
952
|
+
});
|
|
953
|
+
break;
|
|
954
|
+
case "camera":
|
|
955
|
+
r = this.loadCamera(t);
|
|
956
|
+
break;
|
|
957
|
+
default: if (r = this._invokeOne(function(n) {
|
|
958
|
+
return n != this && n.getDependency && n.getDependency(e, t);
|
|
959
|
+
}), !r) throw Error("Unknown type: " + e);
|
|
960
|
+
}
|
|
961
|
+
this.cache.add(n, r);
|
|
962
|
+
}
|
|
963
|
+
return r;
|
|
964
|
+
}
|
|
965
|
+
getDependencies(e) {
|
|
966
|
+
let t = this.cache.get(e);
|
|
967
|
+
if (!t) {
|
|
968
|
+
let n = this, r = this.json[e + (e === "mesh" ? "es" : "s")] || [];
|
|
969
|
+
t = Promise.all(r.map(function(t, r) {
|
|
970
|
+
return n.getDependency(e, r);
|
|
971
|
+
})), this.cache.add(e, t);
|
|
972
|
+
}
|
|
973
|
+
return t;
|
|
974
|
+
}
|
|
975
|
+
loadBuffer(e) {
|
|
976
|
+
let t = this.json.buffers[e], n = this.fileLoader;
|
|
977
|
+
if (t.type && t.type !== "arraybuffer") throw Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
|
|
978
|
+
if (t.uri === void 0 && e === 0) return Promise.resolve(this.extensions[F.KHR_BINARY_GLTF].body);
|
|
979
|
+
let r = this.options;
|
|
980
|
+
return new Promise(function(e, i) {
|
|
981
|
+
n.load(l.resolveURL(t.uri, r.path), e, void 0, function() {
|
|
982
|
+
i(/* @__PURE__ */ Error("THREE.GLTFLoader: Failed to load buffer \"" + t.uri + "\"."));
|
|
983
|
+
});
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
loadBufferView(e) {
|
|
987
|
+
let t = this.json.bufferViews[e];
|
|
988
|
+
return this.getDependency("buffer", t.buffer).then(function(e) {
|
|
989
|
+
let n = t.byteLength || 0, r = t.byteOffset || 0;
|
|
990
|
+
return e.slice(r, r + n);
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
loadAccessor(e) {
|
|
994
|
+
let t = this, n = this.json, i = this.json.accessors[e];
|
|
995
|
+
if (i.bufferView === void 0 && i.sparse === void 0) {
|
|
996
|
+
let e = z[i.type], t = R[i.componentType], n = i.normalized === !0, r = new t(i.count * e);
|
|
997
|
+
return Promise.resolve(new A(r, e, n));
|
|
998
|
+
}
|
|
999
|
+
let a = [];
|
|
1000
|
+
return i.bufferView === void 0 ? a.push(null) : a.push(this.getDependency("bufferView", i.bufferView)), i.sparse !== void 0 && (a.push(this.getDependency("bufferView", i.sparse.indices.bufferView)), a.push(this.getDependency("bufferView", i.sparse.values.bufferView))), Promise.all(a).then(function(e) {
|
|
1001
|
+
let a = e[0], o = z[i.type], s = R[i.componentType], c = s.BYTES_PER_ELEMENT, l = c * o, u = i.byteOffset || 0, d = i.bufferView === void 0 ? void 0 : n.bufferViews[i.bufferView].byteStride, f = i.normalized === !0, p, m;
|
|
1002
|
+
if (d && d !== l) {
|
|
1003
|
+
let e = Math.floor(u / d), n = "InterleavedBuffer:" + i.bufferView + ":" + i.componentType + ":" + e + ":" + i.count, l = t.cache.get(n);
|
|
1004
|
+
l || (p = new s(a, e * d, i.count * d / c), l = new ee(p, d / c), t.cache.add(n, l)), m = new r(l, o, u % d / c, f);
|
|
1005
|
+
} else p = a === null ? new s(i.count * o) : new s(a, u, i.count * o), m = new A(p, o, f);
|
|
1006
|
+
if (i.sparse !== void 0) {
|
|
1007
|
+
let t = z.SCALAR, n = R[i.sparse.indices.componentType], r = i.sparse.indices.byteOffset || 0, c = i.sparse.values.byteOffset || 0, l = new n(e[1], r, i.sparse.count * t), u = new s(e[2], c, i.sparse.count * o);
|
|
1008
|
+
a !== null && (m = new A(m.array.slice(), m.itemSize, m.normalized)), m.normalized = !1;
|
|
1009
|
+
for (let e = 0, t = l.length; e < t; e++) {
|
|
1010
|
+
let t = l[e];
|
|
1011
|
+
if (m.setX(t, u[e * o]), o >= 2 && m.setY(t, u[e * o + 1]), o >= 3 && m.setZ(t, u[e * o + 2]), o >= 4 && m.setW(t, u[e * o + 3]), o >= 5) throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1012
|
+
}
|
|
1013
|
+
m.normalized = f;
|
|
1014
|
+
}
|
|
1015
|
+
return m;
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
loadTexture(e) {
|
|
1019
|
+
let t = this.json, n = this.options, r = t.textures[e].source, i = t.images[r], a = this.textureLoader;
|
|
1020
|
+
if (i.uri) {
|
|
1021
|
+
let e = n.manager.getHandler(i.uri);
|
|
1022
|
+
e !== null && (a = e);
|
|
1023
|
+
}
|
|
1024
|
+
return this.loadTextureImage(e, r, a);
|
|
1025
|
+
}
|
|
1026
|
+
loadTextureImage(e, t, n) {
|
|
1027
|
+
let r = this, i = this.json, a = i.textures[e], o = i.images[t], s = (o.uri || o.bufferView) + ":" + a.sampler;
|
|
1028
|
+
if (this.textureCache[s]) return this.textureCache[s];
|
|
1029
|
+
let c = this.loadImageSource(t, n).then(function(t) {
|
|
1030
|
+
t.flipY = !1, t.name = a.name || o.name || "", t.name === "" && typeof o.uri == "string" && o.uri.startsWith("data:image/") === !1 && (t.name = o.uri);
|
|
1031
|
+
let n = (i.samplers || {})[a.sampler] || {};
|
|
1032
|
+
return t.magFilter = Dt[n.magFilter] || 1006, t.minFilter = Dt[n.minFilter] || 1008, t.wrapS = Ot[n.wrapS] || 1e3, t.wrapT = Ot[n.wrapT] || 1e3, t.generateMipmaps = !t.isCompressedTexture && t.minFilter !== 1003 && t.minFilter !== 1006, r.associations.set(t, { textures: e }), t;
|
|
1033
|
+
}).catch(function() {
|
|
1034
|
+
return null;
|
|
1035
|
+
});
|
|
1036
|
+
return this.textureCache[s] = c, c;
|
|
1037
|
+
}
|
|
1038
|
+
loadImageSource(e, t) {
|
|
1039
|
+
let n = this, r = this.json, i = this.options;
|
|
1040
|
+
if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
|
|
1041
|
+
let a = r.images[e], o = self.URL || self.webkitURL, s = a.uri || "", c = !1, u;
|
|
1042
|
+
if (t.isKTX2Loader === !0 && a.bufferView !== void 0) u = n.getDependency("bufferView", a.bufferView).then(function(e) {
|
|
1043
|
+
return new Promise(function(n, r) {
|
|
1044
|
+
t.parse(e, n, r);
|
|
1045
|
+
});
|
|
1046
|
+
});
|
|
1047
|
+
else {
|
|
1048
|
+
if (a.bufferView !== void 0) s = n.getDependency("bufferView", a.bufferView).then(function(e) {
|
|
1049
|
+
c = !0;
|
|
1050
|
+
let t = new Blob([e], { type: a.mimeType });
|
|
1051
|
+
return s = o.createObjectURL(t), s;
|
|
1052
|
+
});
|
|
1053
|
+
else if (a.uri === void 0) throw Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
|
|
1054
|
+
u = Promise.resolve(s).then(function(e) {
|
|
1055
|
+
return new Promise(function(n, r) {
|
|
1056
|
+
let a = n;
|
|
1057
|
+
t.isImageBitmapLoader === !0 && (a = function(e) {
|
|
1058
|
+
let t = new Me(e);
|
|
1059
|
+
t.needsUpdate = !0, n(t);
|
|
1060
|
+
}), t.load(l.resolveURL(e, i.path), a, void 0, r);
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
let d = u.then(function(e) {
|
|
1065
|
+
return c === !0 && o.revokeObjectURL(s), W(e, a), e.userData.mimeType = a.mimeType || Pt(a.uri), e;
|
|
1066
|
+
}).catch(function(e) {
|
|
1067
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", s), e;
|
|
1068
|
+
});
|
|
1069
|
+
return this.sourceCache[e] = d, d;
|
|
1070
|
+
}
|
|
1071
|
+
assignTexture(e, t, n, r) {
|
|
1072
|
+
let i = this;
|
|
1073
|
+
return this.getDependency("texture", n.index).then(function(a) {
|
|
1074
|
+
if (!a) return null;
|
|
1075
|
+
if (n.texCoord !== void 0 && n.texCoord > 0 && (a = a.clone(), a.channel = n.texCoord), i.extensions[F.KHR_TEXTURE_TRANSFORM]) {
|
|
1076
|
+
let e = n.extensions === void 0 ? void 0 : n.extensions[F.KHR_TEXTURE_TRANSFORM];
|
|
1077
|
+
if (e) {
|
|
1078
|
+
let t = i.associations.get(a);
|
|
1079
|
+
a = i.extensions[F.KHR_TEXTURE_TRANSFORM].extendTexture(a, e), i.associations.set(a, t);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return r !== void 0 && (a.colorSpace = r), e[t] = a, a;
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
assignFinalMaterial(e) {
|
|
1086
|
+
let t = e.geometry, n = e.material, r = t.attributes.tangent === void 0, i = t.attributes.color !== void 0, a = t.attributes.normal === void 0;
|
|
1087
|
+
if (e.isPoints) {
|
|
1088
|
+
let e = "PointsMaterial:" + n.uuid, t = this.cache.get(e);
|
|
1089
|
+
t || (t = new ye(), v.prototype.copy.call(t, n), t.color.copy(n.color), t.map = n.map, t.sizeAttenuation = !1, this.cache.add(e, t)), n = t;
|
|
1090
|
+
} else if (e.isLine) {
|
|
1091
|
+
let e = "LineBasicMaterial:" + n.uuid, t = this.cache.get(e);
|
|
1092
|
+
t || (t = new h(), v.prototype.copy.call(t, n), t.color.copy(n.color), t.map = n.map, this.cache.add(e, t)), n = t;
|
|
1093
|
+
}
|
|
1094
|
+
if (r || i || a) {
|
|
1095
|
+
let e = "ClonedMaterial:" + n.uuid + ":";
|
|
1096
|
+
r && (e += "derivative-tangents:"), i && (e += "vertex-colors:"), a && (e += "flat-shading:");
|
|
1097
|
+
let t = this.cache.get(e);
|
|
1098
|
+
t || (t = n.clone(), i && (t.vertexColors = !0), a && (t.flatShading = !0), r && (t.normalScale && (t.normalScale.y *= -1), t.clearcoatNormalScale && (t.clearcoatNormalScale.y *= -1)), this.cache.add(e, t), this.associations.set(t, this.associations.get(n))), n = t;
|
|
1099
|
+
}
|
|
1100
|
+
e.material = n;
|
|
1101
|
+
}
|
|
1102
|
+
getMaterialType() {
|
|
1103
|
+
return x;
|
|
1104
|
+
}
|
|
1105
|
+
loadMaterial(e) {
|
|
1106
|
+
let t = this, n = this.json, r = this.extensions, i = n.materials[e], a, o = {}, s = i.extensions || {}, l = [];
|
|
1107
|
+
if (s[F.KHR_MATERIALS_UNLIT]) {
|
|
1108
|
+
let e = r[F.KHR_MATERIALS_UNLIT];
|
|
1109
|
+
a = e.getMaterialType(), l.push(e.extendParams(o, i, t));
|
|
1110
|
+
} else {
|
|
1111
|
+
let n = i.pbrMetallicRoughness || {};
|
|
1112
|
+
if (o.color = new O(1, 1, 1), o.opacity = 1, Array.isArray(n.baseColorFactor)) {
|
|
1113
|
+
let e = n.baseColorFactor;
|
|
1114
|
+
o.color.setRGB(e[0], e[1], e[2], g), o.opacity = e[3];
|
|
1115
|
+
}
|
|
1116
|
+
n.baseColorTexture !== void 0 && l.push(t.assignTexture(o, "map", n.baseColorTexture, D)), o.metalness = n.metallicFactor === void 0 ? 1 : n.metallicFactor, o.roughness = n.roughnessFactor === void 0 ? 1 : n.roughnessFactor, n.metallicRoughnessTexture !== void 0 && (l.push(t.assignTexture(o, "metalnessMap", n.metallicRoughnessTexture)), l.push(t.assignTexture(o, "roughnessMap", n.metallicRoughnessTexture))), a = this._invokeOne(function(t) {
|
|
1117
|
+
return t.getMaterialType && t.getMaterialType(e);
|
|
1118
|
+
}), l.push(Promise.all(this._invokeAll(function(t) {
|
|
1119
|
+
return t.extendMaterialParams && t.extendMaterialParams(e, o);
|
|
1120
|
+
})));
|
|
1121
|
+
}
|
|
1122
|
+
i.doubleSided === !0 && (o.side = 2);
|
|
1123
|
+
let u = i.alphaMode || H.OPAQUE;
|
|
1124
|
+
if (u === H.BLEND ? (o.transparent = !0, o.depthWrite = !1) : (o.transparent = !1, u === H.MASK && (o.alphaTest = i.alphaCutoff === void 0 ? .5 : i.alphaCutoff)), i.normalTexture !== void 0 && a !== c && (l.push(t.assignTexture(o, "normalMap", i.normalTexture)), o.normalScale = new E(1, 1), i.normalTexture.scale !== void 0)) {
|
|
1125
|
+
let e = i.normalTexture.scale;
|
|
1126
|
+
o.normalScale.set(e, e);
|
|
1127
|
+
}
|
|
1128
|
+
if (i.occlusionTexture !== void 0 && a !== c && (l.push(t.assignTexture(o, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (o.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && a !== c) {
|
|
1129
|
+
let e = i.emissiveFactor;
|
|
1130
|
+
o.emissive = new O().setRGB(e[0], e[1], e[2], g);
|
|
1131
|
+
}
|
|
1132
|
+
return i.emissiveTexture !== void 0 && a !== c && l.push(t.assignTexture(o, "emissiveMap", i.emissiveTexture, D)), Promise.all(l).then(function() {
|
|
1133
|
+
let n = new a(o);
|
|
1134
|
+
return i.name && (n.name = i.name), W(n, i), t.associations.set(n, { materials: e }), i.extensions && U(r, n, i), n;
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
createUniqueName(e) {
|
|
1138
|
+
let t = we.sanitizeNodeName(e || "");
|
|
1139
|
+
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
|
|
1140
|
+
}
|
|
1141
|
+
loadGeometries(e) {
|
|
1142
|
+
let t = this, n = this.extensions, r = this.primitiveCache;
|
|
1143
|
+
function i(e) {
|
|
1144
|
+
return n[F.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e, t).then(function(n) {
|
|
1145
|
+
return Rt(n, e, t);
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
let a = [];
|
|
1149
|
+
for (let n = 0, o = e.length; n < o; n++) {
|
|
1150
|
+
let o = e[n], s = Nt(o), c = r[s];
|
|
1151
|
+
if (c) a.push(c.promise);
|
|
1152
|
+
else {
|
|
1153
|
+
let e;
|
|
1154
|
+
e = o.extensions && o.extensions[F.KHR_DRACO_MESH_COMPRESSION] ? i(o) : Rt(new Te(), o, t), o.mode === L.TRIANGLE_STRIP ? e = e.then((e) => Je(e, 1)) : o.mode === L.TRIANGLE_FAN && (e = e.then((e) => Je(e, 2))), r[s] = {
|
|
1155
|
+
primitive: o,
|
|
1156
|
+
promise: e
|
|
1157
|
+
}, a.push(e);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return Promise.all(a);
|
|
1161
|
+
}
|
|
1162
|
+
loadMesh(e) {
|
|
1163
|
+
let n = this, r = this.json, a = this.extensions, o = r.meshes[e], s = o.primitives, c = [];
|
|
1164
|
+
for (let e = 0, t = s.length; e < t; e++) {
|
|
1165
|
+
let t = s[e].material === void 0 ? At(this.cache) : this.getDependency("material", s[e].material);
|
|
1166
|
+
c.push(t);
|
|
1167
|
+
}
|
|
1168
|
+
return c.push(n.loadGeometries(s)), Promise.all(c).then(async function(r) {
|
|
1169
|
+
let c = r.slice(0, r.length - 1), l = r[r.length - 1], u = [];
|
|
1170
|
+
for (let r = 0, d = l.length; r < d; r++) {
|
|
1171
|
+
let d = l[r], f = s[r], p, m = c[r];
|
|
1172
|
+
if (f.mode === L.TRIANGLES || f.mode === L.TRIANGLE_STRIP || f.mode === L.TRIANGLE_FAN || f.mode === void 0) {
|
|
1173
|
+
let e = o.isSkinnedMesh === !0, t = d.hasAttribute("skinIndex") && d.hasAttribute("skinWeight");
|
|
1174
|
+
e && t === !1 && console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled."), p = e && t ? new se(d, m) : new ne(d, m), p.isSkinnedMesh === !0 && p.normalizeSkinWeights();
|
|
1175
|
+
} else if (f.mode === L.LINES) p = new t(d, m);
|
|
1176
|
+
else if (f.mode === L.LINE_STRIP) p = new i(d, m);
|
|
1177
|
+
else if (f.mode === L.LINE_LOOP) p = new me(d, m);
|
|
1178
|
+
else if (f.mode === L.POINTS) p = new Oe(d, m);
|
|
1179
|
+
else throw Error("THREE.GLTFLoader: Primitive mode unsupported: " + f.mode);
|
|
1180
|
+
Object.keys(p.geometry.morphAttributes).length > 0 && Mt(p, o), p.name = n.createUniqueName(o.name || "mesh_" + e), W(p, o), f.extensions && U(a, p, f), n.assignFinalMaterial(p), u.push(p);
|
|
1181
|
+
}
|
|
1182
|
+
for (let t = 0, r = u.length; t < r; t++) n.associations.set(u[t], {
|
|
1183
|
+
meshes: e,
|
|
1184
|
+
primitives: t
|
|
1185
|
+
});
|
|
1186
|
+
if (u.length === 1) return o.extensions && U(a, u[0], o), u[0];
|
|
1187
|
+
let d = new C();
|
|
1188
|
+
o.extensions && U(a, d, o), n.associations.set(d, { meshes: e });
|
|
1189
|
+
for (let e = 0, t = u.length; e < t; e++) d.add(u[e]);
|
|
1190
|
+
return d;
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
loadCamera(e) {
|
|
1194
|
+
let t, n = this.json.cameras[e], r = n[n.type];
|
|
1195
|
+
if (!r) console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1196
|
+
else return n.type === "perspective" ? t = new _(Le.radToDeg(r.yfov), r.aspectRatio || 1, r.znear || 1, r.zfar || 2e6) : n.type === "orthographic" && (t = new ie(-r.xmag, r.xmag, r.ymag, -r.ymag, r.znear, r.zfar)), n.name && (t.name = this.createUniqueName(n.name)), W(t, n), Promise.resolve(t);
|
|
1197
|
+
}
|
|
1198
|
+
loadSkin(e) {
|
|
1199
|
+
let t = this.json.skins[e], r = [];
|
|
1200
|
+
for (let e = 0, n = t.joints.length; e < n; e++) r.push(this._loadNodeShallow(t.joints[e]));
|
|
1201
|
+
return t.inverseBindMatrices === void 0 ? r.push(null) : r.push(this.getDependency("accessor", t.inverseBindMatrices)), Promise.all(r).then(function(e) {
|
|
1202
|
+
let r = e.pop(), i = e, a = [], o = [];
|
|
1203
|
+
for (let e = 0, s = i.length; e < s; e++) {
|
|
1204
|
+
let s = i[e];
|
|
1205
|
+
if (s) {
|
|
1206
|
+
a.push(s);
|
|
1207
|
+
let t = new n();
|
|
1208
|
+
r !== null && t.fromArray(r.array, e * 16), o.push(t);
|
|
1209
|
+
} else console.warn("THREE.GLTFLoader: Joint \"%s\" could not be found.", t.joints[e]);
|
|
1210
|
+
}
|
|
1211
|
+
return new Ae(a, o);
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
loadAnimation(e) {
|
|
1215
|
+
let t = this.json, n = this, r = t.animations[e], i = r.name ? r.name : "animation_" + e, a = [], o = [], s = [], c = [], l = [];
|
|
1216
|
+
for (let e = 0, t = r.channels.length; e < t; e++) {
|
|
1217
|
+
let t = r.channels[e], n = r.samplers[t.sampler], i = t.target, u = i.node, d = r.parameters === void 0 ? n.input : r.parameters[n.input], f = r.parameters === void 0 ? n.output : r.parameters[n.output];
|
|
1218
|
+
i.node !== void 0 && (a.push(this.getDependency("node", u)), o.push(this.getDependency("accessor", d)), s.push(this.getDependency("accessor", f)), c.push(n), l.push(i));
|
|
1219
|
+
}
|
|
1220
|
+
return Promise.all([
|
|
1221
|
+
Promise.all(a),
|
|
1222
|
+
Promise.all(o),
|
|
1223
|
+
Promise.all(s),
|
|
1224
|
+
Promise.all(c),
|
|
1225
|
+
Promise.all(l)
|
|
1226
|
+
]).then(function(e) {
|
|
1227
|
+
let t = e[0], a = e[1], o = e[2], s = e[3], c = e[4], l = [];
|
|
1228
|
+
for (let e = 0, r = t.length; e < r; e++) {
|
|
1229
|
+
let r = t[e], i = a[e], u = o[e], d = s[e], f = c[e];
|
|
1230
|
+
if (r === void 0) continue;
|
|
1231
|
+
r.updateMatrix && r.updateMatrix();
|
|
1232
|
+
let p = n._createAnimationTracks(r, i, u, d, f);
|
|
1233
|
+
if (p) for (let e = 0; e < p.length; e++) l.push(p[e]);
|
|
1234
|
+
}
|
|
1235
|
+
let u = new Ce(i, void 0, l);
|
|
1236
|
+
return W(u, r), u;
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
createNodeMesh(e) {
|
|
1240
|
+
let t = this.json, n = this, r = t.nodes[e];
|
|
1241
|
+
return r.mesh === void 0 ? null : n.getDependency("mesh", r.mesh).then(function(e) {
|
|
1242
|
+
let t = n._getNodeRef(n.meshCache, r.mesh, e);
|
|
1243
|
+
return r.weights !== void 0 && t.traverse(function(e) {
|
|
1244
|
+
if (e.isMesh) for (let t = 0, n = r.weights.length; t < n; t++) e.morphTargetInfluences[t] = r.weights[t];
|
|
1245
|
+
}), t;
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
loadNode(e) {
|
|
1249
|
+
let t = this.json, n = this, r = t.nodes[e], i = n._loadNodeShallow(e), a = [], o = r.children || [];
|
|
1250
|
+
for (let e = 0, t = o.length; e < t; e++) a.push(n.getDependency("node", o[e]));
|
|
1251
|
+
let s = r.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", r.skin);
|
|
1252
|
+
return Promise.all([
|
|
1253
|
+
i,
|
|
1254
|
+
Promise.all(a),
|
|
1255
|
+
s
|
|
1256
|
+
]).then(function(e) {
|
|
1257
|
+
let t = e[0], n = e[1], r = e[2];
|
|
1258
|
+
r !== null && t.traverse(function(e) {
|
|
1259
|
+
e.isSkinnedMesh && e.bind(r, Ft);
|
|
1260
|
+
});
|
|
1261
|
+
for (let e = 0, r = n.length; e < r; e++) t.add(n[e]);
|
|
1262
|
+
if (t.userData.pivot !== void 0 && n.length > 0) {
|
|
1263
|
+
let e = t.userData.pivot, r = n[0];
|
|
1264
|
+
t.pivot = new M().fromArray(e), t.position.x -= e[0], t.position.y -= e[1], t.position.z -= e[2], r.position.set(0, 0, 0), delete t.userData.pivot;
|
|
1265
|
+
}
|
|
1266
|
+
return t;
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
_loadNodeShallow(e) {
|
|
1270
|
+
let t = this.json, r = this.extensions, i = this;
|
|
1271
|
+
if (this.nodeCache[e] !== void 0) return this.nodeCache[e];
|
|
1272
|
+
let a = t.nodes[e], o = a.name ? i.createUniqueName(a.name) : "", s = [], c = i._invokeOne(function(t) {
|
|
1273
|
+
return t.createNodeMesh && t.createNodeMesh(e);
|
|
1274
|
+
});
|
|
1275
|
+
return c && s.push(c), a.camera !== void 0 && s.push(i.getDependency("camera", a.camera).then(function(e) {
|
|
1276
|
+
return i._getNodeRef(i.cameraCache, a.camera, e);
|
|
1277
|
+
})), i._invokeAll(function(t) {
|
|
1278
|
+
return t.createNodeAttachment && t.createNodeAttachment(e);
|
|
1279
|
+
}).forEach(function(e) {
|
|
1280
|
+
s.push(e);
|
|
1281
|
+
}), this.nodeCache[e] = Promise.all(s).then(function(t) {
|
|
1282
|
+
let s;
|
|
1283
|
+
if (s = a.isBone === !0 ? new fe() : t.length > 1 ? new C() : t.length === 1 ? t[0] : new S(), s !== t[0]) for (let e = 0, n = t.length; e < n; e++) s.add(t[e]);
|
|
1284
|
+
if (a.name && (s.userData.name = a.name, s.name = o), W(s, a), a.extensions && U(r, s, a), a.matrix !== void 0) {
|
|
1285
|
+
let e = new n();
|
|
1286
|
+
e.fromArray(a.matrix), s.applyMatrix4(e);
|
|
1287
|
+
} else a.translation !== void 0 && s.position.fromArray(a.translation), a.rotation !== void 0 && s.quaternion.fromArray(a.rotation), a.scale !== void 0 && s.scale.fromArray(a.scale);
|
|
1288
|
+
if (!i.associations.has(s)) i.associations.set(s, {});
|
|
1289
|
+
else if (a.mesh !== void 0 && i.meshCache.refs[a.mesh] > 1) {
|
|
1290
|
+
let e = i.associations.get(s);
|
|
1291
|
+
i.associations.set(s, { ...e });
|
|
1292
|
+
}
|
|
1293
|
+
return i.associations.get(s).nodes = e, s;
|
|
1294
|
+
}), this.nodeCache[e];
|
|
1295
|
+
}
|
|
1296
|
+
loadScene(e) {
|
|
1297
|
+
let t = this.extensions, n = this.json.scenes[e], r = this, i = new C();
|
|
1298
|
+
n.name && (i.name = r.createUniqueName(n.name)), W(i, n), n.extensions && U(t, i, n);
|
|
1299
|
+
let a = n.nodes || [], o = [];
|
|
1300
|
+
for (let e = 0, t = a.length; e < t; e++) o.push(r.getDependency("node", a[e]));
|
|
1301
|
+
return Promise.all(o).then(function(e) {
|
|
1302
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
1303
|
+
let n = e[t];
|
|
1304
|
+
n.parent === null ? i.add(n) : i.add(Ye(n));
|
|
1305
|
+
}
|
|
1306
|
+
return r.associations = ((e) => {
|
|
1307
|
+
let t = /* @__PURE__ */ new Map();
|
|
1308
|
+
for (let [e, n] of r.associations) (e instanceof v || e instanceof Me) && t.set(e, n);
|
|
1309
|
+
return e.traverse((e) => {
|
|
1310
|
+
let n = r.associations.get(e);
|
|
1311
|
+
n != null && t.set(e, n);
|
|
1312
|
+
}), t;
|
|
1313
|
+
})(i), i;
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
_createAnimationTracks(e, t, n, r, i) {
|
|
1317
|
+
let o = [], s = e.name ? e.name : e.uuid, c = [];
|
|
1318
|
+
function l(e) {
|
|
1319
|
+
e.morphTargetInfluences && c.push(e.name ? e.name : e.uuid);
|
|
1320
|
+
}
|
|
1321
|
+
V[i.path] === V.weights ? (l(e), e.isGroup && e.children.forEach(l)) : c.push(s);
|
|
1322
|
+
let u;
|
|
1323
|
+
switch (V[i.path]) {
|
|
1324
|
+
case V.weights:
|
|
1325
|
+
u = re;
|
|
1326
|
+
break;
|
|
1327
|
+
case V.rotation:
|
|
1328
|
+
u = ae;
|
|
1329
|
+
break;
|
|
1330
|
+
case V.translation:
|
|
1331
|
+
case V.scale:
|
|
1332
|
+
u = y;
|
|
1333
|
+
break;
|
|
1334
|
+
default: switch (n.itemSize) {
|
|
1335
|
+
case 1:
|
|
1336
|
+
u = re;
|
|
1337
|
+
break;
|
|
1338
|
+
default: u = y;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
let d = r.interpolation === void 0 ? a : kt[r.interpolation], f = this._getArrayFromAccessor(n);
|
|
1342
|
+
for (let e = 0, n = c.length; e < n; e++) {
|
|
1343
|
+
let n = new u(c[e] + "." + V[i.path], t.array, f, d);
|
|
1344
|
+
r.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(n), o.push(n);
|
|
1345
|
+
}
|
|
1346
|
+
return o;
|
|
1347
|
+
}
|
|
1348
|
+
_getArrayFromAccessor(e) {
|
|
1349
|
+
let t = e.array;
|
|
1350
|
+
if (e.normalized) {
|
|
1351
|
+
let e = K(t.constructor), n = new Float32Array(t.length);
|
|
1352
|
+
for (let r = 0, i = t.length; r < i; r++) n[r] = t[r] * e;
|
|
1353
|
+
t = n;
|
|
1354
|
+
}
|
|
1355
|
+
return t;
|
|
1356
|
+
}
|
|
1357
|
+
_createCubicSplineTrackInterpolant(e) {
|
|
1358
|
+
e.createInterpolant = function(e) {
|
|
1359
|
+
return new (this instanceof ae ? Et : wt)(this.times, this.values, this.getValueSize() / 3, e);
|
|
1360
|
+
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
function Lt(e, t, n) {
|
|
1364
|
+
let r = t.attributes, i = new T();
|
|
1365
|
+
if (r.POSITION !== void 0) {
|
|
1366
|
+
let e = n.json.accessors[r.POSITION], t = e.min, a = e.max;
|
|
1367
|
+
if (t !== void 0 && a !== void 0) {
|
|
1368
|
+
if (i.set(new M(t[0], t[1], t[2]), new M(a[0], a[1], a[2])), e.normalized) {
|
|
1369
|
+
let t = K(R[e.componentType]);
|
|
1370
|
+
i.min.multiplyScalar(t), i.max.multiplyScalar(t);
|
|
1371
|
+
}
|
|
1372
|
+
} else {
|
|
1373
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
} else return;
|
|
1377
|
+
let a = t.targets;
|
|
1378
|
+
if (a !== void 0) {
|
|
1379
|
+
let e = new M(), t = new M();
|
|
1380
|
+
for (let r = 0, i = a.length; r < i; r++) {
|
|
1381
|
+
let i = a[r];
|
|
1382
|
+
if (i.POSITION !== void 0) {
|
|
1383
|
+
let r = n.json.accessors[i.POSITION], a = r.min, o = r.max;
|
|
1384
|
+
if (a !== void 0 && o !== void 0) {
|
|
1385
|
+
if (t.setX(Math.max(Math.abs(a[0]), Math.abs(o[0]))), t.setY(Math.max(Math.abs(a[1]), Math.abs(o[1]))), t.setZ(Math.max(Math.abs(a[2]), Math.abs(o[2]))), r.normalized) {
|
|
1386
|
+
let e = K(R[r.componentType]);
|
|
1387
|
+
t.multiplyScalar(e);
|
|
1388
|
+
}
|
|
1389
|
+
e.max(t);
|
|
1390
|
+
} else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
i.expandByVector(e);
|
|
1394
|
+
}
|
|
1395
|
+
e.boundingBox = i;
|
|
1396
|
+
let o = new ue();
|
|
1397
|
+
i.getCenter(o.center), o.radius = i.min.distanceTo(i.max) / 2, e.boundingSphere = o;
|
|
1398
|
+
}
|
|
1399
|
+
function Rt(e, t, n) {
|
|
1400
|
+
let r = t.attributes, i = [];
|
|
1401
|
+
function a(t, r) {
|
|
1402
|
+
return n.getDependency("accessor", t).then(function(t) {
|
|
1403
|
+
e.setAttribute(r, t);
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
for (let t in r) {
|
|
1407
|
+
let n = B[t] || t.toLowerCase();
|
|
1408
|
+
n in e.attributes || i.push(a(r[t], n));
|
|
1409
|
+
}
|
|
1410
|
+
if (t.indices !== void 0 && !e.index) {
|
|
1411
|
+
let r = n.getDependency("accessor", t.indices).then(function(t) {
|
|
1412
|
+
e.setIndex(t);
|
|
1413
|
+
});
|
|
1414
|
+
i.push(r);
|
|
1415
|
+
}
|
|
1416
|
+
return le.workingColorSpace !== "srgb-linear" && "COLOR_0" in r && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${le.workingColorSpace}" not supported.`), W(e, t), Lt(e, t, n), Promise.all(i).then(function() {
|
|
1417
|
+
return t.targets === void 0 ? e : jt(e, t.targets, n);
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
// node_modules/.pnpm/three@0.187.0/node_modules/three/examples/jsm/controls/OrbitControls.js
|
|
1421
|
+
var q = { type: "change" }, J = { type: "start" }, zt = { type: "end" }, Y = new be(), Bt = new e(), Vt = Math.cos(70 * Le.DEG2RAD), X = new M(), Z = 2 * Math.PI, Q = {
|
|
1422
|
+
NONE: -1,
|
|
1423
|
+
ROTATE: 0,
|
|
1424
|
+
DOLLY: 1,
|
|
1425
|
+
PAN: 2,
|
|
1426
|
+
TOUCH_ROTATE: 3,
|
|
1427
|
+
TOUCH_PAN: 4,
|
|
1428
|
+
TOUCH_DOLLY_PAN: 5,
|
|
1429
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
1430
|
+
}, $ = 1e-6, Ht = class extends xe {
|
|
1431
|
+
constructor(e, t = null) {
|
|
1432
|
+
super(e, t), this.state = Q.NONE, this.target = new M(), this.cursor = new M(), this.minDistance = 0, this.maxDistance = Infinity, this.minZoom = 0, this.maxZoom = Infinity, this.minTargetRadius = 0, this.maxTargetRadius = Infinity, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -Infinity, this.maxAzimuthAngle = Infinity, this.enableDamping = !1, this.dampingFactor = .05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = {
|
|
1433
|
+
LEFT: "ArrowLeft",
|
|
1434
|
+
UP: "ArrowUp",
|
|
1435
|
+
RIGHT: "ArrowRight",
|
|
1436
|
+
BOTTOM: "ArrowDown"
|
|
1437
|
+
}, this.mouseButtons = {
|
|
1438
|
+
LEFT: f.ROTATE,
|
|
1439
|
+
MIDDLE: f.DOLLY,
|
|
1440
|
+
RIGHT: f.PAN
|
|
1441
|
+
}, this.touches = {
|
|
1442
|
+
ONE: w.ROTATE,
|
|
1443
|
+
TWO: w.DOLLY_PAN
|
|
1444
|
+
}, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._cursorStyle = "auto", this._domElementKeyEvents = null, this._lastPosition = new M(), this._lastQuaternion = new k(), this._lastTargetPosition = new M(), this._quat = new k().setFromUnitVectors(e.up, new M(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new j(), this._sphericalDelta = new j(), this._scale = 1, this._panOffset = new M(), this._rotateStart = new E(), this._rotateEnd = new E(), this._rotateDelta = new E(), this._panStart = new E(), this._panEnd = new E(), this._panDelta = new E(), this._dollyStart = new E(), this._dollyEnd = new E(), this._dollyDelta = new E(), this._dollyDirection = new M(), this._mouse = new E(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = Wt.bind(this), this._onPointerDown = Ut.bind(this), this._onPointerUp = Gt.bind(this), this._onContextMenu = Qt.bind(this), this._onMouseWheel = Jt.bind(this), this._onKeyDown = Yt.bind(this), this._onTouchStart = Xt.bind(this), this._onTouchMove = Zt.bind(this), this._onMouseDown = Kt.bind(this), this._onMouseMove = qt.bind(this), this._interceptControlDown = $t.bind(this), this._interceptControlUp = en.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
|
|
1445
|
+
}
|
|
1446
|
+
set cursorStyle(e) {
|
|
1447
|
+
this._cursorStyle = e, e === "grab" ? this.domElement.style.cursor = "grab" : this.domElement.style.cursor = "auto";
|
|
1448
|
+
}
|
|
1449
|
+
get cursorStyle() {
|
|
1450
|
+
return this._cursorStyle;
|
|
1451
|
+
}
|
|
1452
|
+
connect(e) {
|
|
1453
|
+
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.ownerDocument.addEventListener("keydown", this._interceptControlDown, {
|
|
1454
|
+
passive: !0,
|
|
1455
|
+
capture: !0
|
|
1456
|
+
}), this.domElement.style.touchAction = "none";
|
|
1457
|
+
}
|
|
1458
|
+
disconnect() {
|
|
1459
|
+
this.state = Q.NONE, this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.ownerDocument.removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.ownerDocument.removeEventListener("keyup", this._interceptControlUp, { capture: !0 }), this._controlActive = !1, this._pointers.length = 0, this._pointerPositions = {}, this.domElement.style.touchAction = "", this.domElement.style.cursor = "auto";
|
|
1460
|
+
}
|
|
1461
|
+
dispose() {
|
|
1462
|
+
this.disconnect();
|
|
1463
|
+
}
|
|
1464
|
+
getPolarAngle() {
|
|
1465
|
+
return this._spherical.phi;
|
|
1466
|
+
}
|
|
1467
|
+
getAzimuthalAngle() {
|
|
1468
|
+
return this._spherical.theta;
|
|
1469
|
+
}
|
|
1470
|
+
getDistance() {
|
|
1471
|
+
return this.object.position.distanceTo(this.target);
|
|
1472
|
+
}
|
|
1473
|
+
listenToKeyEvents(e) {
|
|
1474
|
+
e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e;
|
|
1475
|
+
}
|
|
1476
|
+
stopListenToKeyEvents() {
|
|
1477
|
+
this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
|
|
1478
|
+
}
|
|
1479
|
+
saveState() {
|
|
1480
|
+
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
|
|
1481
|
+
}
|
|
1482
|
+
reset() {
|
|
1483
|
+
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(q), this.update(), this.state = Q.NONE;
|
|
1484
|
+
}
|
|
1485
|
+
pan(e, t) {
|
|
1486
|
+
this._pan(e, t), this.update();
|
|
1487
|
+
}
|
|
1488
|
+
dollyIn(e) {
|
|
1489
|
+
this._dollyIn(e), this.update();
|
|
1490
|
+
}
|
|
1491
|
+
dollyOut(e) {
|
|
1492
|
+
this._dollyOut(e), this.update();
|
|
1493
|
+
}
|
|
1494
|
+
rotateLeft(e) {
|
|
1495
|
+
this._rotateLeft(e), this.update();
|
|
1496
|
+
}
|
|
1497
|
+
rotateUp(e) {
|
|
1498
|
+
this._rotateUp(e), this.update();
|
|
1499
|
+
}
|
|
1500
|
+
update(e = null) {
|
|
1501
|
+
let t = this.object.position;
|
|
1502
|
+
X.copy(t).sub(this.target), X.applyQuaternion(this._quat), this._spherical.setFromVector3(X), this.autoRotate && this.state === Q.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
|
|
1503
|
+
let n = this.minAzimuthAngle, r = this.maxAzimuthAngle;
|
|
1504
|
+
isFinite(n) && isFinite(r) && (n < -Math.PI ? n += Z : n > Math.PI && (n -= Z), r < -Math.PI ? r += Z : r > Math.PI && (r -= Z), n <= r ? this._spherical.theta = Math.max(n, Math.min(r, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + r) / 2 ? Math.max(n, this._spherical.theta) : Math.min(r, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
|
|
1505
|
+
let i = !1;
|
|
1506
|
+
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera) this._spherical.radius = this._clampDistance(this._spherical.radius);
|
|
1507
|
+
else {
|
|
1508
|
+
let e = this._spherical.radius;
|
|
1509
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), i = e != this._spherical.radius;
|
|
1510
|
+
}
|
|
1511
|
+
if (X.setFromSpherical(this._spherical), X.applyQuaternion(this._quatInverse), t.copy(this.target).add(X), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
|
|
1512
|
+
let e = null;
|
|
1513
|
+
if (this.object.isPerspectiveCamera) {
|
|
1514
|
+
let t = X.length();
|
|
1515
|
+
e = this._clampDistance(t * this._scale);
|
|
1516
|
+
let n = t - e;
|
|
1517
|
+
this.object.position.addScaledVector(this._dollyDirection, n), this.object.updateMatrixWorld(), i = !!n;
|
|
1518
|
+
} else if (this.object.isOrthographicCamera) {
|
|
1519
|
+
let t = new M(this._mouse.x, this._mouse.y, 0);
|
|
1520
|
+
t.unproject(this.object);
|
|
1521
|
+
let n = this.object.zoom;
|
|
1522
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), i = n !== this.object.zoom;
|
|
1523
|
+
let r = new M(this._mouse.x, this._mouse.y, 0);
|
|
1524
|
+
r.unproject(this.object), this.object.position.sub(r).add(t), this.object.updateMatrixWorld(), e = X.length();
|
|
1525
|
+
} else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
|
|
1526
|
+
e !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position) : (Y.origin.copy(this.object.position), Y.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Y.direction)) < Vt ? this.object.lookAt(this.target) : (Bt.setFromNormalAndCoplanarPoint(this.object.up, this.target), Y.intersectPlane(Bt, this.target))));
|
|
1527
|
+
} else if (this.object.isOrthographicCamera) {
|
|
1528
|
+
let e = this.object.zoom;
|
|
1529
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), e !== this.object.zoom && (this.object.updateProjectionMatrix(), i = !0);
|
|
1530
|
+
}
|
|
1531
|
+
return this._scale = 1, this._performCursorZoom = !1, i || this._lastPosition.distanceToSquared(this.object.position) > $ || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > $ || this._lastTargetPosition.distanceToSquared(this.target) > $ ? (this.dispatchEvent(q), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
|
|
1532
|
+
}
|
|
1533
|
+
_getAutoRotationAngle(e) {
|
|
1534
|
+
return e === null ? Z / 60 / 60 * this.autoRotateSpeed : Z / 60 * this.autoRotateSpeed * e;
|
|
1535
|
+
}
|
|
1536
|
+
_getZoomScale(e) {
|
|
1537
|
+
let t = Math.abs(e * .01);
|
|
1538
|
+
return .95 ** (this.zoomSpeed * t);
|
|
1539
|
+
}
|
|
1540
|
+
_rotateLeft(e) {
|
|
1541
|
+
this._sphericalDelta.theta -= e;
|
|
1542
|
+
}
|
|
1543
|
+
_rotateUp(e) {
|
|
1544
|
+
this._sphericalDelta.phi -= e;
|
|
1545
|
+
}
|
|
1546
|
+
_panLeft(e, t) {
|
|
1547
|
+
X.setFromMatrixColumn(t, 0), X.multiplyScalar(-e), this._panOffset.add(X);
|
|
1548
|
+
}
|
|
1549
|
+
_panUp(e, t) {
|
|
1550
|
+
this.screenSpacePanning === !0 ? X.setFromMatrixColumn(t, 1) : (X.setFromMatrixColumn(t, 0), X.crossVectors(this.object.up, X)), X.multiplyScalar(e), this._panOffset.add(X);
|
|
1551
|
+
}
|
|
1552
|
+
_pan(e, t) {
|
|
1553
|
+
let n = this.domElement;
|
|
1554
|
+
if (this.object.isPerspectiveCamera) {
|
|
1555
|
+
let r = this.object.position;
|
|
1556
|
+
X.copy(r).sub(this.target);
|
|
1557
|
+
let i = X.length();
|
|
1558
|
+
i *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * i / n.clientHeight, this.object.matrix), this._panUp(2 * t * i / n.clientHeight, this.object.matrix);
|
|
1559
|
+
} else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
|
|
1560
|
+
}
|
|
1561
|
+
_dollyOut(e) {
|
|
1562
|
+
this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
|
|
1563
|
+
}
|
|
1564
|
+
_dollyIn(e) {
|
|
1565
|
+
this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
|
|
1566
|
+
}
|
|
1567
|
+
_updateZoomParameters(e, t) {
|
|
1568
|
+
if (!this.zoomToCursor) return;
|
|
1569
|
+
this._performCursorZoom = !0;
|
|
1570
|
+
let n = this.domElement.getBoundingClientRect(), r = e - n.left, i = t - n.top, a = n.width, o = n.height;
|
|
1571
|
+
this._mouse.x = r / a * 2 - 1, this._mouse.y = -(i / o) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
|
|
1572
|
+
}
|
|
1573
|
+
_clampDistance(e) {
|
|
1574
|
+
return Math.max(this.minDistance, Math.min(this.maxDistance, e));
|
|
1575
|
+
}
|
|
1576
|
+
_handleMouseDownRotate(e) {
|
|
1577
|
+
this._rotateStart.set(e.clientX, e.clientY);
|
|
1578
|
+
}
|
|
1579
|
+
_handleMouseDownDolly(e) {
|
|
1580
|
+
this._updateZoomParameters(e.clientX, e.clientY), this._dollyStart.set(e.clientX, e.clientY);
|
|
1581
|
+
}
|
|
1582
|
+
_handleMouseDownPan(e) {
|
|
1583
|
+
this._panStart.set(e.clientX, e.clientY);
|
|
1584
|
+
}
|
|
1585
|
+
_handleMouseMoveRotate(e) {
|
|
1586
|
+
this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
1587
|
+
let t = this.domElement;
|
|
1588
|
+
this._rotateLeft(Z * this._rotateDelta.x / t.clientHeight), this._rotateUp(Z * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
|
|
1589
|
+
}
|
|
1590
|
+
_handleMouseMoveDolly(e) {
|
|
1591
|
+
this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.zoomToCursor && (this._performCursorZoom = !0, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize()), this.update();
|
|
1592
|
+
}
|
|
1593
|
+
_handleMouseMovePan(e) {
|
|
1594
|
+
this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
|
|
1595
|
+
}
|
|
1596
|
+
_handleMouseWheel(e) {
|
|
1597
|
+
this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0 ? this._dollyIn(this._getZoomScale(e.deltaY)) : e.deltaY > 0 && this._dollyOut(this._getZoomScale(e.deltaY)), this.update();
|
|
1598
|
+
}
|
|
1599
|
+
_handleKeyDown(e) {
|
|
1600
|
+
let t = !1;
|
|
1601
|
+
switch (e.code) {
|
|
1602
|
+
case this.keys.UP:
|
|
1603
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(Z * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), t = !0;
|
|
1604
|
+
break;
|
|
1605
|
+
case this.keys.BOTTOM:
|
|
1606
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-Z * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), t = !0;
|
|
1607
|
+
break;
|
|
1608
|
+
case this.keys.LEFT:
|
|
1609
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(Z * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), t = !0;
|
|
1610
|
+
break;
|
|
1611
|
+
case this.keys.RIGHT: e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-Z * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0;
|
|
1612
|
+
}
|
|
1613
|
+
t && (e.preventDefault(), this.update());
|
|
1614
|
+
}
|
|
1615
|
+
_handleTouchStartRotate(e) {
|
|
1616
|
+
if (this._pointers.length === 1) this._rotateStart.set(e.pageX, e.pageY);
|
|
1617
|
+
else {
|
|
1618
|
+
let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y);
|
|
1619
|
+
this._rotateStart.set(n, r);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
_handleTouchStartPan(e) {
|
|
1623
|
+
if (this._pointers.length === 1) this._panStart.set(e.pageX, e.pageY);
|
|
1624
|
+
else {
|
|
1625
|
+
let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y);
|
|
1626
|
+
this._panStart.set(n, r);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
_handleTouchStartDolly(e) {
|
|
1630
|
+
let t = this._getSecondPointerPosition(e), n = e.pageX - t.x, r = e.pageY - t.y, i = Math.sqrt(n * n + r * r);
|
|
1631
|
+
this._dollyStart.set(0, i);
|
|
1632
|
+
}
|
|
1633
|
+
_handleTouchStartDollyPan(e) {
|
|
1634
|
+
this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
|
|
1635
|
+
}
|
|
1636
|
+
_handleTouchStartDollyRotate(e) {
|
|
1637
|
+
this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e);
|
|
1638
|
+
}
|
|
1639
|
+
_handleTouchMoveRotate(e) {
|
|
1640
|
+
if (this._pointers.length == 1) this._rotateEnd.set(e.pageX, e.pageY);
|
|
1641
|
+
else {
|
|
1642
|
+
let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y);
|
|
1643
|
+
this._rotateEnd.set(n, r);
|
|
1644
|
+
}
|
|
1645
|
+
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
1646
|
+
let t = this.domElement;
|
|
1647
|
+
this._rotateLeft(Z * this._rotateDelta.x / t.clientHeight), this._rotateUp(Z * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd);
|
|
1648
|
+
}
|
|
1649
|
+
_handleTouchMovePan(e) {
|
|
1650
|
+
if (this._pointers.length === 1) this._panEnd.set(e.pageX, e.pageY);
|
|
1651
|
+
else {
|
|
1652
|
+
let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y);
|
|
1653
|
+
this._panEnd.set(n, r);
|
|
1654
|
+
}
|
|
1655
|
+
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
|
|
1656
|
+
}
|
|
1657
|
+
_handleTouchMoveDolly(e) {
|
|
1658
|
+
let t = this._getSecondPointerPosition(e), n = e.pageX - t.x, r = e.pageY - t.y, i = Math.sqrt(n * n + r * r);
|
|
1659
|
+
this._dollyEnd.set(0, i), this._dollyDelta.set(0, (this._dollyEnd.y / this._dollyStart.y) ** +this.zoomSpeed), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
|
|
1660
|
+
let a = (e.pageX + t.x) * .5, o = (e.pageY + t.y) * .5;
|
|
1661
|
+
this._updateZoomParameters(a, o);
|
|
1662
|
+
}
|
|
1663
|
+
_handleTouchMoveDollyPan(e) {
|
|
1664
|
+
this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
|
|
1665
|
+
}
|
|
1666
|
+
_handleTouchMoveDollyRotate(e) {
|
|
1667
|
+
this.enableZoom && this._handleTouchMoveDolly(e), this.enableRotate && this._handleTouchMoveRotate(e);
|
|
1668
|
+
}
|
|
1669
|
+
_addPointer(e) {
|
|
1670
|
+
this._pointers.push(e.pointerId);
|
|
1671
|
+
}
|
|
1672
|
+
_removePointer(e) {
|
|
1673
|
+
delete this._pointerPositions[e.pointerId];
|
|
1674
|
+
for (let t = 0; t < this._pointers.length; t++) if (this._pointers[t] == e.pointerId) {
|
|
1675
|
+
this._pointers.splice(t, 1);
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
_isTrackingPointer(e) {
|
|
1680
|
+
for (let t = 0; t < this._pointers.length; t++) if (this._pointers[t] == e.pointerId) return !0;
|
|
1681
|
+
return !1;
|
|
1682
|
+
}
|
|
1683
|
+
_trackPointer(e) {
|
|
1684
|
+
let t = this._pointerPositions[e.pointerId];
|
|
1685
|
+
t === void 0 && (t = new E(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
|
|
1686
|
+
}
|
|
1687
|
+
_getSecondPointerPosition(e) {
|
|
1688
|
+
let t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
|
|
1689
|
+
return this._pointerPositions[t];
|
|
1690
|
+
}
|
|
1691
|
+
_customWheelEvent(e) {
|
|
1692
|
+
let t = e.deltaMode, n = {
|
|
1693
|
+
clientX: e.clientX,
|
|
1694
|
+
clientY: e.clientY,
|
|
1695
|
+
deltaY: e.deltaY
|
|
1696
|
+
};
|
|
1697
|
+
switch (t) {
|
|
1698
|
+
case 1:
|
|
1699
|
+
n.deltaY *= 16;
|
|
1700
|
+
break;
|
|
1701
|
+
case 2: n.deltaY *= 100;
|
|
1702
|
+
}
|
|
1703
|
+
return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n;
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
function Ut(e) {
|
|
1707
|
+
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(e.pointerId), this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp)), this._isTrackingPointer(e) || (this._addPointer(e), e.pointerType === "touch" ? this._onTouchStart(e) : this._onMouseDown(e), this._cursorStyle === "grab" && (this.domElement.style.cursor = "grabbing")));
|
|
1708
|
+
}
|
|
1709
|
+
function Wt(e) {
|
|
1710
|
+
this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchMove(e) : this._onMouseMove(e));
|
|
1711
|
+
}
|
|
1712
|
+
function Gt(e) {
|
|
1713
|
+
switch (this._removePointer(e), this._pointers.length) {
|
|
1714
|
+
case 0:
|
|
1715
|
+
this.domElement.releasePointerCapture(e.pointerId), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(zt), this.state = Q.NONE, this._cursorStyle === "grab" && (this.domElement.style.cursor = "grab");
|
|
1716
|
+
break;
|
|
1717
|
+
case 1:
|
|
1718
|
+
let t = this._pointers[0], n = this._pointerPositions[t];
|
|
1719
|
+
this._onTouchStart({
|
|
1720
|
+
pointerId: t,
|
|
1721
|
+
pageX: n.x,
|
|
1722
|
+
pageY: n.y
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
function Kt(e) {
|
|
1727
|
+
let t;
|
|
1728
|
+
switch (e.button) {
|
|
1729
|
+
case 0:
|
|
1730
|
+
t = this.mouseButtons.LEFT;
|
|
1731
|
+
break;
|
|
1732
|
+
case 1:
|
|
1733
|
+
t = this.mouseButtons.MIDDLE;
|
|
1734
|
+
break;
|
|
1735
|
+
case 2:
|
|
1736
|
+
t = this.mouseButtons.RIGHT;
|
|
1737
|
+
break;
|
|
1738
|
+
default: t = -1;
|
|
1739
|
+
}
|
|
1740
|
+
switch (t) {
|
|
1741
|
+
case f.DOLLY:
|
|
1742
|
+
if (this.enableZoom === !1) return;
|
|
1743
|
+
this._handleMouseDownDolly(e), this.state = Q.DOLLY;
|
|
1744
|
+
break;
|
|
1745
|
+
case f.ROTATE:
|
|
1746
|
+
if (e.ctrlKey || e.metaKey || e.shiftKey) {
|
|
1747
|
+
if (this.enablePan === !1) return;
|
|
1748
|
+
this._handleMouseDownPan(e), this.state = Q.PAN;
|
|
1749
|
+
} else {
|
|
1750
|
+
if (this.enableRotate === !1) return;
|
|
1751
|
+
this._handleMouseDownRotate(e), this.state = Q.ROTATE;
|
|
1752
|
+
}
|
|
1753
|
+
break;
|
|
1754
|
+
case f.PAN:
|
|
1755
|
+
if (e.ctrlKey || e.metaKey || e.shiftKey) {
|
|
1756
|
+
if (this.enableRotate === !1) return;
|
|
1757
|
+
this._handleMouseDownRotate(e), this.state = Q.ROTATE;
|
|
1758
|
+
} else {
|
|
1759
|
+
if (this.enablePan === !1) return;
|
|
1760
|
+
this._handleMouseDownPan(e), this.state = Q.PAN;
|
|
1761
|
+
}
|
|
1762
|
+
break;
|
|
1763
|
+
default: this.state = Q.NONE;
|
|
1764
|
+
}
|
|
1765
|
+
this.state !== Q.NONE && this.dispatchEvent(J);
|
|
1766
|
+
}
|
|
1767
|
+
function qt(e) {
|
|
1768
|
+
switch (this.state) {
|
|
1769
|
+
case Q.ROTATE:
|
|
1770
|
+
if (this.enableRotate === !1) return;
|
|
1771
|
+
this._handleMouseMoveRotate(e);
|
|
1772
|
+
break;
|
|
1773
|
+
case Q.DOLLY:
|
|
1774
|
+
if (this.enableZoom === !1) return;
|
|
1775
|
+
this._handleMouseMoveDolly(e);
|
|
1776
|
+
break;
|
|
1777
|
+
case Q.PAN:
|
|
1778
|
+
if (this.enablePan === !1) return;
|
|
1779
|
+
this._handleMouseMovePan(e);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function Jt(e) {
|
|
1783
|
+
this.enabled !== !1 && this.enableZoom !== !1 && this.state === Q.NONE && (e.preventDefault(), this.dispatchEvent(J), this._handleMouseWheel(this._customWheelEvent(e)), this.dispatchEvent(zt));
|
|
1784
|
+
}
|
|
1785
|
+
function Yt(e) {
|
|
1786
|
+
this.enabled !== !1 && this._handleKeyDown(e);
|
|
1787
|
+
}
|
|
1788
|
+
function Xt(e) {
|
|
1789
|
+
switch (this._trackPointer(e), this._pointers.length) {
|
|
1790
|
+
case 1:
|
|
1791
|
+
switch (this.touches.ONE) {
|
|
1792
|
+
case w.ROTATE:
|
|
1793
|
+
if (this.enableRotate === !1) {
|
|
1794
|
+
this.state = Q.NONE;
|
|
1795
|
+
break;
|
|
1796
|
+
}
|
|
1797
|
+
this._handleTouchStartRotate(e), this.state = Q.TOUCH_ROTATE;
|
|
1798
|
+
break;
|
|
1799
|
+
case w.PAN:
|
|
1800
|
+
if (this.enablePan === !1) {
|
|
1801
|
+
this.state = Q.NONE;
|
|
1802
|
+
break;
|
|
1803
|
+
}
|
|
1804
|
+
this._handleTouchStartPan(e), this.state = Q.TOUCH_PAN;
|
|
1805
|
+
break;
|
|
1806
|
+
default: this.state = Q.NONE;
|
|
1807
|
+
}
|
|
1808
|
+
break;
|
|
1809
|
+
case 2:
|
|
1810
|
+
switch (this.touches.TWO) {
|
|
1811
|
+
case w.DOLLY_PAN:
|
|
1812
|
+
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
1813
|
+
this._handleTouchStartDollyPan(e), this.state = Q.TOUCH_DOLLY_PAN;
|
|
1814
|
+
break;
|
|
1815
|
+
case w.DOLLY_ROTATE:
|
|
1816
|
+
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
1817
|
+
this._handleTouchStartDollyRotate(e), this.state = Q.TOUCH_DOLLY_ROTATE;
|
|
1818
|
+
break;
|
|
1819
|
+
default: this.state = Q.NONE;
|
|
1820
|
+
}
|
|
1821
|
+
break;
|
|
1822
|
+
default: this.state = Q.NONE;
|
|
1823
|
+
}
|
|
1824
|
+
this.state !== Q.NONE && this.dispatchEvent(J);
|
|
1825
|
+
}
|
|
1826
|
+
function Zt(e) {
|
|
1827
|
+
switch (this._trackPointer(e), this.state) {
|
|
1828
|
+
case Q.TOUCH_ROTATE:
|
|
1829
|
+
if (this.enableRotate === !1) return;
|
|
1830
|
+
this._handleTouchMoveRotate(e), this.update();
|
|
1831
|
+
break;
|
|
1832
|
+
case Q.TOUCH_PAN:
|
|
1833
|
+
if (this.enablePan === !1) return;
|
|
1834
|
+
this._handleTouchMovePan(e), this.update();
|
|
1835
|
+
break;
|
|
1836
|
+
case Q.TOUCH_DOLLY_PAN:
|
|
1837
|
+
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
1838
|
+
this._handleTouchMoveDollyPan(e), this.update();
|
|
1839
|
+
break;
|
|
1840
|
+
case Q.TOUCH_DOLLY_ROTATE:
|
|
1841
|
+
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
1842
|
+
this._handleTouchMoveDollyRotate(e), this.update();
|
|
1843
|
+
break;
|
|
1844
|
+
default: this.state = Q.NONE;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
function Qt(e) {
|
|
1848
|
+
this.enabled !== !1 && e.preventDefault();
|
|
1849
|
+
}
|
|
1850
|
+
function $t(e) {
|
|
1851
|
+
e.key === "Control" && (this._controlActive = !0, this.domElement.ownerDocument.addEventListener("keyup", this._interceptControlUp, {
|
|
1852
|
+
passive: !0,
|
|
1853
|
+
capture: !0
|
|
1854
|
+
}));
|
|
1855
|
+
}
|
|
1856
|
+
function en(e) {
|
|
1857
|
+
e.key === "Control" && (this._controlActive = !1, this.domElement.ownerDocument.removeEventListener("keyup", this._interceptControlUp, {
|
|
1858
|
+
passive: !0,
|
|
1859
|
+
capture: !0
|
|
1860
|
+
}));
|
|
1861
|
+
}
|
|
1862
|
+
// src/components/file-viewer/renderers/Model3dRenderer.vue?vue&type=script&setup=true&lang.ts
|
|
1863
|
+
var tn = { class: "fv-model" }, nn = {
|
|
1864
|
+
key: 0,
|
|
1865
|
+
class: "fv-model-loading"
|
|
1866
|
+
}, rn = /*#__PURE__*/ ze(/* @__PURE__ */ He({
|
|
1867
|
+
__name: "Model3dRenderer",
|
|
1868
|
+
props: {
|
|
1869
|
+
source: {},
|
|
1870
|
+
options: {},
|
|
1871
|
+
viewportWidth: {},
|
|
1872
|
+
viewportHeight: {}
|
|
1873
|
+
},
|
|
1874
|
+
emits: [
|
|
1875
|
+
"ready",
|
|
1876
|
+
"error",
|
|
1877
|
+
"zoom-change"
|
|
1878
|
+
],
|
|
1879
|
+
setup(e, { expose: t, emit: n }) {
|
|
1880
|
+
let r = e, i = n, a = Ke(null), o = Ke("正在加载 3D 模型…"), s = null, c = null, l = null, u = null, d = null, f = 0, p = !1, m = 1, h = 1;
|
|
1881
|
+
function g() {
|
|
1882
|
+
if (!c || !l || !u) return;
|
|
1883
|
+
let e = new T().setFromObject(c);
|
|
1884
|
+
if (e.isEmpty()) return;
|
|
1885
|
+
let t = e.getSize(new M()), n = e.getCenter(new M()), r = Math.max(t.x, t.y, t.z, .001), a = l.fov * Math.PI / 180, o = r / (2 * Math.tan(a / 2)) * 1.8;
|
|
1886
|
+
m = o, h = o, l.position.set(n.x + o * .65, n.y + o * .45, n.z + o), l.near = Math.max(o / 1e3, .01), l.far = o * 100, l.updateProjectionMatrix(), u.target.copy(n), u.update(), i("zoom-change", 100);
|
|
1887
|
+
}
|
|
1888
|
+
function v(e) {
|
|
1889
|
+
if (!l || !u) return;
|
|
1890
|
+
let t = l.position.clone().sub(u.target);
|
|
1891
|
+
h = Math.max(m * .05, h * e), t.setLength(h), l.position.copy(u.target).add(t), u.update(), i("zoom-change", Math.round(m / h * 100));
|
|
1892
|
+
}
|
|
1893
|
+
function ee() {
|
|
1894
|
+
v(1 / 1.2);
|
|
1895
|
+
}
|
|
1896
|
+
function y() {
|
|
1897
|
+
v(1.2);
|
|
1898
|
+
}
|
|
1899
|
+
function te() {
|
|
1900
|
+
if (!u || !l) return;
|
|
1901
|
+
let e = l.position.clone().sub(u.target);
|
|
1902
|
+
h = m, e.setLength(m), l.position.copy(u.target).add(e), u.update(), i("zoom-change", 100);
|
|
1903
|
+
}
|
|
1904
|
+
function b(e) {
|
|
1905
|
+
if (!l || !u) return;
|
|
1906
|
+
let t = l.position.clone().sub(u.target), n = new j().setFromVector3(t);
|
|
1907
|
+
n.theta += e, t.setFromSpherical(n), l.position.copy(u.target).add(t), u.update();
|
|
1908
|
+
}
|
|
1909
|
+
function ne() {
|
|
1910
|
+
s && c && l && (s.render(c, l), Re(s.domElement.toDataURL("image/png"), r.source.name));
|
|
1911
|
+
}
|
|
1912
|
+
function x() {
|
|
1913
|
+
let e = a.value;
|
|
1914
|
+
if (!e || !s || !l) return;
|
|
1915
|
+
let t = e.clientWidth, n = e.clientHeight;
|
|
1916
|
+
t <= 0 || n <= 0 || (s.setSize(t, n, !1), l.aspect = t / n, l.updateProjectionMatrix());
|
|
1917
|
+
}
|
|
1918
|
+
async function S() {
|
|
1919
|
+
let e = a.value;
|
|
1920
|
+
if (e) try {
|
|
1921
|
+
c = new he(), l = new _(45, 1, .1, 1e4), s = new De({
|
|
1922
|
+
antialias: !0,
|
|
1923
|
+
alpha: !0,
|
|
1924
|
+
preserveDrawingBuffer: !0
|
|
1925
|
+
}), s.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)), s.setClearColor(0, 0), s.outputColorSpace = D, s.domElement.className = "fv-model-canvas", e.appendChild(s.domElement), u = new Ht(l, s.domElement), u.enableDamping = !0, u.dampingFactor = .08, u.minDistance = .001, u.maxDistance = 1e7, c.add(new je(16777215, 4473941, 2.2));
|
|
1926
|
+
let t = new ge(16777215, 2);
|
|
1927
|
+
t.position.set(1, 2, 1.5), c.add(t);
|
|
1928
|
+
let n = new ve(16777215, .45);
|
|
1929
|
+
c.add(n);
|
|
1930
|
+
let a = new Ze(), m = r.source.url;
|
|
1931
|
+
if (await new Promise((e, t) => {
|
|
1932
|
+
a.load(m, (t) => {
|
|
1933
|
+
c?.add(t.scene), e();
|
|
1934
|
+
}, void 0, (e) => t(e instanceof Error ? e : /* @__PURE__ */ Error("3D 模型加载失败")));
|
|
1935
|
+
}), p) return;
|
|
1936
|
+
o.value = "", x(), g(), d = new ResizeObserver(() => x()), d.observe(e);
|
|
1937
|
+
let h = () => {
|
|
1938
|
+
p || (u?.update(), s && c && l && s.render(c, l), f = requestAnimationFrame(h));
|
|
1939
|
+
};
|
|
1940
|
+
h(), i("ready");
|
|
1941
|
+
} catch (e) {
|
|
1942
|
+
if (o.value = "", p) return;
|
|
1943
|
+
i("error", e instanceof Error ? e.message : "3D 模型加载失败");
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
return We(S), Ue(() => {
|
|
1947
|
+
p = !0, cancelAnimationFrame(f), d?.disconnect(), d = null, u?.dispose(), u = null, c?.traverse((e) => {
|
|
1948
|
+
let t = e;
|
|
1949
|
+
t.geometry && t.geometry.dispose();
|
|
1950
|
+
let n = t.material;
|
|
1951
|
+
Array.isArray(n) ? n.forEach((e) => e.dispose()) : n?.dispose();
|
|
1952
|
+
}), s?.dispose(), s?.domElement.remove(), s = null, c = null, l = null;
|
|
1953
|
+
}), t({
|
|
1954
|
+
zoomIn: ee,
|
|
1955
|
+
zoomOut: y,
|
|
1956
|
+
resetZoom: te,
|
|
1957
|
+
rotate: b,
|
|
1958
|
+
print: ne
|
|
1959
|
+
}), (e, t) => (Ge(), Ve("div", tn, [N("div", {
|
|
1960
|
+
ref_key: "root",
|
|
1961
|
+
ref: a,
|
|
1962
|
+
class: "fv-model-stage"
|
|
1963
|
+
}, null, 512), o.value ? (Ge(), Ve("div", nn, [t[0] ||= N("span", { class: "fv-model-spinner" }, null, -1), N("span", null, qe(o.value), 1)])) : Be("", !0)]));
|
|
1964
|
+
}
|
|
1965
|
+
}), [["__scopeId", "data-v-b9294de9"]]);
|
|
1966
|
+
export { rn as default };
|