phoria2 1.3.0 → 1.4.1
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 +9 -6
- package/dist/bloom.js +4 -4
- package/dist/bloom.js.map +1 -1
- package/dist/charts.js +436 -436
- package/dist/charts.js.map +1 -1
- package/dist/core.js +1240 -862
- package/dist/core.js.map +1 -1
- package/dist/debug.js +297 -0
- package/dist/debug.js.map +1 -0
- package/dist/edit.js +40 -40
- package/dist/edit.js.map +1 -1
- package/dist/explain.js +32 -13
- package/dist/explain.js.map +1 -1
- package/dist/gltf.js +128 -128
- package/dist/gltf.js.map +1 -1
- package/dist/keyboard.js +19 -19
- package/dist/keyboard.js.map +1 -1
- package/dist/motion.js +35 -35
- package/dist/motion.js.map +1 -1
- package/dist/particles.js +36 -36
- package/dist/particles.js.map +1 -1
- package/dist/passes.js +116 -104
- package/dist/passes.js.map +1 -1
- package/dist/phoria2.js +1 -1
- package/dist/picking.js +90 -71
- 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 +16 -0
- package/dist/types/debug.d.ts +74 -0
- package/dist/types/explain.d.ts +4 -0
- package/dist/types/frame.d.ts +5 -0
- package/dist/types/material/Material.d.ts +52 -0
- package/dist/types/watch.d.ts +8 -1
- package/dist/types/webgl/hooks.d.ts +48 -0
- package/dist/types/webgl/passes.d.ts +4 -0
- package/dist/types/webgl/programs.d.ts +15 -5
- package/dist/types/webgl/shaders.d.ts +36 -5
- package/llms-full.txt +227 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/schema/scene.schema.json +27 -0
- package/src/View.js +105 -7
- package/src/debug.js +283 -0
- package/src/explain.js +19 -0
- package/src/frame.js +7 -2
- package/src/material/Material.js +121 -2
- package/src/scene/drawables.js +21 -4
- package/src/watch.js +18 -2
- package/src/webgl/WebGLRenderer.js +19 -2
- package/src/webgl/hooks.js +121 -0
- package/src/webgl/passes.js +17 -2
- package/src/webgl/picking.js +23 -2
- package/src/webgl/programs.js +20 -9
- package/src/webgl/resources.js +1 -1
- package/src/webgl/shaders.js +443 -35
package/dist/gltf.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as e, It as t, J as n, R as r, Y as i, _t as a, at as o, dt as s, et as c, ht as l, it as u, kt as d, pt as f, rt as p, st as m, ut as h, yt as g, z 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:
|
|
41
|
-
if (t <= n[0] || f === 0) for (let e = 0; e <
|
|
42
|
-
else if (t >= n[f]) for (let e = 0; e <
|
|
40
|
+
let { times: n, values: r, node: i, path: o, interpolation: s } = e, c = o === "quaternion" ? 4 : 3, l = s === "CUBICSPLINE", u = l ? c * 3 : c, d = (e) => l ? e * u + c : e * u, f = n.length - 1, p = y;
|
|
41
|
+
if (t <= n[0] || f === 0) for (let e = 0; e < c; e++) p[e] = r[d(0) + e];
|
|
42
|
+
else if (t >= n[f]) for (let e = 0; e < c; e++) p[e] = r[d(f) + e];
|
|
43
43
|
else {
|
|
44
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
|
-
let
|
|
50
|
-
if (
|
|
51
|
-
else if (
|
|
52
|
-
let t =
|
|
53
|
-
for (let e = 0; e <
|
|
54
|
-
|
|
55
|
-
} else if (
|
|
56
|
-
else for (let t = 0; t < 3; t++) p[t] = r[e * 3 + t] + (r[i * 3 + t] - r[e * 3 + t]) *
|
|
49
|
+
let o = n[e], m = n[i] - o, h = m > 0 ? (t - o) / m : 0;
|
|
50
|
+
if (s === "STEP") for (let t = 0; t < c; t++) p[t] = r[d(e) + t];
|
|
51
|
+
else if (l) {
|
|
52
|
+
let t = h * h, n = t * h, o = 2 * n - 3 * t + 1, s = n - 2 * t + h, l = -2 * n + 3 * t, d = n - t, f = e * u, g = i * u;
|
|
53
|
+
for (let e = 0; e < c; e++) p[e] = o * r[f + c + e] + s * m * r[f + c * 2 + e] + l * r[g + c + e] + d * m * r[g + e];
|
|
54
|
+
c === 4 && a(p, p);
|
|
55
|
+
} else if (c === 4) g(p, r.subarray(e * 4, e * 4 + 4), r.subarray(i * 4, i * 4 + 4), h);
|
|
56
|
+
else for (let t = 0; t < 3; t++) p[t] = r[e * 3 + t] + (r[i * 3 + t] - r[e * 3 + t]) * h;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
o === "quaternion" ? i.quaternion.set(p[0], p[1], p[2], p[3]) : i[o].set(p[0], p[1], p[2]);
|
|
59
59
|
}
|
|
60
60
|
// src/gltf/load.js
|
|
61
61
|
var x = /* @__PURE__ */ new Set([
|
|
@@ -100,7 +100,7 @@ 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 m {
|
|
104
104
|
static type = "model";
|
|
105
105
|
animations = [];
|
|
106
106
|
cameras = [];
|
|
@@ -108,12 +108,12 @@ var x = /* @__PURE__ */ new Set([
|
|
|
108
108
|
return this.findAll((e) => e instanceof c);
|
|
109
109
|
}
|
|
110
110
|
play(e = 0) {
|
|
111
|
-
let
|
|
112
|
-
if (!
|
|
113
|
-
let
|
|
114
|
-
return
|
|
111
|
+
let n = typeof e == "number" ? this.animations[e] : this.animations.find((t) => t.name === e);
|
|
112
|
+
if (!n) {
|
|
113
|
+
let n = this.animations.map((e) => `'${e.name}'`).join(", ");
|
|
114
|
+
return t(this, `no animation ${typeof e == "number" ? e : `'${e}'`} - this model has ${n || "none"}`), null;
|
|
115
115
|
}
|
|
116
|
-
return
|
|
116
|
+
return n.play();
|
|
117
117
|
}
|
|
118
118
|
toJSON() {
|
|
119
119
|
return {
|
|
@@ -124,29 +124,29 @@ 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 d(`loadGLTF: couldn't fetch '${e}' - ${t.message}`);
|
|
128
128
|
});
|
|
129
|
-
if (!n.ok) throw new
|
|
129
|
+
if (!n.ok) throw new d(`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,
|
|
133
133
|
baseUrl: r
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
async function k(e,
|
|
137
|
-
let { json:
|
|
138
|
-
if (!
|
|
139
|
-
for (let e of
|
|
136
|
+
async function k(e, n = {}) {
|
|
137
|
+
let { json: r, bin: i } = A(e), a = String(r.asset?.version ?? "");
|
|
138
|
+
if (!a.startsWith("2.")) throw new d(`loadGLTF: glTF ${a || "(no version)"} isn't supported - only glTF 2.0`);
|
|
139
|
+
for (let e of r.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 d(`loadGLTF: the model requires '${e}', which isn't supported${t}`);
|
|
143
143
|
}
|
|
144
|
-
let
|
|
145
|
-
for (let e of
|
|
146
|
-
let
|
|
147
|
-
await
|
|
148
|
-
let
|
|
149
|
-
return (
|
|
144
|
+
let o = new D({ name: r.scenes?.[r.scene ?? 0]?.name ?? "model" });
|
|
145
|
+
for (let e of r.extensionsUsed ?? []) x.has(e) || t(o, `the model uses '${e}', which isn't supported - it is ignored`);
|
|
146
|
+
let s = new j(r, i, n.baseUrl ?? "", o);
|
|
147
|
+
await s.buffers(), s.scene();
|
|
148
|
+
let c = s.textures();
|
|
149
|
+
return (n.waitForTextures ?? !0) && await c, o;
|
|
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 d("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 d(`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 d(`loadGLTF: couldn't fetch buffer '${e.uri}' - ${t.message}`);
|
|
203
203
|
});
|
|
204
|
-
if (!r.ok) throw new
|
|
204
|
+
if (!r.ok) throw new d(`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) => t(this.model, e.message))));
|
|
210
210
|
for (let e of this.#a) URL.revokeObjectURL(e);
|
|
211
211
|
}
|
|
212
212
|
scene() {
|
|
@@ -224,38 +224,38 @@ var j = class {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
#s(e) {
|
|
227
|
-
let
|
|
228
|
-
|
|
229
|
-
let
|
|
230
|
-
for (let e of
|
|
231
|
-
if (
|
|
232
|
-
let e = this.#h(
|
|
233
|
-
|
|
227
|
+
let n = this.json.nodes[e], r = n.name ?? `node ${e}`;
|
|
228
|
+
n.skin !== void 0 && t(this.model, `skinned meshes aren't supported - '${r}' is drawn in its bind pose`), (n.weights || n.mesh !== void 0 && this.json.meshes[n.mesh].weights) && t(this.model, "morph targets aren't supported - meshes are drawn without them");
|
|
229
|
+
let i = n.mesh === void 0 ? [] : this.#c(n.mesh), a = i.length === 1 ? i[0] : new m();
|
|
230
|
+
for (let e of i.length > 1 ? i : []) a.add(e);
|
|
231
|
+
if (a.name = r, n.matrix ? M(a, n.matrix) : (n.translation && a.position.set(n.translation[0], n.translation[1], n.translation[2]), n.rotation && a.quaternion.set(n.rotation[0], n.rotation[1], n.rotation[2], n.rotation[3]), n.scale && a.scale.set(n.scale[0], n.scale[1], n.scale[2])), n.camera !== void 0) {
|
|
232
|
+
let e = this.#h(n.camera);
|
|
233
|
+
a.add(e), this.model.cameras.push(e);
|
|
234
234
|
}
|
|
235
|
-
let
|
|
236
|
-
return
|
|
235
|
+
let o = n.extensions?.KHR_lights_punctual?.light;
|
|
236
|
+
return o !== void 0 && a.add(this.#g(o)), n.extras && typeof n.extras == "object" && (a.userData = { ...n.extras }), a;
|
|
237
237
|
}
|
|
238
|
-
#c(
|
|
239
|
-
let
|
|
240
|
-
return
|
|
241
|
-
let
|
|
242
|
-
return c = s === 0 ? new
|
|
243
|
-
geometry:
|
|
244
|
-
material: P(
|
|
245
|
-
}) : s === 1 || s === 2 || s === 3 ? new
|
|
246
|
-
geometry: I(
|
|
247
|
-
material: P(
|
|
238
|
+
#c(e) {
|
|
239
|
+
let t = this.json.meshes[e];
|
|
240
|
+
return t.primitives.map((n, r) => {
|
|
241
|
+
let i = this.#l(n), a = n.material === void 0 ? this.#p() : this.#f(n.material), s = n.mode ?? 4, c;
|
|
242
|
+
return c = s === 0 ? new o({
|
|
243
|
+
geometry: i,
|
|
244
|
+
material: P(a)
|
|
245
|
+
}) : s === 1 || s === 2 || s === 3 ? new p({
|
|
246
|
+
geometry: I(i, s),
|
|
247
|
+
material: P(a)
|
|
248
248
|
}) : new u({
|
|
249
|
-
geometry: s === 4 ?
|
|
250
|
-
material:
|
|
251
|
-
}), c.name =
|
|
249
|
+
geometry: s === 4 ? i : F(i, s),
|
|
250
|
+
material: a
|
|
251
|
+
}), c.name = t.primitives.length > 1 ? `${t.name ?? `mesh ${e}`} ${r}` : t.name ?? `mesh ${e}`, c;
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
#l(e) {
|
|
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 d("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
261
|
let a = new f(i);
|
|
@@ -274,9 +274,9 @@ 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
|
|
277
|
+
let s = this.json.bufferViews[e], c = this.#e[s.buffer], l = w[n];
|
|
278
|
+
if (!l) throw new d(`loadGLTF: unknown component type ${n}`);
|
|
279
|
+
let u = l.BYTES_PER_ELEMENT, f = s.byteStride || r * u, p = c.byteOffset + (s.byteOffset ?? 0) + t, m = new DataView(c.buffer), h = {
|
|
280
280
|
5120: (e) => m.getInt8(e),
|
|
281
281
|
5121: (e) => m.getUint8(e),
|
|
282
282
|
5122: (e) => m.getInt16(e, !0),
|
|
@@ -284,13 +284,13 @@ var j = class {
|
|
|
284
284
|
5125: (e) => m.getUint32(e, !0),
|
|
285
285
|
5126: (e) => m.getFloat32(e, !0)
|
|
286
286
|
}[n];
|
|
287
|
-
if (n === 5126 && f === r * 4 && p % 4 == 0 && o === 1 && a instanceof Float32Array) a.set(new Float32Array(
|
|
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 *
|
|
287
|
+
if (n === 5126 && f === r * 4 && p % 4 == 0 && o === 1 && a instanceof Float32Array) a.set(new Float32Array(c.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 * u) * 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 h({ name: n.name ?? `material ${e}` }), a = r.baseColorFactor ?? [
|
|
294
294
|
1,
|
|
295
295
|
1,
|
|
296
296
|
1,
|
|
@@ -319,10 +319,10 @@ var j = class {
|
|
|
319
319
|
}
|
|
320
320
|
let f = s.KHR_materials_anisotropy;
|
|
321
321
|
f && (i.anisotropy = o(f.anisotropyStrength ?? 0), i.anisotropyRotation = f.anisotropyRotation ?? 0);
|
|
322
|
-
let
|
|
323
|
-
if (
|
|
324
|
-
i.translucency = o(
|
|
325
|
-
let e =
|
|
322
|
+
let p = s.KHR_materials_diffuse_transmission;
|
|
323
|
+
if (p) {
|
|
324
|
+
i.translucency = o(p.diffuseTransmissionFactor ?? 0);
|
|
325
|
+
let e = p.diffuseTransmissionColorFactor ?? [
|
|
326
326
|
1,
|
|
327
327
|
1,
|
|
328
328
|
1
|
|
@@ -333,43 +333,43 @@ 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 h({
|
|
337
337
|
name: "default",
|
|
338
338
|
metalness: 1,
|
|
339
339
|
roughness: 1
|
|
340
340
|
})), e;
|
|
341
341
|
}
|
|
342
|
-
#m(e,
|
|
343
|
-
let
|
|
344
|
-
|
|
345
|
-
let
|
|
342
|
+
#m(e, n) {
|
|
343
|
+
let r = e.extensions?.KHR_texture_transform, i = r?.texCoord ?? e.texCoord ?? 0;
|
|
344
|
+
i > 1 && (t(this.model, `textures on a third UV set or later (TEXCOORD_${i}) are drawn with the first`), i = 0);
|
|
345
|
+
let a = JSON.stringify([
|
|
346
346
|
e.index,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
]),
|
|
353
|
-
if (
|
|
347
|
+
n,
|
|
348
|
+
r?.offset,
|
|
349
|
+
r?.scale,
|
|
350
|
+
r?.rotation,
|
|
351
|
+
i
|
|
352
|
+
]), o = this.#t.get(a);
|
|
353
|
+
if (o) return o;
|
|
354
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
|
|
356
|
-
let
|
|
355
|
+
if (c.source === void 0 || !u) throw new d(`loadGLTF: texture ${e.index} has no image (compressed textures aren't supported)`);
|
|
356
|
+
let f;
|
|
357
357
|
if (u.bufferView !== void 0) {
|
|
358
358
|
let e = this.json.bufferViews[u.bufferView], t = this.#e[e.buffer].subarray(e.byteOffset ?? 0, (e.byteOffset ?? 0) + e.byteLength);
|
|
359
|
-
|
|
360
|
-
} else
|
|
361
|
-
let
|
|
362
|
-
url:
|
|
363
|
-
colorSpace:
|
|
359
|
+
f = URL.createObjectURL(new Blob([t], { type: u.mimeType ?? "image/png" })), this.#a.push(f);
|
|
360
|
+
} else f = this.#o(u.uri);
|
|
361
|
+
let p = new s({
|
|
362
|
+
url: f,
|
|
363
|
+
colorSpace: n,
|
|
364
364
|
wrap: E[l.wrapS ?? 10497] ?? "repeat",
|
|
365
365
|
filter: l.magFilter === 9728 ? "nearest" : "linear",
|
|
366
366
|
flipY: !1,
|
|
367
|
-
repeat:
|
|
368
|
-
offset:
|
|
369
|
-
rotation:
|
|
370
|
-
uvSet:
|
|
367
|
+
repeat: r?.scale ?? [1, 1],
|
|
368
|
+
offset: r?.offset ?? [0, 0],
|
|
369
|
+
rotation: r?.rotation ?? 0,
|
|
370
|
+
uvSet: i
|
|
371
371
|
});
|
|
372
|
-
return this.#t.set(
|
|
372
|
+
return this.#t.set(a, p), p;
|
|
373
373
|
}
|
|
374
374
|
#h(e) {
|
|
375
375
|
let t = this.json.cameras[e], r = t.name ?? `camera ${e}`;
|
|
@@ -390,19 +390,19 @@ var j = class {
|
|
|
390
390
|
far: a.zfar ?? 1e6
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
|
-
#g(
|
|
394
|
-
let n = this.json.extensions?.KHR_lights_punctual?.lights?.[
|
|
395
|
-
if (!n) throw new
|
|
393
|
+
#g(t) {
|
|
394
|
+
let n = this.json.extensions?.KHR_lights_punctual?.lights?.[t];
|
|
395
|
+
if (!n) throw new d(`loadGLTF: KHR_lights_punctual light ${t} doesn't exist`);
|
|
396
396
|
let i = n.color ?? [
|
|
397
397
|
1,
|
|
398
398
|
1,
|
|
399
399
|
1
|
|
400
|
-
],
|
|
400
|
+
], a = {
|
|
401
401
|
name: n.name,
|
|
402
402
|
intensity: (n.intensity ?? 1) / Math.PI
|
|
403
|
-
},
|
|
404
|
-
if (n.type === "directional")
|
|
405
|
-
...
|
|
403
|
+
}, o;
|
|
404
|
+
if (n.type === "directional") o = new e({
|
|
405
|
+
...a,
|
|
406
406
|
direction: [
|
|
407
407
|
0,
|
|
408
408
|
0,
|
|
@@ -411,8 +411,8 @@ 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
|
-
|
|
415
|
-
...
|
|
414
|
+
o = new _({
|
|
415
|
+
...a,
|
|
416
416
|
direction: [
|
|
417
417
|
0,
|
|
418
418
|
0,
|
|
@@ -422,42 +422,42 @@ var j = class {
|
|
|
422
422
|
angle: e,
|
|
423
423
|
penumbra: e > 0 ? 1 - t / e : 0
|
|
424
424
|
});
|
|
425
|
-
} else
|
|
426
|
-
...
|
|
425
|
+
} else o = new r({
|
|
426
|
+
...a,
|
|
427
427
|
range: n.range ?? 0
|
|
428
428
|
});
|
|
429
|
-
return
|
|
429
|
+
return o.color.setLinear(i[0], i[1], i[2]), o;
|
|
430
430
|
}
|
|
431
|
-
#_(e,
|
|
432
|
-
let
|
|
433
|
-
for (let
|
|
434
|
-
let
|
|
431
|
+
#_(e, n) {
|
|
432
|
+
let r = [];
|
|
433
|
+
for (let n of e.channels) {
|
|
434
|
+
let i = {
|
|
435
435
|
translation: "position",
|
|
436
436
|
rotation: "quaternion",
|
|
437
437
|
scale: "scale"
|
|
438
|
-
}[
|
|
439
|
-
if (!
|
|
440
|
-
|
|
438
|
+
}[n.target.path];
|
|
439
|
+
if (!i) {
|
|
440
|
+
t(this.model, `'${n.target.path}' animations aren't supported - only translation, rotation and scale`);
|
|
441
441
|
continue;
|
|
442
442
|
}
|
|
443
|
-
let
|
|
444
|
-
if (!
|
|
445
|
-
let
|
|
446
|
-
|
|
447
|
-
node:
|
|
448
|
-
path:
|
|
449
|
-
times: this.#u(
|
|
450
|
-
values: this.#u(
|
|
451
|
-
interpolation:
|
|
443
|
+
let a = this.#i[n.target.node];
|
|
444
|
+
if (!a) continue;
|
|
445
|
+
let o = e.samplers[n.sampler];
|
|
446
|
+
r.push({
|
|
447
|
+
node: a,
|
|
448
|
+
path: i,
|
|
449
|
+
times: this.#u(o.input),
|
|
450
|
+
values: this.#u(o.output),
|
|
451
|
+
interpolation: o.interpolation ?? "LINEAR"
|
|
452
452
|
});
|
|
453
453
|
}
|
|
454
|
-
return new v(e.name ?? `animation ${
|
|
454
|
+
return new v(e.name ?? `animation ${n}`, r);
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
457
|
function M(e, t) {
|
|
458
458
|
let n = Math.hypot(t[0], t[1], t[2]), r = Math.hypot(t[4], t[5], t[6]), i = Math.hypot(t[8], t[9], t[10]);
|
|
459
459
|
t[0] * (t[5] * t[10] - t[6] * t[9]) - t[4] * (t[1] * t[10] - t[2] * t[9]) + t[8] * (t[1] * t[6] - t[2] * t[5]) < 0 && (n = -n);
|
|
460
|
-
let
|
|
460
|
+
let o = [
|
|
461
461
|
t[0] / n,
|
|
462
462
|
t[1] / n,
|
|
463
463
|
t[2] / n,
|
|
@@ -467,7 +467,7 @@ function M(e, t) {
|
|
|
467
467
|
t[8] / i,
|
|
468
468
|
t[9] / i,
|
|
469
469
|
t[10] / i
|
|
470
|
-
],
|
|
470
|
+
], s = a([
|
|
471
471
|
0,
|
|
472
472
|
0,
|
|
473
473
|
0,
|
|
@@ -477,8 +477,8 @@ function M(e, t) {
|
|
|
477
477
|
0,
|
|
478
478
|
0,
|
|
479
479
|
1
|
|
480
|
-
],
|
|
481
|
-
e.position.set(t[12], t[13], t[14]), e.quaternion.set(
|
|
480
|
+
], o));
|
|
481
|
+
e.position.set(t[12], t[13], t[14]), e.quaternion.set(s[0], s[1], s[2], s[3]), e.scale.set(n, r, i);
|
|
482
482
|
}
|
|
483
483
|
function N(e, t) {
|
|
484
484
|
let n = e.length / t, r = new Float32Array(n * 3);
|
|
@@ -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 h({
|
|
493
493
|
name: e.name,
|
|
494
494
|
color: e.color.getStyle(),
|
|
495
495
|
opacity: e.opacity,
|