@kite3d/engine 0.17.0 → 0.19.0-alpha.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.
@@ -1,422 +1,399 @@
1
- import { Box3 as ee, Vector3 as z, Frustum as ue, Matrix4 as ce, EntityComponentPlugin as fe } from "threepipe";
2
- import { getAuthoringMetadata as P, getTrackedRuntimeObjects as de, getRuntimeObjectMetadata as j, KITE3D_AUTHORING_METADATA_KEY as J } from "./authoring.js";
3
- const N = 1e-6;
4
- function Ce(e) {
1
+ import { Box3 as X, Vector3 as V, Frustum as ue, Matrix4 as ce, EntityComponentPlugin as fe } from "threepipe";
2
+ import { getTrackedRuntimeObjects as de, getRuntimeObjectMetadata as U, getAuthoringMetadata as G, KITE3D_AUTHORING_METADATA_KEY as v } from "./authoring.js";
3
+ const x = 1e-6;
4
+ function xe(e) {
5
5
  const t = e.scene;
6
6
  if (!(t != null && t.modelRoot)) throw new Error("Authoring validation requires viewer.scene.modelRoot");
7
7
  t.updateMatrixWorld(!0);
8
- const r = [], n = te(t.modelRoot), o = [], i = [], a = /* @__PURE__ */ new Set(), s = [];
9
- let u = 0, l = 0, m = 0, R = 0;
10
- t.modelRoot.traverse((c) => {
11
- if (c === t.modelRoot) return;
12
- u += 1;
13
- const f = P(c);
14
- if ((f == null ? void 0 : f.role) === "generator" && !f.sourceId && o.push({ object: c, metadata: f }), (f == null ? void 0 : f.role) === "generator" && f.sourceId && i.push({ object: c, metadata: f }), !F(c) || (l += 1, !he(c, t.modelRoot))) return;
15
- m += 1, ye(c) && (R += 1);
16
- const x = new ee().setFromObject(c);
17
- !x.isEmpty() && W(x.min) && W(x.max) && (s.push({ object: c, bounds: x }), (f == null ? void 0 : f.role) === "generator" && f.sourceId && a.add(f.sourceId));
18
- });
19
- for (const c of i) {
20
- const f = n.get(c.metadata.sourceId || "");
21
- (!f || f.metadata.role !== "generator") && G(r, {
22
- code: "MISSING_AUTHORING_SOURCE",
23
- severity: "error",
24
- message: `Generator output source "${c.metadata.sourceId || "(missing)"}" is not present beneath modelRoot.`,
25
- object: _(c.object)
26
- });
27
- }
28
- for (const c of o)
29
- a.has(c.metadata.id) || G(r, {
30
- code: "GENERATOR_PREVIEW_MISSING",
31
- severity: "error",
32
- message: "An authored generator needs a bounded stopped-mode preview.",
33
- object: _(c.object)
34
- });
35
- r.push(...re(t, n));
36
- const S = u === 0 && o.length === 0;
37
- (m === 0 || R === 0) && r.push({
8
+ const n = [], r = Z(t.modelRoot), i = [];
9
+ let s = 0, a = 0, o = 0, u = 0;
10
+ t.modelRoot.traverse((d) => {
11
+ if (d === t.modelRoot || (s += 1, !$(d)) || (a += 1, !he(d, t.modelRoot))) return;
12
+ o += 1, ye(d) && (u += 1);
13
+ const l = new X().setFromObject(d);
14
+ !l.isEmpty() && B(l.min) && B(l.max) && i.push({ object: d, bounds: l });
15
+ }), n.push(...ee(t, r));
16
+ const c = s === 0;
17
+ (o === 0 || u === 0) && n.push({
38
18
  code: "NO_VISIBLE_AUTHORED_CONTENT",
39
- severity: S ? "warning" : "error",
40
- message: S ? "The scene is empty; add authored content when you are ready." : m === 0 ? "No visible renderable authored content exists beneath modelRoot." : "Visible authored renderables are not selectable."
19
+ severity: c ? "warning" : "error",
20
+ message: c ? "The scene is empty; add authored content when you are ready." : o === 0 ? "No visible renderable authored content exists beneath modelRoot." : "Visible authored renderables are not selectable."
41
21
  });
42
- const E = t.defaultCamera || t.mainCamera, w = t.defaultCamera ? "scene.defaultCamera" : "scene.mainCamera", y = S ? { useful: !1, framed: 0, inside: 0 } : le(E, w, s, r), A = r.filter(({ severity: c }) => c === "error"), C = !A.some(({ code: c }) => c === "MISSING_AUTHORING_SOURCE" || c === "RUNTIME_SOURCE_DRIFT"), I = !A.some(({ code: c }) => c === "GENERATOR_PREVIEW_MISSING"), k = A.length === 0;
22
+ const R = t.defaultCamera || t.mainCamera, C = t.defaultCamera ? "scene.defaultCamera" : "scene.mainCamera", w = c ? { useful: !1, framed: 0, inside: 0 } : le(R, C, i, n), p = n.filter(({ severity: d }) => d === "error"), A = !p.some(({ code: d }) => d === "MISSING_AUTHORING_SOURCE" || d === "RUNTIME_SOURCE_DRIFT"), y = p.length === 0;
43
23
  return {
44
- ok: k,
45
- status: k ? "pass" : "fail",
46
- summary: k ? "Stopped-mode authored representation passed." : `${A.length} authoring check(s) failed.`,
47
- issues: r,
24
+ ok: y,
25
+ status: y ? "pass" : "fail",
26
+ summary: y ? "Stopped-mode authored representation passed." : `${p.length} authoring check(s) failed.`,
27
+ issues: n,
48
28
  checks: {
49
- visibleAuthoredContent: m > 0,
50
- selectableAuthoredContent: R > 0,
51
- relationshipsValid: C,
52
- generatorPreviews: I,
53
- cameraUseful: y.useful
29
+ visibleAuthoredContent: o > 0,
30
+ selectableAuthoredContent: u > 0,
31
+ relationshipsValid: A,
32
+ cameraUseful: w.useful
54
33
  },
55
34
  metrics: {
56
- authoredObjectCount: u,
57
- renderableCount: l,
58
- visibleRenderableCount: m,
59
- selectableCount: R,
60
- generatorCount: o.length,
61
- generatorPreviewCount: a.size,
62
- cameraFramedRenderableCount: y.framed,
63
- cameraInsideRenderableCount: y.inside
35
+ authoredObjectCount: s,
36
+ renderableCount: a,
37
+ visibleRenderableCount: o,
38
+ selectableCount: u,
39
+ cameraFramedRenderableCount: w.framed,
40
+ cameraInsideRenderableCount: w.inside
64
41
  }
65
42
  };
66
43
  }
67
- function Ie(e) {
44
+ function Ee(e) {
68
45
  const t = e.scene;
69
46
  if (!(t != null && t.modelRoot)) throw new Error("Runtime cleanup validation requires viewer.scene.modelRoot");
70
47
  t.updateMatrixWorld(!0);
71
- const r = re(t, te(t.modelRoot)), n = de(t), o = /* @__PURE__ */ new Set();
72
- let i = 0;
73
- for (const s of n)
74
- X(s, o) || o.add(s);
75
- t.traverse((s) => {
76
- if (s === t || s === t.modelRoot || ge(s, t.modelRoot) || be(s, t)) return;
77
- F(s) && (i += 1);
78
- const u = Re(s);
79
- u ? X(u, o) || o.add(u) : F(s) && o.add(s);
48
+ const n = ee(t, Z(t.modelRoot)), r = de(t), i = /* @__PURE__ */ new Set();
49
+ let s = 0;
50
+ for (const o of r)
51
+ Q(o, i) || i.add(o);
52
+ t.traverse((o) => {
53
+ if (o === t || o === t.modelRoot || ge(o, t.modelRoot) || be(o, t)) return;
54
+ $(o) && (s += 1);
55
+ const u = Ae(o);
56
+ u ? Q(u, i) || i.add(u) : $(o) && i.add(o);
80
57
  });
81
- for (const s of o)
82
- G(r, {
58
+ for (const o of i)
59
+ M(n, {
83
60
  code: "RUNTIME_OBJECT_AFTER_STOP",
84
61
  severity: "error",
85
- message: j(s) ? "A tracked runtime object remains after Stop." : "An unmarked renderable remains outside modelRoot after Stop.",
86
- object: _(s)
62
+ message: U(o) ? "A tracked runtime object remains after Stop." : "An unmarked renderable remains outside modelRoot after Stop.",
63
+ object: k(o)
87
64
  });
88
- const a = !r.some(({ severity: s }) => s === "error");
65
+ const a = !n.some(({ severity: o }) => o === "error");
89
66
  return {
90
67
  ok: a,
91
68
  status: a ? "pass" : "fail",
92
- summary: a ? "Runtime cleanup passed." : `${r.filter(({ severity: s }) => s === "error").length} runtime cleanup check(s) failed.`,
93
- issues: r,
94
- trackedObjectCount: n.length,
95
- outsideRenderableCount: i
69
+ summary: a ? "Runtime cleanup passed." : `${n.filter(({ severity: o }) => o === "error").length} runtime cleanup check(s) failed.`,
70
+ issues: n,
71
+ trackedObjectCount: r.length,
72
+ outsideRenderableCount: s
96
73
  };
97
74
  }
98
- function H(e) {
75
+ function J(e) {
99
76
  const t = "scene" in e ? e.scene : e;
100
77
  if (!(t != null && t.modelRoot)) throw new Error("A semantic snapshot requires scene.modelRoot");
101
78
  return {
102
79
  schemaVersion: 1,
103
- scene: t.modelRoot.children.filter((r) => {
104
- var n;
105
- return ((n = r.userData) == null ? void 0 : n.excludeFromExport) !== !0;
106
- }).map((r) => ne(r))
80
+ scene: t.modelRoot.children.filter((n) => {
81
+ var r;
82
+ return ((r = n.userData) == null ? void 0 : r.excludeFromExport) !== !0;
83
+ }).map((n) => te(n))
107
84
  };
108
85
  }
109
86
  function Oe(e, t) {
110
- const r = p(v(e)), n = p(v(t)), o = JSON.stringify(r), i = JSON.stringify(n), a = [];
111
- B(r, n, "", a);
112
- const s = a.map((l) => ({
87
+ const n = m(I(e)), r = m(I(t)), i = JSON.stringify(n), s = JSON.stringify(r), a = [];
88
+ z(n, r, "", a);
89
+ const o = a.map((c) => ({
113
90
  code: "PERSISTENCE_DRIFT",
114
91
  severity: "error",
115
- message: `Saved authoring semantics changed at ${l.path || "/"}.`,
116
- ...l
92
+ message: `Saved authoring semantics changed at ${c.path || "/"}.`,
93
+ ...c
117
94
  })), u = a.length === 0;
118
95
  return {
119
96
  ok: u,
120
97
  status: u ? "pass" : "fail",
121
98
  summary: u ? "Save/Reload semantic equivalence passed." : `${a.length} persisted semantic difference(s) found.`,
122
- issues: s,
99
+ issues: o,
123
100
  changes: a,
124
- beforeBytes: o.length,
125
- afterBytes: i.length
101
+ beforeBytes: i.length,
102
+ afterBytes: s.length
126
103
  };
127
104
  }
128
105
  let b;
129
- function xe(e) {
106
+ function Ne(e) {
130
107
  if (!b) throw new Error("registerGameValidation must be called while createGame is active");
131
108
  return b.registerGameValidation(e);
132
109
  }
133
- function Ne(e) {
110
+ function Te(e) {
134
111
  if (!b) throw new Error("publishGameTelemetry must be called while createGame is active");
135
112
  return b.publishGameTelemetry(e);
136
113
  }
137
- function Te() {
114
+ function Ie() {
138
115
  const e = /* @__PURE__ */ new Set();
139
- let t, r = !1;
140
- const n = Object.freeze({
116
+ let t, n = !1;
117
+ const r = Object.freeze({
141
118
  get telemetry() {
142
119
  return t;
143
120
  },
144
- validate: () => o.runGameValidation()
145
- }), o = {
146
- registerGameValidation(i) {
147
- if (r || typeof i != "function") throw new Error("Game validation must be a function on an active game");
148
- return e.add(i), () => e.delete(i);
121
+ validate: () => i.runGameValidation()
122
+ }), i = {
123
+ registerGameValidation(s) {
124
+ if (n || typeof s != "function") throw new Error("Game validation must be a function on an active game");
125
+ return e.add(s), () => e.delete(s);
149
126
  },
150
- publishGameTelemetry(i) {
151
- if (r || !i || typeof i != "object" || Array.isArray(i))
127
+ publishGameTelemetry(s) {
128
+ if (n || !s || typeof s != "object" || Array.isArray(s))
152
129
  throw new Error("Game telemetry must be an object on an active game");
153
- const a = pe(i);
130
+ const a = pe(s);
154
131
  return t = a, () => {
155
132
  t === a && (t = void 0);
156
133
  };
157
134
  },
158
135
  async runGameValidation() {
159
- const i = [];
160
- for (const s of e)
136
+ const s = [];
137
+ for (const o of e)
161
138
  try {
162
- const u = await s();
163
- u === void 0 || u === !0 ? i.push({ status: "pass", summary: "Project validation passed." }) : u === !1 ? i.push({ status: "fail", summary: "Project validation failed." }) : u && ["pass", "fail"].includes(u.status) && typeof u.summary == "string" ? i.push(u) : i.push({ status: "fail", summary: "Project validation returned an invalid result." });
139
+ const u = await o();
140
+ u === void 0 || u === !0 ? s.push({ status: "pass", summary: "Project validation passed." }) : u === !1 ? s.push({ status: "fail", summary: "Project validation failed." }) : u && ["pass", "fail"].includes(u.status) && typeof u.summary == "string" ? s.push(u) : s.push({ status: "fail", summary: "Project validation returned an invalid result." });
164
141
  } catch (u) {
165
- i.push({ status: "fail", summary: `Project validation threw: ${Ae(u)}` });
142
+ s.push({ status: "fail", summary: `Project validation threw: ${Re(u)}` });
166
143
  }
167
- const a = i.filter(({ status: s }) => s === "fail");
144
+ const a = s.filter(({ status: o }) => o === "fail");
168
145
  return {
169
146
  ok: a.length === 0,
170
147
  status: a.length ? "fail" : "pass",
171
- summary: a.length ? a.map(({ summary: s }) => s).join(" ") : "Project validations passed.",
172
- results: i
148
+ summary: a.length ? a.map(({ summary: o }) => o).join(" ") : "Project validations passed.",
149
+ results: s
173
150
  };
174
151
  },
175
152
  dispose() {
176
- r = !0, e.clear(), t = void 0, b === o && (b = void 0), typeof window < "u" && window.kite3dGame === n && delete window.kite3dGame;
153
+ n = !0, e.clear(), t = void 0, b === i && (b = void 0), typeof window < "u" && window.kite3dGame === r && delete window.kite3dGame;
177
154
  }
178
155
  };
179
- return b == null || b.dispose(), b = o, typeof window < "u" && (window.kite3dGame = n), o;
156
+ return b == null || b.dispose(), b = i, typeof window < "u" && (window.kite3dGame = r), i;
180
157
  }
181
- function te(e) {
158
+ function Z(e) {
182
159
  const t = /* @__PURE__ */ new Map();
183
- return e.traverse((r) => {
184
- if (r === e) return;
185
- const n = P(r);
186
- n && !n.sourceId ? t.set(n.id, { object: r, metadata: n }) : n || t.set(r.uuid, { object: r, metadata: { role: "direct", id: r.uuid } });
160
+ return e.traverse((n) => {
161
+ if (n === e) return;
162
+ const r = G(n);
163
+ r && !r.sourceId ? t.set(r.id, { object: n, metadata: r }) : r || t.set(n.uuid, { object: n, metadata: { role: "direct", id: n.uuid } });
187
164
  }), t;
188
165
  }
189
- function re(e, t) {
190
- const r = [];
191
- return e.traverse((n) => {
192
- const o = P(n);
193
- if (!(o != null && o.sourceId)) return;
194
- const i = t.get(o.sourceId);
195
- if (!i) {
196
- G(r, {
166
+ function ee(e, t) {
167
+ const n = [];
168
+ return e.traverse((r) => {
169
+ const i = G(r);
170
+ if (!(i != null && i.sourceId)) return;
171
+ const s = t.get(i.sourceId);
172
+ if (!s) {
173
+ M(n, {
197
174
  code: "MISSING_AUTHORING_SOURCE",
198
175
  severity: "error",
199
- message: `Authored source "${o.sourceId}" is not present beneath modelRoot.`,
200
- object: _(n)
176
+ message: `Authored source "${i.sourceId}" is not present beneath modelRoot.`,
177
+ object: k(r)
201
178
  });
202
179
  return;
203
180
  }
204
- const a = j(n);
205
- if (!a || a.kind === "effect" || i.metadata.role === "generator") return;
206
- const s = new Set(a.overrides || []);
207
- JSON.stringify(U(i.object, s)) !== JSON.stringify(U(n, s)) && G(r, {
181
+ const a = U(r);
182
+ if (!a || a.kind === "effect") return;
183
+ const o = new Set(a.overrides || []);
184
+ JSON.stringify(P(s.object, o)) !== JSON.stringify(P(r, o)) && M(n, {
208
185
  code: "RUNTIME_SOURCE_DRIFT",
209
186
  severity: "error",
210
187
  message: "A runtime copy differs from its authored source in a non-mutable field.",
211
- object: _(n)
188
+ object: k(r)
212
189
  });
213
- }), r;
214
- }
215
- function le(e, t, r, n) {
216
- var S, E, w, y, A;
217
- let o = 0, i = 0, a = !1;
218
- const s = `${t}${e != null && e.name ? ` "${e.name}"` : ""}`;
219
- let u = `${s} must be finite and face visible authored content.`;
220
- const l = e == null ? void 0 : e.projectionMatrix, m = e == null ? void 0 : e.matrixWorldInverse;
221
- if (e && W(e.position) && l && m && r.length) {
222
- e.updateMatrixWorld(!0), (S = e.updateProjectionMatrix) == null || S.call(e);
223
- const C = e.getWorldPosition(new z()), I = new ee().makeEmpty();
224
- for (const { bounds: h } of r) I.union(h);
225
- const k = I.getCenter(new z()), c = (E = e.getWorldDirection) == null ? void 0 : E.call(e, new z()), f = k.clone().sub(C);
226
- a = !c || f.lengthSq() === 0 || c.dot(f.normalize()) > 0;
227
- const x = new ue().setFromProjectionMatrix(new ce().multiplyMatrices(l, m));
228
- o = r.filter(({ bounds: h }) => x.intersectsBox(h)).length;
229
- for (const { object: h, bounds: se } of r) {
230
- if (we(h) || !L(se, C)) continue;
231
- const V = h, g = V.geometry, ie = V.isInstancedMesh || V.isSkinnedMesh || ((y = (w = g == null ? void 0 : g.morphAttributes) == null ? void 0 : w.position) == null ? void 0 : y.length);
232
- if (!g || ie || h.matrixWorld.determinant() === 0) {
233
- q(n, h);
190
+ }), n;
191
+ }
192
+ function le(e, t, n, r) {
193
+ var w, p, A, y, d;
194
+ let i = 0, s = 0, a = !1;
195
+ const o = `${t}${e != null && e.name ? ` "${e.name}"` : ""}`;
196
+ let u = `${o} must be finite and face visible authored content.`;
197
+ const c = e == null ? void 0 : e.projectionMatrix, R = e == null ? void 0 : e.matrixWorldInverse;
198
+ if (e && B(e.position) && c && R && n.length) {
199
+ e.updateMatrixWorld(!0), (w = e.updateProjectionMatrix) == null || w.call(e);
200
+ const l = e.getWorldPosition(new V()), N = new X().makeEmpty();
201
+ for (const { bounds: h } of n) N.union(h);
202
+ const re = N.getCenter(new V()), D = (p = e.getWorldDirection) == null ? void 0 : p.call(e, new V()), W = re.clone().sub(l);
203
+ a = !D || W.lengthSq() === 0 || D.dot(W.normalize()) > 0;
204
+ const oe = new ue().setFromProjectionMatrix(new ce().multiplyMatrices(c, R));
205
+ i = n.filter(({ bounds: h }) => oe.intersectsBox(h)).length;
206
+ for (const { object: h, bounds: ie } of n) {
207
+ if (we(h) || !j(ie, l)) continue;
208
+ const T = h, g = T.geometry, se = T.isInstancedMesh || T.isSkinnedMesh || ((y = (A = g == null ? void 0 : g.morphAttributes) == null ? void 0 : A.position) == null ? void 0 : y.length);
209
+ if (!g || se || h.matrixWorld.determinant() === 0) {
210
+ H(r, h);
234
211
  continue;
235
212
  }
236
- (A = g.computeBoundingBox) == null || A.call(g);
237
- const ae = h.worldToLocal(C.clone());
238
- !g.boundingBox || !L(g.boundingBox, ae) || (V.isMesh && g.type === "BoxGeometry" ? i += 1 : q(n, h));
213
+ (d = g.computeBoundingBox) == null || d.call(g);
214
+ const ae = h.worldToLocal(l.clone());
215
+ !g.boundingBox || !j(g.boundingBox, ae) || (T.isMesh && g.type === "BoxGeometry" ? s += 1 : H(r, h));
239
216
  }
240
- i ? u = `${s} is inside ${i} visible authored mesh(es).` : o ? a || (u = `${s} faces away from visible authored content.`) : u = `No visible authored renderable intersects ${s}'s frustum.`;
217
+ s ? u = `${o} is inside ${s} visible authored mesh(es).` : i ? a || (u = `${o} faces away from visible authored content.`) : u = `No visible authored renderable intersects ${o}'s frustum.`;
241
218
  }
242
- const R = !!(e && r.length && o > 0 && i === 0 && a);
243
- return R || n.push({ code: "CAMERA_NOT_USEFUL", severity: "error", message: u }), { useful: R, framed: o, inside: i };
219
+ const C = !!(e && n.length && i > 0 && s === 0 && a);
220
+ return C || r.push({ code: "CAMERA_NOT_USEFUL", severity: "error", message: u }), { useful: C, framed: i, inside: s };
244
221
  }
245
- function L(e, t) {
246
- return t.x > e.min.x + N && t.x < e.max.x - N && t.y > e.min.y + N && t.y < e.max.y - N && t.z > e.min.z + N && t.z < e.max.z - N;
222
+ function j(e, t) {
223
+ return t.x > e.min.x + x && t.x < e.max.x - x && t.y > e.min.y + x && t.y < e.max.y - x && t.z > e.min.z + x && t.z < e.max.z - x;
247
224
  }
248
- function q(e, t) {
249
- G(e, {
225
+ function H(e, t) {
226
+ M(e, {
250
227
  code: "CAMERA_CONTAINMENT_UNVERIFIED",
251
228
  severity: "warning",
252
229
  message: "The camera intersects local geometry bounds, but hollow or imported mesh containment is unverified.",
253
- object: _(t)
230
+ object: k(t)
254
231
  });
255
232
  }
256
- function U(e, t, r = !0) {
257
- var i;
258
- const n = e, o = {
259
- type: oe(e),
260
- geometry: p((i = n.geometry) == null ? void 0 : i.parameters),
261
- children: e.children.map((a) => U(a, /* @__PURE__ */ new Set(), !1))
233
+ function P(e, t, n = !0) {
234
+ var s;
235
+ const r = e, i = {
236
+ type: ne(e),
237
+ geometry: m((s = r.geometry) == null ? void 0 : s.parameters),
238
+ children: e.children.map((a) => P(a, /* @__PURE__ */ new Set(), !1))
262
239
  };
263
- return (!r || !t.has("visible")) && (o.visible = e.visible), (!r || !t.has("position")) && (o.position = T(e.position)), (!r || !t.has("rotation")) && (o.rotation = T(e.rotation)), (!r || !t.has("scale")) && (o.scale = T(e.scale)), n.material && (!r || !t.has("material")) && (o.material = Array.isArray(n.material) ? n.material.map(K) : K(n.material)), o;
240
+ return (!n || !t.has("visible")) && (i.visible = e.visible), (!n || !t.has("position")) && (i.position = E(e.position)), (!n || !t.has("rotation")) && (i.rotation = E(e.rotation)), (!n || !t.has("scale")) && (i.scale = E(e.scale)), r.material && (!n || !t.has("material")) && (i.material = Array.isArray(r.material) ? r.material.map(L) : L(r.material)), i;
264
241
  }
265
- function K(e) {
266
- var r, n, o, i;
242
+ function L(e) {
243
+ var n, r, i, s;
267
244
  const t = e;
268
- return p({
245
+ return m({
269
246
  type: t == null ? void 0 : t.type,
270
- color: (n = (r = t == null ? void 0 : t.color) == null ? void 0 : r.getHex) == null ? void 0 : n.call(r),
271
- emissive: (i = (o = t == null ? void 0 : t.emissive) == null ? void 0 : o.getHex) == null ? void 0 : i.call(o),
247
+ color: (r = (n = t == null ? void 0 : t.color) == null ? void 0 : n.getHex) == null ? void 0 : r.call(n),
248
+ emissive: (s = (i = t == null ? void 0 : t.emissive) == null ? void 0 : i.getHex) == null ? void 0 : s.call(i),
272
249
  opacity: t == null ? void 0 : t.opacity,
273
250
  transparent: t == null ? void 0 : t.transparent,
274
251
  metalness: t == null ? void 0 : t.metalness,
275
252
  roughness: t == null ? void 0 : t.roughness
276
253
  });
277
254
  }
278
- function ne(e) {
279
- const t = P(e);
280
- return p({
255
+ function te(e) {
256
+ const t = G(e);
257
+ return m({
281
258
  name: e.name,
282
- type: oe(e),
259
+ type: ne(e),
283
260
  visible: e.visible,
284
- position: T(e.position),
285
- rotation: T(e.rotation),
286
- scale: T(e.scale),
261
+ position: E(e.position),
262
+ rotation: E(e.rotation),
263
+ scale: E(e.scale),
287
264
  components: me(e),
288
265
  ...t ? { authoring: t } : {},
289
- children: e.children.filter((r) => {
290
- var n;
291
- return ((n = r.userData) == null ? void 0 : n.excludeFromExport) !== !0;
292
- }).map((r) => ne(r))
266
+ children: e.children.filter((n) => {
267
+ var r;
268
+ return ((r = n.userData) == null ? void 0 : r.excludeFromExport) !== !0;
269
+ }).map((n) => te(n))
293
270
  });
294
271
  }
295
272
  function me(e) {
296
- var n;
273
+ var r;
297
274
  const t = fe.ObjectToComponents.get(e);
298
275
  if (t != null && t.length)
299
- return t.map((o) => {
300
- const i = o.constructor, a = (i.StateProperties || []).map((s) => typeof s == "string" ? s : s.name || s.key).filter((s) => !!s);
301
- return p({
302
- id: o.uuid,
303
- type: i.ComponentType || o.constructor.name,
304
- state: Object.fromEntries(a.map((s) => [s, O(o[s])]))
276
+ return t.map((i) => {
277
+ const s = i.constructor, a = (s.StateProperties || []).map((o) => typeof o == "string" ? o : o.name || o.key).filter((o) => !!o);
278
+ return m({
279
+ id: i.uuid,
280
+ type: s.ComponentType || i.constructor.name,
281
+ state: Object.fromEntries(a.map((o) => [o, S(i[o])]))
305
282
  });
306
- }).sort(D);
307
- const r = (n = e.userData) == null ? void 0 : n.EntityComponentPlugin;
308
- return d(r) ? Object.entries(r).map(([o, i]) => {
309
- const a = d(i) ? i : {};
310
- return p({ id: o, type: a.type, state: O(a.state) });
311
- }).sort(D) : [];
312
- }
313
- function v(e) {
314
- if (typeof e == "string") return v(JSON.parse(e));
315
- if (e instanceof Uint8Array) return v(JSON.parse(new TextDecoder().decode(e)));
316
- if (d(e) && d(e.document)) return Q(e.document);
317
- if (d(e) && e.schemaVersion === 1 && Array.isArray(e.scene)) return e;
318
- if (d(e) && d(e.asset)) return Q(e);
319
- if (d(e) && "scene" in e || d(e) && "modelRoot" in e) return H(e);
283
+ }).sort(F);
284
+ const n = (r = e.userData) == null ? void 0 : r.EntityComponentPlugin;
285
+ return f(n) ? Object.entries(n).map(([i, s]) => {
286
+ const a = f(s) ? s : {};
287
+ return m({ id: i, type: a.type, state: S(a.state) });
288
+ }).sort(F) : [];
289
+ }
290
+ function I(e) {
291
+ if (typeof e == "string") return I(JSON.parse(e));
292
+ if (e instanceof Uint8Array) return I(JSON.parse(new TextDecoder().decode(e)));
293
+ if (f(e) && f(e.document)) return q(e.document);
294
+ if (f(e) && e.schemaVersion === 1 && Array.isArray(e.scene)) return e;
295
+ if (f(e) && f(e.asset)) return q(e);
296
+ if (f(e) && "scene" in e || f(e) && "modelRoot" in e) return J(e);
320
297
  throw new Error("Persistence comparison requires a semantic snapshot, viewer, scene, or serialized glTF document");
321
298
  }
322
- function Q(e) {
323
- const t = Array.isArray(e.nodes) ? e.nodes : [], r = Array.isArray(e.scenes) ? e.scenes : [], n = typeof e.scene == "number" ? e.scene : 0, o = d(r[n]) ? r[n] : {}, i = Array.isArray(o.nodes) ? o.nodes : [], a = (s) => {
324
- const u = typeof s == "number" && d(t[s]) ? t[s] : {}, l = d(u.extras) ? u.extras : {}, m = d(l[J]) ? l[J] : void 0, R = d(l.EntityComponentPlugin) ? l.EntityComponentPlugin : {}, S = Object.entries(R).map(([A, C]) => {
325
- const I = d(C) ? C : {};
326
- return p({ id: A, type: I.type, state: O(I.state) });
327
- }).sort(D), E = $(u.translation, [0, 0, 0]), w = $(u.rotation, [0, 0, 0, 1]), y = $(u.scale, [1, 1, 1]);
328
- return p({
299
+ function q(e) {
300
+ const t = Array.isArray(e.nodes) ? e.nodes : [], n = Array.isArray(e.scenes) ? e.scenes : [], r = typeof e.scene == "number" ? e.scene : 0, i = f(n[r]) ? n[r] : {}, s = Array.isArray(i.nodes) ? i.nodes : [], a = (o) => {
301
+ const u = typeof o == "number" && f(t[o]) ? t[o] : {}, c = f(u.extras) ? u.extras : {}, R = f(c[v]) ? c[v] : void 0, C = f(c.EntityComponentPlugin) ? c.EntityComponentPlugin : {}, w = Object.entries(C).map(([d, l]) => {
302
+ const N = f(l) ? l : {};
303
+ return m({ id: d, type: N.type, state: S(N.state) });
304
+ }).sort(F), p = _(u.translation, [0, 0, 0]), A = _(u.rotation, [0, 0, 0, 1]), y = _(u.scale, [1, 1, 1]);
305
+ return m({
329
306
  name: typeof u.name == "string" ? u.name : "",
330
307
  type: typeof u.mesh == "number" ? "Mesh" : typeof u.camera == "number" ? "Camera" : "Group",
331
- visible: l.visible !== !1,
332
- position: { x: E[0], y: E[1], z: E[2] },
333
- quaternion: { x: w[0], y: w[1], z: w[2], w: w[3] },
308
+ visible: c.visible !== !1,
309
+ position: { x: p[0], y: p[1], z: p[2] },
310
+ quaternion: { x: A[0], y: A[1], z: A[2], w: A[3] },
334
311
  scale: { x: y[0], y: y[1], z: y[2] },
335
- components: S,
336
- ...m ? { authoring: O(m) } : {},
312
+ components: w,
313
+ ...R ? { authoring: S(R) } : {},
337
314
  children: (Array.isArray(u.children) ? u.children : []).map(a)
338
315
  });
339
316
  };
340
- return { schemaVersion: 1, scene: i.map(a) };
317
+ return { schemaVersion: 1, scene: s.map(a) };
341
318
  }
342
- function B(e, t, r, n) {
343
- if (n.length >= 50 || Object.is(e, t) || e === t) return;
319
+ function z(e, t, n, r) {
320
+ if (r.length >= 50 || Object.is(e, t) || e === t) return;
344
321
  if (!e || !t || typeof e != "object" || typeof t != "object" || Array.isArray(e) !== Array.isArray(t)) {
345
- n.push({ path: r || "/", before: e, after: t });
322
+ r.push({ path: n || "/", before: e, after: t });
346
323
  return;
347
324
  }
348
325
  if (Array.isArray(e) && Array.isArray(t)) {
349
- const s = Math.max(e.length, t.length);
350
- for (let u = 0; u < s; u += 1) {
351
- const l = Y(e[u]) || Y(t[u]);
352
- B(e[u], t[u], `${r}/${Z(l || String(u))}`, n);
326
+ const o = Math.max(e.length, t.length);
327
+ for (let u = 0; u < o; u += 1) {
328
+ const c = K(e[u]) || K(t[u]);
329
+ z(e[u], t[u], `${n}/${Y(c || String(u))}`, r);
353
330
  }
354
331
  return;
355
332
  }
356
- const o = e, i = t, a = [.../* @__PURE__ */ new Set([...Object.keys(o), ...Object.keys(i)])].sort();
357
- for (const s of a) B(o[s], i[s], `${r}/${Z(s)}`, n);
333
+ const i = e, s = t, a = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(s)])].sort();
334
+ for (const o of a) z(i[o], s[o], `${n}/${Y(o)}`, r);
358
335
  }
359
- function Y(e) {
360
- if (!(!d(e) || typeof e.name != "string"))
336
+ function K(e) {
337
+ if (!(!f(e) || typeof e.name != "string"))
361
338
  return e.name || void 0;
362
339
  }
363
- function O(e, t = /* @__PURE__ */ new WeakSet(), r = 0) {
364
- var i;
365
- if (typeof e == "number") return M(e);
340
+ function S(e, t = /* @__PURE__ */ new WeakSet(), n = 0) {
341
+ var s;
342
+ if (typeof e == "number") return O(e);
366
343
  if (e === null || typeof e == "string" || typeof e == "boolean") return e;
367
344
  if (e === void 0 || typeof e == "function") return;
368
- if (Array.isArray(e)) return e.map((a) => O(a, t, r + 1));
369
- if (typeof e != "object" || r > 5) return String(e);
345
+ if (Array.isArray(e)) return e.map((a) => S(a, t, n + 1));
346
+ if (typeof e != "object" || n > 5) return String(e);
370
347
  if (t.has(e)) return "[Circular]";
371
348
  t.add(e);
372
- const n = e;
373
- if (n.isColor && n.getHexString) return `#${n.getHexString()}`;
374
- if (n.toArray && /Vector|Euler|Quaternion/.test(((i = e.constructor) == null ? void 0 : i.name) || ""))
375
- return n.toArray().map((a) => O(a, t, r + 1));
376
- const o = {};
377
- for (const a of Object.keys(n).sort()) {
349
+ const r = e;
350
+ if (r.isColor && r.getHexString) return `#${r.getHexString()}`;
351
+ if (r.toArray && /Vector|Euler|Quaternion/.test(((s = e.constructor) == null ? void 0 : s.name) || ""))
352
+ return r.toArray().map((a) => S(a, t, n + 1));
353
+ const i = {};
354
+ for (const a of Object.keys(r).sort()) {
378
355
  if (a.startsWith("_") || ["id", "uuid", "uiConfig", "object", "ctx", "body", "world"].includes(a)) continue;
379
- const s = O(n[a], t, r + 1);
380
- s !== void 0 && (o[a] = s);
356
+ const o = S(r[a], t, n + 1);
357
+ o !== void 0 && (i[a] = o);
381
358
  }
382
- return o;
359
+ return i;
383
360
  }
384
- function p(e) {
385
- return typeof e == "number" ? M(e) : Array.isArray(e) ? e.map(p) : d(e) ? Object.fromEntries(Object.keys(e).sort().flatMap((t) => {
386
- const r = p(e[t]);
387
- return r === void 0 ? [] : [[t, r]];
361
+ function m(e) {
362
+ return typeof e == "number" ? O(e) : Array.isArray(e) ? e.map(m) : f(e) ? Object.fromEntries(Object.keys(e).sort().flatMap((t) => {
363
+ const n = m(e[t]);
364
+ return n === void 0 ? [] : [[t, n]];
388
365
  })) : e;
389
366
  }
390
- function T(e) {
391
- return { x: M(e.x), y: M(e.y), z: M(e.z) };
367
+ function E(e) {
368
+ return { x: O(e.x), y: O(e.y), z: O(e.z) };
392
369
  }
393
- function M(e) {
370
+ function O(e) {
394
371
  if (!Number.isFinite(e)) return null;
395
372
  const t = Math.round(e * 1e6) / 1e6;
396
373
  return Object.is(t, -0) ? 0 : t;
397
374
  }
398
- function $(e, t) {
399
- return !Array.isArray(e) || e.some((r) => typeof r != "number") ? t : e.map((r) => M(r) ?? 0);
375
+ function _(e, t) {
376
+ return !Array.isArray(e) || e.some((n) => typeof n != "number") ? t : e.map((n) => O(n) ?? 0);
400
377
  }
401
378
  function pe(e) {
402
- const t = typeof structuredClone == "function" ? structuredClone(e) : JSON.parse(JSON.stringify(e)), r = (n) => {
403
- if (!(!n || typeof n != "object" || Object.isFrozen(n))) {
404
- for (const o of Object.values(n)) r(o);
405
- Object.freeze(n);
379
+ const t = typeof structuredClone == "function" ? structuredClone(e) : JSON.parse(JSON.stringify(e)), n = (r) => {
380
+ if (!(!r || typeof r != "object" || Object.isFrozen(r))) {
381
+ for (const i of Object.values(r)) n(i);
382
+ Object.freeze(r);
406
383
  }
407
384
  };
408
- return r(t), t;
385
+ return n(t), t;
409
386
  }
410
- function G(e, t) {
411
- e.some((r) => {
412
- var n, o;
413
- return r.code === t.code && ((n = r.object) == null ? void 0 : n.uuid) === ((o = t.object) == null ? void 0 : o.uuid) && r.path === t.path;
387
+ function M(e, t) {
388
+ e.some((n) => {
389
+ var r, i;
390
+ return n.code === t.code && ((r = n.object) == null ? void 0 : r.uuid) === ((i = t.object) == null ? void 0 : i.uuid) && n.path === t.path;
414
391
  }) || e.push(t);
415
392
  }
416
- function _(e) {
393
+ function k(e) {
417
394
  return { uuid: e.uuid, name: e.name || "(unnamed)" };
418
395
  }
419
- function F(e) {
396
+ function $(e) {
420
397
  const t = e;
421
398
  return !!(t.isMesh || t.isLine || t.isPoints || t.isSprite);
422
399
  }
@@ -425,64 +402,64 @@ function ye(e) {
425
402
  return ((t = e.userData) == null ? void 0 : t.selectable) !== !1 && !e.isWidget;
426
403
  }
427
404
  function he(e, t) {
428
- for (let r = e; r; r = r.parent) {
429
- if (!r.visible) return !1;
430
- if (r === t) return !0;
405
+ for (let n = e; n; n = n.parent) {
406
+ if (!n.visible) return !1;
407
+ if (n === t) return !0;
431
408
  }
432
409
  return !1;
433
410
  }
434
411
  function ge(e, t) {
435
- for (let r = e; r; r = r.parent)
436
- if (r === t) return !0;
412
+ for (let n = e; n; n = n.parent)
413
+ if (n === t) return !0;
437
414
  return !1;
438
415
  }
439
416
  function be(e, t) {
440
417
  if (e === t.mainCamera || e === t.defaultCamera) return !0;
441
- for (let r = e; r; r = r.parent)
442
- if (r.isWidget) return !0;
418
+ for (let n = e; n; n = n.parent)
419
+ if (n.isWidget) return !0;
443
420
  return !1;
444
421
  }
445
- function Re(e) {
422
+ function Ae(e) {
446
423
  for (let t = e; t; t = t.parent)
447
- if (j(t)) return t;
424
+ if (U(t)) return t;
448
425
  }
449
- function X(e, t) {
450
- for (let r = e.parent; r; r = r.parent)
451
- if (t.has(r)) return !0;
426
+ function Q(e, t) {
427
+ for (let n = e.parent; n; n = n.parent)
428
+ if (t.has(n)) return !0;
452
429
  return !1;
453
430
  }
454
431
  function we(e) {
455
432
  var t;
456
- for (let r = e; r; r = r.parent)
457
- if ((t = P(r)) != null && t.allowCameraInside) return !0;
433
+ for (let n = e; n; n = n.parent)
434
+ if ((t = G(n)) != null && t.allowCameraInside) return !0;
458
435
  return !1;
459
436
  }
460
- function W(e) {
437
+ function B(e) {
461
438
  return Number.isFinite(e.x) && Number.isFinite(e.y) && Number.isFinite(e.z);
462
439
  }
463
- function oe(e) {
440
+ function ne(e) {
464
441
  const t = e;
465
442
  return t.isMesh ? "Mesh" : t.isCamera ? "Camera" : t.isLight ? "Light" : e.children.length ? "Group" : e.type;
466
443
  }
467
- function D(e, t) {
444
+ function F(e, t) {
468
445
  return JSON.stringify(e).localeCompare(JSON.stringify(t));
469
446
  }
470
- function Z(e) {
447
+ function Y(e) {
471
448
  return e.replace(/~/g, "~0").replace(/\//g, "~1");
472
449
  }
473
- function Ae(e) {
450
+ function Re(e) {
474
451
  return e instanceof Error ? e.message : String(e);
475
452
  }
476
- function d(e) {
453
+ function f(e) {
477
454
  return !!e && typeof e == "object" && !Array.isArray(e);
478
455
  }
479
456
  export {
480
- Ce as authoringQualityReport,
481
- Te as installGameHooks,
457
+ xe as authoringQualityReport,
458
+ Ie as installGameHooks,
482
459
  Oe as persistenceReport,
483
- Ne as publishGameTelemetry,
484
- xe as registerGameValidation,
485
- Ie as runtimeCleanupReport,
486
- H as semanticSceneSnapshot
460
+ Te as publishGameTelemetry,
461
+ Ne as registerGameValidation,
462
+ Ee as runtimeCleanupReport,
463
+ J as semanticSceneSnapshot
487
464
  };
488
465
  //# sourceMappingURL=authoringValidation.js.map