phoria2 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/charts.js +476 -459
- package/dist/charts.js.map +1 -1
- package/dist/core.js +1192 -963
- package/dist/core.js.map +1 -1
- package/dist/edit.js +75 -75
- package/dist/edit.js.map +1 -1
- package/dist/explain.js +1 -1
- package/dist/gltf.js +84 -84
- package/dist/gltf.js.map +1 -1
- package/dist/keyboard.js +188 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/motion.js +35 -35
- package/dist/motion.js.map +1 -1
- package/dist/particles.js +191 -118
- package/dist/particles.js.map +1 -1
- package/dist/passes.js +16 -16
- package/dist/passes.js.map +1 -1
- package/dist/phoria2.js +1 -1
- package/dist/picking.js +30 -14
- package/dist/picking.js.map +1 -1
- package/dist/snapshot.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/types/View.d.ts +11 -0
- package/dist/types/area.d.ts +18 -0
- package/dist/types/geometry/Geometry.d.ts +16 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/material/Material.d.ts +15 -0
- package/dist/types/material/Texture.d.ts +18 -2
- package/dist/types/particles/Emitter.d.ts +39 -2
- package/dist/types/scene/drawables.d.ts +23 -2
- package/dist/types/webgl/resources.d.ts +12 -2
- package/dist/types/webgl/shaders.d.ts +7 -2
- package/llms-full.txt +48 -1
- package/package.json +1 -1
- package/schema/scene.schema.json +48 -0
- package/src/View.js +16 -0
- package/src/area.js +131 -0
- package/src/charts/marks.js +29 -2
- package/src/geometry/Geometry.js +16 -1
- package/src/index.js +1 -0
- package/src/material/Material.js +9 -2
- package/src/material/Texture.js +55 -2
- package/src/particles/Emitter.js +121 -10
- package/src/scene/drawables.js +68 -4
- package/src/watch.js +8 -1
- package/src/webgl/WebGLRenderer.js +36 -5
- package/src/webgl/picking.js +22 -1
- package/src/webgl/resources.js +168 -14
- package/src/webgl/shaders.js +110 -11
package/dist/gltf.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as e, F as t, G as n, I as r, K as i, M as a,
|
|
1
|
+
import { $ as e, F as t, G as n, I as r, K as i, M as a, Mt as o, Tt as s, X as c, dt as l, et as u, ht as d, lt as f, ot as p, pt as m, rt as h, st as g, tt as _ } from "./core.js";
|
|
2
2
|
// src/gltf/Animation.js
|
|
3
3
|
var v = class {
|
|
4
4
|
name;
|
|
@@ -37,25 +37,25 @@ var v = class {
|
|
|
37
37
|
}
|
|
38
38
|
}, y = /* @__PURE__ */ new Float32Array(4);
|
|
39
39
|
function b(e, t) {
|
|
40
|
-
let { times: n, values: r, node: i, path: a, interpolation: o } = e, s = a === "quaternion" ? 4 : 3, c = o === "CUBICSPLINE", l = c ? s * 3 : s,
|
|
41
|
-
if (t <= n[0] ||
|
|
42
|
-
else if (t >= n[
|
|
40
|
+
let { times: n, values: r, node: i, path: a, interpolation: o } = e, s = a === "quaternion" ? 4 : 3, c = o === "CUBICSPLINE", l = c ? s * 3 : s, u = (e) => c ? e * l + s : e * l, f = n.length - 1, p = y;
|
|
41
|
+
if (t <= n[0] || f === 0) for (let e = 0; e < s; e++) p[e] = r[u(0) + e];
|
|
42
|
+
else if (t >= n[f]) for (let e = 0; e < s; e++) p[e] = r[u(f) + e];
|
|
43
43
|
else {
|
|
44
|
-
let e = 0, i =
|
|
44
|
+
let e = 0, i = f;
|
|
45
45
|
for (; i - e > 1;) {
|
|
46
46
|
let r = e + i >> 1;
|
|
47
47
|
n[r] <= t ? e = r : i = r;
|
|
48
48
|
}
|
|
49
49
|
let a = n[e], h = n[i] - a, g = h > 0 ? (t - a) / h : 0;
|
|
50
|
-
if (o === "STEP") for (let t = 0; t < s; t++)
|
|
50
|
+
if (o === "STEP") for (let t = 0; t < s; t++) p[t] = r[u(e) + t];
|
|
51
51
|
else if (c) {
|
|
52
|
-
let t = g * g, n = t * g, a = 2 * n - 3 * t + 1, o = n - 2 * t + g, c = -2 * n + 3 * t,
|
|
53
|
-
for (let e = 0; e < s; e++)
|
|
54
|
-
s === 4 &&
|
|
55
|
-
} else if (s === 4)
|
|
56
|
-
else for (let t = 0; t < 3; t++)
|
|
52
|
+
let t = g * g, n = t * g, a = 2 * n - 3 * t + 1, o = n - 2 * t + g, c = -2 * n + 3 * t, u = n - t, d = e * l, f = i * l;
|
|
53
|
+
for (let e = 0; e < s; e++) p[e] = a * r[d + s + e] + o * h * r[d + s * 2 + e] + c * r[f + s + e] + u * h * r[f + e];
|
|
54
|
+
s === 4 && m(p, p);
|
|
55
|
+
} else if (s === 4) d(p, r.subarray(e * 4, e * 4 + 4), r.subarray(i * 4, i * 4 + 4), g);
|
|
56
|
+
else for (let t = 0; t < 3; t++) p[t] = r[e * 3 + t] + (r[i * 3 + t] - r[e * 3 + t]) * g;
|
|
57
57
|
}
|
|
58
|
-
a === "quaternion" ? i.quaternion.set(
|
|
58
|
+
a === "quaternion" ? i.quaternion.set(p[0], p[1], p[2], p[3]) : i[a].set(p[0], p[1], p[2]);
|
|
59
59
|
}
|
|
60
60
|
// src/gltf/load.js
|
|
61
61
|
var x = /* @__PURE__ */ new Set([
|
|
@@ -100,18 +100,18 @@ var x = /* @__PURE__ */ new Set([
|
|
|
100
100
|
33071: "clamp",
|
|
101
101
|
33648: "mirror",
|
|
102
102
|
10497: "repeat"
|
|
103
|
-
}, D = class extends
|
|
103
|
+
}, D = class extends h {
|
|
104
104
|
static type = "model";
|
|
105
105
|
animations = [];
|
|
106
106
|
cameras = [];
|
|
107
107
|
get meshes() {
|
|
108
|
-
return this.findAll((e) => e instanceof
|
|
108
|
+
return this.findAll((e) => e instanceof c);
|
|
109
109
|
}
|
|
110
110
|
play(e = 0) {
|
|
111
111
|
let t = typeof e == "number" ? this.animations[e] : this.animations.find((t) => t.name === e);
|
|
112
112
|
if (!t) {
|
|
113
113
|
let t = this.animations.map((e) => `'${e.name}'`).join(", ");
|
|
114
|
-
return
|
|
114
|
+
return o(this, `no animation ${typeof e == "number" ? e : `'${e}'`} - this model has ${t || "none"}`), null;
|
|
115
115
|
}
|
|
116
116
|
return t.play();
|
|
117
117
|
}
|
|
@@ -124,9 +124,9 @@ var x = /* @__PURE__ */ new Set([
|
|
|
124
124
|
};
|
|
125
125
|
async function O(e, t = {}) {
|
|
126
126
|
let n = await fetch(e).catch((t) => {
|
|
127
|
-
throw new
|
|
127
|
+
throw new s(`loadGLTF: couldn't fetch '${e}' - ${t.message}`);
|
|
128
128
|
});
|
|
129
|
-
if (!n.ok) throw new
|
|
129
|
+
if (!n.ok) throw new s(`loadGLTF: couldn't fetch '${e}' (${n.status} ${n.statusText})`);
|
|
130
130
|
let r = t.baseUrl ?? new URL(e, globalThis.location?.href ?? "file:///").href;
|
|
131
131
|
return k(await n.arrayBuffer(), {
|
|
132
132
|
...t,
|
|
@@ -135,18 +135,18 @@ async function O(e, t = {}) {
|
|
|
135
135
|
}
|
|
136
136
|
async function k(e, t = {}) {
|
|
137
137
|
let { json: n, bin: r } = A(e), i = String(n.asset?.version ?? "");
|
|
138
|
-
if (!i.startsWith("2.")) throw new
|
|
138
|
+
if (!i.startsWith("2.")) throw new s(`loadGLTF: glTF ${i || "(no version)"} isn't supported - only glTF 2.0`);
|
|
139
139
|
for (let e of n.extensionsRequired ?? []) {
|
|
140
140
|
if (x.has(e)) continue;
|
|
141
141
|
let t = S.has(e) ? " - export the model without compression for now" : "";
|
|
142
|
-
throw new
|
|
142
|
+
throw new s(`loadGLTF: the model requires '${e}', which isn't supported${t}`);
|
|
143
143
|
}
|
|
144
144
|
let a = new D({ name: n.scenes?.[n.scene ?? 0]?.name ?? "model" });
|
|
145
|
-
for (let e of n.extensionsUsed ?? []) x.has(e) ||
|
|
146
|
-
let
|
|
147
|
-
await
|
|
148
|
-
let
|
|
149
|
-
return (t.waitForTextures ?? !0) && await
|
|
145
|
+
for (let e of n.extensionsUsed ?? []) x.has(e) || o(a, `the model uses '${e}', which isn't supported - it is ignored`);
|
|
146
|
+
let c = new j(n, r, t.baseUrl ?? "", a);
|
|
147
|
+
await c.buffers(), c.scene();
|
|
148
|
+
let l = c.textures();
|
|
149
|
+
return (t.waitForTextures ?? !0) && await l, a;
|
|
150
150
|
}
|
|
151
151
|
function A(e) {
|
|
152
152
|
if (typeof e == "string") return {
|
|
@@ -164,7 +164,7 @@ function A(e) {
|
|
|
164
164
|
let a = n.getUint32(i, !0), o = n.getUint32(i + 4, !0), s = t.subarray(i + 8, i + 8 + a);
|
|
165
165
|
o === 1313821514 ? e = JSON.parse(new TextDecoder().decode(s)) : o === 5130562 && (r = s), i += 8 + a;
|
|
166
166
|
}
|
|
167
|
-
if (!e) throw new
|
|
167
|
+
if (!e) throw new s("loadGLTF: the .glb file has no JSON chunk");
|
|
168
168
|
return {
|
|
169
169
|
json: e,
|
|
170
170
|
bin: r
|
|
@@ -195,18 +195,18 @@ var j = class {
|
|
|
195
195
|
async buffers() {
|
|
196
196
|
this.#e = await Promise.all((this.json.buffers ?? []).map(async (e, t) => {
|
|
197
197
|
if (e.uri === void 0) {
|
|
198
|
-
if (t !== 0 || !this.bin) throw new
|
|
198
|
+
if (t !== 0 || !this.bin) throw new s(`loadGLTF: buffer ${t} has no uri and there is no binary chunk`);
|
|
199
199
|
return this.bin;
|
|
200
200
|
}
|
|
201
201
|
let n = this.#o(e.uri), r = await fetch(n).catch((t) => {
|
|
202
|
-
throw new
|
|
202
|
+
throw new s(`loadGLTF: couldn't fetch buffer '${e.uri}' - ${t.message}`);
|
|
203
203
|
});
|
|
204
|
-
if (!r.ok) throw new
|
|
204
|
+
if (!r.ok) throw new s(`loadGLTF: couldn't fetch buffer '${e.uri}' (${r.status})`);
|
|
205
205
|
return new Uint8Array(await r.arrayBuffer());
|
|
206
206
|
}));
|
|
207
207
|
}
|
|
208
208
|
async textures() {
|
|
209
|
-
await Promise.all([...this.#t.values()].map((e) => e.ready.catch((e) =>
|
|
209
|
+
await Promise.all([...this.#t.values()].map((e) => e.ready.catch((e) => o(this.model, e.message))));
|
|
210
210
|
for (let e of this.#a) URL.revokeObjectURL(e);
|
|
211
211
|
}
|
|
212
212
|
scene() {
|
|
@@ -225,8 +225,8 @@ var j = class {
|
|
|
225
225
|
}
|
|
226
226
|
#s(e) {
|
|
227
227
|
let t = this.json.nodes[e], n = t.name ?? `node ${e}`;
|
|
228
|
-
t.skin !== void 0 &&
|
|
229
|
-
let r = t.mesh === void 0 ? [] : this.#c(t.mesh), i = r.length === 1 ? r[0] : new
|
|
228
|
+
t.skin !== void 0 && o(this.model, `skinned meshes aren't supported - '${n}' is drawn in its bind pose`), (t.weights || t.mesh !== void 0 && this.json.meshes[t.mesh].weights) && o(this.model, "morph targets aren't supported - meshes are drawn without them");
|
|
229
|
+
let r = t.mesh === void 0 ? [] : this.#c(t.mesh), i = r.length === 1 ? r[0] : new h();
|
|
230
230
|
for (let e of r.length > 1 ? r : []) i.add(e);
|
|
231
231
|
if (i.name = n, t.matrix ? M(i, t.matrix) : (t.translation && i.position.set(t.translation[0], t.translation[1], t.translation[2]), t.rotation && i.quaternion.set(t.rotation[0], t.rotation[1], t.rotation[2], t.rotation[3]), t.scale && i.scale.set(t.scale[0], t.scale[1], t.scale[2])), t.camera !== void 0) {
|
|
232
232
|
let e = this.#h(t.camera);
|
|
@@ -239,13 +239,13 @@ var j = class {
|
|
|
239
239
|
let n = this.json.meshes[t];
|
|
240
240
|
return n.primitives.map((r, i) => {
|
|
241
241
|
let a = this.#l(r), o = r.material === void 0 ? this.#p() : this.#f(r.material), s = r.mode ?? 4, c;
|
|
242
|
-
return c = s === 0 ? new
|
|
242
|
+
return c = s === 0 ? new _({
|
|
243
243
|
geometry: a,
|
|
244
244
|
material: P(o)
|
|
245
245
|
}) : s === 1 || s === 2 || s === 3 ? new e({
|
|
246
246
|
geometry: I(a, s),
|
|
247
247
|
material: P(o)
|
|
248
|
-
}) : new
|
|
248
|
+
}) : new u({
|
|
249
249
|
geometry: s === 4 ? a : F(a, s),
|
|
250
250
|
material: o
|
|
251
251
|
}), c.name = n.primitives.length > 1 ? `${n.name ?? `mesh ${t}`} ${i}` : n.name ?? `mesh ${t}`, c;
|
|
@@ -255,10 +255,10 @@ var j = class {
|
|
|
255
255
|
let t = JSON.stringify([e.attributes, e.indices]), n = this.#r.get(t);
|
|
256
256
|
if (n) return n;
|
|
257
257
|
let r = e.attributes;
|
|
258
|
-
if (r.POSITION === void 0) throw new
|
|
258
|
+
if (r.POSITION === void 0) throw new s("loadGLTF: a mesh primitive has no POSITION");
|
|
259
259
|
let i = { positions: this.#u(r.POSITION) };
|
|
260
260
|
r.NORMAL !== void 0 && (i.normals = this.#u(r.NORMAL)), r.TEXCOORD_0 !== void 0 && (i.uvs = this.#u(r.TEXCOORD_0)), r.TEXCOORD_1 !== void 0 && (i.uvs2 = this.#u(r.TEXCOORD_1)), r.COLOR_0 !== void 0 && (i.colors = N(this.#u(r.COLOR_0), C[this.json.accessors[r.COLOR_0].type])), e.indices !== void 0 && (i.indices = this.#u(e.indices, !0));
|
|
261
|
-
let a = new
|
|
261
|
+
let a = new f(i);
|
|
262
262
|
return this.#r.set(t, a), a;
|
|
263
263
|
}
|
|
264
264
|
#u(e, t = !1) {
|
|
@@ -274,52 +274,52 @@ var j = class {
|
|
|
274
274
|
return a;
|
|
275
275
|
}
|
|
276
276
|
#d(e, t, n, r, i, a, o) {
|
|
277
|
-
let
|
|
278
|
-
if (!
|
|
279
|
-
let
|
|
280
|
-
5120: (e) =>
|
|
281
|
-
5121: (e) =>
|
|
282
|
-
5122: (e) =>
|
|
283
|
-
5123: (e) =>
|
|
284
|
-
5125: (e) =>
|
|
285
|
-
5126: (e) =>
|
|
277
|
+
let c = this.json.bufferViews[e], l = this.#e[c.buffer], u = w[n];
|
|
278
|
+
if (!u) throw new s(`loadGLTF: unknown component type ${n}`);
|
|
279
|
+
let d = u.BYTES_PER_ELEMENT, f = c.byteStride || r * d, p = l.byteOffset + (c.byteOffset ?? 0) + t, m = new DataView(l.buffer), h = {
|
|
280
|
+
5120: (e) => m.getInt8(e),
|
|
281
|
+
5121: (e) => m.getUint8(e),
|
|
282
|
+
5122: (e) => m.getInt16(e, !0),
|
|
283
|
+
5123: (e) => m.getUint16(e, !0),
|
|
284
|
+
5125: (e) => m.getUint32(e, !0),
|
|
285
|
+
5126: (e) => m.getFloat32(e, !0)
|
|
286
286
|
}[n];
|
|
287
|
-
if (n === 5126 &&
|
|
288
|
-
else for (let e = 0; e < i; e++) for (let t = 0; t < r; t++) a[e * r + t] =
|
|
287
|
+
if (n === 5126 && f === r * 4 && p % 4 == 0 && o === 1 && a instanceof Float32Array) a.set(new Float32Array(l.buffer, p, i * r));
|
|
288
|
+
else for (let e = 0; e < i; e++) for (let t = 0; t < r; t++) a[e * r + t] = h(p + e * f + t * d) * o;
|
|
289
289
|
}
|
|
290
290
|
#f(e) {
|
|
291
291
|
let t = this.#n.get(e);
|
|
292
292
|
if (t) return t;
|
|
293
|
-
let n = this.json.materials[e], r = n.pbrMetallicRoughness ?? {}, i = new
|
|
293
|
+
let n = this.json.materials[e], r = n.pbrMetallicRoughness ?? {}, i = new p({ name: n.name ?? `material ${e}` }), a = r.baseColorFactor ?? [
|
|
294
294
|
1,
|
|
295
295
|
1,
|
|
296
296
|
1,
|
|
297
297
|
1
|
|
298
298
|
];
|
|
299
299
|
i.color.setLinear(a[0], a[1], a[2]), i.metalness = r.metallicFactor ?? 1, i.roughness = r.roughnessFactor ?? 1, r.baseColorTexture && (i.map = this.#m(r.baseColorTexture, "srgb")), r.metallicRoughnessTexture && (i.roughnessMap = i.metalnessMap = this.#m(r.metallicRoughnessTexture, "linear")), n.normalTexture && (i.normalMap = this.#m(n.normalTexture, "linear"), i.normalScale = n.normalTexture.scale ?? 1), n.occlusionTexture && (i.aoMap = this.#m(n.occlusionTexture, "linear"), i.aoMapIntensity = Math.min(Math.max(n.occlusionTexture.strength ?? 1, 0), 1)), n.emissiveFactor && i.emissive.setLinear(n.emissiveFactor[0], n.emissiveFactor[1], n.emissiveFactor[2]), n.emissiveTexture && (i.emissiveMap = this.#m(n.emissiveTexture, "srgb"), n.emissiveFactor || i.emissive.setLinear(1, 1, 1)), i.emissiveIntensity = n.extensions?.KHR_materials_emissive_strength?.emissiveStrength ?? 1, n.extensions?.KHR_materials_unlit && (i.unlit = !0);
|
|
300
|
-
let o = (e) => Math.min(Math.max(e, 0), 1),
|
|
301
|
-
if (
|
|
302
|
-
let e =
|
|
300
|
+
let o = (e) => Math.min(Math.max(e, 0), 1), s = n.extensions ?? {}, c = s.KHR_materials_transmission, l = s.KHR_materials_clearcoat, u = s.KHR_materials_sheen;
|
|
301
|
+
if (c && (i.transmission = o(c.transmissionFactor ?? 0)), l && (i.clearcoat = o(l.clearcoatFactor ?? 0), i.clearcoatRoughness = o(l.clearcoatRoughnessFactor ?? 0)), u) {
|
|
302
|
+
let e = u.sheenColorFactor ?? [
|
|
303
303
|
0,
|
|
304
304
|
0,
|
|
305
305
|
0
|
|
306
306
|
];
|
|
307
|
-
Math.max(e[0], e[1], e[2]) > 0 && (i.sheen = 1, i.sheenColor.setLinear(e[0], e[1], e[2])), i.sheenRoughness = o(
|
|
307
|
+
Math.max(e[0], e[1], e[2]) > 0 && (i.sheen = 1, i.sheenColor.setLinear(e[0], e[1], e[2])), i.sheenRoughness = o(u.sheenRoughnessFactor ?? 0);
|
|
308
308
|
}
|
|
309
|
-
|
|
310
|
-
let
|
|
311
|
-
if (
|
|
312
|
-
i.specularIntensity = o(
|
|
313
|
-
let e =
|
|
309
|
+
s.KHR_materials_ior?.ior >= 1 && (i.ior = s.KHR_materials_ior.ior);
|
|
310
|
+
let d = s.KHR_materials_specular;
|
|
311
|
+
if (d) {
|
|
312
|
+
i.specularIntensity = o(d.specularFactor ?? 1);
|
|
313
|
+
let e = d.specularColorFactor ?? [
|
|
314
314
|
1,
|
|
315
315
|
1,
|
|
316
316
|
1
|
|
317
317
|
];
|
|
318
318
|
i.specularColor.setLinear(e[0], e[1], e[2]);
|
|
319
319
|
}
|
|
320
|
-
let
|
|
321
|
-
|
|
322
|
-
let m =
|
|
320
|
+
let f = s.KHR_materials_anisotropy;
|
|
321
|
+
f && (i.anisotropy = o(f.anisotropyStrength ?? 0), i.anisotropyRotation = f.anisotropyRotation ?? 0);
|
|
322
|
+
let m = s.KHR_materials_diffuse_transmission;
|
|
323
323
|
if (m) {
|
|
324
324
|
i.translucency = o(m.diffuseTransmissionFactor ?? 0);
|
|
325
325
|
let e = m.diffuseTransmissionColorFactor ?? [
|
|
@@ -333,7 +333,7 @@ var j = class {
|
|
|
333
333
|
}
|
|
334
334
|
#p() {
|
|
335
335
|
let e = this.#n.get(-1);
|
|
336
|
-
return e || this.#n.set(-1, e = new
|
|
336
|
+
return e || this.#n.set(-1, e = new p({
|
|
337
337
|
name: "default",
|
|
338
338
|
metalness: 1,
|
|
339
339
|
roughness: 1
|
|
@@ -341,7 +341,7 @@ var j = class {
|
|
|
341
341
|
}
|
|
342
342
|
#m(e, t) {
|
|
343
343
|
let n = e.extensions?.KHR_texture_transform, r = n?.texCoord ?? e.texCoord ?? 0;
|
|
344
|
-
r > 1 && (
|
|
344
|
+
r > 1 && (o(this.model, `textures on a third UV set or later (TEXCOORD_${r}) are drawn with the first`), r = 0);
|
|
345
345
|
let i = JSON.stringify([
|
|
346
346
|
e.index,
|
|
347
347
|
t,
|
|
@@ -351,25 +351,25 @@ var j = class {
|
|
|
351
351
|
r
|
|
352
352
|
]), a = this.#t.get(i);
|
|
353
353
|
if (a) return a;
|
|
354
|
-
let
|
|
355
|
-
if (
|
|
356
|
-
let
|
|
357
|
-
if (
|
|
358
|
-
let e = this.json.bufferViews[
|
|
359
|
-
|
|
360
|
-
} else
|
|
361
|
-
let
|
|
362
|
-
url:
|
|
354
|
+
let c = this.json.textures[e.index], l = this.json.samplers?.[c.sampler] ?? {}, u = this.json.images[c.source];
|
|
355
|
+
if (c.source === void 0 || !u) throw new s(`loadGLTF: texture ${e.index} has no image (compressed textures aren't supported)`);
|
|
356
|
+
let d;
|
|
357
|
+
if (u.bufferView !== void 0) {
|
|
358
|
+
let e = this.json.bufferViews[u.bufferView], t = this.#e[e.buffer].subarray(e.byteOffset ?? 0, (e.byteOffset ?? 0) + e.byteLength);
|
|
359
|
+
d = URL.createObjectURL(new Blob([t], { type: u.mimeType ?? "image/png" })), this.#a.push(d);
|
|
360
|
+
} else d = this.#o(u.uri);
|
|
361
|
+
let f = new g({
|
|
362
|
+
url: d,
|
|
363
363
|
colorSpace: t,
|
|
364
|
-
wrap: E[
|
|
365
|
-
filter:
|
|
364
|
+
wrap: E[l.wrapS ?? 10497] ?? "repeat",
|
|
365
|
+
filter: l.magFilter === 9728 ? "nearest" : "linear",
|
|
366
366
|
flipY: !1,
|
|
367
367
|
repeat: n?.scale ?? [1, 1],
|
|
368
368
|
offset: n?.offset ?? [0, 0],
|
|
369
369
|
rotation: n?.rotation ?? 0,
|
|
370
370
|
uvSet: r
|
|
371
371
|
});
|
|
372
|
-
return this.#t.set(i,
|
|
372
|
+
return this.#t.set(i, f), f;
|
|
373
373
|
}
|
|
374
374
|
#h(e) {
|
|
375
375
|
let t = this.json.cameras[e], r = t.name ?? `camera ${e}`;
|
|
@@ -392,7 +392,7 @@ var j = class {
|
|
|
392
392
|
}
|
|
393
393
|
#g(e) {
|
|
394
394
|
let n = this.json.extensions?.KHR_lights_punctual?.lights?.[e];
|
|
395
|
-
if (!n) throw new
|
|
395
|
+
if (!n) throw new s(`loadGLTF: KHR_lights_punctual light ${e} doesn't exist`);
|
|
396
396
|
let i = n.color ?? [
|
|
397
397
|
1,
|
|
398
398
|
1,
|
|
@@ -400,8 +400,8 @@ var j = class {
|
|
|
400
400
|
], o = {
|
|
401
401
|
name: n.name,
|
|
402
402
|
intensity: (n.intensity ?? 1) / Math.PI
|
|
403
|
-
},
|
|
404
|
-
if (n.type === "directional")
|
|
403
|
+
}, c;
|
|
404
|
+
if (n.type === "directional") c = new a({
|
|
405
405
|
...o,
|
|
406
406
|
direction: [
|
|
407
407
|
0,
|
|
@@ -411,7 +411,7 @@ var j = class {
|
|
|
411
411
|
});
|
|
412
412
|
else if (n.type === "spot") {
|
|
413
413
|
let e = n.spot?.outerConeAngle ?? Math.PI / 4, t = n.spot?.innerConeAngle ?? 0;
|
|
414
|
-
|
|
414
|
+
c = new r({
|
|
415
415
|
...o,
|
|
416
416
|
direction: [
|
|
417
417
|
0,
|
|
@@ -422,11 +422,11 @@ var j = class {
|
|
|
422
422
|
angle: e,
|
|
423
423
|
penumbra: e > 0 ? 1 - t / e : 0
|
|
424
424
|
});
|
|
425
|
-
} else
|
|
425
|
+
} else c = new t({
|
|
426
426
|
...o,
|
|
427
427
|
range: n.range ?? 0
|
|
428
428
|
});
|
|
429
|
-
return
|
|
429
|
+
return c.color.setLinear(i[0], i[1], i[2]), c;
|
|
430
430
|
}
|
|
431
431
|
#_(e, t) {
|
|
432
432
|
let n = [];
|
|
@@ -437,7 +437,7 @@ var j = class {
|
|
|
437
437
|
scale: "scale"
|
|
438
438
|
}[t.target.path];
|
|
439
439
|
if (!r) {
|
|
440
|
-
|
|
440
|
+
o(this.model, `'${t.target.path}' animations aren't supported - only translation, rotation and scale`);
|
|
441
441
|
continue;
|
|
442
442
|
}
|
|
443
443
|
let i = this.#i[t.target.node];
|
|
@@ -467,12 +467,12 @@ function M(e, t) {
|
|
|
467
467
|
t[8] / i,
|
|
468
468
|
t[9] / i,
|
|
469
469
|
t[10] / i
|
|
470
|
-
], o =
|
|
470
|
+
], o = m([
|
|
471
471
|
0,
|
|
472
472
|
0,
|
|
473
473
|
0,
|
|
474
474
|
1
|
|
475
|
-
],
|
|
475
|
+
], l([
|
|
476
476
|
0,
|
|
477
477
|
0,
|
|
478
478
|
0,
|
|
@@ -489,7 +489,7 @@ function N(e, t) {
|
|
|
489
489
|
return r;
|
|
490
490
|
}
|
|
491
491
|
function P(e) {
|
|
492
|
-
return new
|
|
492
|
+
return new p({
|
|
493
493
|
name: e.name,
|
|
494
494
|
color: e.color.getStyle(),
|
|
495
495
|
opacity: e.opacity,
|
|
@@ -511,7 +511,7 @@ function I(e, t) {
|
|
|
511
511
|
return t === 2 && n.length > 2 && r.push(n[n.length - 1], n[0]), L(e, r, !1);
|
|
512
512
|
}
|
|
513
513
|
function L(e, t, n) {
|
|
514
|
-
return new
|
|
514
|
+
return new f({
|
|
515
515
|
positions: e.positions,
|
|
516
516
|
normals: n && e.hasNormals ? e.normals : void 0,
|
|
517
517
|
uvs: e.uvs ?? void 0,
|