@roomle/web-sdk 3.6.0-alpha.2 → 3.6.0-alpha.3
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/lib/{BufferGeometry-BZdSmtHt.mjs → BufferGeometry-C1o0MiFL.mjs} +2 -2
- package/lib/{BufferGeometry-BZdSmtHt.mjs.map → BufferGeometry-C1o0MiFL.mjs.map} +1 -1
- package/lib/ConfiguratorKernel.js +2 -2
- package/lib/ConfiguratorKernel.wasm +0 -0
- package/lib/{GLTFExporter-DiE_HuI6.mjs → GLTFExporter-CXMBueJw.mjs} +510 -473
- package/lib/GLTFExporter-CXMBueJw.mjs.map +1 -0
- package/lib/{PointLightHelper-BvRpTX7D.mjs → PointLightHelper-ICWLqwjK.mjs} +3 -3
- package/lib/{PointLightHelper-BvRpTX7D.mjs.map → PointLightHelper-ICWLqwjK.mjs.map} +1 -1
- package/lib/RoomleCore.js +4 -4
- package/lib/RoomleCore.wasm +0 -0
- package/lib/RoomleToolsCore.wasm +0 -0
- package/lib/{SpotLightHelper-Byg39thi.mjs → SpotLightHelper-CW5lDGFp.mjs} +3 -3
- package/lib/{SpotLightHelper-Byg39thi.mjs.map → SpotLightHelper-CW5lDGFp.mjs.map} +1 -1
- package/lib/{USDZExporter-VBx9xybH.mjs → USDZExporter-CUp3dX08.mjs} +218 -211
- package/lib/USDZExporter-CUp3dX08.mjs.map +1 -0
- package/lib/asset-loader.worker.js +1 -1
- package/lib/{banana-for-scale-C9_AyZkI.mjs → banana-for-scale-CfQ8dnY2.mjs} +2 -2
- package/lib/{banana-for-scale-C9_AyZkI.mjs.map → banana-for-scale-CfQ8dnY2.mjs.map} +1 -1
- package/lib/component-dimensioning-C9AWhxvj.mjs +237 -0
- package/lib/component-dimensioning-C9AWhxvj.mjs.map +1 -0
- package/lib/{continuous-drawing-helper-BNHRsd4B.mjs → continuous-drawing-helper-B5BlbPPz.mjs} +2 -2
- package/lib/{continuous-drawing-helper-BNHRsd4B.mjs.map → continuous-drawing-helper-B5BlbPPz.mjs.map} +1 -1
- package/lib/{homag-intelligence-BraN723F.mjs → homag-intelligence-UFo9Z8FS.mjs} +42 -38
- package/lib/homag-intelligence-UFo9Z8FS.mjs.map +1 -0
- package/lib/{imos-ix-poc-export-helper-D7ubISCJ.mjs → imos-ix-poc-export-helper-CGSk-8yx.mjs} +2 -2
- package/lib/{imos-ix-poc-export-helper-D7ubISCJ.mjs.map → imos-ix-poc-export-helper-CGSk-8yx.mjs.map} +1 -1
- package/lib/{index-C-Prfui2.mjs → index-DIyMlQBA.mjs} +46178 -18733
- package/lib/index-DIyMlQBA.mjs.map +1 -0
- package/lib/{material-viewer-DyVGp6Xm.mjs → material-viewer-QTlidNBs.mjs} +7 -6
- package/lib/material-viewer-QTlidNBs.mjs.map +1 -0
- package/lib/roomle-sdk.d.ts +287 -132
- package/lib/roomle-sdk.js +29 -29
- package/lib/static/asset-loader.worker.js +1 -1
- package/lib/static/roomle-core-hsc/ConfiguratorKernel.js +2 -2
- package/lib/static/roomle-core-hsc/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleCore.js +4 -4
- package/lib/static/roomle-core-hsc/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleToolsCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/configurableObject.d.ts +2 -2
- package/lib/static/roomle-core-hsc/configurableObject.js +6 -6
- package/lib/static/roomle-core-hsc/configurableObject.js.map +1 -1
- package/lib/static/roomle-core-hsc/configurationLoader.js +1 -5
- package/lib/static/roomle-core-hsc/configurationLoader.js.map +1 -1
- package/lib/static/roomle-core-hsc/configurationManager.d.ts +1 -0
- package/lib/static/roomle-core-hsc/configurationManager.js +6 -0
- package/lib/static/roomle-core-hsc/configurationManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/configuratorCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/configuratorCoreInterface.d.ts +22 -29
- package/lib/static/roomle-core-hsc/embind/configuratorCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/embind/configuratorCoreInterface.d.ts +22 -29
- package/lib/static/roomle-core-hsc/embind/plannerCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.d.ts +1 -1
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.js.map +1 -1
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.d.ts +74 -81
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.js +1 -6
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.js.map +1 -1
- package/lib/static/roomle-core-hsc/loader/configurableObject.d.ts +2 -2
- package/lib/static/roomle-core-hsc/loader/configurableObject.js +6 -6
- package/lib/static/roomle-core-hsc/loader/configurableObject.js.map +1 -1
- package/lib/static/roomle-core-hsc/loader/configurationLoader.js +1 -5
- package/lib/static/roomle-core-hsc/loader/configurationLoader.js.map +1 -1
- package/lib/static/roomle-core-hsc/loader/configurationManager.d.ts +1 -0
- package/lib/static/roomle-core-hsc/loader/configurationManager.js +6 -0
- package/lib/static/roomle-core-hsc/loader/configurationManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/loader/planElementManager.d.ts +2 -2
- package/lib/static/roomle-core-hsc/loader/planElementManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/package.json +1 -1
- package/lib/static/roomle-core-hsc/planElementManager.d.ts +2 -2
- package/lib/static/roomle-core-hsc/planElementManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/plannerCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/plannerCoreCallback.d.ts +1 -1
- package/lib/static/roomle-core-hsc/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/plannerCoreCallback.js.map +1 -1
- package/lib/static/roomle-core-hsc/plannerCoreInterface.d.ts +74 -81
- package/lib/static/roomle-core-hsc/plannerCoreInterface.js +1 -6
- package/lib/static/roomle-core-hsc/plannerCoreInterface.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/embind/configuratorCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts +22 -29
- package/lib/static/roomle-core-hsc/src/embind/plannerCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.d.ts +1 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +74 -81
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.js +1 -6
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/loader/configurableObject.d.ts +2 -2
- package/lib/static/roomle-core-hsc/src/loader/configurableObject.js +6 -6
- package/lib/static/roomle-core-hsc/src/loader/configurableObject.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/loader/configurationLoader.js +1 -5
- package/lib/static/roomle-core-hsc/src/loader/configurationLoader.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/loader/configurationManager.d.ts +1 -0
- package/lib/static/roomle-core-hsc/src/loader/configurationManager.js +6 -0
- package/lib/static/roomle-core-hsc/src/loader/configurationManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/src/loader/planElementManager.d.ts +2 -2
- package/lib/static/roomle-core-hsc/src/loader/planElementManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/wasm_modern/ConfiguratorKernel.js +2 -2
- package/lib/static/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleCore.js +4 -4
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/{stats-helper-UQlUyOTj.mjs → stats-helper-cTITQsAT.mjs} +2 -2
- package/lib/{stats-helper-UQlUyOTj.mjs.map → stats-helper-cTITQsAT.mjs.map} +1 -1
- package/lib/{tools-core-wkPFRdnH.mjs → tools-core-CCWbo8fD.mjs} +2 -2
- package/lib/{tools-core-wkPFRdnH.mjs.map → tools-core-CCWbo8fD.mjs.map} +1 -1
- package/package.json +3 -3
- package/lib/GLTFExporter-DiE_HuI6.mjs.map +0 -1
- package/lib/USDZExporter-VBx9xybH.mjs.map +0 -1
- package/lib/component-dimensioning-DHTSa-If.mjs +0 -229
- package/lib/component-dimensioning-DHTSa-If.mjs.map +0 -1
- package/lib/homag-intelligence-BraN723F.mjs.map +0 -1
- package/lib/index-C-Prfui2.mjs.map +0 -1
- package/lib/material-viewer-DyVGp6Xm.mjs.map +0 -1
- package/lib/three.webgpu-sHJcp001.mjs +0 -27625
- package/lib/three.webgpu-sHJcp001.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as $,
|
|
2
|
-
const
|
|
1
|
+
import { f as $, aK as Z, as as z, aL as ee, ay as b, aM as se, aN as B, aO as te, aJ as ne, aP as H, aQ as ie, aR as re, j as oe, aS as D, aT as ae, aU as Y, aV as ce, aW as le, aX as ue, aY as he, aZ as fe, a_ as pe, a$ as de, b0 as xe, b1 as ye, b2 as ge, b3 as Te } from "./index-DIyMlQBA.mjs";
|
|
2
|
+
const K = {
|
|
3
3
|
POSITION: [
|
|
4
4
|
"byte",
|
|
5
5
|
"byte normalized",
|
|
@@ -27,35 +27,35 @@ const Y = {
|
|
|
27
27
|
"unsigned short"
|
|
28
28
|
]
|
|
29
29
|
};
|
|
30
|
-
class
|
|
30
|
+
class O {
|
|
31
31
|
/**
|
|
32
32
|
* Constructs a new glTF exporter.
|
|
33
33
|
*/
|
|
34
34
|
constructor() {
|
|
35
35
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
36
|
-
return new Le(e);
|
|
37
|
-
}), this.register(function(e) {
|
|
38
36
|
return new _e(e);
|
|
39
37
|
}), this.register(function(e) {
|
|
40
|
-
return new
|
|
38
|
+
return new be(e);
|
|
41
39
|
}), this.register(function(e) {
|
|
42
40
|
return new ve(e);
|
|
41
|
+
}), this.register(function(e) {
|
|
42
|
+
return new Oe(e);
|
|
43
43
|
}), this.register(function(e) {
|
|
44
44
|
return new ze(e);
|
|
45
45
|
}), this.register(function(e) {
|
|
46
46
|
return new De(e);
|
|
47
|
-
}), this.register(function(e) {
|
|
48
|
-
return new Ue(e);
|
|
49
47
|
}), this.register(function(e) {
|
|
50
48
|
return new Ce(e);
|
|
49
|
+
}), this.register(function(e) {
|
|
50
|
+
return new Ue(e);
|
|
51
51
|
}), this.register(function(e) {
|
|
52
52
|
return new Fe(e);
|
|
53
|
+
}), this.register(function(e) {
|
|
54
|
+
return new Pe(e);
|
|
53
55
|
}), this.register(function(e) {
|
|
54
56
|
return new Be(e);
|
|
55
57
|
}), this.register(function(e) {
|
|
56
58
|
return new Ge(e);
|
|
57
|
-
}), this.register(function(e) {
|
|
58
|
-
return new Pe(e);
|
|
59
59
|
}), this.register(function(e) {
|
|
60
60
|
return new ke(e);
|
|
61
61
|
}), this.register(function(e) {
|
|
@@ -102,11 +102,11 @@ class H {
|
|
|
102
102
|
* @param {GLTFExporter~OnError} onError - A callback function that is executed when an error happens.
|
|
103
103
|
* @param {GLTFExporter~Options} options - options
|
|
104
104
|
*/
|
|
105
|
-
parse(e, s,
|
|
106
|
-
const
|
|
105
|
+
parse(e, s, r, t) {
|
|
106
|
+
const n = new Le(), i = [];
|
|
107
107
|
for (let o = 0, c = this.pluginCallbacks.length; o < c; o++)
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
i.push(this.pluginCallbacks[o](n));
|
|
109
|
+
n.setPlugins(i), n.setTextureUtils(this.textureUtils), n.writeAsync(e, s, t).catch(r);
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Async version of {@link GLTFExporter#parse}.
|
|
@@ -116,13 +116,13 @@ class H {
|
|
|
116
116
|
* @return {Promise<ArrayBuffer|string>} A Promise that resolved with the exported glTF data.
|
|
117
117
|
*/
|
|
118
118
|
parseAsync(e, s) {
|
|
119
|
-
const
|
|
120
|
-
return new Promise(function(t,
|
|
121
|
-
|
|
119
|
+
const r = this;
|
|
120
|
+
return new Promise(function(t, n) {
|
|
121
|
+
r.parse(e, t, n, s);
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
const
|
|
125
|
+
const T = {
|
|
126
126
|
POINTS: 0,
|
|
127
127
|
LINES: 1,
|
|
128
128
|
LINE_LOOP: 2,
|
|
@@ -146,63 +146,63 @@ const g = {
|
|
|
146
146
|
CLAMP_TO_EDGE: 33071,
|
|
147
147
|
MIRRORED_REPEAT: 33648,
|
|
148
148
|
REPEAT: 10497
|
|
149
|
-
}, G = "KHR_mesh_quantization",
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const
|
|
149
|
+
}, G = "KHR_mesh_quantization", N = {};
|
|
150
|
+
N[le] = T.NEAREST;
|
|
151
|
+
N[ue] = T.NEAREST_MIPMAP_NEAREST;
|
|
152
|
+
N[he] = T.NEAREST_MIPMAP_LINEAR;
|
|
153
|
+
N[fe] = T.LINEAR;
|
|
154
|
+
N[pe] = T.LINEAR_MIPMAP_NEAREST;
|
|
155
|
+
N[de] = T.LINEAR_MIPMAP_LINEAR;
|
|
156
|
+
N[xe] = T.CLAMP_TO_EDGE;
|
|
157
|
+
N[ye] = T.REPEAT;
|
|
158
|
+
N[ge] = T.MIRRORED_REPEAT;
|
|
159
|
+
const W = {
|
|
160
160
|
scale: "scale",
|
|
161
161
|
position: "translation",
|
|
162
162
|
quaternion: "rotation",
|
|
163
163
|
morphTargetInfluences: "weights"
|
|
164
|
-
}, we = new $(), q = 12, me = 1179937895, Me = 2,
|
|
165
|
-
function
|
|
166
|
-
return a.length === e.length && a.every(function(s,
|
|
167
|
-
return s === e[
|
|
164
|
+
}, we = new $(), q = 12, me = 1179937895, Me = 2, X = 8, Ae = 1313821514, Ee = 5130562;
|
|
165
|
+
function L(a, e) {
|
|
166
|
+
return a.length === e.length && a.every(function(s, r) {
|
|
167
|
+
return s === e[r];
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
function Ie(a) {
|
|
171
171
|
return new TextEncoder().encode(a).buffer;
|
|
172
172
|
}
|
|
173
173
|
function Re(a) {
|
|
174
|
-
return
|
|
174
|
+
return L(a.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
const
|
|
176
|
+
function Ne(a, e, s) {
|
|
177
|
+
const r = {
|
|
178
178
|
min: new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
179
179
|
max: new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
180
180
|
};
|
|
181
181
|
for (let t = e; t < e + s; t++)
|
|
182
|
-
for (let
|
|
183
|
-
let
|
|
184
|
-
a.itemSize > 4 ?
|
|
182
|
+
for (let n = 0; n < a.itemSize; n++) {
|
|
183
|
+
let i;
|
|
184
|
+
a.itemSize > 4 ? i = a.array[t * a.itemSize + n] : (n === 0 ? i = a.getX(t) : n === 1 ? i = a.getY(t) : n === 2 ? i = a.getZ(t) : n === 3 && (i = a.getW(t)), a.normalized === !0 && (i = H.normalize(i, a.array))), r.min[n] = Math.min(r.min[n], i), r.max[n] = Math.max(r.max[n], i);
|
|
185
185
|
}
|
|
186
|
-
return
|
|
186
|
+
return r;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function j(a) {
|
|
189
189
|
return Math.ceil(a / 4) * 4;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
const s =
|
|
191
|
+
function k(a, e = 0) {
|
|
192
|
+
const s = j(a.byteLength);
|
|
193
193
|
if (s !== a.byteLength) {
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
194
|
+
const r = new Uint8Array(s);
|
|
195
|
+
if (r.set(new Uint8Array(a)), e !== 0)
|
|
196
196
|
for (let t = a.byteLength; t < s; t++)
|
|
197
|
-
|
|
198
|
-
return
|
|
197
|
+
r[t] = e;
|
|
198
|
+
return r.buffer;
|
|
199
199
|
}
|
|
200
200
|
return a;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function J() {
|
|
203
203
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Se(a, e) {
|
|
206
206
|
if (typeof OffscreenCanvas < "u" && a instanceof OffscreenCanvas) {
|
|
207
207
|
let s;
|
|
208
208
|
return e === "image/jpeg" ? s = 0.92 : e === "image/webp" && (s = 0.8), a.convertToBlob({
|
|
@@ -212,7 +212,7 @@ function Ne(a, e) {
|
|
|
212
212
|
} else
|
|
213
213
|
return new Promise((s) => a.toBlob(s, e));
|
|
214
214
|
}
|
|
215
|
-
class
|
|
215
|
+
class Le {
|
|
216
216
|
constructor() {
|
|
217
217
|
this.plugins = [], this.options = {}, this.pending = [], this.buffers = [], this.byteOffset = 0, this.buffers = [], this.nodeMap = /* @__PURE__ */ new Map(), this.skins = [], this.extensionsUsed = {}, this.extensionsRequired = {}, this.uids = /* @__PURE__ */ new Map(), this.uid = 0, this.json = {
|
|
218
218
|
asset: {
|
|
@@ -241,7 +241,7 @@ class Se {
|
|
|
241
241
|
* @param {Function} onDone Callback on completed
|
|
242
242
|
* @param {Object} options options
|
|
243
243
|
*/
|
|
244
|
-
async writeAsync(e, s,
|
|
244
|
+
async writeAsync(e, s, r = {}) {
|
|
245
245
|
this.options = Object.assign({
|
|
246
246
|
// default options
|
|
247
247
|
binary: !1,
|
|
@@ -250,40 +250,40 @@ class Se {
|
|
|
250
250
|
maxTextureSize: 1 / 0,
|
|
251
251
|
animations: [],
|
|
252
252
|
includeCustomExtensions: !1
|
|
253
|
-
},
|
|
254
|
-
const t = this,
|
|
255
|
-
|
|
256
|
-
const o = t.extensionsUsed, c = t.extensionsRequired,
|
|
257
|
-
if (
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
y,
|
|
271
|
-
x,
|
|
253
|
+
}, r), this.options.animations.length > 0 && (this.options.trs = !0), await this.processInputAsync(e), await Promise.all(this.pending);
|
|
254
|
+
const t = this, n = t.buffers, i = t.json;
|
|
255
|
+
r = t.options;
|
|
256
|
+
const o = t.extensionsUsed, c = t.extensionsRequired, u = new Blob(n, { type: "application/octet-stream" }), f = Object.keys(o), l = Object.keys(c);
|
|
257
|
+
if (f.length > 0 && (i.extensionsUsed = f), l.length > 0 && (i.extensionsRequired = l), i.buffers && i.buffers.length > 0 && (i.buffers[0].byteLength = u.size), r.binary === !0) {
|
|
258
|
+
const g = new FileReader();
|
|
259
|
+
g.readAsArrayBuffer(u), g.onloadend = function() {
|
|
260
|
+
const h = k(g.result), x = new DataView(new ArrayBuffer(X));
|
|
261
|
+
x.setUint32(0, h.byteLength, !0), x.setUint32(4, Ee, !0);
|
|
262
|
+
const p = k(Ie(JSON.stringify(i)), 32), d = new DataView(new ArrayBuffer(X));
|
|
263
|
+
d.setUint32(0, p.byteLength, !0), d.setUint32(4, Ae, !0);
|
|
264
|
+
const m = new ArrayBuffer(q), A = new DataView(m);
|
|
265
|
+
A.setUint32(0, me, !0), A.setUint32(4, Me, !0);
|
|
266
|
+
const _ = q + d.byteLength + p.byteLength + x.byteLength + h.byteLength;
|
|
267
|
+
A.setUint32(8, _, !0);
|
|
268
|
+
const y = new Blob([
|
|
269
|
+
m,
|
|
272
270
|
d,
|
|
273
|
-
|
|
271
|
+
p,
|
|
272
|
+
x,
|
|
273
|
+
h
|
|
274
274
|
], { type: "application/octet-stream" }), w = new FileReader();
|
|
275
|
-
w.readAsArrayBuffer(
|
|
275
|
+
w.readAsArrayBuffer(y), w.onloadend = function() {
|
|
276
276
|
s(w.result);
|
|
277
277
|
};
|
|
278
278
|
};
|
|
279
|
-
} else if (
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
279
|
+
} else if (i.buffers && i.buffers.length > 0) {
|
|
280
|
+
const g = new FileReader();
|
|
281
|
+
g.readAsDataURL(u), g.onloadend = function() {
|
|
282
|
+
const h = g.result;
|
|
283
|
+
i.buffers[0].uri = h, s(i);
|
|
284
284
|
};
|
|
285
285
|
} else
|
|
286
|
-
s(
|
|
286
|
+
s(i);
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* Serializes a userData.
|
|
@@ -293,18 +293,18 @@ class Se {
|
|
|
293
293
|
*/
|
|
294
294
|
serializeUserData(e, s) {
|
|
295
295
|
if (Object.keys(e.userData).length === 0) return;
|
|
296
|
-
const
|
|
296
|
+
const r = this.options, t = this.extensionsUsed;
|
|
297
297
|
try {
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
298
|
+
const n = JSON.parse(JSON.stringify(e.userData));
|
|
299
|
+
if (r.includeCustomExtensions && n.gltfExtensions) {
|
|
300
300
|
s.extensions === void 0 && (s.extensions = {});
|
|
301
|
-
for (const
|
|
302
|
-
s.extensions[
|
|
303
|
-
delete
|
|
301
|
+
for (const i in n.gltfExtensions)
|
|
302
|
+
s.extensions[i] = n.gltfExtensions[i], t[i] = !0;
|
|
303
|
+
delete n.gltfExtensions;
|
|
304
304
|
}
|
|
305
|
-
Object.keys(
|
|
306
|
-
} catch (
|
|
307
|
-
console.warn("THREE.GLTFExporter: userData of '" + e.name + "' won't be serialized because of JSON.stringify error - " +
|
|
305
|
+
Object.keys(n).length > 0 && (s.extras = n);
|
|
306
|
+
} catch (n) {
|
|
307
|
+
console.warn("THREE.GLTFExporter: userData of '" + e.name + "' won't be serialized because of JSON.stringify error - " + n.message);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
/**
|
|
@@ -329,9 +329,9 @@ class Se {
|
|
|
329
329
|
*/
|
|
330
330
|
isNormalizedNormalAttribute(e) {
|
|
331
331
|
if (this.cache.attributesNormalized.has(e)) return !1;
|
|
332
|
-
const
|
|
333
|
-
for (let t = 0,
|
|
334
|
-
if (Math.abs(
|
|
332
|
+
const r = new z();
|
|
333
|
+
for (let t = 0, n = e.count; t < n; t++)
|
|
334
|
+
if (Math.abs(r.fromBufferAttribute(e, t).length() - 1) > 5e-4) return !1;
|
|
335
335
|
return !0;
|
|
336
336
|
}
|
|
337
337
|
/**
|
|
@@ -344,10 +344,10 @@ class Se {
|
|
|
344
344
|
createNormalizedNormalAttribute(e) {
|
|
345
345
|
const s = this.cache;
|
|
346
346
|
if (s.attributesNormalized.has(e)) return s.attributesNormalized.get(e);
|
|
347
|
-
const
|
|
348
|
-
for (let
|
|
349
|
-
t.fromBufferAttribute(
|
|
350
|
-
return s.attributesNormalized.set(e,
|
|
347
|
+
const r = e.clone(), t = new z();
|
|
348
|
+
for (let n = 0, i = r.count; n < i; n++)
|
|
349
|
+
t.fromBufferAttribute(r, n), t.x === 0 && t.y === 0 && t.z === 0 ? t.setX(1) : t.normalize(), r.setXYZ(n, t.x, t.y, t.z);
|
|
350
|
+
return s.attributesNormalized.set(e, r), r;
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* Applies a texture transform, if present, to the map definition. Requires
|
|
@@ -357,42 +357,42 @@ class Se {
|
|
|
357
357
|
* @param {THREE.Texture} texture
|
|
358
358
|
*/
|
|
359
359
|
applyTextureTransform(e, s) {
|
|
360
|
-
let
|
|
360
|
+
let r = !1;
|
|
361
361
|
const t = {};
|
|
362
|
-
(s.offset.x !== 0 || s.offset.y !== 0) && (t.offset = s.offset.toArray(),
|
|
362
|
+
(s.offset.x !== 0 || s.offset.y !== 0) && (t.offset = s.offset.toArray(), r = !0), s.rotation !== 0 && (t.rotation = s.rotation, r = !0), (s.repeat.x !== 1 || s.repeat.y !== 1) && (t.scale = s.repeat.toArray(), r = !0), r && (e.extensions = e.extensions || {}, e.extensions.KHR_texture_transform = t, this.extensionsUsed.KHR_texture_transform = !0);
|
|
363
363
|
}
|
|
364
364
|
async buildMetalRoughTextureAsync(e, s) {
|
|
365
365
|
if (e === s) return e;
|
|
366
|
-
function
|
|
367
|
-
return
|
|
368
|
-
return
|
|
369
|
-
} : function(
|
|
370
|
-
return
|
|
366
|
+
function r(h) {
|
|
367
|
+
return h.colorSpace === ce ? function(p) {
|
|
368
|
+
return p < 0.04045 ? p * 0.0773993808 : Math.pow(p * 0.9478672986 + 0.0521327014, 2.4);
|
|
369
|
+
} : function(p) {
|
|
370
|
+
return p;
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
373
|
e instanceof B && (e = await this.decompressTextureAsync(e)), s instanceof B && (s = await this.decompressTextureAsync(s));
|
|
374
|
-
const t = e ? e.image : null,
|
|
375
|
-
c.width =
|
|
376
|
-
const
|
|
374
|
+
const t = e ? e.image : null, n = s ? s.image : null, i = Math.max(t ? t.width : 0, n ? n.width : 0), o = Math.max(t ? t.height : 0, n ? n.height : 0), c = J();
|
|
375
|
+
c.width = i, c.height = o;
|
|
376
|
+
const u = c.getContext("2d", {
|
|
377
377
|
willReadFrequently: !0
|
|
378
378
|
});
|
|
379
|
-
|
|
380
|
-
const
|
|
379
|
+
u.fillStyle = "#00ffff", u.fillRect(0, 0, i, o);
|
|
380
|
+
const f = u.getImageData(0, 0, i, o);
|
|
381
381
|
if (t) {
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
for (let
|
|
385
|
-
|
|
382
|
+
u.drawImage(t, 0, 0, i, o);
|
|
383
|
+
const h = r(e), x = u.getImageData(0, 0, i, o).data;
|
|
384
|
+
for (let p = 2; p < x.length; p += 4)
|
|
385
|
+
f.data[p] = h(x[p] / 256) * 256;
|
|
386
386
|
}
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
for (let
|
|
391
|
-
|
|
387
|
+
if (n) {
|
|
388
|
+
u.drawImage(n, 0, 0, i, o);
|
|
389
|
+
const h = r(s), x = u.getImageData(0, 0, i, o).data;
|
|
390
|
+
for (let p = 1; p < x.length; p += 4)
|
|
391
|
+
f.data[p] = h(x[p] / 256) * 256;
|
|
392
392
|
}
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
return
|
|
393
|
+
u.putImageData(f, 0, 0);
|
|
394
|
+
const g = (e || s).clone();
|
|
395
|
+
return g.source = new te(c), g.colorSpace = ne, g.channel = (e || s).channel, e && s && e.channel !== s.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), g;
|
|
396
396
|
}
|
|
397
397
|
async decompressTextureAsync(e, s = 1 / 0) {
|
|
398
398
|
if (this.textureUtils === null)
|
|
@@ -405,8 +405,8 @@ class Se {
|
|
|
405
405
|
* @return {0}
|
|
406
406
|
*/
|
|
407
407
|
processBuffer(e) {
|
|
408
|
-
const s = this.json,
|
|
409
|
-
return s.buffers || (s.buffers = [{ byteLength: 0 }]),
|
|
408
|
+
const s = this.json, r = this.buffers;
|
|
409
|
+
return s.buffers || (s.buffers = [{ byteLength: 0 }]), r.push(e), 0;
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
412
|
* Process and generate a BufferView
|
|
@@ -417,40 +417,40 @@ class Se {
|
|
|
417
417
|
* @param {number} [target] Target usage of the BufferView
|
|
418
418
|
* @return {Object}
|
|
419
419
|
*/
|
|
420
|
-
processBufferView(e, s,
|
|
421
|
-
const
|
|
422
|
-
|
|
420
|
+
processBufferView(e, s, r, t, n) {
|
|
421
|
+
const i = this.json;
|
|
422
|
+
i.bufferViews || (i.bufferViews = []);
|
|
423
423
|
let o;
|
|
424
424
|
switch (s) {
|
|
425
|
-
case
|
|
426
|
-
case
|
|
425
|
+
case T.BYTE:
|
|
426
|
+
case T.UNSIGNED_BYTE:
|
|
427
427
|
o = 1;
|
|
428
428
|
break;
|
|
429
|
-
case
|
|
430
|
-
case
|
|
429
|
+
case T.SHORT:
|
|
430
|
+
case T.UNSIGNED_SHORT:
|
|
431
431
|
o = 2;
|
|
432
432
|
break;
|
|
433
433
|
default:
|
|
434
434
|
o = 4;
|
|
435
435
|
}
|
|
436
436
|
let c = e.itemSize * o;
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
let
|
|
440
|
-
for (let
|
|
441
|
-
for (let
|
|
442
|
-
let
|
|
443
|
-
e.itemSize > 4 ?
|
|
437
|
+
n === T.ARRAY_BUFFER && (c = Math.ceil(c / 4) * 4);
|
|
438
|
+
const u = j(t * c), f = new DataView(new ArrayBuffer(u));
|
|
439
|
+
let l = 0;
|
|
440
|
+
for (let x = r; x < r + t; x++) {
|
|
441
|
+
for (let p = 0; p < e.itemSize; p++) {
|
|
442
|
+
let d;
|
|
443
|
+
e.itemSize > 4 ? d = e.array[x * e.itemSize + p] : (p === 0 ? d = e.getX(x) : p === 1 ? d = e.getY(x) : p === 2 ? d = e.getZ(x) : p === 3 && (d = e.getW(x)), e.normalized === !0 && (d = H.normalize(d, e.array))), s === T.FLOAT ? f.setFloat32(l, d, !0) : s === T.INT ? f.setInt32(l, d, !0) : s === T.UNSIGNED_INT ? f.setUint32(l, d, !0) : s === T.SHORT ? f.setInt16(l, d, !0) : s === T.UNSIGNED_SHORT ? f.setUint16(l, d, !0) : s === T.BYTE ? f.setInt8(l, d) : s === T.UNSIGNED_BYTE && f.setUint8(l, d), l += o;
|
|
444
444
|
}
|
|
445
|
-
|
|
445
|
+
l % c !== 0 && (l += c - l % c);
|
|
446
446
|
}
|
|
447
|
-
const
|
|
448
|
-
buffer: this.processBuffer(
|
|
447
|
+
const g = {
|
|
448
|
+
buffer: this.processBuffer(f.buffer),
|
|
449
449
|
byteOffset: this.byteOffset,
|
|
450
|
-
byteLength:
|
|
450
|
+
byteLength: u
|
|
451
451
|
};
|
|
452
|
-
return
|
|
453
|
-
id:
|
|
452
|
+
return n !== void 0 && (g.target = n), n === T.ARRAY_BUFFER && (g.byteStride = c), this.byteOffset += u, i.bufferViews.push(g), {
|
|
453
|
+
id: i.bufferViews.length - 1,
|
|
454
454
|
byteLength: 0
|
|
455
455
|
};
|
|
456
456
|
}
|
|
@@ -460,16 +460,16 @@ class Se {
|
|
|
460
460
|
* @return {Promise<number>} An integer
|
|
461
461
|
*/
|
|
462
462
|
processBufferViewImage(e) {
|
|
463
|
-
const s = this,
|
|
464
|
-
return
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
buffer: s.processBuffer(
|
|
463
|
+
const s = this, r = s.json;
|
|
464
|
+
return r.bufferViews || (r.bufferViews = []), new Promise(function(t) {
|
|
465
|
+
const n = new FileReader();
|
|
466
|
+
n.readAsArrayBuffer(e), n.onloadend = function() {
|
|
467
|
+
const i = k(n.result), o = {
|
|
468
|
+
buffer: s.processBuffer(i),
|
|
469
469
|
byteOffset: s.byteOffset,
|
|
470
|
-
byteLength:
|
|
470
|
+
byteLength: i.byteLength
|
|
471
471
|
};
|
|
472
|
-
s.byteOffset +=
|
|
472
|
+
s.byteOffset += i.byteLength, t(r.bufferViews.push(o) - 1);
|
|
473
473
|
};
|
|
474
474
|
});
|
|
475
475
|
}
|
|
@@ -481,8 +481,8 @@ class Se {
|
|
|
481
481
|
* @param {number} [count=Infinity]
|
|
482
482
|
* @return {?number} Index of the processed accessor on the "accessors" array
|
|
483
483
|
*/
|
|
484
|
-
processAccessor(e, s,
|
|
485
|
-
const
|
|
484
|
+
processAccessor(e, s, r, t) {
|
|
485
|
+
const n = this.json, i = {
|
|
486
486
|
1: "SCALAR",
|
|
487
487
|
2: "VEC2",
|
|
488
488
|
3: "VEC3",
|
|
@@ -492,35 +492,35 @@ class Se {
|
|
|
492
492
|
};
|
|
493
493
|
let o;
|
|
494
494
|
if (e.array.constructor === Float32Array)
|
|
495
|
-
o =
|
|
495
|
+
o = T.FLOAT;
|
|
496
496
|
else if (e.array.constructor === Int32Array)
|
|
497
|
-
o =
|
|
497
|
+
o = T.INT;
|
|
498
498
|
else if (e.array.constructor === Uint32Array)
|
|
499
|
-
o =
|
|
499
|
+
o = T.UNSIGNED_INT;
|
|
500
500
|
else if (e.array.constructor === Int16Array)
|
|
501
|
-
o =
|
|
501
|
+
o = T.SHORT;
|
|
502
502
|
else if (e.array.constructor === Uint16Array)
|
|
503
|
-
o =
|
|
503
|
+
o = T.UNSIGNED_SHORT;
|
|
504
504
|
else if (e.array.constructor === Int8Array)
|
|
505
|
-
o =
|
|
505
|
+
o = T.BYTE;
|
|
506
506
|
else if (e.array.constructor === Uint8Array)
|
|
507
|
-
o =
|
|
507
|
+
o = T.UNSIGNED_BYTE;
|
|
508
508
|
else
|
|
509
509
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + e.array.constructor.name);
|
|
510
|
-
if (
|
|
511
|
-
const c =
|
|
512
|
-
let
|
|
513
|
-
s !== void 0 && (
|
|
514
|
-
const
|
|
515
|
-
bufferView:
|
|
516
|
-
byteOffset:
|
|
510
|
+
if (r === void 0 && (r = 0), (t === void 0 || t === 1 / 0) && (t = e.count), t === 0) return null;
|
|
511
|
+
const c = Ne(e, r, t);
|
|
512
|
+
let u;
|
|
513
|
+
s !== void 0 && (u = e === s.index ? T.ELEMENT_ARRAY_BUFFER : T.ARRAY_BUFFER);
|
|
514
|
+
const f = this.processBufferView(e, o, r, t, u), l = {
|
|
515
|
+
bufferView: f.id,
|
|
516
|
+
byteOffset: f.byteOffset,
|
|
517
517
|
componentType: o,
|
|
518
518
|
count: t,
|
|
519
519
|
max: c.max,
|
|
520
520
|
min: c.min,
|
|
521
|
-
type:
|
|
521
|
+
type: i[e.itemSize]
|
|
522
522
|
};
|
|
523
|
-
return e.normalized === !0 && (
|
|
523
|
+
return e.normalized === !0 && (l.normalized = !0), n.accessors || (n.accessors = []), n.accessors.push(l) - 1;
|
|
524
524
|
}
|
|
525
525
|
/**
|
|
526
526
|
* Process image
|
|
@@ -530,35 +530,35 @@ class Se {
|
|
|
530
530
|
* @param {string} mimeType export format
|
|
531
531
|
* @return {number} Index of the processed texture in the "images" array
|
|
532
532
|
*/
|
|
533
|
-
processImage(e, s,
|
|
533
|
+
processImage(e, s, r, t = "image/png") {
|
|
534
534
|
if (e !== null) {
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
535
|
+
const n = this, i = n.cache, o = n.json, c = n.options, u = n.pending;
|
|
536
|
+
i.images.has(e) || i.images.set(e, {});
|
|
537
|
+
const f = i.images.get(e), l = t + ":flipY/" + r.toString();
|
|
538
|
+
if (f[l] !== void 0) return f[l];
|
|
539
539
|
o.images || (o.images = []);
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
const
|
|
540
|
+
const g = { mimeType: t }, h = J();
|
|
541
|
+
h.width = Math.min(e.width, c.maxTextureSize), h.height = Math.min(e.height, c.maxTextureSize);
|
|
542
|
+
const x = h.getContext("2d", {
|
|
543
543
|
willReadFrequently: !0
|
|
544
544
|
});
|
|
545
|
-
if (
|
|
545
|
+
if (r === !0 && (x.translate(0, h.height), x.scale(1, -1)), e.data !== void 0) {
|
|
546
546
|
s !== ie && console.error("GLTFExporter: Only RGBAFormat is supported.", s), (e.width > c.maxTextureSize || e.height > c.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", e);
|
|
547
|
-
const
|
|
548
|
-
for (let
|
|
549
|
-
|
|
550
|
-
|
|
547
|
+
const d = new Uint8ClampedArray(e.height * e.width * 4);
|
|
548
|
+
for (let m = 0; m < d.length; m += 4)
|
|
549
|
+
d[m + 0] = e.data[m + 0], d[m + 1] = e.data[m + 1], d[m + 2] = e.data[m + 2], d[m + 3] = e.data[m + 3];
|
|
550
|
+
x.putImageData(new ImageData(d, e.width, e.height), 0, 0);
|
|
551
551
|
} else if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas)
|
|
552
|
-
|
|
552
|
+
x.drawImage(e, 0, 0, h.width, h.height);
|
|
553
553
|
else
|
|
554
554
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
555
|
-
c.binary === !0 ?
|
|
556
|
-
|
|
557
|
-
|
|
555
|
+
c.binary === !0 ? u.push(
|
|
556
|
+
Se(h, t).then((d) => n.processBufferViewImage(d)).then((d) => {
|
|
557
|
+
g.bufferView = d;
|
|
558
558
|
})
|
|
559
|
-
) :
|
|
560
|
-
const
|
|
561
|
-
return
|
|
559
|
+
) : g.uri = re.getDataURL(h, t);
|
|
560
|
+
const p = o.images.push(g) - 1;
|
|
561
|
+
return f[l] = p, p;
|
|
562
562
|
} else
|
|
563
563
|
throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
|
|
564
564
|
}
|
|
@@ -570,13 +570,13 @@ class Se {
|
|
|
570
570
|
processSampler(e) {
|
|
571
571
|
const s = this.json;
|
|
572
572
|
s.samplers || (s.samplers = []);
|
|
573
|
-
const
|
|
574
|
-
magFilter:
|
|
575
|
-
minFilter:
|
|
576
|
-
wrapS:
|
|
577
|
-
wrapT:
|
|
573
|
+
const r = {
|
|
574
|
+
magFilter: N[e.magFilter],
|
|
575
|
+
minFilter: N[e.minFilter],
|
|
576
|
+
wrapS: N[e.wrapS],
|
|
577
|
+
wrapT: N[e.wrapT]
|
|
578
578
|
};
|
|
579
|
-
return s.samplers.push(
|
|
579
|
+
return s.samplers.push(r) - 1;
|
|
580
580
|
}
|
|
581
581
|
/**
|
|
582
582
|
* Process texture
|
|
@@ -584,19 +584,19 @@ class Se {
|
|
|
584
584
|
* @return {Promise<number>} Index of the processed texture in the "textures" array
|
|
585
585
|
*/
|
|
586
586
|
async processTextureAsync(e) {
|
|
587
|
-
const
|
|
587
|
+
const r = this.options, t = this.cache, n = this.json;
|
|
588
588
|
if (t.textures.has(e)) return t.textures.get(e);
|
|
589
|
-
|
|
590
|
-
let
|
|
591
|
-
|
|
589
|
+
n.textures || (n.textures = []), e instanceof B && (e = await this.decompressTextureAsync(e, r.maxTextureSize));
|
|
590
|
+
let i = e.userData.mimeType;
|
|
591
|
+
i === "image/webp" && (i = "image/png");
|
|
592
592
|
const o = {
|
|
593
593
|
sampler: this.processSampler(e),
|
|
594
|
-
source: this.processImage(e.image, e.format, e.flipY,
|
|
594
|
+
source: this.processImage(e.image, e.format, e.flipY, i)
|
|
595
595
|
};
|
|
596
|
-
e.name && (o.name = e.name), await this._invokeAllAsync(async function(
|
|
597
|
-
|
|
596
|
+
e.name && (o.name = e.name), await this._invokeAllAsync(async function(u) {
|
|
597
|
+
u.writeTexture && await u.writeTexture(e, o);
|
|
598
598
|
});
|
|
599
|
-
const c =
|
|
599
|
+
const c = n.textures.push(o) - 1;
|
|
600
600
|
return t.textures.set(e, c), c;
|
|
601
601
|
}
|
|
602
602
|
/**
|
|
@@ -605,15 +605,15 @@ class Se {
|
|
|
605
605
|
* @return {Promise<?number>} Index of the processed material in the "materials" array
|
|
606
606
|
*/
|
|
607
607
|
async processMaterialAsync(e) {
|
|
608
|
-
const s = this.cache,
|
|
608
|
+
const s = this.cache, r = this.json;
|
|
609
609
|
if (s.materials.has(e)) return s.materials.get(e);
|
|
610
610
|
if (e.isShaderMaterial)
|
|
611
611
|
return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."), null;
|
|
612
|
-
|
|
612
|
+
r.materials || (r.materials = []);
|
|
613
613
|
const t = { pbrMetallicRoughness: {} };
|
|
614
614
|
e.isMeshStandardMaterial !== !0 && e.isMeshBasicMaterial !== !0 && console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
615
|
+
const n = e.color.toArray().concat([e.opacity]);
|
|
616
|
+
if (L(n, [1, 1, 1, 1]) || (t.pbrMetallicRoughness.baseColorFactor = n), e.isMeshStandardMaterial ? (t.pbrMetallicRoughness.metallicFactor = e.metalness, t.pbrMetallicRoughness.roughnessFactor = e.roughness) : (t.pbrMetallicRoughness.metallicFactor = 0, t.pbrMetallicRoughness.roughnessFactor = 1), e.metalnessMap || e.roughnessMap) {
|
|
617
617
|
const o = await this.buildMetalRoughTextureAsync(e.metalnessMap, e.roughnessMap), c = {
|
|
618
618
|
index: await this.processTextureAsync(o),
|
|
619
619
|
texCoord: o.channel
|
|
@@ -630,11 +630,11 @@ class Se {
|
|
|
630
630
|
if (e.emissive) {
|
|
631
631
|
const o = e.emissive;
|
|
632
632
|
if (Math.max(o.r, o.g, o.b) > 0 && (t.emissiveFactor = e.emissive.toArray()), e.emissiveMap) {
|
|
633
|
-
const
|
|
633
|
+
const u = {
|
|
634
634
|
index: await this.processTextureAsync(e.emissiveMap),
|
|
635
635
|
texCoord: e.emissiveMap.channel
|
|
636
636
|
};
|
|
637
|
-
this.applyTextureTransform(
|
|
637
|
+
this.applyTextureTransform(u, e.emissiveMap), t.emissiveTexture = u;
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
640
|
if (e.normalMap) {
|
|
@@ -654,8 +654,8 @@ class Se {
|
|
|
654
654
|
e.transparent ? t.alphaMode = "BLEND" : e.alphaTest > 0 && (t.alphaMode = "MASK", t.alphaCutoff = e.alphaTest), e.side === oe && (t.doubleSided = !0), e.name !== "" && (t.name = e.name), this.serializeUserData(e, t), await this._invokeAllAsync(async function(o) {
|
|
655
655
|
o.writeMaterialAsync && await o.writeMaterialAsync(e, t);
|
|
656
656
|
});
|
|
657
|
-
const
|
|
658
|
-
return s.materials.set(e,
|
|
657
|
+
const i = r.materials.push(t) - 1;
|
|
658
|
+
return s.materials.set(e, i), i;
|
|
659
659
|
}
|
|
660
660
|
/**
|
|
661
661
|
* Process mesh
|
|
@@ -663,18 +663,18 @@ class Se {
|
|
|
663
663
|
* @return {Promise<?number>} Index of the processed mesh in the "meshes" array
|
|
664
664
|
*/
|
|
665
665
|
async processMeshAsync(e) {
|
|
666
|
-
const s = this.cache,
|
|
666
|
+
const s = this.cache, r = this.json, t = [e.geometry.uuid];
|
|
667
667
|
if (Array.isArray(e.material))
|
|
668
|
-
for (let
|
|
669
|
-
t.push(e.material[
|
|
668
|
+
for (let y = 0, w = e.material.length; y < w; y++)
|
|
669
|
+
t.push(e.material[y].uuid);
|
|
670
670
|
else
|
|
671
671
|
t.push(e.material.uuid);
|
|
672
|
-
const
|
|
673
|
-
if (s.meshes.has(
|
|
674
|
-
const
|
|
672
|
+
const n = t.join(":");
|
|
673
|
+
if (s.meshes.has(n)) return s.meshes.get(n);
|
|
674
|
+
const i = e.geometry;
|
|
675
675
|
let o;
|
|
676
|
-
e.isLineSegments ? o =
|
|
677
|
-
const c = {},
|
|
676
|
+
e.isLineSegments ? o = T.LINES : e.isLineLoop ? o = T.LINE_LOOP : e.isLine ? o = T.LINE_STRIP : e.isPoints ? o = T.POINTS : o = e.material.wireframe ? T.LINES : T.TRIANGLES;
|
|
677
|
+
const c = {}, u = {}, f = [], l = [], g = {
|
|
678
678
|
uv: "TEXCOORD_0",
|
|
679
679
|
uv1: "TEXCOORD_1",
|
|
680
680
|
uv2: "TEXCOORD_2",
|
|
@@ -682,79 +682,79 @@ class Se {
|
|
|
682
682
|
color: "COLOR_0",
|
|
683
683
|
skinWeight: "WEIGHTS_0",
|
|
684
684
|
skinIndex: "JOINTS_0"
|
|
685
|
-
},
|
|
686
|
-
|
|
687
|
-
let
|
|
688
|
-
for (let
|
|
689
|
-
if (
|
|
690
|
-
const w =
|
|
691
|
-
if (
|
|
692
|
-
|
|
685
|
+
}, h = i.getAttribute("normal");
|
|
686
|
+
h !== void 0 && !this.isNormalizedNormalAttribute(h) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), i.setAttribute("normal", this.createNormalizedNormalAttribute(h)));
|
|
687
|
+
let x = null;
|
|
688
|
+
for (let y in i.attributes) {
|
|
689
|
+
if (y.slice(0, 5) === "morph") continue;
|
|
690
|
+
const w = i.attributes[y];
|
|
691
|
+
if (y = g[y] || y.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(y) || (y = "_" + y), s.attributes.has(this.getUID(w))) {
|
|
692
|
+
u[y] = s.attributes.get(this.getUID(w));
|
|
693
693
|
continue;
|
|
694
694
|
}
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
695
|
+
x = null;
|
|
696
|
+
const M = w.array;
|
|
697
|
+
y === "JOINTS_0" && !(M instanceof Uint16Array) && !(M instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), x = O.Utils.toTypedBufferAttribute(w, Uint16Array)) : (M instanceof Uint32Array || M instanceof Int32Array) && !y.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${y}" converted to type FLOAT.`), x = O.Utils.toTypedBufferAttribute(w, Float32Array));
|
|
698
|
+
const R = this.processAccessor(x || w, i);
|
|
699
|
+
R !== null && (y.startsWith("_") || this.detectMeshQuantization(y, w), u[y] = R, s.attributes.set(this.getUID(w), R));
|
|
700
700
|
}
|
|
701
|
-
if (
|
|
701
|
+
if (h !== void 0 && i.setAttribute("normal", h), Object.keys(u).length === 0) return null;
|
|
702
702
|
if (e.morphTargetInfluences !== void 0 && e.morphTargetInfluences.length > 0) {
|
|
703
|
-
const
|
|
703
|
+
const y = [], w = [], E = {};
|
|
704
704
|
if (e.morphTargetDictionary !== void 0)
|
|
705
|
-
for (const
|
|
706
|
-
|
|
707
|
-
for (let
|
|
708
|
-
const
|
|
705
|
+
for (const M in e.morphTargetDictionary)
|
|
706
|
+
E[e.morphTargetDictionary[M]] = M;
|
|
707
|
+
for (let M = 0; M < e.morphTargetInfluences.length; ++M) {
|
|
708
|
+
const R = {};
|
|
709
709
|
let V = !1;
|
|
710
|
-
for (const
|
|
711
|
-
if (
|
|
710
|
+
for (const U in i.morphAttributes) {
|
|
711
|
+
if (U !== "position" && U !== "normal") {
|
|
712
712
|
V || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), V = !0);
|
|
713
713
|
continue;
|
|
714
714
|
}
|
|
715
|
-
const
|
|
716
|
-
if (s.attributes.has(this.getUID(
|
|
717
|
-
|
|
715
|
+
const S = i.morphAttributes[U][M], P = U.toUpperCase(), F = i.attributes[U];
|
|
716
|
+
if (s.attributes.has(this.getUID(S, !0))) {
|
|
717
|
+
R[P] = s.attributes.get(this.getUID(S, !0));
|
|
718
718
|
continue;
|
|
719
719
|
}
|
|
720
|
-
const
|
|
721
|
-
if (!
|
|
722
|
-
for (let
|
|
723
|
-
for (let
|
|
724
|
-
|
|
725
|
-
|
|
720
|
+
const v = S.clone();
|
|
721
|
+
if (!i.morphTargetsRelative)
|
|
722
|
+
for (let I = 0, Q = S.count; I < Q; I++)
|
|
723
|
+
for (let C = 0; C < S.itemSize; C++)
|
|
724
|
+
C === 0 && v.setX(I, S.getX(I) - F.getX(I)), C === 1 && v.setY(I, S.getY(I) - F.getY(I)), C === 2 && v.setZ(I, S.getZ(I) - F.getZ(I)), C === 3 && v.setW(I, S.getW(I) - F.getW(I));
|
|
725
|
+
R[P] = this.processAccessor(v, i), s.attributes.set(this.getUID(F, !0), R[P]);
|
|
726
726
|
}
|
|
727
|
-
|
|
727
|
+
l.push(R), y.push(e.morphTargetInfluences[M]), e.morphTargetDictionary !== void 0 && w.push(E[M]);
|
|
728
728
|
}
|
|
729
|
-
c.weights =
|
|
729
|
+
c.weights = y, w.length > 0 && (c.extras = {}, c.extras.targetNames = w);
|
|
730
730
|
}
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
733
|
-
let
|
|
734
|
-
if (
|
|
735
|
-
const
|
|
736
|
-
for (let w = 0,
|
|
737
|
-
|
|
738
|
-
|
|
731
|
+
const p = Array.isArray(e.material);
|
|
732
|
+
if (p && i.groups.length === 0) return null;
|
|
733
|
+
let d = !1;
|
|
734
|
+
if (p && i.index === null) {
|
|
735
|
+
const y = [];
|
|
736
|
+
for (let w = 0, E = i.attributes.position.count; w < E; w++)
|
|
737
|
+
y[w] = w;
|
|
738
|
+
i.setIndex(y), d = !0;
|
|
739
739
|
}
|
|
740
|
-
const
|
|
741
|
-
for (let
|
|
742
|
-
const
|
|
740
|
+
const m = p ? e.material : [e.material], A = p ? i.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
741
|
+
for (let y = 0, w = A.length; y < w; y++) {
|
|
742
|
+
const E = {
|
|
743
743
|
mode: o,
|
|
744
|
-
attributes:
|
|
744
|
+
attributes: u
|
|
745
745
|
};
|
|
746
|
-
if (this.serializeUserData(
|
|
747
|
-
let
|
|
748
|
-
(
|
|
746
|
+
if (this.serializeUserData(i, E), l.length > 0 && (E.targets = l), i.index !== null) {
|
|
747
|
+
let R = this.getUID(i.index);
|
|
748
|
+
(A[y].start !== void 0 || A[y].count !== void 0) && (R += ":" + A[y].start + ":" + A[y].count), s.attributes.has(R) ? E.indices = s.attributes.get(R) : (E.indices = this.processAccessor(i.index, i, A[y].start, A[y].count), s.attributes.set(R, E.indices)), E.indices === null && delete E.indices;
|
|
749
749
|
}
|
|
750
|
-
const
|
|
751
|
-
|
|
750
|
+
const M = await this.processMaterialAsync(m[A[y].materialIndex]);
|
|
751
|
+
M !== null && (E.material = M), f.push(E);
|
|
752
752
|
}
|
|
753
|
-
|
|
754
|
-
|
|
753
|
+
d === !0 && i.setIndex(null), c.primitives = f, r.meshes || (r.meshes = []), await this._invokeAllAsync(function(y) {
|
|
754
|
+
y.writeMesh && y.writeMesh(e, c);
|
|
755
755
|
});
|
|
756
|
-
const
|
|
757
|
-
return s.meshes.set(
|
|
756
|
+
const _ = r.meshes.push(c) - 1;
|
|
757
|
+
return s.meshes.set(n, _), _;
|
|
758
758
|
}
|
|
759
759
|
/**
|
|
760
760
|
* If a vertex attribute with a
|
|
@@ -769,26 +769,26 @@ class Se {
|
|
|
769
769
|
*/
|
|
770
770
|
detectMeshQuantization(e, s) {
|
|
771
771
|
if (this.extensionsUsed[G]) return;
|
|
772
|
-
let
|
|
772
|
+
let r;
|
|
773
773
|
switch (s.array.constructor) {
|
|
774
774
|
case Int8Array:
|
|
775
|
-
|
|
775
|
+
r = "byte";
|
|
776
776
|
break;
|
|
777
777
|
case Uint8Array:
|
|
778
|
-
|
|
778
|
+
r = "unsigned byte";
|
|
779
779
|
break;
|
|
780
780
|
case Int16Array:
|
|
781
|
-
|
|
781
|
+
r = "short";
|
|
782
782
|
break;
|
|
783
783
|
case Uint16Array:
|
|
784
|
-
|
|
784
|
+
r = "unsigned short";
|
|
785
785
|
break;
|
|
786
786
|
default:
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
|
-
s.normalized && (
|
|
789
|
+
s.normalized && (r += " normalized");
|
|
790
790
|
const t = e.split("_", 1)[0];
|
|
791
|
-
|
|
791
|
+
K[t] && K[t].includes(r) && (this.extensionsUsed[G] = !0, this.extensionsRequired[G] = !0);
|
|
792
792
|
}
|
|
793
793
|
/**
|
|
794
794
|
* Process camera
|
|
@@ -798,17 +798,17 @@ class Se {
|
|
|
798
798
|
processCamera(e) {
|
|
799
799
|
const s = this.json;
|
|
800
800
|
s.cameras || (s.cameras = []);
|
|
801
|
-
const
|
|
802
|
-
type:
|
|
801
|
+
const r = e.isOrthographicCamera, t = {
|
|
802
|
+
type: r ? "orthographic" : "perspective"
|
|
803
803
|
};
|
|
804
|
-
return
|
|
804
|
+
return r ? t.orthographic = {
|
|
805
805
|
xmag: e.right * 2,
|
|
806
806
|
ymag: e.top * 2,
|
|
807
807
|
zfar: e.far <= 0 ? 1e-3 : e.far,
|
|
808
808
|
znear: e.near < 0 ? 0 : e.near
|
|
809
809
|
} : t.perspective = {
|
|
810
810
|
aspectRatio: e.aspect,
|
|
811
|
-
yfov:
|
|
811
|
+
yfov: H.degToRad(e.fov),
|
|
812
812
|
zfar: e.far <= 0 ? 1e-3 : e.far,
|
|
813
813
|
znear: e.near < 0 ? 0 : e.near
|
|
814
814
|
}, e.name !== "" && (t.name = e.type), s.cameras.push(t) - 1;
|
|
@@ -824,56 +824,56 @@ class Se {
|
|
|
824
824
|
* @return {?number}
|
|
825
825
|
*/
|
|
826
826
|
processAnimation(e, s) {
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
for (let
|
|
831
|
-
const
|
|
832
|
-
let
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
835
|
-
console.warn('THREE.GLTFExporter: Could not export animation track "%s".',
|
|
827
|
+
const r = this.json, t = this.nodeMap;
|
|
828
|
+
r.animations || (r.animations = []), e = O.Utils.mergeMorphTargetTracks(e.clone(), s);
|
|
829
|
+
const n = e.tracks, i = [], o = [];
|
|
830
|
+
for (let u = 0; u < n.length; ++u) {
|
|
831
|
+
const f = n[u], l = D.parseTrackName(f.name);
|
|
832
|
+
let g = D.findNode(s, l.nodeName);
|
|
833
|
+
const h = W[l.propertyName];
|
|
834
|
+
if (l.objectName === "bones" && (g.isSkinnedMesh === !0 ? g = g.skeleton.getBoneByName(l.objectIndex) : g = void 0), !g || !h) {
|
|
835
|
+
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', f.name);
|
|
836
836
|
continue;
|
|
837
837
|
}
|
|
838
|
-
const
|
|
839
|
-
let
|
|
840
|
-
|
|
841
|
-
let
|
|
842
|
-
|
|
843
|
-
input: this.processAccessor(new
|
|
844
|
-
output: this.processAccessor(new
|
|
845
|
-
interpolation:
|
|
846
|
-
}),
|
|
838
|
+
const x = 1;
|
|
839
|
+
let p = f.values.length / f.times.length;
|
|
840
|
+
h === W.morphTargetInfluences && (p /= g.morphTargetInfluences.length);
|
|
841
|
+
let d;
|
|
842
|
+
f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (d = "CUBICSPLINE", p /= 3) : f.getInterpolation() === ae ? d = "STEP" : d = "LINEAR", o.push({
|
|
843
|
+
input: this.processAccessor(new b(f.times, x)),
|
|
844
|
+
output: this.processAccessor(new b(f.values, p)),
|
|
845
|
+
interpolation: d
|
|
846
|
+
}), i.push({
|
|
847
847
|
sampler: o.length - 1,
|
|
848
848
|
target: {
|
|
849
|
-
node: t.get(
|
|
850
|
-
path:
|
|
849
|
+
node: t.get(g),
|
|
850
|
+
path: h
|
|
851
851
|
}
|
|
852
852
|
});
|
|
853
853
|
}
|
|
854
854
|
const c = {
|
|
855
|
-
name: e.name || "clip_" +
|
|
855
|
+
name: e.name || "clip_" + r.animations.length,
|
|
856
856
|
samplers: o,
|
|
857
|
-
channels:
|
|
857
|
+
channels: i
|
|
858
858
|
};
|
|
859
|
-
return this.serializeUserData(e, c),
|
|
859
|
+
return this.serializeUserData(e, c), r.animations.push(c), r.animations.length - 1;
|
|
860
860
|
}
|
|
861
861
|
/**
|
|
862
862
|
* @param {THREE.Object3D} object
|
|
863
863
|
* @return {?number}
|
|
864
864
|
*/
|
|
865
865
|
processSkin(e) {
|
|
866
|
-
const s = this.json,
|
|
866
|
+
const s = this.json, r = this.nodeMap, t = s.nodes[r.get(e)], n = e.skeleton;
|
|
867
|
+
if (n === void 0) return null;
|
|
868
|
+
const i = e.skeleton.bones[0];
|
|
867
869
|
if (i === void 0) return null;
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
for (let u = 0; u < i.bones.length; ++u)
|
|
872
|
-
o.push(n.get(i.bones[u])), l.copy(i.boneInverses[u]), l.multiply(e.bindMatrix).toArray(c, u * 16);
|
|
870
|
+
const o = [], c = new Float32Array(n.bones.length * 16), u = new Z();
|
|
871
|
+
for (let l = 0; l < n.bones.length; ++l)
|
|
872
|
+
o.push(r.get(n.bones[l])), u.copy(n.boneInverses[l]), u.multiply(e.bindMatrix).toArray(c, l * 16);
|
|
873
873
|
return s.skins === void 0 && (s.skins = []), s.skins.push({
|
|
874
|
-
inverseBindMatrices: this.processAccessor(new
|
|
874
|
+
inverseBindMatrices: this.processAccessor(new b(c, 16)),
|
|
875
875
|
joints: o,
|
|
876
|
-
skeleton:
|
|
876
|
+
skeleton: r.get(i)
|
|
877
877
|
}), t.skin = s.skins.length - 1;
|
|
878
878
|
}
|
|
879
879
|
/**
|
|
@@ -882,63 +882,100 @@ class Se {
|
|
|
882
882
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
883
883
|
*/
|
|
884
884
|
async processNodeAsync(e) {
|
|
885
|
-
const s = this.json,
|
|
886
|
-
s.nodes || (s.nodes = [])
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
885
|
+
const s = this.json, r = this.options, t = this.nodeMap;
|
|
886
|
+
if (s.nodes || (s.nodes = []), e.pivot !== null)
|
|
887
|
+
return await this._processNodeWithPivotAsync(e);
|
|
888
|
+
const n = {};
|
|
889
|
+
if (r.trs) {
|
|
890
|
+
const o = e.quaternion.toArray(), c = e.position.toArray(), u = e.scale.toArray();
|
|
891
|
+
L(o, [0, 0, 0, 1]) || (n.rotation = o), L(c, [0, 0, 0]) || (n.translation = c), L(u, [1, 1, 1]) || (n.scale = u);
|
|
891
892
|
} else
|
|
892
|
-
e.matrixAutoUpdate && e.updateMatrix(), Re(e.matrix) === !1 && (
|
|
893
|
-
if (e.name !== "" && (
|
|
893
|
+
e.matrixAutoUpdate && e.updateMatrix(), Re(e.matrix) === !1 && (n.matrix = e.matrix.elements);
|
|
894
|
+
if (e.name !== "" && (n.name = String(e.name)), this.serializeUserData(e, n), e.isMesh || e.isLine || e.isPoints) {
|
|
894
895
|
const o = await this.processMeshAsync(e);
|
|
895
|
-
o !== null && (
|
|
896
|
-
} else e.isCamera && (
|
|
896
|
+
o !== null && (n.mesh = o);
|
|
897
|
+
} else e.isCamera && (n.camera = this.processCamera(e));
|
|
897
898
|
e.isSkinnedMesh && this.skins.push(e);
|
|
898
|
-
const
|
|
899
|
-
if (t.set(e,
|
|
899
|
+
const i = s.nodes.push(n) - 1;
|
|
900
|
+
if (t.set(e, i), e.children.length > 0) {
|
|
900
901
|
const o = [];
|
|
901
|
-
for (let c = 0,
|
|
902
|
-
const
|
|
903
|
-
if (
|
|
904
|
-
const
|
|
905
|
-
|
|
902
|
+
for (let c = 0, u = e.children.length; c < u; c++) {
|
|
903
|
+
const f = e.children[c];
|
|
904
|
+
if (f.visible || r.onlyVisible === !1) {
|
|
905
|
+
const l = await this.processNodeAsync(f);
|
|
906
|
+
l !== null && o.push(l);
|
|
906
907
|
}
|
|
907
908
|
}
|
|
908
|
-
o.length > 0 && (
|
|
909
|
+
o.length > 0 && (n.children = o);
|
|
909
910
|
}
|
|
910
911
|
return await this._invokeAllAsync(function(o) {
|
|
911
|
-
o.writeNode && o.writeNode(e,
|
|
912
|
-
}),
|
|
912
|
+
o.writeNode && o.writeNode(e, n);
|
|
913
|
+
}), i;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Process Object3D node with pivot using container approach
|
|
917
|
+
* @param {THREE.Object3D} object Object3D with pivot
|
|
918
|
+
* @return {Promise<number>} Index of the container node
|
|
919
|
+
*/
|
|
920
|
+
async _processNodeWithPivotAsync(e) {
|
|
921
|
+
const s = this.json, r = this.options, t = this.nodeMap, n = e.pivot, i = {}, o = e.quaternion.toArray(), c = [
|
|
922
|
+
e.position.x + n.x,
|
|
923
|
+
e.position.y + n.y,
|
|
924
|
+
e.position.z + n.z
|
|
925
|
+
], u = e.scale.toArray();
|
|
926
|
+
L(o, [0, 0, 0, 1]) || (i.rotation = o), L(c, [0, 0, 0]) || (i.translation = c), L(u, [1, 1, 1]) || (i.scale = u), i.extras = { pivot: n.toArray() }, e.name !== "" && (i.name = String(e.name)), this.serializeUserData(e, i);
|
|
927
|
+
const f = s.nodes.push(i) - 1;
|
|
928
|
+
t.set(e, f);
|
|
929
|
+
const l = {}, g = [-n.x, -n.y, -n.z];
|
|
930
|
+
if (L(g, [0, 0, 0]) || (l.translation = g), e.isMesh || e.isLine || e.isPoints) {
|
|
931
|
+
const p = await this.processMeshAsync(e);
|
|
932
|
+
p !== null && (l.mesh = p);
|
|
933
|
+
} else e.isCamera && (l.camera = this.processCamera(e));
|
|
934
|
+
e.isSkinnedMesh && this.skins.push(e);
|
|
935
|
+
const x = [s.nodes.push(l) - 1];
|
|
936
|
+
if (e.children.length > 0) {
|
|
937
|
+
const p = [];
|
|
938
|
+
for (let d = 0, m = e.children.length; d < m; d++) {
|
|
939
|
+
const A = e.children[d];
|
|
940
|
+
if (A.visible || r.onlyVisible === !1) {
|
|
941
|
+
const _ = await this.processNodeAsync(A);
|
|
942
|
+
_ !== null && p.push(_);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
p.length > 0 && (l.children = p);
|
|
946
|
+
}
|
|
947
|
+
return i.children = x, await this._invokeAllAsync(function(p) {
|
|
948
|
+
p.writeNode && p.writeNode(e, i);
|
|
949
|
+
}), f;
|
|
913
950
|
}
|
|
914
951
|
/**
|
|
915
952
|
* Process Scene
|
|
916
953
|
* @param {Scene} scene Scene to process
|
|
917
954
|
*/
|
|
918
955
|
async processSceneAsync(e) {
|
|
919
|
-
const s = this.json,
|
|
956
|
+
const s = this.json, r = this.options;
|
|
920
957
|
s.scenes || (s.scenes = [], s.scene = 0);
|
|
921
958
|
const t = {};
|
|
922
959
|
e.name !== "" && (t.name = e.name), s.scenes.push(t);
|
|
923
|
-
const
|
|
924
|
-
for (let
|
|
925
|
-
const c = e.children[
|
|
926
|
-
if (c.visible ||
|
|
927
|
-
const
|
|
928
|
-
|
|
960
|
+
const n = [];
|
|
961
|
+
for (let i = 0, o = e.children.length; i < o; i++) {
|
|
962
|
+
const c = e.children[i];
|
|
963
|
+
if (c.visible || r.onlyVisible === !1) {
|
|
964
|
+
const u = await this.processNodeAsync(c);
|
|
965
|
+
u !== null && n.push(u);
|
|
929
966
|
}
|
|
930
967
|
}
|
|
931
|
-
|
|
968
|
+
n.length > 0 && (t.nodes = n), this.serializeUserData(e, t);
|
|
932
969
|
}
|
|
933
970
|
/**
|
|
934
971
|
* Creates a Scene to hold a list of objects and parse it
|
|
935
972
|
* @param {Array<THREE.Object3D>} objects List of objects to process
|
|
936
973
|
*/
|
|
937
974
|
async processObjectsAsync(e) {
|
|
938
|
-
const s = new
|
|
975
|
+
const s = new Y();
|
|
939
976
|
s.name = "AuxScene";
|
|
940
|
-
for (let
|
|
941
|
-
s.children.push(e[
|
|
977
|
+
for (let r = 0; r < e.length; r++)
|
|
978
|
+
s.children.push(e[r]);
|
|
942
979
|
await this.processSceneAsync(s);
|
|
943
980
|
}
|
|
944
981
|
/**
|
|
@@ -949,10 +986,10 @@ class Se {
|
|
|
949
986
|
e = e instanceof Array ? e : [e], await this._invokeAllAsync(function(t) {
|
|
950
987
|
t.beforeParse && t.beforeParse(e);
|
|
951
988
|
});
|
|
952
|
-
const
|
|
989
|
+
const r = [];
|
|
953
990
|
for (let t = 0; t < e.length; t++)
|
|
954
|
-
e[t] instanceof
|
|
955
|
-
|
|
991
|
+
e[t] instanceof Y ? await this.processSceneAsync(e[t]) : r.push(e[t]);
|
|
992
|
+
r.length > 0 && await this.processObjectsAsync(r);
|
|
956
993
|
for (let t = 0; t < this.skins.length; ++t)
|
|
957
994
|
this.processSkin(this.skins[t]);
|
|
958
995
|
for (let t = 0; t < s.animations.length; ++t)
|
|
@@ -962,11 +999,11 @@ class Se {
|
|
|
962
999
|
});
|
|
963
1000
|
}
|
|
964
1001
|
async _invokeAllAsync(e) {
|
|
965
|
-
for (let s = 0,
|
|
1002
|
+
for (let s = 0, r = this.plugins.length; s < r; s++)
|
|
966
1003
|
await e(this.plugins[s]);
|
|
967
1004
|
}
|
|
968
1005
|
}
|
|
969
|
-
class
|
|
1006
|
+
class _e {
|
|
970
1007
|
constructor(e) {
|
|
971
1008
|
this.writer = e, this.name = "KHR_lights_punctual";
|
|
972
1009
|
}
|
|
@@ -976,13 +1013,13 @@ class Le {
|
|
|
976
1013
|
console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.", e);
|
|
977
1014
|
return;
|
|
978
1015
|
}
|
|
979
|
-
const
|
|
980
|
-
e.name && (
|
|
1016
|
+
const r = this.writer, t = r.json, n = r.extensionsUsed, i = {};
|
|
1017
|
+
e.name && (i.name = e.name), i.color = e.color.toArray(), i.intensity = e.intensity, e.isDirectionalLight ? i.type = "directional" : e.isPointLight ? (i.type = "point", e.distance > 0 && (i.range = e.distance)) : e.isSpotLight && (i.type = "spot", e.distance > 0 && (i.range = e.distance), i.spot = {}, i.spot.innerConeAngle = (1 - e.penumbra) * e.angle, i.spot.outerConeAngle = e.angle), e.decay !== void 0 && e.decay !== 2 && console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."), e.target && (e.target.parent !== e || e.target.position.x !== 0 || e.target.position.y !== 0 || e.target.position.z !== -1) && console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."), n[this.name] || (t.extensions = t.extensions || {}, t.extensions[this.name] = { lights: [] }, n[this.name] = !0);
|
|
981
1018
|
const o = t.extensions[this.name].lights;
|
|
982
|
-
o.push(
|
|
1019
|
+
o.push(i), s.extensions = s.extensions || {}, s.extensions[this.name] = { light: o.length - 1 };
|
|
983
1020
|
}
|
|
984
1021
|
}
|
|
985
|
-
class
|
|
1022
|
+
class be {
|
|
986
1023
|
constructor(e) {
|
|
987
1024
|
this.writer = e, this.name = "KHR_materials_unlit";
|
|
988
1025
|
}
|
|
@@ -992,45 +1029,45 @@ class _e {
|
|
|
992
1029
|
s.extensions = s.extensions || {}, s.extensions[this.name] = {}, t[this.name] = !0, s.pbrMetallicRoughness.metallicFactor = 0, s.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
993
1030
|
}
|
|
994
1031
|
}
|
|
995
|
-
class
|
|
1032
|
+
class Ce {
|
|
996
1033
|
constructor(e) {
|
|
997
1034
|
this.writer = e, this.name = "KHR_materials_clearcoat";
|
|
998
1035
|
}
|
|
999
1036
|
async writeMaterialAsync(e, s) {
|
|
1000
1037
|
if (!e.isMeshPhysicalMaterial || e.clearcoat === 0) return;
|
|
1001
|
-
const
|
|
1002
|
-
if (
|
|
1003
|
-
const
|
|
1004
|
-
index: await
|
|
1038
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1039
|
+
if (n.clearcoatFactor = e.clearcoat, e.clearcoatMap) {
|
|
1040
|
+
const i = {
|
|
1041
|
+
index: await r.processTextureAsync(e.clearcoatMap),
|
|
1005
1042
|
texCoord: e.clearcoatMap.channel
|
|
1006
1043
|
};
|
|
1007
|
-
|
|
1044
|
+
r.applyTextureTransform(i, e.clearcoatMap), n.clearcoatTexture = i;
|
|
1008
1045
|
}
|
|
1009
|
-
if (
|
|
1010
|
-
const
|
|
1011
|
-
index: await
|
|
1046
|
+
if (n.clearcoatRoughnessFactor = e.clearcoatRoughness, e.clearcoatRoughnessMap) {
|
|
1047
|
+
const i = {
|
|
1048
|
+
index: await r.processTextureAsync(e.clearcoatRoughnessMap),
|
|
1012
1049
|
texCoord: e.clearcoatRoughnessMap.channel
|
|
1013
1050
|
};
|
|
1014
|
-
|
|
1051
|
+
r.applyTextureTransform(i, e.clearcoatRoughnessMap), n.clearcoatRoughnessTexture = i;
|
|
1015
1052
|
}
|
|
1016
1053
|
if (e.clearcoatNormalMap) {
|
|
1017
|
-
const
|
|
1018
|
-
index: await
|
|
1054
|
+
const i = {
|
|
1055
|
+
index: await r.processTextureAsync(e.clearcoatNormalMap),
|
|
1019
1056
|
texCoord: e.clearcoatNormalMap.channel
|
|
1020
1057
|
};
|
|
1021
|
-
e.clearcoatNormalScale.x !== 1 && (
|
|
1058
|
+
e.clearcoatNormalScale.x !== 1 && (i.scale = e.clearcoatNormalScale.x), r.applyTextureTransform(i, e.clearcoatNormalMap), n.clearcoatNormalTexture = i;
|
|
1022
1059
|
}
|
|
1023
|
-
s.extensions = s.extensions || {}, s.extensions[this.name] =
|
|
1060
|
+
s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1024
1061
|
}
|
|
1025
1062
|
}
|
|
1026
|
-
class
|
|
1063
|
+
class Ue {
|
|
1027
1064
|
constructor(e) {
|
|
1028
1065
|
this.writer = e, this.name = "KHR_materials_dispersion";
|
|
1029
1066
|
}
|
|
1030
1067
|
async writeMaterialAsync(e, s) {
|
|
1031
1068
|
if (!e.isMeshPhysicalMaterial || e.dispersion === 0) return;
|
|
1032
|
-
const t = this.writer.extensionsUsed,
|
|
1033
|
-
|
|
1069
|
+
const t = this.writer.extensionsUsed, n = {};
|
|
1070
|
+
n.dispersion = e.dispersion, s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1034
1071
|
}
|
|
1035
1072
|
}
|
|
1036
1073
|
class Fe {
|
|
@@ -1039,56 +1076,56 @@ class Fe {
|
|
|
1039
1076
|
}
|
|
1040
1077
|
async writeMaterialAsync(e, s) {
|
|
1041
1078
|
if (!e.isMeshPhysicalMaterial || e.iridescence === 0) return;
|
|
1042
|
-
const
|
|
1043
|
-
if (
|
|
1044
|
-
const
|
|
1045
|
-
index: await
|
|
1079
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1080
|
+
if (n.iridescenceFactor = e.iridescence, e.iridescenceMap) {
|
|
1081
|
+
const i = {
|
|
1082
|
+
index: await r.processTextureAsync(e.iridescenceMap),
|
|
1046
1083
|
texCoord: e.iridescenceMap.channel
|
|
1047
1084
|
};
|
|
1048
|
-
|
|
1085
|
+
r.applyTextureTransform(i, e.iridescenceMap), n.iridescenceTexture = i;
|
|
1049
1086
|
}
|
|
1050
|
-
if (
|
|
1051
|
-
const
|
|
1052
|
-
index: await
|
|
1087
|
+
if (n.iridescenceIor = e.iridescenceIOR, n.iridescenceThicknessMinimum = e.iridescenceThicknessRange[0], n.iridescenceThicknessMaximum = e.iridescenceThicknessRange[1], e.iridescenceThicknessMap) {
|
|
1088
|
+
const i = {
|
|
1089
|
+
index: await r.processTextureAsync(e.iridescenceThicknessMap),
|
|
1053
1090
|
texCoord: e.iridescenceThicknessMap.channel
|
|
1054
1091
|
};
|
|
1055
|
-
|
|
1092
|
+
r.applyTextureTransform(i, e.iridescenceThicknessMap), n.iridescenceThicknessTexture = i;
|
|
1056
1093
|
}
|
|
1057
|
-
s.extensions = s.extensions || {}, s.extensions[this.name] =
|
|
1094
|
+
s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1058
1095
|
}
|
|
1059
1096
|
}
|
|
1060
|
-
class
|
|
1097
|
+
class ve {
|
|
1061
1098
|
constructor(e) {
|
|
1062
1099
|
this.writer = e, this.name = "KHR_materials_transmission";
|
|
1063
1100
|
}
|
|
1064
1101
|
async writeMaterialAsync(e, s) {
|
|
1065
1102
|
if (!e.isMeshPhysicalMaterial || e.transmission === 0) return;
|
|
1066
|
-
const
|
|
1067
|
-
if (
|
|
1068
|
-
const
|
|
1069
|
-
index: await
|
|
1103
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1104
|
+
if (n.transmissionFactor = e.transmission, e.transmissionMap) {
|
|
1105
|
+
const i = {
|
|
1106
|
+
index: await r.processTextureAsync(e.transmissionMap),
|
|
1070
1107
|
texCoord: e.transmissionMap.channel
|
|
1071
1108
|
};
|
|
1072
|
-
|
|
1109
|
+
r.applyTextureTransform(i, e.transmissionMap), n.transmissionTexture = i;
|
|
1073
1110
|
}
|
|
1074
|
-
s.extensions = s.extensions || {}, s.extensions[this.name] =
|
|
1111
|
+
s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1075
1112
|
}
|
|
1076
1113
|
}
|
|
1077
|
-
class
|
|
1114
|
+
class Oe {
|
|
1078
1115
|
constructor(e) {
|
|
1079
1116
|
this.writer = e, this.name = "KHR_materials_volume";
|
|
1080
1117
|
}
|
|
1081
1118
|
async writeMaterialAsync(e, s) {
|
|
1082
1119
|
if (!e.isMeshPhysicalMaterial || e.transmission === 0) return;
|
|
1083
|
-
const
|
|
1084
|
-
if (
|
|
1085
|
-
const
|
|
1086
|
-
index: await
|
|
1120
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1121
|
+
if (n.thicknessFactor = e.thickness, e.thicknessMap) {
|
|
1122
|
+
const i = {
|
|
1123
|
+
index: await r.processTextureAsync(e.thicknessMap),
|
|
1087
1124
|
texCoord: e.thicknessMap.channel
|
|
1088
1125
|
};
|
|
1089
|
-
|
|
1126
|
+
r.applyTextureTransform(i, e.thicknessMap), n.thicknessTexture = i;
|
|
1090
1127
|
}
|
|
1091
|
-
e.attenuationDistance !== 1 / 0 && (
|
|
1128
|
+
e.attenuationDistance !== 1 / 0 && (n.attenuationDistance = e.attenuationDistance), n.attenuationColor = e.attenuationColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1092
1129
|
}
|
|
1093
1130
|
}
|
|
1094
1131
|
class ze {
|
|
@@ -1097,8 +1134,8 @@ class ze {
|
|
|
1097
1134
|
}
|
|
1098
1135
|
async writeMaterialAsync(e, s) {
|
|
1099
1136
|
if (!e.isMeshPhysicalMaterial || e.ior === 1.5) return;
|
|
1100
|
-
const t = this.writer.extensionsUsed,
|
|
1101
|
-
|
|
1137
|
+
const t = this.writer.extensionsUsed, n = {};
|
|
1138
|
+
n.ior = e.ior, s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1102
1139
|
}
|
|
1103
1140
|
}
|
|
1104
1141
|
class De {
|
|
@@ -1107,70 +1144,70 @@ class De {
|
|
|
1107
1144
|
}
|
|
1108
1145
|
async writeMaterialAsync(e, s) {
|
|
1109
1146
|
if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(we) && !e.specularIntensityMap && !e.specularColorMap) return;
|
|
1110
|
-
const
|
|
1147
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1111
1148
|
if (e.specularIntensityMap) {
|
|
1112
|
-
const
|
|
1113
|
-
index: await
|
|
1149
|
+
const i = {
|
|
1150
|
+
index: await r.processTextureAsync(e.specularIntensityMap),
|
|
1114
1151
|
texCoord: e.specularIntensityMap.channel
|
|
1115
1152
|
};
|
|
1116
|
-
|
|
1153
|
+
r.applyTextureTransform(i, e.specularIntensityMap), n.specularTexture = i;
|
|
1117
1154
|
}
|
|
1118
1155
|
if (e.specularColorMap) {
|
|
1119
|
-
const
|
|
1120
|
-
index: await
|
|
1156
|
+
const i = {
|
|
1157
|
+
index: await r.processTextureAsync(e.specularColorMap),
|
|
1121
1158
|
texCoord: e.specularColorMap.channel
|
|
1122
1159
|
};
|
|
1123
|
-
|
|
1160
|
+
r.applyTextureTransform(i, e.specularColorMap), n.specularColorTexture = i;
|
|
1124
1161
|
}
|
|
1125
|
-
|
|
1162
|
+
n.specularFactor = e.specularIntensity, n.specularColorFactor = e.specularColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1126
1163
|
}
|
|
1127
1164
|
}
|
|
1128
|
-
class
|
|
1165
|
+
class Pe {
|
|
1129
1166
|
constructor(e) {
|
|
1130
1167
|
this.writer = e, this.name = "KHR_materials_sheen";
|
|
1131
1168
|
}
|
|
1132
1169
|
async writeMaterialAsync(e, s) {
|
|
1133
1170
|
if (!e.isMeshPhysicalMaterial || e.sheen == 0) return;
|
|
1134
|
-
const
|
|
1171
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1135
1172
|
if (e.sheenRoughnessMap) {
|
|
1136
|
-
const
|
|
1137
|
-
index: await
|
|
1173
|
+
const i = {
|
|
1174
|
+
index: await r.processTextureAsync(e.sheenRoughnessMap),
|
|
1138
1175
|
texCoord: e.sheenRoughnessMap.channel
|
|
1139
1176
|
};
|
|
1140
|
-
|
|
1177
|
+
r.applyTextureTransform(i, e.sheenRoughnessMap), n.sheenRoughnessTexture = i;
|
|
1141
1178
|
}
|
|
1142
1179
|
if (e.sheenColorMap) {
|
|
1143
|
-
const
|
|
1144
|
-
index: await
|
|
1180
|
+
const i = {
|
|
1181
|
+
index: await r.processTextureAsync(e.sheenColorMap),
|
|
1145
1182
|
texCoord: e.sheenColorMap.channel
|
|
1146
1183
|
};
|
|
1147
|
-
|
|
1184
|
+
r.applyTextureTransform(i, e.sheenColorMap), n.sheenColorTexture = i;
|
|
1148
1185
|
}
|
|
1149
|
-
|
|
1186
|
+
n.sheenRoughnessFactor = e.sheenRoughness, n.sheenColorFactor = e.sheenColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1150
1187
|
}
|
|
1151
1188
|
}
|
|
1152
|
-
class
|
|
1189
|
+
class Be {
|
|
1153
1190
|
constructor(e) {
|
|
1154
1191
|
this.writer = e, this.name = "KHR_materials_anisotropy";
|
|
1155
1192
|
}
|
|
1156
1193
|
async writeMaterialAsync(e, s) {
|
|
1157
1194
|
if (!e.isMeshPhysicalMaterial || e.anisotropy == 0) return;
|
|
1158
|
-
const
|
|
1195
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1159
1196
|
if (e.anisotropyMap) {
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1197
|
+
const i = { index: await r.processTextureAsync(e.anisotropyMap) };
|
|
1198
|
+
r.applyTextureTransform(i, e.anisotropyMap), n.anisotropyTexture = i;
|
|
1162
1199
|
}
|
|
1163
|
-
|
|
1200
|
+
n.anisotropyStrength = e.anisotropy, n.anisotropyRotation = e.anisotropyRotation, s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1164
1201
|
}
|
|
1165
1202
|
}
|
|
1166
|
-
class
|
|
1203
|
+
class Ge {
|
|
1167
1204
|
constructor(e) {
|
|
1168
1205
|
this.writer = e, this.name = "KHR_materials_emissive_strength";
|
|
1169
1206
|
}
|
|
1170
1207
|
async writeMaterialAsync(e, s) {
|
|
1171
1208
|
if (!e.isMeshStandardMaterial || e.emissiveIntensity === 1) return;
|
|
1172
|
-
const t = this.writer.extensionsUsed,
|
|
1173
|
-
|
|
1209
|
+
const t = this.writer.extensionsUsed, n = {};
|
|
1210
|
+
n.emissiveStrength = e.emissiveIntensity, s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1174
1211
|
}
|
|
1175
1212
|
}
|
|
1176
1213
|
class ke {
|
|
@@ -1179,15 +1216,15 @@ class ke {
|
|
|
1179
1216
|
}
|
|
1180
1217
|
async writeMaterialAsync(e, s) {
|
|
1181
1218
|
if (!e.isMeshStandardMaterial || e.bumpScale === 1 && !e.bumpMap) return;
|
|
1182
|
-
const
|
|
1219
|
+
const r = this.writer, t = r.extensionsUsed, n = {};
|
|
1183
1220
|
if (e.bumpMap) {
|
|
1184
|
-
const
|
|
1185
|
-
index: await
|
|
1221
|
+
const i = {
|
|
1222
|
+
index: await r.processTextureAsync(e.bumpMap),
|
|
1186
1223
|
texCoord: e.bumpMap.channel
|
|
1187
1224
|
};
|
|
1188
|
-
|
|
1225
|
+
r.applyTextureTransform(i, e.bumpMap), n.bumpTexture = i;
|
|
1189
1226
|
}
|
|
1190
|
-
|
|
1227
|
+
n.bumpFactor = e.bumpScale, s.extensions = s.extensions || {}, s.extensions[this.name] = n, t[this.name] = !0;
|
|
1191
1228
|
}
|
|
1192
1229
|
}
|
|
1193
1230
|
class He {
|
|
@@ -1196,91 +1233,91 @@ class He {
|
|
|
1196
1233
|
}
|
|
1197
1234
|
writeNode(e, s) {
|
|
1198
1235
|
if (!e.isInstancedMesh) return;
|
|
1199
|
-
const
|
|
1200
|
-
for (let
|
|
1201
|
-
t.getMatrixAt(
|
|
1202
|
-
const
|
|
1203
|
-
TRANSLATION:
|
|
1204
|
-
ROTATION:
|
|
1205
|
-
SCALE:
|
|
1236
|
+
const r = this.writer, t = e, n = new Float32Array(t.count * 3), i = new Float32Array(t.count * 4), o = new Float32Array(t.count * 3), c = new Z(), u = new z(), f = new ee(), l = new z();
|
|
1237
|
+
for (let h = 0; h < t.count; h++)
|
|
1238
|
+
t.getMatrixAt(h, c), c.decompose(u, f, l), u.toArray(n, h * 3), f.toArray(i, h * 4), l.toArray(o, h * 3);
|
|
1239
|
+
const g = {
|
|
1240
|
+
TRANSLATION: r.processAccessor(new b(n, 3)),
|
|
1241
|
+
ROTATION: r.processAccessor(new b(i, 4)),
|
|
1242
|
+
SCALE: r.processAccessor(new b(o, 3))
|
|
1206
1243
|
};
|
|
1207
|
-
t.instanceColor && (
|
|
1244
|
+
t.instanceColor && (g._COLOR_0 = r.processAccessor(t.instanceColor)), s.extensions = s.extensions || {}, s.extensions[this.name] = { attributes: g }, r.extensionsUsed[this.name] = !0, r.extensionsRequired[this.name] = !0;
|
|
1208
1245
|
}
|
|
1209
1246
|
}
|
|
1210
|
-
|
|
1247
|
+
O.Utils = {
|
|
1211
1248
|
insertKeyframe: function(a, e) {
|
|
1212
|
-
const
|
|
1249
|
+
const r = a.getValueSize(), t = new a.TimeBufferType(a.times.length + 1), n = new a.ValueBufferType(a.values.length + r), i = a.createInterpolant(new a.ValueBufferType(r));
|
|
1213
1250
|
let o;
|
|
1214
1251
|
if (a.times.length === 0) {
|
|
1215
1252
|
t[0] = e;
|
|
1216
|
-
for (let c = 0; c <
|
|
1217
|
-
|
|
1253
|
+
for (let c = 0; c < r; c++)
|
|
1254
|
+
n[c] = 0;
|
|
1218
1255
|
o = 0;
|
|
1219
1256
|
} else if (e < a.times[0]) {
|
|
1220
1257
|
if (Math.abs(a.times[0] - e) < 1e-3) return 0;
|
|
1221
|
-
t[0] = e, t.set(a.times, 1),
|
|
1258
|
+
t[0] = e, t.set(a.times, 1), n.set(i.evaluate(e), 0), n.set(a.values, r), o = 0;
|
|
1222
1259
|
} else if (e > a.times[a.times.length - 1]) {
|
|
1223
1260
|
if (Math.abs(a.times[a.times.length - 1] - e) < 1e-3)
|
|
1224
1261
|
return a.times.length - 1;
|
|
1225
|
-
t[t.length - 1] = e, t.set(a.times, 0),
|
|
1262
|
+
t[t.length - 1] = e, t.set(a.times, 0), n.set(a.values, 0), n.set(i.evaluate(e), a.values.length), o = t.length - 1;
|
|
1226
1263
|
} else
|
|
1227
1264
|
for (let c = 0; c < a.times.length; c++) {
|
|
1228
1265
|
if (Math.abs(a.times[c] - e) < 1e-3) return c;
|
|
1229
1266
|
if (a.times[c] < e && a.times[c + 1] > e) {
|
|
1230
|
-
t.set(a.times.slice(0, c + 1), 0), t[c + 1] = e, t.set(a.times.slice(c + 1), c + 2),
|
|
1267
|
+
t.set(a.times.slice(0, c + 1), 0), t[c + 1] = e, t.set(a.times.slice(c + 1), c + 2), n.set(a.values.slice(0, (c + 1) * r), 0), n.set(i.evaluate(e), (c + 1) * r), n.set(a.values.slice((c + 1) * r), (c + 2) * r), o = c + 1;
|
|
1231
1268
|
break;
|
|
1232
1269
|
}
|
|
1233
1270
|
}
|
|
1234
|
-
return a.times = t, a.values =
|
|
1271
|
+
return a.times = t, a.values = n, o;
|
|
1235
1272
|
},
|
|
1236
1273
|
mergeMorphTargetTracks: function(a, e) {
|
|
1237
|
-
const s = [],
|
|
1238
|
-
for (let
|
|
1239
|
-
let
|
|
1240
|
-
const o =
|
|
1274
|
+
const s = [], r = {}, t = a.tracks;
|
|
1275
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1276
|
+
let i = t[n];
|
|
1277
|
+
const o = D.parseTrackName(i.name), c = D.findNode(e, o.nodeName);
|
|
1241
1278
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
1242
|
-
s.push(
|
|
1279
|
+
s.push(i);
|
|
1243
1280
|
continue;
|
|
1244
1281
|
}
|
|
1245
|
-
if (
|
|
1246
|
-
if (
|
|
1282
|
+
if (i.createInterpolant !== i.InterpolantFactoryMethodDiscrete && i.createInterpolant !== i.InterpolantFactoryMethodLinear) {
|
|
1283
|
+
if (i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
1247
1284
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
1248
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),
|
|
1285
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), i = i.clone(), i.setInterpolation(Te);
|
|
1249
1286
|
}
|
|
1250
|
-
const
|
|
1251
|
-
if (
|
|
1287
|
+
const u = c.morphTargetInfluences.length, f = c.morphTargetDictionary[o.propertyIndex];
|
|
1288
|
+
if (f === void 0)
|
|
1252
1289
|
throw new Error("THREE.GLTFExporter: Morph target name not found: " + o.propertyIndex);
|
|
1253
|
-
let
|
|
1254
|
-
if (
|
|
1255
|
-
|
|
1256
|
-
const
|
|
1257
|
-
for (let
|
|
1258
|
-
|
|
1259
|
-
|
|
1290
|
+
let l;
|
|
1291
|
+
if (r[c.uuid] === void 0) {
|
|
1292
|
+
l = i.clone();
|
|
1293
|
+
const h = new l.ValueBufferType(u * l.times.length);
|
|
1294
|
+
for (let x = 0; x < l.times.length; x++)
|
|
1295
|
+
h[x * u + f] = l.values[x];
|
|
1296
|
+
l.name = (o.nodeName || "") + ".morphTargetInfluences", l.values = h, r[c.uuid] = l, s.push(l);
|
|
1260
1297
|
continue;
|
|
1261
1298
|
}
|
|
1262
|
-
const
|
|
1263
|
-
|
|
1264
|
-
for (let
|
|
1265
|
-
|
|
1266
|
-
for (let
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1299
|
+
const g = i.createInterpolant(new i.ValueBufferType(1));
|
|
1300
|
+
l = r[c.uuid];
|
|
1301
|
+
for (let h = 0; h < l.times.length; h++)
|
|
1302
|
+
l.values[h * u + f] = g.evaluate(l.times[h]);
|
|
1303
|
+
for (let h = 0; h < i.times.length; h++) {
|
|
1304
|
+
const x = this.insertKeyframe(l, i.times[h]);
|
|
1305
|
+
l.values[x * u + f] = i.values[h];
|
|
1269
1306
|
}
|
|
1270
1307
|
}
|
|
1271
1308
|
return a.tracks = s, a;
|
|
1272
1309
|
},
|
|
1273
|
-
|
|
1274
|
-
const
|
|
1310
|
+
toTypedBufferAttribute: function(a, e) {
|
|
1311
|
+
const s = new b(new e(a.count * a.itemSize), a.itemSize, !1);
|
|
1275
1312
|
if (!a.normalized && !a.isInterleavedBufferAttribute)
|
|
1276
|
-
return
|
|
1277
|
-
for (let
|
|
1278
|
-
for (let
|
|
1279
|
-
|
|
1280
|
-
return
|
|
1313
|
+
return s.array.set(a.array), s;
|
|
1314
|
+
for (let r = 0, t = a.count; r < t; r++)
|
|
1315
|
+
for (let n = 0; n < a.itemSize; n++)
|
|
1316
|
+
s.setComponent(r, n, a.getComponent(r, n));
|
|
1317
|
+
return s;
|
|
1281
1318
|
}
|
|
1282
1319
|
};
|
|
1283
1320
|
export {
|
|
1284
|
-
|
|
1321
|
+
O as GLTFExporter
|
|
1285
1322
|
};
|
|
1286
|
-
//# sourceMappingURL=GLTFExporter-
|
|
1323
|
+
//# sourceMappingURL=GLTFExporter-CXMBueJw.mjs.map
|