ss-component-new 1.2.2 → 1.2.4
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/dist/OrbitControls-Co_9huz0.cjs +1 -0
- package/dist/OrbitControls-DA4VpOM_.js +458 -0
- package/dist/STLLoader-DmGTF0Nv.js +657 -0
- package/dist/STLLoader-RU7KqloS.cjs +6 -0
- package/dist/{animationData-BDq02_ir.js → animationData-9n1X4UvO.js} +4 -4
- package/dist/{animationData-BRDoJBuV.cjs → animationData-CfT99nMO.cjs} +1 -1
- package/dist/{array-BtZq8qON.cjs → array-BPHS7JFA.cjs} +1 -1
- package/dist/{array-A59WrroX.js → array-pg68Qbs1.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{iconfont-7cEds3Xj.js → iconfont-ljBfzBSE.js} +2 -2
- package/dist/{iconfont-CsuwJCas.cjs → iconfont-t5epssvu.cjs} +1 -1
- package/dist/{index-wq8KZGnQ.js → index---6UATT0.js} +3 -3
- package/dist/{index-D8S0DVkq.cjs → index-1DtctdYW.cjs} +1 -1
- package/dist/index-5hLZZ6t-.cjs +1 -0
- package/dist/{index-DygW4mGC.js → index-8CcD03tl.js} +6 -6
- package/dist/{index-C6Uddqal.js → index-B5gNufYw.js} +2 -2
- package/dist/{index-BgJn4mlV.js → index-B5srJr0o.js} +2 -2
- package/dist/{index-B_k7wRBo.cjs → index-B5vIeQUq.cjs} +1 -1
- package/dist/{index-DS3OziT5.cjs → index-B8J_v2Ky.cjs} +1 -1
- package/dist/{index-DQTI3BuS.cjs → index-B9nZeing.cjs} +1 -1
- package/dist/{index-BeqNCviq.js → index-BAj0dyBF.js} +152 -152
- package/dist/{index-BeTQ6ief.js → index-BEJOd_29.js} +4 -4
- package/dist/{index-Dn9I5-1H.cjs → index-BKhDFqMM.cjs} +1 -1
- package/dist/{index-Cz03X-rX.js → index-BNNxPuEV.js} +1 -1
- package/dist/{index-DmwVXfrE.cjs → index-BOVdAFDH.cjs} +1 -1
- package/dist/{index-Crd4LGue.cjs → index-Bi7yv8jC.cjs} +1 -1
- package/dist/{index-CFg3-0Tk.js → index-BjXcyVvp.js} +2 -2
- package/dist/{index-CxnH4vfV.cjs → index-BrsIZVyD.cjs} +1 -1
- package/dist/{index-BB6zZsmY.cjs → index-Bsdjuxq1.cjs} +1 -1
- package/dist/{index-C461j30b.js → index-BuKHInQb.js} +1 -1
- package/dist/{index-CJzA3AAO.cjs → index-Bx4qIiIa.cjs} +1 -1
- package/dist/{index-HFf3Z0Ft.cjs → index-C-AOuDkl.cjs} +1 -1
- package/dist/{index-C3CD2NW8.cjs → index-C0HHmjrg.cjs} +1 -1
- package/dist/{index-BTrjEMt1.js → index-C1lB8apW.js} +4 -4
- package/dist/{index-DqquxuCt.cjs → index-CAHYTZ1Q.cjs} +1 -1
- package/dist/{index-BdL8I_2i.cjs → index-CCIJ-P3X.cjs} +1 -1
- package/dist/{index-B9j8fCyS.js → index-CCsSOTaB.js} +2 -2
- package/dist/{index-YQnrEK_K.js → index-CDXq3gs4.js} +21 -21
- package/dist/{index-CrWFG4Wb.cjs → index-CK_O7QdV.cjs} +1 -1
- package/dist/{index-N7dEiXLQ.js → index-CLtFz5gE.js} +3 -3
- package/dist/{index-6t33eejU.cjs → index-CMlYJD5U.cjs} +1 -1
- package/dist/{index-BxPnA2or.js → index-CdPbJekh.js} +448 -448
- package/dist/{index-CjI5pDiU.cjs → index-CmlXlH2b.cjs} +1 -1
- package/dist/{index-C_VamYcq.js → index-CpE8hbs0.js} +6 -6
- package/dist/{index-CNJzNn6z.cjs → index-CxNBcsll.cjs} +1 -1
- package/dist/{index-BqCCREh3.js → index-CyP2hcVu.js} +6 -6
- package/dist/{index-gjDjqhNq.cjs → index-D-r_YKrq.cjs} +2 -2
- package/dist/{index-C23iUpXa.js → index-D0_4keB8.js} +5 -5
- package/dist/{index-db5CgGrA.js → index-DBScQH7L.js} +13 -13
- package/dist/{index-Cx302rHQ.cjs → index-DCf7Tz40.cjs} +1 -1
- package/dist/{index-DNE4QDIf.js → index-DEwcUkb-.js} +3 -3
- package/dist/{index-qoqka5Nb.js → index-DFg-bhPI.js} +1 -1
- package/dist/{index-CtPy-3S1.cjs → index-DJ1PTHpx.cjs} +1 -1
- package/dist/{index-DqaA5Rvx.cjs → index-DOlPMLvf.cjs} +1 -1
- package/dist/{index-Kg96Vvn5.cjs → index-DPaTtF3h.cjs} +1 -1
- package/dist/{index-CVl84S8B.cjs → index-DPyzaxnq.cjs} +1 -1
- package/dist/{index-DH0dVg0N.js → index-DS5z17Mc.js} +7 -7
- package/dist/{index-B35e4i9n.js → index-DSsZtYMz.js} +2 -2
- package/dist/{index-DVvt9_w0.js → index-Dk8D9SRm.js} +1 -1
- package/dist/{index-wHil9Fox.js → index-DsHRVZ0E.js} +2 -2
- package/dist/{index-DmB0dlGH.cjs → index-DszzdQnM.cjs} +1 -1
- package/dist/{index-BwjuTBrR.js → index-FxX6NP0J.js} +1 -1
- package/dist/{index-CtG-uyjY.cjs → index-LXb5DfDE.cjs} +1 -1
- package/dist/{index-byBdKAky.cjs → index-NFCeQcv4.cjs} +1 -1
- package/dist/{index-BvPC1LSv.js → index-PIEkAjRf.js} +12 -12
- package/dist/{index-CYp77kPp.js → index-UN4JU0ly.js} +1 -1
- package/dist/{index-CvEj4aiY.js → index-Y7MUJdPv.js} +2 -2
- package/dist/{index-aneoZx5F.js → index-bj8hK6Pe.js} +2 -2
- package/dist/{index-1z9RrjZc.cjs → index-d6tSWKtY.cjs} +1 -1
- package/dist/{index-DIm3MBK_.cjs → index-nUEWiqy9.cjs} +1 -1
- package/dist/{index-dqBbhGfy.js → index-pLeOyTaj.js} +6 -6
- package/dist/{index-nq9fleOT.js → index-xHEf6hcO.js} +2 -2
- package/dist/{index-XQxaEXgz.cjs → index-zQVJFawn.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Dmm4yqcc.js → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-BTu7I4mn.js} +2 -2
- package/dist/{index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-CzcK5mCc.cjs → index.vue_vue_type_style_index_0_scoped_0f027c8c_lang-Cmc1oALS.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_92477073_lang-B0Ivzvcp.js → index.vue_vue_type_style_index_0_scoped_92477073_lang-Bg_c-oAL.js} +6 -6
- package/dist/{index.vue_vue_type_style_index_0_scoped_92477073_lang-xm0hMPwT.cjs → index.vue_vue_type_style_index_0_scoped_92477073_lang-C795GAHK.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-Czu5g16A.js → index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-9kDr7Iek.js} +13 -13
- package/dist/{index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-CMx9TLjC.cjs → index.vue_vue_type_style_index_0_scoped_bcdf4fb0_lang-Bn5qXF4J.cjs} +1 -1
- package/dist/{index.vue_vue_type_style_index_1_lang-CXwGS60-.cjs → index.vue_vue_type_style_index_1_lang-Bn7P4fYM.cjs} +46 -45
- package/dist/{index.vue_vue_type_style_index_1_lang-BxEXAMMV.js → index.vue_vue_type_style_index_1_lang-D1n_3_F6.js} +5100 -5012
- package/dist/{index.vue_vue_type_style_index_1_lang-AXp5rRSK.js → index.vue_vue_type_style_index_1_lang-Exyt6qTf.js} +525 -525
- package/dist/{index.vue_vue_type_style_index_1_lang-j5HrYuvy.cjs → index.vue_vue_type_style_index_1_lang-zN5mc8b0.cjs} +2 -2
- package/dist/{isString-BNK38WbE.js → isString-BAN9KLwf.js} +1 -1
- package/dist/{isString-BmAegMGI.cjs → isString-ChvWbctO.cjs} +1 -1
- package/dist/{main-BgpAXuSa.cjs → main-BUEuCNq-.cjs} +1 -1
- package/dist/{main-t7yIujwl.js → main-Dk3BZDsa.js} +5 -5
- package/dist/ss-component.cjs +1 -1
- package/dist/ss-component.css +1 -1
- package/dist/ss-component.js +11 -11
- package/dist/ss-component2.cjs +1 -1
- package/dist/ss-component2.js +12 -12
- package/dist/three-viewport-gizmo-BHznJ6W3.js +26015 -0
- package/dist/three-viewport-gizmo-BV37JzRa.cjs +4197 -0
- package/dist/{threeLatheView-sTBlm0tt.js → threeLatheView-DcuDjVv0.js} +4 -4
- package/dist/{threeLatheView-BzHB-t_G.cjs → threeLatheView-DfSxRY8B.cjs} +1 -1
- package/dist/{threeModel-BudPgWiX.cjs → threeModel-DjjtL0-a.cjs} +1 -1
- package/dist/{threeModel-11Yk8w2d.js → threeModel-YRFvkgXU.js} +5 -5
- package/dist/threePreview-ByUYJkts.cjs +1 -0
- package/dist/threePreview-CyYfnbB6.js +1972 -0
- package/dist/{threeSceneView-DT-STxuj.cjs → threeSceneView-mhrcH0WG.cjs} +1 -1
- package/dist/{threeSceneView-Bwed326O.js → threeSceneView-zvyCHrp1.js} +24 -24
- package/dist/{threeSceneViewForCPMPIP-RRDb_tZ0.cjs → threeSceneViewForCPMPIP-DA-twBdG.cjs} +2 -2
- package/dist/{threeSceneViewForCPMPIP-PgPPGBxu.js → threeSceneViewForCPMPIP-axjwKt9X.js} +27 -27
- package/dist/{threeViewerHost-Brgx-J3Q.cjs → threeViewerHost-B02OtfCk.cjs} +1 -1
- package/dist/{threeViewerHost-k5I66uBW.js → threeViewerHost-D7L1FW__.js} +4 -4
- package/dist/{useRayCaster-TCYe6KMI.js → useRayCaster-CAqupK7D.js} +12 -12
- package/dist/{useRayCaster-CLcetetd.cjs → useRayCaster-ClcofJkf.cjs} +1 -1
- package/package.json +1 -1
- package/public/config.js +1 -1
- package/dist/OrbitControls-D1lM0xvz.cjs +0 -1
- package/dist/OrbitControls-DI8fa9gz.js +0 -419
- package/dist/STLLoader-KxFIlfhN.cjs +0 -6
- package/dist/STLLoader-memlq1bT.js +0 -609
- package/dist/index-TXrydBPq.cjs +0 -1
- package/dist/three-viewport-gizmo-BxFHxv_x.js +0 -18587
- package/dist/three-viewport-gizmo-CwaL5sMV.cjs +0 -4195
- package/dist/threePreview-Cy7NY-gw.cjs +0 -1
- package/dist/threePreview-DPyqhBkJ.js +0 -1873
|
@@ -0,0 +1,1972 @@
|
|
|
1
|
+
import { ref as K, shallowRef as je, defineComponent as Be, watch as Z, onMounted as Ke, nextTick as Ve, onBeforeUnmount as ze, resolveComponent as Xe, createElementBlock as ee, openBlock as ne, createElementVNode as _, withDirectives as z, createCommentVNode as he, createVNode as H, unref as y, toDisplayString as pe, withCtx as qe, isRef as $, vModelRadio as J, vShow as We } from "vue";
|
|
2
|
+
import { u as Ye, a as $e, b as Je, S as j } from "./iconfont-ljBfzBSE.js";
|
|
3
|
+
import { M as Qe, O as Ze, S as en } from "./STLLoader-DmGTF0Nv.js";
|
|
4
|
+
import { v as nn, w as ce, x as ye, y as tn, z as W, F as be, I as O, J as Se, C as G, K as F, b as Y, N as sn, g as rn, D as on, k as Q, V as B, O as an, Q as Ne, R as cn, U as Ie, Y as ln, Z as un, _ as te, $ as dn, a0 as Ce, a1 as fn, a2 as hn, a3 as pn, a4 as le, a5 as Oe, a6 as ue, a7 as mn, a8 as gn, a9 as Tn, aa as se, ab as xn, n as ve, i as Rn, ac as q, ad as En, p as An, ae as Ln, e as ke, af as _n, r as Mn, ag as wn, ah as yn, o as re, P as bn, l as Sn, ai as Nn, aj as In, ak as Cn, al as On, am as vn, an as Fe, ao as kn, ap as me, aq as ge, ar as Te, as as xe, at as Re, au as Fn, av as Pn, B as Pe, aw as Dn, h as Hn } from "./three-viewport-gizmo-BHznJ6W3.js";
|
|
5
|
+
import { E as Ee } from "./index-UN4JU0ly.js";
|
|
6
|
+
import { _ as Un } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
|
+
function Ae(d, n) {
|
|
8
|
+
if (n === nn)
|
|
9
|
+
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
|
|
10
|
+
if (n === ce || n === ye) {
|
|
11
|
+
let e = d.getIndex();
|
|
12
|
+
if (e === null) {
|
|
13
|
+
const r = [], a = d.getAttribute("position");
|
|
14
|
+
if (a !== void 0) {
|
|
15
|
+
for (let o = 0; o < a.count; o++)
|
|
16
|
+
r.push(o);
|
|
17
|
+
d.setIndex(r), e = d.getIndex();
|
|
18
|
+
} else
|
|
19
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), d;
|
|
20
|
+
}
|
|
21
|
+
const i = e.count - 2, t = [];
|
|
22
|
+
if (n === ce)
|
|
23
|
+
for (let r = 1; r <= i; r++)
|
|
24
|
+
t.push(e.getX(0)), t.push(e.getX(r)), t.push(e.getX(r + 1));
|
|
25
|
+
else
|
|
26
|
+
for (let r = 0; r < i; r++)
|
|
27
|
+
r % 2 === 0 ? (t.push(e.getX(r)), t.push(e.getX(r + 1)), t.push(e.getX(r + 2))) : (t.push(e.getX(r + 2)), t.push(e.getX(r + 1)), t.push(e.getX(r)));
|
|
28
|
+
t.length / 3 !== i && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
29
|
+
const s = d.clone();
|
|
30
|
+
return s.setIndex(t), s.clearGroups(), s;
|
|
31
|
+
} else
|
|
32
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", n), d;
|
|
33
|
+
}
|
|
34
|
+
class Gn extends tn {
|
|
35
|
+
/**
|
|
36
|
+
* Constructs a new glTF loader.
|
|
37
|
+
*
|
|
38
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
39
|
+
*/
|
|
40
|
+
constructor(n) {
|
|
41
|
+
super(n), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
42
|
+
return new zn(e);
|
|
43
|
+
}), this.register(function(e) {
|
|
44
|
+
return new Xn(e);
|
|
45
|
+
}), this.register(function(e) {
|
|
46
|
+
return new nt(e);
|
|
47
|
+
}), this.register(function(e) {
|
|
48
|
+
return new tt(e);
|
|
49
|
+
}), this.register(function(e) {
|
|
50
|
+
return new st(e);
|
|
51
|
+
}), this.register(function(e) {
|
|
52
|
+
return new Wn(e);
|
|
53
|
+
}), this.register(function(e) {
|
|
54
|
+
return new Yn(e);
|
|
55
|
+
}), this.register(function(e) {
|
|
56
|
+
return new $n(e);
|
|
57
|
+
}), this.register(function(e) {
|
|
58
|
+
return new Jn(e);
|
|
59
|
+
}), this.register(function(e) {
|
|
60
|
+
return new Vn(e);
|
|
61
|
+
}), this.register(function(e) {
|
|
62
|
+
return new Qn(e);
|
|
63
|
+
}), this.register(function(e) {
|
|
64
|
+
return new qn(e);
|
|
65
|
+
}), this.register(function(e) {
|
|
66
|
+
return new et(e);
|
|
67
|
+
}), this.register(function(e) {
|
|
68
|
+
return new Zn(e);
|
|
69
|
+
}), this.register(function(e) {
|
|
70
|
+
return new Bn(e);
|
|
71
|
+
}), this.register(function(e) {
|
|
72
|
+
return new rt(e);
|
|
73
|
+
}), this.register(function(e) {
|
|
74
|
+
return new it(e);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
79
|
+
* to the `onLoad()` callback.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
82
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
83
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
84
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
85
|
+
*/
|
|
86
|
+
load(n, e, i, t) {
|
|
87
|
+
const s = this;
|
|
88
|
+
let r;
|
|
89
|
+
if (this.resourcePath !== "")
|
|
90
|
+
r = this.resourcePath;
|
|
91
|
+
else if (this.path !== "") {
|
|
92
|
+
const c = W.extractUrlBase(n);
|
|
93
|
+
r = W.resolveURL(c, this.path);
|
|
94
|
+
} else
|
|
95
|
+
r = W.extractUrlBase(n);
|
|
96
|
+
this.manager.itemStart(n);
|
|
97
|
+
const a = function(c) {
|
|
98
|
+
t ? t(c) : console.error(c), s.manager.itemError(n), s.manager.itemEnd(n);
|
|
99
|
+
}, o = new be(this.manager);
|
|
100
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(n, function(c) {
|
|
101
|
+
try {
|
|
102
|
+
s.parse(c, r, function(u) {
|
|
103
|
+
e(u), s.manager.itemEnd(n);
|
|
104
|
+
}, a);
|
|
105
|
+
} catch (u) {
|
|
106
|
+
a(u);
|
|
107
|
+
}
|
|
108
|
+
}, i, a);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
112
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
113
|
+
*
|
|
114
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
115
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
116
|
+
*/
|
|
117
|
+
setDRACOLoader(n) {
|
|
118
|
+
return this.dracoLoader = n, this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
122
|
+
* compressed textures.
|
|
123
|
+
*
|
|
124
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
125
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
126
|
+
*/
|
|
127
|
+
setKTX2Loader(n) {
|
|
128
|
+
return this.ktx2Loader = n, this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
132
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
133
|
+
*
|
|
134
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
135
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
136
|
+
*/
|
|
137
|
+
setMeshoptDecoder(n) {
|
|
138
|
+
return this.meshoptDecoder = n, this;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
142
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
143
|
+
* to the loader.
|
|
144
|
+
*
|
|
145
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
146
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
147
|
+
*/
|
|
148
|
+
register(n) {
|
|
149
|
+
return this.pluginCallbacks.indexOf(n) === -1 && this.pluginCallbacks.push(n), this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Unregisters a plugin callback.
|
|
153
|
+
*
|
|
154
|
+
* @param {Function} callback - The callback function to unregister.
|
|
155
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
156
|
+
*/
|
|
157
|
+
unregister(n) {
|
|
158
|
+
return this.pluginCallbacks.indexOf(n) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(n), 1), this;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parses the given FBX data and returns the resulting group.
|
|
162
|
+
*
|
|
163
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
164
|
+
* @param {string} path - The URL base path.
|
|
165
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
166
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
167
|
+
*/
|
|
168
|
+
parse(n, e, i, t) {
|
|
169
|
+
let s;
|
|
170
|
+
const r = {}, a = {}, o = new TextDecoder();
|
|
171
|
+
if (typeof n == "string")
|
|
172
|
+
s = JSON.parse(n);
|
|
173
|
+
else if (n instanceof ArrayBuffer)
|
|
174
|
+
if (o.decode(new Uint8Array(n, 0, 4)) === De) {
|
|
175
|
+
try {
|
|
176
|
+
r[E.KHR_BINARY_GLTF] = new ot(n);
|
|
177
|
+
} catch (l) {
|
|
178
|
+
t && t(l);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
s = JSON.parse(r[E.KHR_BINARY_GLTF].content);
|
|
182
|
+
} else
|
|
183
|
+
s = JSON.parse(o.decode(n));
|
|
184
|
+
else
|
|
185
|
+
s = n;
|
|
186
|
+
if (s.asset === void 0 || s.asset.version[0] < 2) {
|
|
187
|
+
t && t(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const c = new Rt(s, {
|
|
191
|
+
path: e || this.resourcePath || "",
|
|
192
|
+
crossOrigin: this.crossOrigin,
|
|
193
|
+
requestHeader: this.requestHeader,
|
|
194
|
+
manager: this.manager,
|
|
195
|
+
ktx2Loader: this.ktx2Loader,
|
|
196
|
+
meshoptDecoder: this.meshoptDecoder
|
|
197
|
+
});
|
|
198
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
199
|
+
for (let u = 0; u < this.pluginCallbacks.length; u++) {
|
|
200
|
+
const l = this.pluginCallbacks[u](c);
|
|
201
|
+
l.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[l.name] = l, r[l.name] = !0;
|
|
202
|
+
}
|
|
203
|
+
if (s.extensionsUsed)
|
|
204
|
+
for (let u = 0; u < s.extensionsUsed.length; ++u) {
|
|
205
|
+
const l = s.extensionsUsed[u], f = s.extensionsRequired || [];
|
|
206
|
+
switch (l) {
|
|
207
|
+
case E.KHR_MATERIALS_UNLIT:
|
|
208
|
+
r[l] = new Kn();
|
|
209
|
+
break;
|
|
210
|
+
case E.KHR_DRACO_MESH_COMPRESSION:
|
|
211
|
+
r[l] = new at(s, this.dracoLoader);
|
|
212
|
+
break;
|
|
213
|
+
case E.KHR_TEXTURE_TRANSFORM:
|
|
214
|
+
r[l] = new ct();
|
|
215
|
+
break;
|
|
216
|
+
case E.KHR_MESH_QUANTIZATION:
|
|
217
|
+
r[l] = new lt();
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
f.indexOf(l) >= 0 && a[l] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + l + '".');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
c.setExtensions(r), c.setPlugins(a), c.parse(i, t);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
227
|
+
*
|
|
228
|
+
* @async
|
|
229
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
230
|
+
* @param {string} path - The URL base path.
|
|
231
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
232
|
+
*/
|
|
233
|
+
parseAsync(n, e) {
|
|
234
|
+
const i = this;
|
|
235
|
+
return new Promise(function(t, s) {
|
|
236
|
+
i.parse(n, e, t, s);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function jn() {
|
|
241
|
+
let d = {};
|
|
242
|
+
return {
|
|
243
|
+
get: function(n) {
|
|
244
|
+
return d[n];
|
|
245
|
+
},
|
|
246
|
+
add: function(n, e) {
|
|
247
|
+
d[n] = e;
|
|
248
|
+
},
|
|
249
|
+
remove: function(n) {
|
|
250
|
+
delete d[n];
|
|
251
|
+
},
|
|
252
|
+
removeAll: function() {
|
|
253
|
+
d = {};
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const E = {
|
|
258
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
259
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
260
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
261
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
262
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
263
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
264
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
265
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
266
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
267
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
268
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
269
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
270
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
271
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
272
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
273
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
274
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
275
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
276
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
277
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
278
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
279
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
280
|
+
};
|
|
281
|
+
class Bn {
|
|
282
|
+
constructor(n) {
|
|
283
|
+
this.parser = n, this.name = E.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
284
|
+
}
|
|
285
|
+
_markDefs() {
|
|
286
|
+
const n = this.parser, e = this.parser.json.nodes || [];
|
|
287
|
+
for (let i = 0, t = e.length; i < t; i++) {
|
|
288
|
+
const s = e[i];
|
|
289
|
+
s.extensions && s.extensions[this.name] && s.extensions[this.name].light !== void 0 && n._addNodeRef(this.cache, s.extensions[this.name].light);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
_loadLight(n) {
|
|
293
|
+
const e = this.parser, i = "light:" + n;
|
|
294
|
+
let t = e.cache.get(i);
|
|
295
|
+
if (t) return t;
|
|
296
|
+
const s = e.json, o = ((s.extensions && s.extensions[this.name] || {}).lights || [])[n];
|
|
297
|
+
let c;
|
|
298
|
+
const u = new G(16777215);
|
|
299
|
+
o.color !== void 0 && u.setRGB(o.color[0], o.color[1], o.color[2], F);
|
|
300
|
+
const l = o.range !== void 0 ? o.range : 0;
|
|
301
|
+
switch (o.type) {
|
|
302
|
+
case "directional":
|
|
303
|
+
c = new on(u), c.target.position.set(0, 0, -1), c.add(c.target);
|
|
304
|
+
break;
|
|
305
|
+
case "point":
|
|
306
|
+
c = new rn(u), c.distance = l;
|
|
307
|
+
break;
|
|
308
|
+
case "spot":
|
|
309
|
+
c = new sn(u), c.distance = l, o.spot = o.spot || {}, o.spot.innerConeAngle = o.spot.innerConeAngle !== void 0 ? o.spot.innerConeAngle : 0, o.spot.outerConeAngle = o.spot.outerConeAngle !== void 0 ? o.spot.outerConeAngle : Math.PI / 4, c.angle = o.spot.outerConeAngle, c.penumbra = 1 - o.spot.innerConeAngle / o.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
|
|
310
|
+
break;
|
|
311
|
+
default:
|
|
312
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + o.type);
|
|
313
|
+
}
|
|
314
|
+
return c.position.set(0, 0, 0), k(c, o), o.intensity !== void 0 && (c.intensity = o.intensity), c.name = e.createUniqueName(o.name || "light_" + n), t = Promise.resolve(c), e.cache.add(i, t), t;
|
|
315
|
+
}
|
|
316
|
+
getDependency(n, e) {
|
|
317
|
+
if (n === "light")
|
|
318
|
+
return this._loadLight(e);
|
|
319
|
+
}
|
|
320
|
+
createNodeAttachment(n) {
|
|
321
|
+
const e = this, i = this.parser, s = i.json.nodes[n], a = (s.extensions && s.extensions[this.name] || {}).light;
|
|
322
|
+
return a === void 0 ? null : this._loadLight(a).then(function(o) {
|
|
323
|
+
return i._getNodeRef(e.cache, a, o);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
class Kn {
|
|
328
|
+
constructor() {
|
|
329
|
+
this.name = E.KHR_MATERIALS_UNLIT;
|
|
330
|
+
}
|
|
331
|
+
getMaterialType() {
|
|
332
|
+
return q;
|
|
333
|
+
}
|
|
334
|
+
extendParams(n, e, i) {
|
|
335
|
+
const t = [];
|
|
336
|
+
n.color = new G(1, 1, 1), n.opacity = 1;
|
|
337
|
+
const s = e.pbrMetallicRoughness;
|
|
338
|
+
if (s) {
|
|
339
|
+
if (Array.isArray(s.baseColorFactor)) {
|
|
340
|
+
const r = s.baseColorFactor;
|
|
341
|
+
n.color.setRGB(r[0], r[1], r[2], F), n.opacity = r[3];
|
|
342
|
+
}
|
|
343
|
+
s.baseColorTexture !== void 0 && t.push(i.assignTexture(n, "map", s.baseColorTexture, Y));
|
|
344
|
+
}
|
|
345
|
+
return Promise.all(t);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
class Vn {
|
|
349
|
+
constructor(n) {
|
|
350
|
+
this.parser = n, this.name = E.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
351
|
+
}
|
|
352
|
+
extendMaterialParams(n, e) {
|
|
353
|
+
const t = this.parser.json.materials[n];
|
|
354
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
355
|
+
return Promise.resolve();
|
|
356
|
+
const s = t.extensions[this.name].emissiveStrength;
|
|
357
|
+
return s !== void 0 && (e.emissiveIntensity = s), Promise.resolve();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
class zn {
|
|
361
|
+
constructor(n) {
|
|
362
|
+
this.parser = n, this.name = E.KHR_MATERIALS_CLEARCOAT;
|
|
363
|
+
}
|
|
364
|
+
getMaterialType(n) {
|
|
365
|
+
const i = this.parser.json.materials[n];
|
|
366
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
367
|
+
}
|
|
368
|
+
extendMaterialParams(n, e) {
|
|
369
|
+
const i = this.parser, t = i.json.materials[n];
|
|
370
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
371
|
+
return Promise.resolve();
|
|
372
|
+
const s = [], r = t.extensions[this.name];
|
|
373
|
+
if (r.clearcoatFactor !== void 0 && (e.clearcoat = r.clearcoatFactor), r.clearcoatTexture !== void 0 && s.push(i.assignTexture(e, "clearcoatMap", r.clearcoatTexture)), r.clearcoatRoughnessFactor !== void 0 && (e.clearcoatRoughness = r.clearcoatRoughnessFactor), r.clearcoatRoughnessTexture !== void 0 && s.push(i.assignTexture(e, "clearcoatRoughnessMap", r.clearcoatRoughnessTexture)), r.clearcoatNormalTexture !== void 0 && (s.push(i.assignTexture(e, "clearcoatNormalMap", r.clearcoatNormalTexture)), r.clearcoatNormalTexture.scale !== void 0)) {
|
|
374
|
+
const a = r.clearcoatNormalTexture.scale;
|
|
375
|
+
e.clearcoatNormalScale = new Se(a, a);
|
|
376
|
+
}
|
|
377
|
+
return Promise.all(s);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
class Xn {
|
|
381
|
+
constructor(n) {
|
|
382
|
+
this.parser = n, this.name = E.KHR_MATERIALS_DISPERSION;
|
|
383
|
+
}
|
|
384
|
+
getMaterialType(n) {
|
|
385
|
+
const i = this.parser.json.materials[n];
|
|
386
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
387
|
+
}
|
|
388
|
+
extendMaterialParams(n, e) {
|
|
389
|
+
const t = this.parser.json.materials[n];
|
|
390
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
391
|
+
return Promise.resolve();
|
|
392
|
+
const s = t.extensions[this.name];
|
|
393
|
+
return e.dispersion = s.dispersion !== void 0 ? s.dispersion : 0, Promise.resolve();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class qn {
|
|
397
|
+
constructor(n) {
|
|
398
|
+
this.parser = n, this.name = E.KHR_MATERIALS_IRIDESCENCE;
|
|
399
|
+
}
|
|
400
|
+
getMaterialType(n) {
|
|
401
|
+
const i = this.parser.json.materials[n];
|
|
402
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
403
|
+
}
|
|
404
|
+
extendMaterialParams(n, e) {
|
|
405
|
+
const i = this.parser, t = i.json.materials[n];
|
|
406
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
407
|
+
return Promise.resolve();
|
|
408
|
+
const s = [], r = t.extensions[this.name];
|
|
409
|
+
return r.iridescenceFactor !== void 0 && (e.iridescence = r.iridescenceFactor), r.iridescenceTexture !== void 0 && s.push(i.assignTexture(e, "iridescenceMap", r.iridescenceTexture)), r.iridescenceIor !== void 0 && (e.iridescenceIOR = r.iridescenceIor), e.iridescenceThicknessRange === void 0 && (e.iridescenceThicknessRange = [100, 400]), r.iridescenceThicknessMinimum !== void 0 && (e.iridescenceThicknessRange[0] = r.iridescenceThicknessMinimum), r.iridescenceThicknessMaximum !== void 0 && (e.iridescenceThicknessRange[1] = r.iridescenceThicknessMaximum), r.iridescenceThicknessTexture !== void 0 && s.push(i.assignTexture(e, "iridescenceThicknessMap", r.iridescenceThicknessTexture)), Promise.all(s);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
class Wn {
|
|
413
|
+
constructor(n) {
|
|
414
|
+
this.parser = n, this.name = E.KHR_MATERIALS_SHEEN;
|
|
415
|
+
}
|
|
416
|
+
getMaterialType(n) {
|
|
417
|
+
const i = this.parser.json.materials[n];
|
|
418
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
419
|
+
}
|
|
420
|
+
extendMaterialParams(n, e) {
|
|
421
|
+
const i = this.parser, t = i.json.materials[n];
|
|
422
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
423
|
+
return Promise.resolve();
|
|
424
|
+
const s = [];
|
|
425
|
+
e.sheenColor = new G(0, 0, 0), e.sheenRoughness = 0, e.sheen = 1;
|
|
426
|
+
const r = t.extensions[this.name];
|
|
427
|
+
if (r.sheenColorFactor !== void 0) {
|
|
428
|
+
const a = r.sheenColorFactor;
|
|
429
|
+
e.sheenColor.setRGB(a[0], a[1], a[2], F);
|
|
430
|
+
}
|
|
431
|
+
return r.sheenRoughnessFactor !== void 0 && (e.sheenRoughness = r.sheenRoughnessFactor), r.sheenColorTexture !== void 0 && s.push(i.assignTexture(e, "sheenColorMap", r.sheenColorTexture, Y)), r.sheenRoughnessTexture !== void 0 && s.push(i.assignTexture(e, "sheenRoughnessMap", r.sheenRoughnessTexture)), Promise.all(s);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
class Yn {
|
|
435
|
+
constructor(n) {
|
|
436
|
+
this.parser = n, this.name = E.KHR_MATERIALS_TRANSMISSION;
|
|
437
|
+
}
|
|
438
|
+
getMaterialType(n) {
|
|
439
|
+
const i = this.parser.json.materials[n];
|
|
440
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
441
|
+
}
|
|
442
|
+
extendMaterialParams(n, e) {
|
|
443
|
+
const i = this.parser, t = i.json.materials[n];
|
|
444
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
445
|
+
return Promise.resolve();
|
|
446
|
+
const s = [], r = t.extensions[this.name];
|
|
447
|
+
return r.transmissionFactor !== void 0 && (e.transmission = r.transmissionFactor), r.transmissionTexture !== void 0 && s.push(i.assignTexture(e, "transmissionMap", r.transmissionTexture)), Promise.all(s);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
class $n {
|
|
451
|
+
constructor(n) {
|
|
452
|
+
this.parser = n, this.name = E.KHR_MATERIALS_VOLUME;
|
|
453
|
+
}
|
|
454
|
+
getMaterialType(n) {
|
|
455
|
+
const i = this.parser.json.materials[n];
|
|
456
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
457
|
+
}
|
|
458
|
+
extendMaterialParams(n, e) {
|
|
459
|
+
const i = this.parser, t = i.json.materials[n];
|
|
460
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
461
|
+
return Promise.resolve();
|
|
462
|
+
const s = [], r = t.extensions[this.name];
|
|
463
|
+
e.thickness = r.thicknessFactor !== void 0 ? r.thicknessFactor : 0, r.thicknessTexture !== void 0 && s.push(i.assignTexture(e, "thicknessMap", r.thicknessTexture)), e.attenuationDistance = r.attenuationDistance || 1 / 0;
|
|
464
|
+
const a = r.attenuationColor || [1, 1, 1];
|
|
465
|
+
return e.attenuationColor = new G().setRGB(a[0], a[1], a[2], F), Promise.all(s);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
class Jn {
|
|
469
|
+
constructor(n) {
|
|
470
|
+
this.parser = n, this.name = E.KHR_MATERIALS_IOR;
|
|
471
|
+
}
|
|
472
|
+
getMaterialType(n) {
|
|
473
|
+
const i = this.parser.json.materials[n];
|
|
474
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
475
|
+
}
|
|
476
|
+
extendMaterialParams(n, e) {
|
|
477
|
+
const t = this.parser.json.materials[n];
|
|
478
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
479
|
+
return Promise.resolve();
|
|
480
|
+
const s = t.extensions[this.name];
|
|
481
|
+
return e.ior = s.ior !== void 0 ? s.ior : 1.5, Promise.resolve();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
class Qn {
|
|
485
|
+
constructor(n) {
|
|
486
|
+
this.parser = n, this.name = E.KHR_MATERIALS_SPECULAR;
|
|
487
|
+
}
|
|
488
|
+
getMaterialType(n) {
|
|
489
|
+
const i = this.parser.json.materials[n];
|
|
490
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
491
|
+
}
|
|
492
|
+
extendMaterialParams(n, e) {
|
|
493
|
+
const i = this.parser, t = i.json.materials[n];
|
|
494
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
495
|
+
return Promise.resolve();
|
|
496
|
+
const s = [], r = t.extensions[this.name];
|
|
497
|
+
e.specularIntensity = r.specularFactor !== void 0 ? r.specularFactor : 1, r.specularTexture !== void 0 && s.push(i.assignTexture(e, "specularIntensityMap", r.specularTexture));
|
|
498
|
+
const a = r.specularColorFactor || [1, 1, 1];
|
|
499
|
+
return e.specularColor = new G().setRGB(a[0], a[1], a[2], F), r.specularColorTexture !== void 0 && s.push(i.assignTexture(e, "specularColorMap", r.specularColorTexture, Y)), Promise.all(s);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
class Zn {
|
|
503
|
+
constructor(n) {
|
|
504
|
+
this.parser = n, this.name = E.EXT_MATERIALS_BUMP;
|
|
505
|
+
}
|
|
506
|
+
getMaterialType(n) {
|
|
507
|
+
const i = this.parser.json.materials[n];
|
|
508
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
509
|
+
}
|
|
510
|
+
extendMaterialParams(n, e) {
|
|
511
|
+
const i = this.parser, t = i.json.materials[n];
|
|
512
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
513
|
+
return Promise.resolve();
|
|
514
|
+
const s = [], r = t.extensions[this.name];
|
|
515
|
+
return e.bumpScale = r.bumpFactor !== void 0 ? r.bumpFactor : 1, r.bumpTexture !== void 0 && s.push(i.assignTexture(e, "bumpMap", r.bumpTexture)), Promise.all(s);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
class et {
|
|
519
|
+
constructor(n) {
|
|
520
|
+
this.parser = n, this.name = E.KHR_MATERIALS_ANISOTROPY;
|
|
521
|
+
}
|
|
522
|
+
getMaterialType(n) {
|
|
523
|
+
const i = this.parser.json.materials[n];
|
|
524
|
+
return !i.extensions || !i.extensions[this.name] ? null : O;
|
|
525
|
+
}
|
|
526
|
+
extendMaterialParams(n, e) {
|
|
527
|
+
const i = this.parser, t = i.json.materials[n];
|
|
528
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
529
|
+
return Promise.resolve();
|
|
530
|
+
const s = [], r = t.extensions[this.name];
|
|
531
|
+
return r.anisotropyStrength !== void 0 && (e.anisotropy = r.anisotropyStrength), r.anisotropyRotation !== void 0 && (e.anisotropyRotation = r.anisotropyRotation), r.anisotropyTexture !== void 0 && s.push(i.assignTexture(e, "anisotropyMap", r.anisotropyTexture)), Promise.all(s);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
class nt {
|
|
535
|
+
constructor(n) {
|
|
536
|
+
this.parser = n, this.name = E.KHR_TEXTURE_BASISU;
|
|
537
|
+
}
|
|
538
|
+
loadTexture(n) {
|
|
539
|
+
const e = this.parser, i = e.json, t = i.textures[n];
|
|
540
|
+
if (!t.extensions || !t.extensions[this.name])
|
|
541
|
+
return null;
|
|
542
|
+
const s = t.extensions[this.name], r = e.options.ktx2Loader;
|
|
543
|
+
if (!r) {
|
|
544
|
+
if (i.extensionsRequired && i.extensionsRequired.indexOf(this.name) >= 0)
|
|
545
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
return e.loadTextureImage(n, s.source, r);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
class tt {
|
|
552
|
+
constructor(n) {
|
|
553
|
+
this.parser = n, this.name = E.EXT_TEXTURE_WEBP;
|
|
554
|
+
}
|
|
555
|
+
loadTexture(n) {
|
|
556
|
+
const e = this.name, i = this.parser, t = i.json, s = t.textures[n];
|
|
557
|
+
if (!s.extensions || !s.extensions[e])
|
|
558
|
+
return null;
|
|
559
|
+
const r = s.extensions[e], a = t.images[r.source];
|
|
560
|
+
let o = i.textureLoader;
|
|
561
|
+
if (a.uri) {
|
|
562
|
+
const c = i.options.manager.getHandler(a.uri);
|
|
563
|
+
c !== null && (o = c);
|
|
564
|
+
}
|
|
565
|
+
return i.loadTextureImage(n, r.source, o);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
class st {
|
|
569
|
+
constructor(n) {
|
|
570
|
+
this.parser = n, this.name = E.EXT_TEXTURE_AVIF;
|
|
571
|
+
}
|
|
572
|
+
loadTexture(n) {
|
|
573
|
+
const e = this.name, i = this.parser, t = i.json, s = t.textures[n];
|
|
574
|
+
if (!s.extensions || !s.extensions[e])
|
|
575
|
+
return null;
|
|
576
|
+
const r = s.extensions[e], a = t.images[r.source];
|
|
577
|
+
let o = i.textureLoader;
|
|
578
|
+
if (a.uri) {
|
|
579
|
+
const c = i.options.manager.getHandler(a.uri);
|
|
580
|
+
c !== null && (o = c);
|
|
581
|
+
}
|
|
582
|
+
return i.loadTextureImage(n, r.source, o);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
class rt {
|
|
586
|
+
constructor(n) {
|
|
587
|
+
this.name = E.EXT_MESHOPT_COMPRESSION, this.parser = n;
|
|
588
|
+
}
|
|
589
|
+
loadBufferView(n) {
|
|
590
|
+
const e = this.parser.json, i = e.bufferViews[n];
|
|
591
|
+
if (i.extensions && i.extensions[this.name]) {
|
|
592
|
+
const t = i.extensions[this.name], s = this.parser.getDependency("buffer", t.buffer), r = this.parser.options.meshoptDecoder;
|
|
593
|
+
if (!r || !r.supported) {
|
|
594
|
+
if (e.extensionsRequired && e.extensionsRequired.indexOf(this.name) >= 0)
|
|
595
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
return s.then(function(a) {
|
|
599
|
+
const o = t.byteOffset || 0, c = t.byteLength || 0, u = t.count, l = t.byteStride, f = new Uint8Array(a, o, c);
|
|
600
|
+
return r.decodeGltfBufferAsync ? r.decodeGltfBufferAsync(u, l, f, t.mode, t.filter).then(function(h) {
|
|
601
|
+
return h.buffer;
|
|
602
|
+
}) : r.ready.then(function() {
|
|
603
|
+
const h = new ArrayBuffer(u * l);
|
|
604
|
+
return r.decodeGltfBuffer(new Uint8Array(h), u, l, f, t.mode, t.filter), h;
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
} else
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
class it {
|
|
612
|
+
constructor(n) {
|
|
613
|
+
this.name = E.EXT_MESH_GPU_INSTANCING, this.parser = n;
|
|
614
|
+
}
|
|
615
|
+
createNodeMesh(n) {
|
|
616
|
+
const e = this.parser.json, i = e.nodes[n];
|
|
617
|
+
if (!i.extensions || !i.extensions[this.name] || i.mesh === void 0)
|
|
618
|
+
return null;
|
|
619
|
+
const t = e.meshes[i.mesh];
|
|
620
|
+
for (const c of t.primitives)
|
|
621
|
+
if (c.mode !== C.TRIANGLES && c.mode !== C.TRIANGLE_STRIP && c.mode !== C.TRIANGLE_FAN && c.mode !== void 0)
|
|
622
|
+
return null;
|
|
623
|
+
const r = i.extensions[this.name].attributes, a = [], o = {};
|
|
624
|
+
for (const c in r)
|
|
625
|
+
a.push(this.parser.getDependency("accessor", r[c]).then((u) => (o[c] = u, o[c])));
|
|
626
|
+
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(n)), Promise.all(a).then((c) => {
|
|
627
|
+
const u = c.pop(), l = u.isGroup ? u.children : [u], f = c[0].count, h = [];
|
|
628
|
+
for (const p of l) {
|
|
629
|
+
const R = new Q(), m = new B(), g = new Ne(), A = new B(1, 1, 1), M = new an(p.geometry, p.material, f);
|
|
630
|
+
for (let T = 0; T < f; T++)
|
|
631
|
+
o.TRANSLATION && m.fromBufferAttribute(o.TRANSLATION, T), o.ROTATION && g.fromBufferAttribute(o.ROTATION, T), o.SCALE && A.fromBufferAttribute(o.SCALE, T), M.setMatrixAt(T, R.compose(m, g, A));
|
|
632
|
+
for (const T in o)
|
|
633
|
+
if (T === "_COLOR_0") {
|
|
634
|
+
const S = o[T];
|
|
635
|
+
M.instanceColor = new cn(S.array, S.itemSize, S.normalized);
|
|
636
|
+
} else T !== "TRANSLATION" && T !== "ROTATION" && T !== "SCALE" && p.geometry.setAttribute(T, o[T]);
|
|
637
|
+
Ie.prototype.copy.call(M, p), this.parser.assignFinalMaterial(M), h.push(M);
|
|
638
|
+
}
|
|
639
|
+
return u.isGroup ? (u.clear(), u.add(...h), u) : h[0];
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const De = "glTF", X = 12, Le = { JSON: 1313821514, BIN: 5130562 };
|
|
644
|
+
class ot {
|
|
645
|
+
constructor(n) {
|
|
646
|
+
this.name = E.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
647
|
+
const e = new DataView(n, 0, X), i = new TextDecoder();
|
|
648
|
+
if (this.header = {
|
|
649
|
+
magic: i.decode(new Uint8Array(n.slice(0, 4))),
|
|
650
|
+
version: e.getUint32(4, !0),
|
|
651
|
+
length: e.getUint32(8, !0)
|
|
652
|
+
}, this.header.magic !== De)
|
|
653
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
654
|
+
if (this.header.version < 2)
|
|
655
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
656
|
+
const t = this.header.length - X, s = new DataView(n, X);
|
|
657
|
+
let r = 0;
|
|
658
|
+
for (; r < t; ) {
|
|
659
|
+
const a = s.getUint32(r, !0);
|
|
660
|
+
r += 4;
|
|
661
|
+
const o = s.getUint32(r, !0);
|
|
662
|
+
if (r += 4, o === Le.JSON) {
|
|
663
|
+
const c = new Uint8Array(n, X + r, a);
|
|
664
|
+
this.content = i.decode(c);
|
|
665
|
+
} else if (o === Le.BIN) {
|
|
666
|
+
const c = X + r;
|
|
667
|
+
this.body = n.slice(c, c + a);
|
|
668
|
+
}
|
|
669
|
+
r += a;
|
|
670
|
+
}
|
|
671
|
+
if (this.content === null)
|
|
672
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
class at {
|
|
676
|
+
constructor(n, e) {
|
|
677
|
+
if (!e)
|
|
678
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
679
|
+
this.name = E.KHR_DRACO_MESH_COMPRESSION, this.json = n, this.dracoLoader = e, this.dracoLoader.preload();
|
|
680
|
+
}
|
|
681
|
+
decodePrimitive(n, e) {
|
|
682
|
+
const i = this.json, t = this.dracoLoader, s = n.extensions[this.name].bufferView, r = n.extensions[this.name].attributes, a = {}, o = {}, c = {};
|
|
683
|
+
for (const u in r) {
|
|
684
|
+
const l = de[u] || u.toLowerCase();
|
|
685
|
+
a[l] = r[u];
|
|
686
|
+
}
|
|
687
|
+
for (const u in n.attributes) {
|
|
688
|
+
const l = de[u] || u.toLowerCase();
|
|
689
|
+
if (r[u] !== void 0) {
|
|
690
|
+
const f = i.accessors[n.attributes[u]], h = V[f.componentType];
|
|
691
|
+
c[l] = h.name, o[l] = f.normalized === !0;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return e.getDependency("bufferView", s).then(function(u) {
|
|
695
|
+
return new Promise(function(l, f) {
|
|
696
|
+
t.decodeDracoFile(u, function(h) {
|
|
697
|
+
for (const p in h.attributes) {
|
|
698
|
+
const R = h.attributes[p], m = o[p];
|
|
699
|
+
m !== void 0 && (R.normalized = m);
|
|
700
|
+
}
|
|
701
|
+
l(h);
|
|
702
|
+
}, a, c, F, f);
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
class ct {
|
|
708
|
+
constructor() {
|
|
709
|
+
this.name = E.KHR_TEXTURE_TRANSFORM;
|
|
710
|
+
}
|
|
711
|
+
extendTexture(n, e) {
|
|
712
|
+
return (e.texCoord === void 0 || e.texCoord === n.channel) && e.offset === void 0 && e.rotation === void 0 && e.scale === void 0 || (n = n.clone(), e.texCoord !== void 0 && (n.channel = e.texCoord), e.offset !== void 0 && n.offset.fromArray(e.offset), e.rotation !== void 0 && (n.rotation = e.rotation), e.scale !== void 0 && n.repeat.fromArray(e.scale), n.needsUpdate = !0), n;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
class lt {
|
|
716
|
+
constructor() {
|
|
717
|
+
this.name = E.KHR_MESH_QUANTIZATION;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
class He extends Pn {
|
|
721
|
+
constructor(n, e, i, t) {
|
|
722
|
+
super(n, e, i, t);
|
|
723
|
+
}
|
|
724
|
+
copySampleValue_(n) {
|
|
725
|
+
const e = this.resultBuffer, i = this.sampleValues, t = this.valueSize, s = n * t * 3 + t;
|
|
726
|
+
for (let r = 0; r !== t; r++)
|
|
727
|
+
e[r] = i[s + r];
|
|
728
|
+
return e;
|
|
729
|
+
}
|
|
730
|
+
interpolate_(n, e, i, t) {
|
|
731
|
+
const s = this.resultBuffer, r = this.sampleValues, a = this.valueSize, o = a * 2, c = a * 3, u = t - e, l = (i - e) / u, f = l * l, h = f * l, p = n * c, R = p - c, m = -2 * h + 3 * f, g = h - f, A = 1 - m, M = g - f + l;
|
|
732
|
+
for (let T = 0; T !== a; T++) {
|
|
733
|
+
const S = r[R + T + a], I = r[R + T + o] * u, L = r[p + T + a], v = r[p + T] * u;
|
|
734
|
+
s[T] = A * S + M * I + m * L + g * v;
|
|
735
|
+
}
|
|
736
|
+
return s;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const ut = new Ne();
|
|
740
|
+
class dt extends He {
|
|
741
|
+
interpolate_(n, e, i, t) {
|
|
742
|
+
const s = super.interpolate_(n, e, i, t);
|
|
743
|
+
return ut.fromArray(s).normalize().toArray(s), s;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const C = {
|
|
747
|
+
POINTS: 0,
|
|
748
|
+
LINES: 1,
|
|
749
|
+
LINE_LOOP: 2,
|
|
750
|
+
LINE_STRIP: 3,
|
|
751
|
+
TRIANGLES: 4,
|
|
752
|
+
TRIANGLE_STRIP: 5,
|
|
753
|
+
TRIANGLE_FAN: 6
|
|
754
|
+
}, V = {
|
|
755
|
+
5120: Int8Array,
|
|
756
|
+
5121: Uint8Array,
|
|
757
|
+
5122: Int16Array,
|
|
758
|
+
5123: Uint16Array,
|
|
759
|
+
5125: Uint32Array,
|
|
760
|
+
5126: Float32Array
|
|
761
|
+
}, _e = {
|
|
762
|
+
9728: Oe,
|
|
763
|
+
9729: le,
|
|
764
|
+
9984: pn,
|
|
765
|
+
9985: hn,
|
|
766
|
+
9986: fn,
|
|
767
|
+
9987: Ce
|
|
768
|
+
}, Me = {
|
|
769
|
+
33071: gn,
|
|
770
|
+
33648: mn,
|
|
771
|
+
10497: ue
|
|
772
|
+
}, ie = {
|
|
773
|
+
SCALAR: 1,
|
|
774
|
+
VEC2: 2,
|
|
775
|
+
VEC3: 3,
|
|
776
|
+
VEC4: 4,
|
|
777
|
+
MAT2: 4,
|
|
778
|
+
MAT3: 9,
|
|
779
|
+
MAT4: 16
|
|
780
|
+
}, de = {
|
|
781
|
+
POSITION: "position",
|
|
782
|
+
NORMAL: "normal",
|
|
783
|
+
TANGENT: "tangent",
|
|
784
|
+
TEXCOORD_0: "uv",
|
|
785
|
+
TEXCOORD_1: "uv1",
|
|
786
|
+
TEXCOORD_2: "uv2",
|
|
787
|
+
TEXCOORD_3: "uv3",
|
|
788
|
+
COLOR_0: "color",
|
|
789
|
+
WEIGHTS_0: "skinWeight",
|
|
790
|
+
JOINTS_0: "skinIndex"
|
|
791
|
+
}, D = {
|
|
792
|
+
scale: "scale",
|
|
793
|
+
translation: "position",
|
|
794
|
+
rotation: "quaternion",
|
|
795
|
+
weights: "morphTargetInfluences"
|
|
796
|
+
}, ft = {
|
|
797
|
+
CUBICSPLINE: void 0,
|
|
798
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
799
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
800
|
+
LINEAR: Fe,
|
|
801
|
+
STEP: vn
|
|
802
|
+
}, oe = {
|
|
803
|
+
OPAQUE: "OPAQUE",
|
|
804
|
+
MASK: "MASK",
|
|
805
|
+
BLEND: "BLEND"
|
|
806
|
+
};
|
|
807
|
+
function ht(d) {
|
|
808
|
+
return d.DefaultMaterial === void 0 && (d.DefaultMaterial = new ve({
|
|
809
|
+
color: 16777215,
|
|
810
|
+
emissive: 0,
|
|
811
|
+
metalness: 1,
|
|
812
|
+
roughness: 1,
|
|
813
|
+
transparent: !1,
|
|
814
|
+
depthTest: !0,
|
|
815
|
+
side: Fn
|
|
816
|
+
})), d.DefaultMaterial;
|
|
817
|
+
}
|
|
818
|
+
function U(d, n, e) {
|
|
819
|
+
for (const i in e.extensions)
|
|
820
|
+
d[i] === void 0 && (n.userData.gltfExtensions = n.userData.gltfExtensions || {}, n.userData.gltfExtensions[i] = e.extensions[i]);
|
|
821
|
+
}
|
|
822
|
+
function k(d, n) {
|
|
823
|
+
n.extras !== void 0 && (typeof n.extras == "object" ? Object.assign(d.userData, n.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + n.extras));
|
|
824
|
+
}
|
|
825
|
+
function pt(d, n, e) {
|
|
826
|
+
let i = !1, t = !1, s = !1;
|
|
827
|
+
for (let c = 0, u = n.length; c < u; c++) {
|
|
828
|
+
const l = n[c];
|
|
829
|
+
if (l.POSITION !== void 0 && (i = !0), l.NORMAL !== void 0 && (t = !0), l.COLOR_0 !== void 0 && (s = !0), i && t && s) break;
|
|
830
|
+
}
|
|
831
|
+
if (!i && !t && !s) return Promise.resolve(d);
|
|
832
|
+
const r = [], a = [], o = [];
|
|
833
|
+
for (let c = 0, u = n.length; c < u; c++) {
|
|
834
|
+
const l = n[c];
|
|
835
|
+
if (i) {
|
|
836
|
+
const f = l.POSITION !== void 0 ? e.getDependency("accessor", l.POSITION) : d.attributes.position;
|
|
837
|
+
r.push(f);
|
|
838
|
+
}
|
|
839
|
+
if (t) {
|
|
840
|
+
const f = l.NORMAL !== void 0 ? e.getDependency("accessor", l.NORMAL) : d.attributes.normal;
|
|
841
|
+
a.push(f);
|
|
842
|
+
}
|
|
843
|
+
if (s) {
|
|
844
|
+
const f = l.COLOR_0 !== void 0 ? e.getDependency("accessor", l.COLOR_0) : d.attributes.color;
|
|
845
|
+
o.push(f);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return Promise.all([
|
|
849
|
+
Promise.all(r),
|
|
850
|
+
Promise.all(a),
|
|
851
|
+
Promise.all(o)
|
|
852
|
+
]).then(function(c) {
|
|
853
|
+
const u = c[0], l = c[1], f = c[2];
|
|
854
|
+
return i && (d.morphAttributes.position = u), t && (d.morphAttributes.normal = l), s && (d.morphAttributes.color = f), d.morphTargetsRelative = !0, d;
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
function mt(d, n) {
|
|
858
|
+
if (d.updateMorphTargets(), n.weights !== void 0)
|
|
859
|
+
for (let e = 0, i = n.weights.length; e < i; e++)
|
|
860
|
+
d.morphTargetInfluences[e] = n.weights[e];
|
|
861
|
+
if (n.extras && Array.isArray(n.extras.targetNames)) {
|
|
862
|
+
const e = n.extras.targetNames;
|
|
863
|
+
if (d.morphTargetInfluences.length === e.length) {
|
|
864
|
+
d.morphTargetDictionary = {};
|
|
865
|
+
for (let i = 0, t = e.length; i < t; i++)
|
|
866
|
+
d.morphTargetDictionary[e[i]] = i;
|
|
867
|
+
} else
|
|
868
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
function gt(d) {
|
|
872
|
+
let n;
|
|
873
|
+
const e = d.extensions && d.extensions[E.KHR_DRACO_MESH_COMPRESSION];
|
|
874
|
+
if (e ? n = "draco:" + e.bufferView + ":" + e.indices + ":" + ae(e.attributes) : n = d.indices + ":" + ae(d.attributes) + ":" + d.mode, d.targets !== void 0)
|
|
875
|
+
for (let i = 0, t = d.targets.length; i < t; i++)
|
|
876
|
+
n += ":" + ae(d.targets[i]);
|
|
877
|
+
return n;
|
|
878
|
+
}
|
|
879
|
+
function ae(d) {
|
|
880
|
+
let n = "";
|
|
881
|
+
const e = Object.keys(d).sort();
|
|
882
|
+
for (let i = 0, t = e.length; i < t; i++)
|
|
883
|
+
n += e[i] + ":" + d[e[i]] + ";";
|
|
884
|
+
return n;
|
|
885
|
+
}
|
|
886
|
+
function fe(d) {
|
|
887
|
+
switch (d) {
|
|
888
|
+
case Int8Array:
|
|
889
|
+
return 1 / 127;
|
|
890
|
+
case Uint8Array:
|
|
891
|
+
return 1 / 255;
|
|
892
|
+
case Int16Array:
|
|
893
|
+
return 1 / 32767;
|
|
894
|
+
case Uint16Array:
|
|
895
|
+
return 1 / 65535;
|
|
896
|
+
default:
|
|
897
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function Tt(d) {
|
|
901
|
+
return d.search(/\.jpe?g($|\?)/i) > 0 || d.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : d.search(/\.webp($|\?)/i) > 0 || d.search(/^data\:image\/webp/) === 0 ? "image/webp" : d.search(/\.ktx2($|\?)/i) > 0 || d.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
902
|
+
}
|
|
903
|
+
const xt = new Q();
|
|
904
|
+
class Rt {
|
|
905
|
+
constructor(n = {}, e = {}) {
|
|
906
|
+
this.json = n, this.extensions = {}, this.plugins = {}, this.options = e, this.cache = new jn(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
907
|
+
let i = !1, t = -1, s = !1, r = -1;
|
|
908
|
+
if (typeof navigator < "u") {
|
|
909
|
+
const a = navigator.userAgent;
|
|
910
|
+
i = /^((?!chrome|android).)*safari/i.test(a) === !0;
|
|
911
|
+
const o = a.match(/Version\/(\d+)/);
|
|
912
|
+
t = i && o ? parseInt(o[1], 10) : -1, s = a.indexOf("Firefox") > -1, r = s ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
913
|
+
}
|
|
914
|
+
typeof createImageBitmap > "u" || i && t < 17 || s && r < 98 ? this.textureLoader = new ln(this.options.manager) : this.textureLoader = new un(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new be(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
915
|
+
}
|
|
916
|
+
setExtensions(n) {
|
|
917
|
+
this.extensions = n;
|
|
918
|
+
}
|
|
919
|
+
setPlugins(n) {
|
|
920
|
+
this.plugins = n;
|
|
921
|
+
}
|
|
922
|
+
parse(n, e) {
|
|
923
|
+
const i = this, t = this.json, s = this.extensions;
|
|
924
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(r) {
|
|
925
|
+
return r._markDefs && r._markDefs();
|
|
926
|
+
}), Promise.all(this._invokeAll(function(r) {
|
|
927
|
+
return r.beforeRoot && r.beforeRoot();
|
|
928
|
+
})).then(function() {
|
|
929
|
+
return Promise.all([
|
|
930
|
+
i.getDependencies("scene"),
|
|
931
|
+
i.getDependencies("animation"),
|
|
932
|
+
i.getDependencies("camera")
|
|
933
|
+
]);
|
|
934
|
+
}).then(function(r) {
|
|
935
|
+
const a = {
|
|
936
|
+
scene: r[0][t.scene || 0],
|
|
937
|
+
scenes: r[0],
|
|
938
|
+
animations: r[1],
|
|
939
|
+
cameras: r[2],
|
|
940
|
+
asset: t.asset,
|
|
941
|
+
parser: i,
|
|
942
|
+
userData: {}
|
|
943
|
+
};
|
|
944
|
+
return U(s, a, t), k(a, t), Promise.all(i._invokeAll(function(o) {
|
|
945
|
+
return o.afterRoot && o.afterRoot(a);
|
|
946
|
+
})).then(function() {
|
|
947
|
+
for (const o of a.scenes)
|
|
948
|
+
o.updateMatrixWorld();
|
|
949
|
+
n(a);
|
|
950
|
+
});
|
|
951
|
+
}).catch(e);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
955
|
+
*
|
|
956
|
+
* @private
|
|
957
|
+
*/
|
|
958
|
+
_markDefs() {
|
|
959
|
+
const n = this.json.nodes || [], e = this.json.skins || [], i = this.json.meshes || [];
|
|
960
|
+
for (let t = 0, s = e.length; t < s; t++) {
|
|
961
|
+
const r = e[t].joints;
|
|
962
|
+
for (let a = 0, o = r.length; a < o; a++)
|
|
963
|
+
n[r[a]].isBone = !0;
|
|
964
|
+
}
|
|
965
|
+
for (let t = 0, s = n.length; t < s; t++) {
|
|
966
|
+
const r = n[t];
|
|
967
|
+
r.mesh !== void 0 && (this._addNodeRef(this.meshCache, r.mesh), r.skin !== void 0 && (i[r.mesh].isSkinnedMesh = !0)), r.camera !== void 0 && this._addNodeRef(this.cameraCache, r.camera);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
972
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
973
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
974
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
975
|
+
* Textures) can be reused directly and are not marked here.
|
|
976
|
+
*
|
|
977
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
978
|
+
*
|
|
979
|
+
* @private
|
|
980
|
+
* @param {Object} cache
|
|
981
|
+
* @param {Object3D} index
|
|
982
|
+
*/
|
|
983
|
+
_addNodeRef(n, e) {
|
|
984
|
+
e !== void 0 && (n.refs[e] === void 0 && (n.refs[e] = n.uses[e] = 0), n.refs[e]++);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
988
|
+
*
|
|
989
|
+
* @private
|
|
990
|
+
* @param {Object} cache
|
|
991
|
+
* @param {number} index
|
|
992
|
+
* @param {Object} object
|
|
993
|
+
* @return {Object}
|
|
994
|
+
*/
|
|
995
|
+
_getNodeRef(n, e, i) {
|
|
996
|
+
if (n.refs[e] <= 1) return i;
|
|
997
|
+
const t = i.clone(), s = (r, a) => {
|
|
998
|
+
const o = this.associations.get(r);
|
|
999
|
+
o != null && this.associations.set(a, o);
|
|
1000
|
+
for (const [c, u] of r.children.entries())
|
|
1001
|
+
s(u, a.children[c]);
|
|
1002
|
+
};
|
|
1003
|
+
return s(i, t), t.name += "_instance_" + n.uses[e]++, t;
|
|
1004
|
+
}
|
|
1005
|
+
_invokeOne(n) {
|
|
1006
|
+
const e = Object.values(this.plugins);
|
|
1007
|
+
e.push(this);
|
|
1008
|
+
for (let i = 0; i < e.length; i++) {
|
|
1009
|
+
const t = n(e[i]);
|
|
1010
|
+
if (t) return t;
|
|
1011
|
+
}
|
|
1012
|
+
return null;
|
|
1013
|
+
}
|
|
1014
|
+
_invokeAll(n) {
|
|
1015
|
+
const e = Object.values(this.plugins);
|
|
1016
|
+
e.unshift(this);
|
|
1017
|
+
const i = [];
|
|
1018
|
+
for (let t = 0; t < e.length; t++) {
|
|
1019
|
+
const s = n(e[t]);
|
|
1020
|
+
s && i.push(s);
|
|
1021
|
+
}
|
|
1022
|
+
return i;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
1026
|
+
*
|
|
1027
|
+
* @private
|
|
1028
|
+
* @param {string} type
|
|
1029
|
+
* @param {number} index
|
|
1030
|
+
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
|
|
1031
|
+
*/
|
|
1032
|
+
getDependency(n, e) {
|
|
1033
|
+
const i = n + ":" + e;
|
|
1034
|
+
let t = this.cache.get(i);
|
|
1035
|
+
if (!t) {
|
|
1036
|
+
switch (n) {
|
|
1037
|
+
case "scene":
|
|
1038
|
+
t = this.loadScene(e);
|
|
1039
|
+
break;
|
|
1040
|
+
case "node":
|
|
1041
|
+
t = this._invokeOne(function(s) {
|
|
1042
|
+
return s.loadNode && s.loadNode(e);
|
|
1043
|
+
});
|
|
1044
|
+
break;
|
|
1045
|
+
case "mesh":
|
|
1046
|
+
t = this._invokeOne(function(s) {
|
|
1047
|
+
return s.loadMesh && s.loadMesh(e);
|
|
1048
|
+
});
|
|
1049
|
+
break;
|
|
1050
|
+
case "accessor":
|
|
1051
|
+
t = this.loadAccessor(e);
|
|
1052
|
+
break;
|
|
1053
|
+
case "bufferView":
|
|
1054
|
+
t = this._invokeOne(function(s) {
|
|
1055
|
+
return s.loadBufferView && s.loadBufferView(e);
|
|
1056
|
+
});
|
|
1057
|
+
break;
|
|
1058
|
+
case "buffer":
|
|
1059
|
+
t = this.loadBuffer(e);
|
|
1060
|
+
break;
|
|
1061
|
+
case "material":
|
|
1062
|
+
t = this._invokeOne(function(s) {
|
|
1063
|
+
return s.loadMaterial && s.loadMaterial(e);
|
|
1064
|
+
});
|
|
1065
|
+
break;
|
|
1066
|
+
case "texture":
|
|
1067
|
+
t = this._invokeOne(function(s) {
|
|
1068
|
+
return s.loadTexture && s.loadTexture(e);
|
|
1069
|
+
});
|
|
1070
|
+
break;
|
|
1071
|
+
case "skin":
|
|
1072
|
+
t = this.loadSkin(e);
|
|
1073
|
+
break;
|
|
1074
|
+
case "animation":
|
|
1075
|
+
t = this._invokeOne(function(s) {
|
|
1076
|
+
return s.loadAnimation && s.loadAnimation(e);
|
|
1077
|
+
});
|
|
1078
|
+
break;
|
|
1079
|
+
case "camera":
|
|
1080
|
+
t = this.loadCamera(e);
|
|
1081
|
+
break;
|
|
1082
|
+
default:
|
|
1083
|
+
if (t = this._invokeOne(function(s) {
|
|
1084
|
+
return s != this && s.getDependency && s.getDependency(n, e);
|
|
1085
|
+
}), !t)
|
|
1086
|
+
throw new Error("Unknown type: " + n);
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
this.cache.add(i, t);
|
|
1090
|
+
}
|
|
1091
|
+
return t;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1095
|
+
*
|
|
1096
|
+
* @private
|
|
1097
|
+
* @param {string} type
|
|
1098
|
+
* @return {Promise<Array<Object>>}
|
|
1099
|
+
*/
|
|
1100
|
+
getDependencies(n) {
|
|
1101
|
+
let e = this.cache.get(n);
|
|
1102
|
+
if (!e) {
|
|
1103
|
+
const i = this, t = this.json[n + (n === "mesh" ? "es" : "s")] || [];
|
|
1104
|
+
e = Promise.all(t.map(function(s, r) {
|
|
1105
|
+
return i.getDependency(n, r);
|
|
1106
|
+
})), this.cache.add(n, e);
|
|
1107
|
+
}
|
|
1108
|
+
return e;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1112
|
+
*
|
|
1113
|
+
* @private
|
|
1114
|
+
* @param {number} bufferIndex
|
|
1115
|
+
* @return {Promise<ArrayBuffer>}
|
|
1116
|
+
*/
|
|
1117
|
+
loadBuffer(n) {
|
|
1118
|
+
const e = this.json.buffers[n], i = this.fileLoader;
|
|
1119
|
+
if (e.type && e.type !== "arraybuffer")
|
|
1120
|
+
throw new Error("THREE.GLTFLoader: " + e.type + " buffer type is not supported.");
|
|
1121
|
+
if (e.uri === void 0 && n === 0)
|
|
1122
|
+
return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);
|
|
1123
|
+
const t = this.options;
|
|
1124
|
+
return new Promise(function(s, r) {
|
|
1125
|
+
i.load(W.resolveURL(e.uri, t.path), s, void 0, function() {
|
|
1126
|
+
r(new Error('THREE.GLTFLoader: Failed to load buffer "' + e.uri + '".'));
|
|
1127
|
+
});
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1132
|
+
*
|
|
1133
|
+
* @private
|
|
1134
|
+
* @param {number} bufferViewIndex
|
|
1135
|
+
* @return {Promise<ArrayBuffer>}
|
|
1136
|
+
*/
|
|
1137
|
+
loadBufferView(n) {
|
|
1138
|
+
const e = this.json.bufferViews[n];
|
|
1139
|
+
return this.getDependency("buffer", e.buffer).then(function(i) {
|
|
1140
|
+
const t = e.byteLength || 0, s = e.byteOffset || 0;
|
|
1141
|
+
return i.slice(s, s + t);
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1146
|
+
*
|
|
1147
|
+
* @private
|
|
1148
|
+
* @param {number} accessorIndex
|
|
1149
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1150
|
+
*/
|
|
1151
|
+
loadAccessor(n) {
|
|
1152
|
+
const e = this, i = this.json, t = this.json.accessors[n];
|
|
1153
|
+
if (t.bufferView === void 0 && t.sparse === void 0) {
|
|
1154
|
+
const r = ie[t.type], a = V[t.componentType], o = t.normalized === !0, c = new a(t.count * r);
|
|
1155
|
+
return Promise.resolve(new te(c, r, o));
|
|
1156
|
+
}
|
|
1157
|
+
const s = [];
|
|
1158
|
+
return t.bufferView !== void 0 ? s.push(this.getDependency("bufferView", t.bufferView)) : s.push(null), t.sparse !== void 0 && (s.push(this.getDependency("bufferView", t.sparse.indices.bufferView)), s.push(this.getDependency("bufferView", t.sparse.values.bufferView))), Promise.all(s).then(function(r) {
|
|
1159
|
+
const a = r[0], o = ie[t.type], c = V[t.componentType], u = c.BYTES_PER_ELEMENT, l = u * o, f = t.byteOffset || 0, h = t.bufferView !== void 0 ? i.bufferViews[t.bufferView].byteStride : void 0, p = t.normalized === !0;
|
|
1160
|
+
let R, m;
|
|
1161
|
+
if (h && h !== l) {
|
|
1162
|
+
const g = Math.floor(f / h), A = "InterleavedBuffer:" + t.bufferView + ":" + t.componentType + ":" + g + ":" + t.count;
|
|
1163
|
+
let M = e.cache.get(A);
|
|
1164
|
+
M || (R = new c(a, g * h, t.count * h / u), M = new dn(R, h / u), e.cache.add(A, M)), m = new kn(M, o, f % h / u, p);
|
|
1165
|
+
} else
|
|
1166
|
+
a === null ? R = new c(t.count * o) : R = new c(a, f, t.count * o), m = new te(R, o, p);
|
|
1167
|
+
if (t.sparse !== void 0) {
|
|
1168
|
+
const g = ie.SCALAR, A = V[t.sparse.indices.componentType], M = t.sparse.indices.byteOffset || 0, T = t.sparse.values.byteOffset || 0, S = new A(r[1], M, t.sparse.count * g), I = new c(r[2], T, t.sparse.count * o);
|
|
1169
|
+
a !== null && (m = new te(m.array.slice(), m.itemSize, m.normalized)), m.normalized = !1;
|
|
1170
|
+
for (let L = 0, v = S.length; L < v; L++) {
|
|
1171
|
+
const w = S[L];
|
|
1172
|
+
if (m.setX(w, I[L * o]), o >= 2 && m.setY(w, I[L * o + 1]), o >= 3 && m.setZ(w, I[L * o + 2]), o >= 4 && m.setW(w, I[L * o + 3]), o >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1173
|
+
}
|
|
1174
|
+
m.normalized = p;
|
|
1175
|
+
}
|
|
1176
|
+
return m;
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1181
|
+
*
|
|
1182
|
+
* @private
|
|
1183
|
+
* @param {number} textureIndex
|
|
1184
|
+
* @return {Promise<THREE.Texture|null>}
|
|
1185
|
+
*/
|
|
1186
|
+
loadTexture(n) {
|
|
1187
|
+
const e = this.json, i = this.options, s = e.textures[n].source, r = e.images[s];
|
|
1188
|
+
let a = this.textureLoader;
|
|
1189
|
+
if (r.uri) {
|
|
1190
|
+
const o = i.manager.getHandler(r.uri);
|
|
1191
|
+
o !== null && (a = o);
|
|
1192
|
+
}
|
|
1193
|
+
return this.loadTextureImage(n, s, a);
|
|
1194
|
+
}
|
|
1195
|
+
loadTextureImage(n, e, i) {
|
|
1196
|
+
const t = this, s = this.json, r = s.textures[n], a = s.images[e], o = (a.uri || a.bufferView) + ":" + r.sampler;
|
|
1197
|
+
if (this.textureCache[o])
|
|
1198
|
+
return this.textureCache[o];
|
|
1199
|
+
const c = this.loadImageSource(e, i).then(function(u) {
|
|
1200
|
+
u.flipY = !1, u.name = r.name || a.name || "", u.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (u.name = a.uri);
|
|
1201
|
+
const f = (s.samplers || {})[r.sampler] || {};
|
|
1202
|
+
return u.magFilter = _e[f.magFilter] || le, u.minFilter = _e[f.minFilter] || Ce, u.wrapS = Me[f.wrapS] || ue, u.wrapT = Me[f.wrapT] || ue, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== Oe && u.minFilter !== le, t.associations.set(u, { textures: n }), u;
|
|
1203
|
+
}).catch(function() {
|
|
1204
|
+
return null;
|
|
1205
|
+
});
|
|
1206
|
+
return this.textureCache[o] = c, c;
|
|
1207
|
+
}
|
|
1208
|
+
loadImageSource(n, e) {
|
|
1209
|
+
const i = this, t = this.json, s = this.options;
|
|
1210
|
+
if (this.sourceCache[n] !== void 0)
|
|
1211
|
+
return this.sourceCache[n].then((l) => l.clone());
|
|
1212
|
+
const r = t.images[n], a = self.URL || self.webkitURL;
|
|
1213
|
+
let o = r.uri || "", c = !1;
|
|
1214
|
+
if (r.bufferView !== void 0)
|
|
1215
|
+
o = i.getDependency("bufferView", r.bufferView).then(function(l) {
|
|
1216
|
+
c = !0;
|
|
1217
|
+
const f = new Blob([l], { type: r.mimeType });
|
|
1218
|
+
return o = a.createObjectURL(f), o;
|
|
1219
|
+
});
|
|
1220
|
+
else if (r.uri === void 0)
|
|
1221
|
+
throw new Error("THREE.GLTFLoader: Image " + n + " is missing URI and bufferView");
|
|
1222
|
+
const u = Promise.resolve(o).then(function(l) {
|
|
1223
|
+
return new Promise(function(f, h) {
|
|
1224
|
+
let p = f;
|
|
1225
|
+
e.isImageBitmapLoader === !0 && (p = function(R) {
|
|
1226
|
+
const m = new me(R);
|
|
1227
|
+
m.needsUpdate = !0, f(m);
|
|
1228
|
+
}), e.load(W.resolveURL(l, s.path), p, void 0, h);
|
|
1229
|
+
});
|
|
1230
|
+
}).then(function(l) {
|
|
1231
|
+
return c === !0 && a.revokeObjectURL(o), k(l, r), l.userData.mimeType = r.mimeType || Tt(r.uri), l;
|
|
1232
|
+
}).catch(function(l) {
|
|
1233
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", o), l;
|
|
1234
|
+
});
|
|
1235
|
+
return this.sourceCache[n] = u, u;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1239
|
+
*
|
|
1240
|
+
* @private
|
|
1241
|
+
* @param {Object} materialParams
|
|
1242
|
+
* @param {string} mapName
|
|
1243
|
+
* @param {Object} mapDef
|
|
1244
|
+
* @param {string} [colorSpace]
|
|
1245
|
+
* @return {Promise<Texture>}
|
|
1246
|
+
*/
|
|
1247
|
+
assignTexture(n, e, i, t) {
|
|
1248
|
+
const s = this;
|
|
1249
|
+
return this.getDependency("texture", i.index).then(function(r) {
|
|
1250
|
+
if (!r) return null;
|
|
1251
|
+
if (i.texCoord !== void 0 && i.texCoord > 0 && (r = r.clone(), r.channel = i.texCoord), s.extensions[E.KHR_TEXTURE_TRANSFORM]) {
|
|
1252
|
+
const a = i.extensions !== void 0 ? i.extensions[E.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1253
|
+
if (a) {
|
|
1254
|
+
const o = s.associations.get(r);
|
|
1255
|
+
r = s.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(r, a), s.associations.set(r, o);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return t !== void 0 && (r.colorSpace = t), n[e] = r, r;
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1263
|
+
* already has a material (generated from the glTF material options alone)
|
|
1264
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1265
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1266
|
+
* be created if necessary, and reused from a cache.
|
|
1267
|
+
*
|
|
1268
|
+
* @private
|
|
1269
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1270
|
+
*/
|
|
1271
|
+
assignFinalMaterial(n) {
|
|
1272
|
+
const e = n.geometry;
|
|
1273
|
+
let i = n.material;
|
|
1274
|
+
const t = e.attributes.tangent === void 0, s = e.attributes.color !== void 0, r = e.attributes.normal === void 0;
|
|
1275
|
+
if (n.isPoints) {
|
|
1276
|
+
const a = "PointsMaterial:" + i.uuid;
|
|
1277
|
+
let o = this.cache.get(a);
|
|
1278
|
+
o || (o = new Tn(), se.prototype.copy.call(o, i), o.color.copy(i.color), o.map = i.map, o.sizeAttenuation = !1, this.cache.add(a, o)), i = o;
|
|
1279
|
+
} else if (n.isLine) {
|
|
1280
|
+
const a = "LineBasicMaterial:" + i.uuid;
|
|
1281
|
+
let o = this.cache.get(a);
|
|
1282
|
+
o || (o = new xn(), se.prototype.copy.call(o, i), o.color.copy(i.color), o.map = i.map, this.cache.add(a, o)), i = o;
|
|
1283
|
+
}
|
|
1284
|
+
if (t || s || r) {
|
|
1285
|
+
let a = "ClonedMaterial:" + i.uuid + ":";
|
|
1286
|
+
t && (a += "derivative-tangents:"), s && (a += "vertex-colors:"), r && (a += "flat-shading:");
|
|
1287
|
+
let o = this.cache.get(a);
|
|
1288
|
+
o || (o = i.clone(), s && (o.vertexColors = !0), r && (o.flatShading = !0), t && (o.normalScale && (o.normalScale.y *= -1), o.clearcoatNormalScale && (o.clearcoatNormalScale.y *= -1)), this.cache.add(a, o), this.associations.set(o, this.associations.get(i))), i = o;
|
|
1289
|
+
}
|
|
1290
|
+
n.material = i;
|
|
1291
|
+
}
|
|
1292
|
+
getMaterialType() {
|
|
1293
|
+
return ve;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1297
|
+
*
|
|
1298
|
+
* @private
|
|
1299
|
+
* @param {number} materialIndex
|
|
1300
|
+
* @return {Promise<Material>}
|
|
1301
|
+
*/
|
|
1302
|
+
loadMaterial(n) {
|
|
1303
|
+
const e = this, i = this.json, t = this.extensions, s = i.materials[n];
|
|
1304
|
+
let r;
|
|
1305
|
+
const a = {}, o = s.extensions || {}, c = [];
|
|
1306
|
+
if (o[E.KHR_MATERIALS_UNLIT]) {
|
|
1307
|
+
const l = t[E.KHR_MATERIALS_UNLIT];
|
|
1308
|
+
r = l.getMaterialType(), c.push(l.extendParams(a, s, e));
|
|
1309
|
+
} else {
|
|
1310
|
+
const l = s.pbrMetallicRoughness || {};
|
|
1311
|
+
if (a.color = new G(1, 1, 1), a.opacity = 1, Array.isArray(l.baseColorFactor)) {
|
|
1312
|
+
const f = l.baseColorFactor;
|
|
1313
|
+
a.color.setRGB(f[0], f[1], f[2], F), a.opacity = f[3];
|
|
1314
|
+
}
|
|
1315
|
+
l.baseColorTexture !== void 0 && c.push(e.assignTexture(a, "map", l.baseColorTexture, Y)), a.metalness = l.metallicFactor !== void 0 ? l.metallicFactor : 1, a.roughness = l.roughnessFactor !== void 0 ? l.roughnessFactor : 1, l.metallicRoughnessTexture !== void 0 && (c.push(e.assignTexture(a, "metalnessMap", l.metallicRoughnessTexture)), c.push(e.assignTexture(a, "roughnessMap", l.metallicRoughnessTexture))), r = this._invokeOne(function(f) {
|
|
1316
|
+
return f.getMaterialType && f.getMaterialType(n);
|
|
1317
|
+
}), c.push(Promise.all(this._invokeAll(function(f) {
|
|
1318
|
+
return f.extendMaterialParams && f.extendMaterialParams(n, a);
|
|
1319
|
+
})));
|
|
1320
|
+
}
|
|
1321
|
+
s.doubleSided === !0 && (a.side = Rn);
|
|
1322
|
+
const u = s.alphaMode || oe.OPAQUE;
|
|
1323
|
+
if (u === oe.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, u === oe.MASK && (a.alphaTest = s.alphaCutoff !== void 0 ? s.alphaCutoff : 0.5)), s.normalTexture !== void 0 && r !== q && (c.push(e.assignTexture(a, "normalMap", s.normalTexture)), a.normalScale = new Se(1, 1), s.normalTexture.scale !== void 0)) {
|
|
1324
|
+
const l = s.normalTexture.scale;
|
|
1325
|
+
a.normalScale.set(l, l);
|
|
1326
|
+
}
|
|
1327
|
+
if (s.occlusionTexture !== void 0 && r !== q && (c.push(e.assignTexture(a, "aoMap", s.occlusionTexture)), s.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = s.occlusionTexture.strength)), s.emissiveFactor !== void 0 && r !== q) {
|
|
1328
|
+
const l = s.emissiveFactor;
|
|
1329
|
+
a.emissive = new G().setRGB(l[0], l[1], l[2], F);
|
|
1330
|
+
}
|
|
1331
|
+
return s.emissiveTexture !== void 0 && r !== q && c.push(e.assignTexture(a, "emissiveMap", s.emissiveTexture, Y)), Promise.all(c).then(function() {
|
|
1332
|
+
const l = new r(a);
|
|
1333
|
+
return s.name && (l.name = s.name), k(l, s), e.associations.set(l, { materials: n }), s.extensions && U(t, l, s), l;
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
1338
|
+
*
|
|
1339
|
+
* @private
|
|
1340
|
+
* @param {string} originalName
|
|
1341
|
+
* @return {string}
|
|
1342
|
+
*/
|
|
1343
|
+
createUniqueName(n) {
|
|
1344
|
+
const e = En.sanitizeNodeName(n || "");
|
|
1345
|
+
return e in this.nodeNamesUsed ? e + "_" + ++this.nodeNamesUsed[e] : (this.nodeNamesUsed[e] = 0, e);
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
1349
|
+
*
|
|
1350
|
+
* Creates BufferGeometries from primitives.
|
|
1351
|
+
*
|
|
1352
|
+
* @private
|
|
1353
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
1354
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
1355
|
+
*/
|
|
1356
|
+
loadGeometries(n) {
|
|
1357
|
+
const e = this, i = this.extensions, t = this.primitiveCache;
|
|
1358
|
+
function s(a) {
|
|
1359
|
+
return i[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, e).then(function(o) {
|
|
1360
|
+
return we(o, a, e);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
const r = [];
|
|
1364
|
+
for (let a = 0, o = n.length; a < o; a++) {
|
|
1365
|
+
const c = n[a], u = gt(c), l = t[u];
|
|
1366
|
+
if (l)
|
|
1367
|
+
r.push(l.promise);
|
|
1368
|
+
else {
|
|
1369
|
+
let f;
|
|
1370
|
+
c.extensions && c.extensions[E.KHR_DRACO_MESH_COMPRESSION] ? f = s(c) : f = we(new An(), c, e), t[u] = { primitive: c, promise: f }, r.push(f);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return Promise.all(r);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
1377
|
+
*
|
|
1378
|
+
* @private
|
|
1379
|
+
* @param {number} meshIndex
|
|
1380
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
1381
|
+
*/
|
|
1382
|
+
loadMesh(n) {
|
|
1383
|
+
const e = this, i = this.json, t = this.extensions, s = i.meshes[n], r = s.primitives, a = [];
|
|
1384
|
+
for (let o = 0, c = r.length; o < c; o++) {
|
|
1385
|
+
const u = r[o].material === void 0 ? ht(this.cache) : this.getDependency("material", r[o].material);
|
|
1386
|
+
a.push(u);
|
|
1387
|
+
}
|
|
1388
|
+
return a.push(e.loadGeometries(r)), Promise.all(a).then(function(o) {
|
|
1389
|
+
const c = o.slice(0, o.length - 1), u = o[o.length - 1], l = [];
|
|
1390
|
+
for (let h = 0, p = u.length; h < p; h++) {
|
|
1391
|
+
const R = u[h], m = r[h];
|
|
1392
|
+
let g;
|
|
1393
|
+
const A = c[h];
|
|
1394
|
+
if (m.mode === C.TRIANGLES || m.mode === C.TRIANGLE_STRIP || m.mode === C.TRIANGLE_FAN || m.mode === void 0)
|
|
1395
|
+
g = s.isSkinnedMesh === !0 ? new Ln(R, A) : new ke(R, A), g.isSkinnedMesh === !0 && g.normalizeSkinWeights(), m.mode === C.TRIANGLE_STRIP ? g.geometry = Ae(g.geometry, ye) : m.mode === C.TRIANGLE_FAN && (g.geometry = Ae(g.geometry, ce));
|
|
1396
|
+
else if (m.mode === C.LINES)
|
|
1397
|
+
g = new _n(R, A);
|
|
1398
|
+
else if (m.mode === C.LINE_STRIP)
|
|
1399
|
+
g = new Mn(R, A);
|
|
1400
|
+
else if (m.mode === C.LINE_LOOP)
|
|
1401
|
+
g = new wn(R, A);
|
|
1402
|
+
else if (m.mode === C.POINTS)
|
|
1403
|
+
g = new yn(R, A);
|
|
1404
|
+
else
|
|
1405
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + m.mode);
|
|
1406
|
+
Object.keys(g.geometry.morphAttributes).length > 0 && mt(g, s), g.name = e.createUniqueName(s.name || "mesh_" + n), k(g, s), m.extensions && U(t, g, m), e.assignFinalMaterial(g), l.push(g);
|
|
1407
|
+
}
|
|
1408
|
+
for (let h = 0, p = l.length; h < p; h++)
|
|
1409
|
+
e.associations.set(l[h], {
|
|
1410
|
+
meshes: n,
|
|
1411
|
+
primitives: h
|
|
1412
|
+
});
|
|
1413
|
+
if (l.length === 1)
|
|
1414
|
+
return s.extensions && U(t, l[0], s), l[0];
|
|
1415
|
+
const f = new re();
|
|
1416
|
+
s.extensions && U(t, f, s), e.associations.set(f, { meshes: n });
|
|
1417
|
+
for (let h = 0, p = l.length; h < p; h++)
|
|
1418
|
+
f.add(l[h]);
|
|
1419
|
+
return f;
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
1424
|
+
*
|
|
1425
|
+
* @private
|
|
1426
|
+
* @param {number} cameraIndex
|
|
1427
|
+
* @return {Promise<THREE.Camera>}
|
|
1428
|
+
*/
|
|
1429
|
+
loadCamera(n) {
|
|
1430
|
+
let e;
|
|
1431
|
+
const i = this.json.cameras[n], t = i[i.type];
|
|
1432
|
+
if (!t) {
|
|
1433
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
return i.type === "perspective" ? e = new bn(Sn.radToDeg(t.yfov), t.aspectRatio || 1, t.znear || 1, t.zfar || 2e6) : i.type === "orthographic" && (e = new Nn(-t.xmag, t.xmag, t.ymag, -t.ymag, t.znear, t.zfar)), i.name && (e.name = this.createUniqueName(i.name)), k(e, i), Promise.resolve(e);
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
1440
|
+
*
|
|
1441
|
+
* @private
|
|
1442
|
+
* @param {number} skinIndex
|
|
1443
|
+
* @return {Promise<Skeleton>}
|
|
1444
|
+
*/
|
|
1445
|
+
loadSkin(n) {
|
|
1446
|
+
const e = this.json.skins[n], i = [];
|
|
1447
|
+
for (let t = 0, s = e.joints.length; t < s; t++)
|
|
1448
|
+
i.push(this._loadNodeShallow(e.joints[t]));
|
|
1449
|
+
return e.inverseBindMatrices !== void 0 ? i.push(this.getDependency("accessor", e.inverseBindMatrices)) : i.push(null), Promise.all(i).then(function(t) {
|
|
1450
|
+
const s = t.pop(), r = t, a = [], o = [];
|
|
1451
|
+
for (let c = 0, u = r.length; c < u; c++) {
|
|
1452
|
+
const l = r[c];
|
|
1453
|
+
if (l) {
|
|
1454
|
+
a.push(l);
|
|
1455
|
+
const f = new Q();
|
|
1456
|
+
s !== null && f.fromArray(s.array, c * 16), o.push(f);
|
|
1457
|
+
} else
|
|
1458
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', e.joints[c]);
|
|
1459
|
+
}
|
|
1460
|
+
return new In(a, o);
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
1465
|
+
*
|
|
1466
|
+
* @private
|
|
1467
|
+
* @param {number} animationIndex
|
|
1468
|
+
* @return {Promise<AnimationClip>}
|
|
1469
|
+
*/
|
|
1470
|
+
loadAnimation(n) {
|
|
1471
|
+
const e = this.json, i = this, t = e.animations[n], s = t.name ? t.name : "animation_" + n, r = [], a = [], o = [], c = [], u = [];
|
|
1472
|
+
for (let l = 0, f = t.channels.length; l < f; l++) {
|
|
1473
|
+
const h = t.channels[l], p = t.samplers[h.sampler], R = h.target, m = R.node, g = t.parameters !== void 0 ? t.parameters[p.input] : p.input, A = t.parameters !== void 0 ? t.parameters[p.output] : p.output;
|
|
1474
|
+
R.node !== void 0 && (r.push(this.getDependency("node", m)), a.push(this.getDependency("accessor", g)), o.push(this.getDependency("accessor", A)), c.push(p), u.push(R));
|
|
1475
|
+
}
|
|
1476
|
+
return Promise.all([
|
|
1477
|
+
Promise.all(r),
|
|
1478
|
+
Promise.all(a),
|
|
1479
|
+
Promise.all(o),
|
|
1480
|
+
Promise.all(c),
|
|
1481
|
+
Promise.all(u)
|
|
1482
|
+
]).then(function(l) {
|
|
1483
|
+
const f = l[0], h = l[1], p = l[2], R = l[3], m = l[4], g = [];
|
|
1484
|
+
for (let A = 0, M = f.length; A < M; A++) {
|
|
1485
|
+
const T = f[A], S = h[A], I = p[A], L = R[A], v = m[A];
|
|
1486
|
+
if (T === void 0) continue;
|
|
1487
|
+
T.updateMatrix && T.updateMatrix();
|
|
1488
|
+
const w = i._createAnimationTracks(T, S, I, L, v);
|
|
1489
|
+
if (w)
|
|
1490
|
+
for (let P = 0; P < w.length; P++)
|
|
1491
|
+
g.push(w[P]);
|
|
1492
|
+
}
|
|
1493
|
+
return new Cn(s, void 0, g);
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
createNodeMesh(n) {
|
|
1497
|
+
const e = this.json, i = this, t = e.nodes[n];
|
|
1498
|
+
return t.mesh === void 0 ? null : i.getDependency("mesh", t.mesh).then(function(s) {
|
|
1499
|
+
const r = i._getNodeRef(i.meshCache, t.mesh, s);
|
|
1500
|
+
return t.weights !== void 0 && r.traverse(function(a) {
|
|
1501
|
+
if (a.isMesh)
|
|
1502
|
+
for (let o = 0, c = t.weights.length; o < c; o++)
|
|
1503
|
+
a.morphTargetInfluences[o] = t.weights[o];
|
|
1504
|
+
}), r;
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
1509
|
+
*
|
|
1510
|
+
* @private
|
|
1511
|
+
* @param {number} nodeIndex
|
|
1512
|
+
* @return {Promise<Object3D>}
|
|
1513
|
+
*/
|
|
1514
|
+
loadNode(n) {
|
|
1515
|
+
const e = this.json, i = this, t = e.nodes[n], s = i._loadNodeShallow(n), r = [], a = t.children || [];
|
|
1516
|
+
for (let c = 0, u = a.length; c < u; c++)
|
|
1517
|
+
r.push(i.getDependency("node", a[c]));
|
|
1518
|
+
const o = t.skin === void 0 ? Promise.resolve(null) : i.getDependency("skin", t.skin);
|
|
1519
|
+
return Promise.all([
|
|
1520
|
+
s,
|
|
1521
|
+
Promise.all(r),
|
|
1522
|
+
o
|
|
1523
|
+
]).then(function(c) {
|
|
1524
|
+
const u = c[0], l = c[1], f = c[2];
|
|
1525
|
+
f !== null && u.traverse(function(h) {
|
|
1526
|
+
h.isSkinnedMesh && h.bind(f, xt);
|
|
1527
|
+
});
|
|
1528
|
+
for (let h = 0, p = l.length; h < p; h++)
|
|
1529
|
+
u.add(l[h]);
|
|
1530
|
+
return u;
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
// ._loadNodeShallow() parses a single node.
|
|
1534
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
1535
|
+
_loadNodeShallow(n) {
|
|
1536
|
+
const e = this.json, i = this.extensions, t = this;
|
|
1537
|
+
if (this.nodeCache[n] !== void 0)
|
|
1538
|
+
return this.nodeCache[n];
|
|
1539
|
+
const s = e.nodes[n], r = s.name ? t.createUniqueName(s.name) : "", a = [], o = t._invokeOne(function(c) {
|
|
1540
|
+
return c.createNodeMesh && c.createNodeMesh(n);
|
|
1541
|
+
});
|
|
1542
|
+
return o && a.push(o), s.camera !== void 0 && a.push(t.getDependency("camera", s.camera).then(function(c) {
|
|
1543
|
+
return t._getNodeRef(t.cameraCache, s.camera, c);
|
|
1544
|
+
})), t._invokeAll(function(c) {
|
|
1545
|
+
return c.createNodeAttachment && c.createNodeAttachment(n);
|
|
1546
|
+
}).forEach(function(c) {
|
|
1547
|
+
a.push(c);
|
|
1548
|
+
}), this.nodeCache[n] = Promise.all(a).then(function(c) {
|
|
1549
|
+
let u;
|
|
1550
|
+
if (s.isBone === !0 ? u = new On() : c.length > 1 ? u = new re() : c.length === 1 ? u = c[0] : u = new Ie(), u !== c[0])
|
|
1551
|
+
for (let l = 0, f = c.length; l < f; l++)
|
|
1552
|
+
u.add(c[l]);
|
|
1553
|
+
if (s.name && (u.userData.name = s.name, u.name = r), k(u, s), s.extensions && U(i, u, s), s.matrix !== void 0) {
|
|
1554
|
+
const l = new Q();
|
|
1555
|
+
l.fromArray(s.matrix), u.applyMatrix4(l);
|
|
1556
|
+
} else
|
|
1557
|
+
s.translation !== void 0 && u.position.fromArray(s.translation), s.rotation !== void 0 && u.quaternion.fromArray(s.rotation), s.scale !== void 0 && u.scale.fromArray(s.scale);
|
|
1558
|
+
if (!t.associations.has(u))
|
|
1559
|
+
t.associations.set(u, {});
|
|
1560
|
+
else if (s.mesh !== void 0 && t.meshCache.refs[s.mesh] > 1) {
|
|
1561
|
+
const l = t.associations.get(u);
|
|
1562
|
+
t.associations.set(u, { ...l });
|
|
1563
|
+
}
|
|
1564
|
+
return t.associations.get(u).nodes = n, u;
|
|
1565
|
+
}), this.nodeCache[n];
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
1569
|
+
*
|
|
1570
|
+
* @private
|
|
1571
|
+
* @param {number} sceneIndex
|
|
1572
|
+
* @return {Promise<Group>}
|
|
1573
|
+
*/
|
|
1574
|
+
loadScene(n) {
|
|
1575
|
+
const e = this.extensions, i = this.json.scenes[n], t = this, s = new re();
|
|
1576
|
+
i.name && (s.name = t.createUniqueName(i.name)), k(s, i), i.extensions && U(e, s, i);
|
|
1577
|
+
const r = i.nodes || [], a = [];
|
|
1578
|
+
for (let o = 0, c = r.length; o < c; o++)
|
|
1579
|
+
a.push(t.getDependency("node", r[o]));
|
|
1580
|
+
return Promise.all(a).then(function(o) {
|
|
1581
|
+
for (let u = 0, l = o.length; u < l; u++)
|
|
1582
|
+
s.add(o[u]);
|
|
1583
|
+
const c = (u) => {
|
|
1584
|
+
const l = /* @__PURE__ */ new Map();
|
|
1585
|
+
for (const [f, h] of t.associations)
|
|
1586
|
+
(f instanceof se || f instanceof me) && l.set(f, h);
|
|
1587
|
+
return u.traverse((f) => {
|
|
1588
|
+
const h = t.associations.get(f);
|
|
1589
|
+
h != null && l.set(f, h);
|
|
1590
|
+
}), l;
|
|
1591
|
+
};
|
|
1592
|
+
return t.associations = c(s), s;
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
_createAnimationTracks(n, e, i, t, s) {
|
|
1596
|
+
const r = [], a = n.name ? n.name : n.uuid, o = [];
|
|
1597
|
+
D[s.path] === D.weights ? n.traverse(function(f) {
|
|
1598
|
+
f.morphTargetInfluences && o.push(f.name ? f.name : f.uuid);
|
|
1599
|
+
}) : o.push(a);
|
|
1600
|
+
let c;
|
|
1601
|
+
switch (D[s.path]) {
|
|
1602
|
+
case D.weights:
|
|
1603
|
+
c = Te;
|
|
1604
|
+
break;
|
|
1605
|
+
case D.rotation:
|
|
1606
|
+
c = xe;
|
|
1607
|
+
break;
|
|
1608
|
+
case D.translation:
|
|
1609
|
+
case D.scale:
|
|
1610
|
+
c = ge;
|
|
1611
|
+
break;
|
|
1612
|
+
default:
|
|
1613
|
+
switch (i.itemSize) {
|
|
1614
|
+
case 1:
|
|
1615
|
+
c = Te;
|
|
1616
|
+
break;
|
|
1617
|
+
case 2:
|
|
1618
|
+
case 3:
|
|
1619
|
+
default:
|
|
1620
|
+
c = ge;
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1625
|
+
const u = t.interpolation !== void 0 ? ft[t.interpolation] : Fe, l = this._getArrayFromAccessor(i);
|
|
1626
|
+
for (let f = 0, h = o.length; f < h; f++) {
|
|
1627
|
+
const p = new c(
|
|
1628
|
+
o[f] + "." + D[s.path],
|
|
1629
|
+
e.array,
|
|
1630
|
+
l,
|
|
1631
|
+
u
|
|
1632
|
+
);
|
|
1633
|
+
t.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(p), r.push(p);
|
|
1634
|
+
}
|
|
1635
|
+
return r;
|
|
1636
|
+
}
|
|
1637
|
+
_getArrayFromAccessor(n) {
|
|
1638
|
+
let e = n.array;
|
|
1639
|
+
if (n.normalized) {
|
|
1640
|
+
const i = fe(e.constructor), t = new Float32Array(e.length);
|
|
1641
|
+
for (let s = 0, r = e.length; s < r; s++)
|
|
1642
|
+
t[s] = e[s] * i;
|
|
1643
|
+
e = t;
|
|
1644
|
+
}
|
|
1645
|
+
return e;
|
|
1646
|
+
}
|
|
1647
|
+
_createCubicSplineTrackInterpolant(n) {
|
|
1648
|
+
n.createInterpolant = function(i) {
|
|
1649
|
+
const t = this instanceof xe ? dt : He;
|
|
1650
|
+
return new t(this.times, this.values, this.getValueSize() / 3, i);
|
|
1651
|
+
}, n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
function Et(d, n, e) {
|
|
1655
|
+
const i = n.attributes, t = new Pe();
|
|
1656
|
+
if (i.POSITION !== void 0) {
|
|
1657
|
+
const a = e.json.accessors[i.POSITION], o = a.min, c = a.max;
|
|
1658
|
+
if (o !== void 0 && c !== void 0) {
|
|
1659
|
+
if (t.set(
|
|
1660
|
+
new B(o[0], o[1], o[2]),
|
|
1661
|
+
new B(c[0], c[1], c[2])
|
|
1662
|
+
), a.normalized) {
|
|
1663
|
+
const u = fe(V[a.componentType]);
|
|
1664
|
+
t.min.multiplyScalar(u), t.max.multiplyScalar(u);
|
|
1665
|
+
}
|
|
1666
|
+
} else {
|
|
1667
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
} else
|
|
1671
|
+
return;
|
|
1672
|
+
const s = n.targets;
|
|
1673
|
+
if (s !== void 0) {
|
|
1674
|
+
const a = new B(), o = new B();
|
|
1675
|
+
for (let c = 0, u = s.length; c < u; c++) {
|
|
1676
|
+
const l = s[c];
|
|
1677
|
+
if (l.POSITION !== void 0) {
|
|
1678
|
+
const f = e.json.accessors[l.POSITION], h = f.min, p = f.max;
|
|
1679
|
+
if (h !== void 0 && p !== void 0) {
|
|
1680
|
+
if (o.setX(Math.max(Math.abs(h[0]), Math.abs(p[0]))), o.setY(Math.max(Math.abs(h[1]), Math.abs(p[1]))), o.setZ(Math.max(Math.abs(h[2]), Math.abs(p[2]))), f.normalized) {
|
|
1681
|
+
const R = fe(V[f.componentType]);
|
|
1682
|
+
o.multiplyScalar(R);
|
|
1683
|
+
}
|
|
1684
|
+
a.max(o);
|
|
1685
|
+
} else
|
|
1686
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
t.expandByVector(a);
|
|
1690
|
+
}
|
|
1691
|
+
d.boundingBox = t;
|
|
1692
|
+
const r = new Dn();
|
|
1693
|
+
t.getCenter(r.center), r.radius = t.min.distanceTo(t.max) / 2, d.boundingSphere = r;
|
|
1694
|
+
}
|
|
1695
|
+
function we(d, n, e) {
|
|
1696
|
+
const i = n.attributes, t = [];
|
|
1697
|
+
function s(r, a) {
|
|
1698
|
+
return e.getDependency("accessor", r).then(function(o) {
|
|
1699
|
+
d.setAttribute(a, o);
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
for (const r in i) {
|
|
1703
|
+
const a = de[r] || r.toLowerCase();
|
|
1704
|
+
a in d.attributes || t.push(s(i[r], a));
|
|
1705
|
+
}
|
|
1706
|
+
if (n.indices !== void 0 && !d.index) {
|
|
1707
|
+
const r = e.getDependency("accessor", n.indices).then(function(a) {
|
|
1708
|
+
d.setIndex(a);
|
|
1709
|
+
});
|
|
1710
|
+
t.push(r);
|
|
1711
|
+
}
|
|
1712
|
+
return Re.workingColorSpace !== F && "COLOR_0" in i && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Re.workingColorSpace}" not supported.`), k(d, n), Et(d, n, e), Promise.all(t).then(function() {
|
|
1713
|
+
return n.targets !== void 0 ? pt(d, n.targets, e) : d;
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
function At() {
|
|
1717
|
+
const d = K(!1), n = K(""), e = je([]), i = K(null), t = new Qe(), s = new Ze(), r = new en(), a = new Gn();
|
|
1718
|
+
return {
|
|
1719
|
+
isLoading: d,
|
|
1720
|
+
loadingProgress: n,
|
|
1721
|
+
loadedModels: e,
|
|
1722
|
+
error: i,
|
|
1723
|
+
loadModelsFromBlobs: async (c) => {
|
|
1724
|
+
var h;
|
|
1725
|
+
if (!c || c.length === 0) {
|
|
1726
|
+
console.warn("loadModelsFromBlobs 加载的文件数组为空!");
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
d.value = !0, n.value = "准备加载...", e.value = [], i.value = null;
|
|
1730
|
+
const u = /* @__PURE__ */ new Map();
|
|
1731
|
+
c.forEach((p) => {
|
|
1732
|
+
p instanceof File && u.set(p.name.toLowerCase(), p);
|
|
1733
|
+
});
|
|
1734
|
+
const l = [], f = [];
|
|
1735
|
+
try {
|
|
1736
|
+
for (const p of c) {
|
|
1737
|
+
const R = p.name || "unknown_file", m = (h = R.split(".").pop()) == null ? void 0 : h.toLowerCase();
|
|
1738
|
+
if (m === "mtl") continue;
|
|
1739
|
+
const g = URL.createObjectURL(p);
|
|
1740
|
+
l.push(g);
|
|
1741
|
+
let A = null;
|
|
1742
|
+
const M = (T) => {
|
|
1743
|
+
const S = T.lengthComputable ? T.loaded / T.total * 100 : 0;
|
|
1744
|
+
n.value = `正在加载 ${R}... ${Math.round(S)}%`;
|
|
1745
|
+
};
|
|
1746
|
+
switch (n.value = `正在加载 ${R}... 0%`, m) {
|
|
1747
|
+
case "obj":
|
|
1748
|
+
const T = R.replace(/\.obj$/i, ".mtl").toLowerCase();
|
|
1749
|
+
if (u.has(T)) {
|
|
1750
|
+
const v = u.get(T), w = URL.createObjectURL(v);
|
|
1751
|
+
l.push(w);
|
|
1752
|
+
const P = await t.loadAsync(w);
|
|
1753
|
+
P.preload(), s.setMaterials(P);
|
|
1754
|
+
} else
|
|
1755
|
+
s.setMaterials(null);
|
|
1756
|
+
A = await s.loadAsync(g, M);
|
|
1757
|
+
break;
|
|
1758
|
+
case "stl":
|
|
1759
|
+
const S = await r.loadAsync(g, M), I = new Hn({ color: 11184810, specular: 1118481, shininess: 200 });
|
|
1760
|
+
A = new ke(S, I);
|
|
1761
|
+
break;
|
|
1762
|
+
case "gltf":
|
|
1763
|
+
case "glb":
|
|
1764
|
+
A = (await a.loadAsync(g, M)).scene;
|
|
1765
|
+
break;
|
|
1766
|
+
default:
|
|
1767
|
+
console.warn(`不支持的文件类型: .${m}`), n.value = `不支持的文件类型: ${R}`;
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
A && (A.userData.boundingBox = new Pe().setFromObject(A), f.push(A));
|
|
1771
|
+
}
|
|
1772
|
+
e.value = f, n.value = "加载完成!";
|
|
1773
|
+
} catch (p) {
|
|
1774
|
+
throw console.error("加载模型时出错:", p), i.value = `加载失败: ${p.message || "未知错误"}`, n.value = "加载失败!", e.value = [], p;
|
|
1775
|
+
} finally {
|
|
1776
|
+
d.value = !1, l.forEach((p) => URL.revokeObjectURL(p));
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
const Lt = { class: "obj-viewer-container" }, _t = { class: "buttonGroup-topLeft" }, Mt = { class: "buttonGroup-left" }, wt = { class: "left-panel" }, yt = { class: "panel-header" }, bt = {
|
|
1782
|
+
key: 0,
|
|
1783
|
+
class: "clipping-content"
|
|
1784
|
+
}, St = { class: "radio-group" }, Nt = { class: "radio-label" }, It = { class: "radio-label" }, Ct = { class: "radio-label" }, Ot = { class: "radio-label" }, vt = {
|
|
1785
|
+
key: 0,
|
|
1786
|
+
class: "loading-overlay"
|
|
1787
|
+
}, kt = /* @__PURE__ */ Be({
|
|
1788
|
+
__name: "threePreview",
|
|
1789
|
+
props: {
|
|
1790
|
+
fileBlobs: { default: () => [] }
|
|
1791
|
+
},
|
|
1792
|
+
setup(d) {
|
|
1793
|
+
const n = d, e = K(null), i = K(!1), t = K(""), {
|
|
1794
|
+
currentModels: s,
|
|
1795
|
+
resetView: r,
|
|
1796
|
+
initThreeJS: a,
|
|
1797
|
+
handleResize: o,
|
|
1798
|
+
getThreeJSObjects: c,
|
|
1799
|
+
cleanup: u,
|
|
1800
|
+
setModels: l,
|
|
1801
|
+
axesHelperVisible: f,
|
|
1802
|
+
toggleAxesVisibility: h
|
|
1803
|
+
} = Ye(e), {
|
|
1804
|
+
isLoading: p,
|
|
1805
|
+
loadingProgress: R,
|
|
1806
|
+
loadedModels: m,
|
|
1807
|
+
error: g,
|
|
1808
|
+
loadModelsFromBlobs: A
|
|
1809
|
+
} = At(), { isAnimating: M, toggleAnimation: T, stopAnimation: S } = $e(c, s), { isClipping: I, activeClippingAxis: L, toggleClipping: v, updateClippingPlanes: w } = Je(
|
|
1810
|
+
c,
|
|
1811
|
+
s
|
|
1812
|
+
), P = () => {
|
|
1813
|
+
h();
|
|
1814
|
+
};
|
|
1815
|
+
Z(() => n.fileBlobs, (N) => {
|
|
1816
|
+
N && N.length > 0 && A(N).catch((x) => {
|
|
1817
|
+
console.error("加载错误:", x);
|
|
1818
|
+
});
|
|
1819
|
+
}, {
|
|
1820
|
+
immediate: !0,
|
|
1821
|
+
deep: !0
|
|
1822
|
+
}), Z(m, (N) => {
|
|
1823
|
+
N && N.length > 0 && l(N);
|
|
1824
|
+
}), Z(g, (N) => {
|
|
1825
|
+
N && Ee.error(`模型加载失败: ${N}`);
|
|
1826
|
+
});
|
|
1827
|
+
const Ue = (N) => {
|
|
1828
|
+
i.value = !0, t.value = N, I.value || v();
|
|
1829
|
+
};
|
|
1830
|
+
return Ke(async () => {
|
|
1831
|
+
await Ve();
|
|
1832
|
+
try {
|
|
1833
|
+
a(), window.addEventListener("resize", o);
|
|
1834
|
+
} catch (N) {
|
|
1835
|
+
console.error("Three.js 初始化失败:", N), Ee.error("渲染引擎初始化失败!");
|
|
1836
|
+
}
|
|
1837
|
+
}), ze(() => {
|
|
1838
|
+
t.value = "", window.removeEventListener("resize", o), M.value && S(), u();
|
|
1839
|
+
}), (N, x) => {
|
|
1840
|
+
const Ge = Xe("el-scrollbar");
|
|
1841
|
+
return ne(), ee("div", Lt, [
|
|
1842
|
+
_("div", {
|
|
1843
|
+
ref_key: "threejsContainer",
|
|
1844
|
+
ref: e,
|
|
1845
|
+
class: "threejs-container"
|
|
1846
|
+
}, null, 512),
|
|
1847
|
+
x[15] || (x[15] = _("div", { class: "buttonGroup-top" }, null, -1)),
|
|
1848
|
+
_("div", _t, [
|
|
1849
|
+
H(j, {
|
|
1850
|
+
name: "viewReset",
|
|
1851
|
+
size: "24",
|
|
1852
|
+
onClick: y(r),
|
|
1853
|
+
title: "重置"
|
|
1854
|
+
}, null, 8, ["onClick"]),
|
|
1855
|
+
H(j, {
|
|
1856
|
+
name: "fangda",
|
|
1857
|
+
size: "24",
|
|
1858
|
+
title: "放大"
|
|
1859
|
+
}),
|
|
1860
|
+
H(j, {
|
|
1861
|
+
name: "suoxiao",
|
|
1862
|
+
size: "24",
|
|
1863
|
+
title: "缩小"
|
|
1864
|
+
}),
|
|
1865
|
+
H(j, {
|
|
1866
|
+
name: "lookAround",
|
|
1867
|
+
size: "24",
|
|
1868
|
+
onClick: y(T),
|
|
1869
|
+
title: y(M) ? "停止动画" : "动画视图"
|
|
1870
|
+
}, null, 8, ["onClick", "title"]),
|
|
1871
|
+
H(j, {
|
|
1872
|
+
name: "zuobiaoxi",
|
|
1873
|
+
size: "24",
|
|
1874
|
+
active: y(f),
|
|
1875
|
+
onClick: P,
|
|
1876
|
+
title: "显隐坐标轴"
|
|
1877
|
+
}, null, 8, ["active"])
|
|
1878
|
+
]),
|
|
1879
|
+
_("div", Mt, [
|
|
1880
|
+
H(j, {
|
|
1881
|
+
name: "clipping",
|
|
1882
|
+
size: "24",
|
|
1883
|
+
onClick: x[0] || (x[0] = (b) => Ue("剖面视图")),
|
|
1884
|
+
active: i.value && t.value === "剖面视图",
|
|
1885
|
+
title: "剖面视图"
|
|
1886
|
+
}, null, 8, ["active"])
|
|
1887
|
+
]),
|
|
1888
|
+
x[16] || (x[16] = _("div", { class: "buttonGroup-right" }, null, -1)),
|
|
1889
|
+
x[17] || (x[17] = _("div", { class: "buttonGroup-bottom" }, null, -1)),
|
|
1890
|
+
z(_("div", wt, [
|
|
1891
|
+
_("div", yt, [
|
|
1892
|
+
_("span", null, pe(t.value), 1),
|
|
1893
|
+
_("span", {
|
|
1894
|
+
class: "close",
|
|
1895
|
+
onClick: x[1] || (x[1] = (b) => i.value = !1)
|
|
1896
|
+
}, " X ")
|
|
1897
|
+
]),
|
|
1898
|
+
H(Ge, { "max-height": "650px" }, {
|
|
1899
|
+
default: qe(() => [
|
|
1900
|
+
t.value === "剖面视图" ? (ne(), ee("div", bt, [
|
|
1901
|
+
_("div", St, [
|
|
1902
|
+
_("label", Nt, [
|
|
1903
|
+
z(_("input", {
|
|
1904
|
+
type: "radio",
|
|
1905
|
+
name: "clipping-axis",
|
|
1906
|
+
value: "none",
|
|
1907
|
+
"onUpdate:modelValue": x[2] || (x[2] = (b) => $(L) ? L.value = b : null),
|
|
1908
|
+
onChange: x[3] || (x[3] = //@ts-ignore
|
|
1909
|
+
(...b) => y(w) && y(w)(...b))
|
|
1910
|
+
}, null, 544), [
|
|
1911
|
+
[J, y(L)]
|
|
1912
|
+
]),
|
|
1913
|
+
x[10] || (x[10] = _("span", { class: "radio-text" }, "无切割", -1))
|
|
1914
|
+
]),
|
|
1915
|
+
_("label", It, [
|
|
1916
|
+
z(_("input", {
|
|
1917
|
+
type: "radio",
|
|
1918
|
+
name: "clipping-axis",
|
|
1919
|
+
value: "x",
|
|
1920
|
+
"onUpdate:modelValue": x[4] || (x[4] = (b) => $(L) ? L.value = b : null),
|
|
1921
|
+
onChange: x[5] || (x[5] = //@ts-ignore
|
|
1922
|
+
(...b) => y(w) && y(w)(...b))
|
|
1923
|
+
}, null, 544), [
|
|
1924
|
+
[J, y(L)]
|
|
1925
|
+
]),
|
|
1926
|
+
x[11] || (x[11] = _("span", { class: "radio-text" }, "X轴切割", -1))
|
|
1927
|
+
]),
|
|
1928
|
+
_("label", Ct, [
|
|
1929
|
+
z(_("input", {
|
|
1930
|
+
type: "radio",
|
|
1931
|
+
name: "clipping-axis",
|
|
1932
|
+
value: "y",
|
|
1933
|
+
"onUpdate:modelValue": x[6] || (x[6] = (b) => $(L) ? L.value = b : null),
|
|
1934
|
+
onChange: x[7] || (x[7] = //@ts-ignore
|
|
1935
|
+
(...b) => y(w) && y(w)(...b))
|
|
1936
|
+
}, null, 544), [
|
|
1937
|
+
[J, y(L)]
|
|
1938
|
+
]),
|
|
1939
|
+
x[12] || (x[12] = _("span", { class: "radio-text" }, "Y轴切割", -1))
|
|
1940
|
+
]),
|
|
1941
|
+
_("label", Ot, [
|
|
1942
|
+
z(_("input", {
|
|
1943
|
+
type: "radio",
|
|
1944
|
+
name: "clipping-axis",
|
|
1945
|
+
value: "z",
|
|
1946
|
+
"onUpdate:modelValue": x[8] || (x[8] = (b) => $(L) ? L.value = b : null),
|
|
1947
|
+
onChange: x[9] || (x[9] = //@ts-ignore
|
|
1948
|
+
(...b) => y(w) && y(w)(...b))
|
|
1949
|
+
}, null, 544), [
|
|
1950
|
+
[J, y(L)]
|
|
1951
|
+
]),
|
|
1952
|
+
x[13] || (x[13] = _("span", { class: "radio-text" }, "Z轴切割", -1))
|
|
1953
|
+
])
|
|
1954
|
+
])
|
|
1955
|
+
])) : he("", !0)
|
|
1956
|
+
]),
|
|
1957
|
+
_: 1
|
|
1958
|
+
})
|
|
1959
|
+
], 512), [
|
|
1960
|
+
[We, i.value]
|
|
1961
|
+
]),
|
|
1962
|
+
y(p) ? (ne(), ee("div", vt, [
|
|
1963
|
+
x[14] || (x[14] = _("div", { class: "loading-spinner" }, null, -1)),
|
|
1964
|
+
_("p", null, pe(y(R)), 1)
|
|
1965
|
+
])) : he("", !0)
|
|
1966
|
+
]);
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
}), jt = /* @__PURE__ */ Un(kt, [["__scopeId", "data-v-cdd00cd0"]]);
|
|
1970
|
+
export {
|
|
1971
|
+
jt as default
|
|
1972
|
+
};
|