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.
Files changed (56) hide show
  1. package/README.md +9 -6
  2. package/dist/bloom.js +4 -4
  3. package/dist/bloom.js.map +1 -1
  4. package/dist/charts.js +436 -436
  5. package/dist/charts.js.map +1 -1
  6. package/dist/core.js +1240 -862
  7. package/dist/core.js.map +1 -1
  8. package/dist/debug.js +297 -0
  9. package/dist/debug.js.map +1 -0
  10. package/dist/edit.js +40 -40
  11. package/dist/edit.js.map +1 -1
  12. package/dist/explain.js +32 -13
  13. package/dist/explain.js.map +1 -1
  14. package/dist/gltf.js +128 -128
  15. package/dist/gltf.js.map +1 -1
  16. package/dist/keyboard.js +19 -19
  17. package/dist/keyboard.js.map +1 -1
  18. package/dist/motion.js +35 -35
  19. package/dist/motion.js.map +1 -1
  20. package/dist/particles.js +36 -36
  21. package/dist/particles.js.map +1 -1
  22. package/dist/passes.js +116 -104
  23. package/dist/passes.js.map +1 -1
  24. package/dist/phoria2.js +1 -1
  25. package/dist/picking.js +90 -71
  26. package/dist/picking.js.map +1 -1
  27. package/dist/snapshot.js +1 -1
  28. package/dist/tooltip.js +1 -1
  29. package/dist/types/View.d.ts +16 -0
  30. package/dist/types/debug.d.ts +74 -0
  31. package/dist/types/explain.d.ts +4 -0
  32. package/dist/types/frame.d.ts +5 -0
  33. package/dist/types/material/Material.d.ts +52 -0
  34. package/dist/types/watch.d.ts +8 -1
  35. package/dist/types/webgl/hooks.d.ts +48 -0
  36. package/dist/types/webgl/passes.d.ts +4 -0
  37. package/dist/types/webgl/programs.d.ts +15 -5
  38. package/dist/types/webgl/shaders.d.ts +36 -5
  39. package/llms-full.txt +227 -0
  40. package/llms.txt +1 -1
  41. package/package.json +1 -1
  42. package/schema/scene.schema.json +27 -0
  43. package/src/View.js +105 -7
  44. package/src/debug.js +283 -0
  45. package/src/explain.js +19 -0
  46. package/src/frame.js +7 -2
  47. package/src/material/Material.js +121 -2
  48. package/src/scene/drawables.js +21 -4
  49. package/src/watch.js +18 -2
  50. package/src/webgl/WebGLRenderer.js +19 -2
  51. package/src/webgl/hooks.js +121 -0
  52. package/src/webgl/passes.js +17 -2
  53. package/src/webgl/picking.js +23 -2
  54. package/src/webgl/programs.js +20 -9
  55. package/src/webgl/resources.js +1 -1
  56. package/src/webgl/shaders.js +443 -35
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, 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";
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: 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];
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 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++) p[t] = r[u(e) + t];
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, 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;
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
- a === "quaternion" ? i.quaternion.set(p[0], p[1], p[2], p[3]) : i[a].set(p[0], p[1], p[2]);
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 h {
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 t = typeof e == "number" ? this.animations[e] : this.animations.find((t) => t.name === e);
112
- if (!t) {
113
- let t = this.animations.map((e) => `'${e.name}'`).join(", ");
114
- return o(this, `no animation ${typeof e == "number" ? e : `'${e}'`} - this model has ${t || "none"}`), null;
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 t.play();
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 s(`loadGLTF: couldn't fetch '${e}' - ${t.message}`);
127
+ throw new d(`loadGLTF: couldn't fetch '${e}' - ${t.message}`);
128
128
  });
129
- if (!n.ok) throw new s(`loadGLTF: couldn't fetch '${e}' (${n.status} ${n.statusText})`);
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, t = {}) {
137
- let { json: n, bin: r } = A(e), i = String(n.asset?.version ?? "");
138
- if (!i.startsWith("2.")) throw new s(`loadGLTF: glTF ${i || "(no version)"} isn't supported - only glTF 2.0`);
139
- for (let e of n.extensionsRequired ?? []) {
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 s(`loadGLTF: the model requires '${e}', which isn't supported${t}`);
142
+ throw new d(`loadGLTF: the model requires '${e}', which isn't supported${t}`);
143
143
  }
144
- let a = new D({ name: n.scenes?.[n.scene ?? 0]?.name ?? "model" });
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;
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 s("loadGLTF: the .glb file has no JSON chunk");
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 s(`loadGLTF: buffer ${t} has no uri and there is no binary chunk`);
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 s(`loadGLTF: couldn't fetch buffer '${e.uri}' - ${t.message}`);
202
+ throw new d(`loadGLTF: couldn't fetch buffer '${e.uri}' - ${t.message}`);
203
203
  });
204
- if (!r.ok) throw new s(`loadGLTF: couldn't fetch buffer '${e.uri}' (${r.status})`);
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) => o(this.model, e.message))));
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 t = this.json.nodes[e], n = t.name ?? `node ${e}`;
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
- for (let e of r.length > 1 ? r : []) i.add(e);
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
- let e = this.#h(t.camera);
233
- i.add(e), this.model.cameras.push(e);
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 a = t.extensions?.KHR_lights_punctual?.light;
236
- return a !== void 0 && i.add(this.#g(a)), t.extras && typeof t.extras == "object" && (i.userData = { ...t.extras }), i;
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(t) {
239
- let n = this.json.meshes[t];
240
- return n.primitives.map((r, i) => {
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 _({
243
- geometry: a,
244
- material: P(o)
245
- }) : s === 1 || s === 2 || s === 3 ? new e({
246
- geometry: I(a, s),
247
- material: P(o)
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 ? a : F(a, s),
250
- material: o
251
- }), c.name = n.primitives.length > 1 ? `${n.name ?? `mesh ${t}`} ${i}` : n.name ?? `mesh ${t}`, c;
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 s("loadGLTF: a mesh primitive has no POSITION");
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 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 = {
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(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;
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 p({ name: n.name ?? `material ${e}` }), a = r.baseColorFactor ?? [
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 m = s.KHR_materials_diffuse_transmission;
323
- if (m) {
324
- i.translucency = o(m.diffuseTransmissionFactor ?? 0);
325
- let e = m.diffuseTransmissionColorFactor ?? [
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 p({
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, t) {
343
- let n = e.extensions?.KHR_texture_transform, r = n?.texCoord ?? e.texCoord ?? 0;
344
- r > 1 && (o(this.model, `textures on a third UV set or later (TEXCOORD_${r}) are drawn with the first`), r = 0);
345
- let i = JSON.stringify([
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
- t,
348
- n?.offset,
349
- n?.scale,
350
- n?.rotation,
351
- r
352
- ]), a = this.#t.get(i);
353
- if (a) return a;
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 s(`loadGLTF: texture ${e.index} has no image (compressed textures aren't supported)`);
356
- let d;
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
- 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
- colorSpace: t,
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: n?.scale ?? [1, 1],
368
- offset: n?.offset ?? [0, 0],
369
- rotation: n?.rotation ?? 0,
370
- uvSet: r
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(i, f), f;
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(e) {
394
- let n = this.json.extensions?.KHR_lights_punctual?.lights?.[e];
395
- if (!n) throw new s(`loadGLTF: KHR_lights_punctual light ${e} doesn't exist`);
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
- ], o = {
400
+ ], a = {
401
401
  name: n.name,
402
402
  intensity: (n.intensity ?? 1) / Math.PI
403
- }, c;
404
- if (n.type === "directional") c = new a({
405
- ...o,
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
- c = new r({
415
- ...o,
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 c = new t({
426
- ...o,
425
+ } else o = new r({
426
+ ...a,
427
427
  range: n.range ?? 0
428
428
  });
429
- return c.color.setLinear(i[0], i[1], i[2]), c;
429
+ return o.color.setLinear(i[0], i[1], i[2]), o;
430
430
  }
431
- #_(e, t) {
432
- let n = [];
433
- for (let t of e.channels) {
434
- let r = {
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
- }[t.target.path];
439
- if (!r) {
440
- o(this.model, `'${t.target.path}' animations aren't supported - only translation, rotation and scale`);
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 i = this.#i[t.target.node];
444
- if (!i) continue;
445
- let a = e.samplers[t.sampler];
446
- n.push({
447
- node: i,
448
- path: r,
449
- times: this.#u(a.input),
450
- values: this.#u(a.output),
451
- interpolation: a.interpolation ?? "LINEAR"
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 ${t}`, n);
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 a = [
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
- ], o = m([
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
- ], a));
481
- e.position.set(t[12], t[13], t[14]), e.quaternion.set(o[0], o[1], o[2], o[3]), e.scale.set(n, r, i);
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 p({
492
+ return new h({
493
493
  name: e.name,
494
494
  color: e.color.getStyle(),
495
495
  opacity: e.opacity,