@nebula-spatial/studio 0.1.0 → 0.1.2
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 -0
- package/dist/assets/openusd_three_loader-DLiqJWUM.js +13769 -0
- package/dist/assets/usd-export-worker-BRxTLqer.js +182 -0
- package/dist/assets/usd-worker-DekqMsQv.js +1392 -0
- package/dist/{builders-BAXRR5o5.js → builders-lydx4-Rh.js} +1 -1
- package/dist/core/session-persistence-controller.d.ts +55 -0
- package/dist/doc/placement-policy.d.ts +4 -0
- package/dist/editor/editor.d.ts +3 -1
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/session-persistence.d.ts +54 -0
- package/dist/editor.js +727 -490
- package/dist/export-evidence-z2Ne7Trf.js +2387 -0
- package/dist/generalization.js +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +314 -306
- package/dist/mjcf-visual-IOy-ucto.js +72 -0
- package/dist/mujoco-runtime-BYZnrvbR.js +467 -0
- package/dist/persist/indexeddb-store.d.ts +22 -2
- package/dist/persist/session.d.ts +22 -0
- package/dist/persist/snapshot.d.ts +24 -0
- package/dist/{physics-facts-tfQYyNTD.js → physics-facts-D-URIBrt.js} +8 -7
- package/dist/{placement-policy-DY_FNRDu.js → placement-policy-C6dV6Tf-.js} +161 -141
- package/dist/ports/persistence.d.ts +45 -1
- package/dist/project/contracts.d.ts +3 -0
- package/dist/remote-asset-resolver-D-UeyDMD.js +311 -0
- package/dist/{scene-graph-DBLKAhxa.js → scene-graph-DVOXjMmp.js} +2 -2
- package/dist/scene-session-PhoFXFCY.js +22006 -0
- package/dist/scene.js +2 -2
- package/dist/session-2bp8YOA4.js +963 -0
- package/dist/session-B3WbC7Y2.js +296 -0
- package/dist/session-B9kEf4xN.js +915 -0
- package/dist/session-DYThdzLZ.js +825 -0
- package/dist/studio/index.d.ts +5 -0
- package/dist/studio/indexeddb-persistence.d.ts +2 -0
- package/dist/studio/indexeddb-session-persistence.d.ts +11 -0
- package/dist/studio/scene-package-asset-sources.d.ts +14 -0
- package/dist/studio.js +1423 -1220
- package/dist/urdf-session-CRXL4bHf.js +1230 -0
- package/dist/usd-session-CTzInpNy.js +7385 -0
- package/dist/version.d.ts +1 -1
- package/dist/view/scene-session.d.ts +5 -1
- package/dist/wasm-module-DZn2AM1W.js +13 -0
- package/dist/xacro-IpPHTMYs.js +76 -0
- package/package.json +1 -1
- package/dist/asset-source-BExlEcRt.js +0 -444
- package/dist/assets/usd-export-worker-BsGubtAE.js +0 -1
- package/dist/editorial-BkAFWfbg.js +0 -83
- package/dist/export-evidence-B_0zRmb8.js +0 -5027
- package/dist/remote-asset-resolver-Cb8cfNmw.js +0 -136
- package/dist/scene-session-BV1HnxNh.js +0 -3506
package/dist/editor.js
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var I = (
|
|
4
|
-
import { a as
|
|
5
|
-
import { z as
|
|
6
|
-
import {
|
|
7
|
-
import { v as
|
|
8
|
-
import { e as
|
|
9
|
-
import { c as
|
|
10
|
-
import { S as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return { present: l, available: e, canVisualize: o, source: t, reason: s };
|
|
1
|
+
var Pe = Object.defineProperty;
|
|
2
|
+
var Oe = (r, e, t) => e in r ? Pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var I = (r, e, t) => Oe(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { a as T, Y as me, b as fe, d as _e, Z as Re, U as j, J as De, P as Ve, L as Ce, I as Le, q as Me, f as xe, x as Fe, t as Be, V as Ue, e as ke } from "./builders-lydx4-Rh.js";
|
|
5
|
+
import { z as w, d as ie, a as ne, V as X, s as x, E as Ge, w as R, W as F, Z, U as J, _ as ge, M as B, k as ve, N as W, X as $e, $ as je, a0 as K, a1 as We, B as Q, a2 as Se, a3 as Ke } from "./scene-graph-DVOXjMmp.js";
|
|
6
|
+
import { A as Ye, J as ze, q as He, c as Xe, k as we, K as Ze } from "./session-B9kEf4xN.js";
|
|
7
|
+
import { v as Je, D as Qe, n as qe, q, r as ee, h as U, t as Ie } from "./placement-policy-C6dV6Tf-.js";
|
|
8
|
+
import { e as C, g as et, f as tt } from "./physics-facts-D-URIBrt.js";
|
|
9
|
+
import { c as st, t as ot } from "./scene-session-PhoFXFCY.js";
|
|
10
|
+
import { S as ye, i as it, a as nt } from "./remote-asset-resolver-D-UeyDMD.js";
|
|
11
|
+
const k = (r) => r !== null && typeof r == "object" && !Array.isArray(r) ? r : null, Y = (r) => Array.isArray(r) ? r.map(k).filter((e) => e !== null) : null, rt = (r, e) => Array.isArray(r) && r.length === e && r.every((t) => typeof t == "number" && Number.isFinite(t)), at = (r) => typeof r == "number" && Number.isFinite(r) && r > 0;
|
|
12
|
+
function A(r, e, t, s, o = !1) {
|
|
13
|
+
return { present: r, available: e, canVisualize: o, source: t, reason: s };
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
if (!
|
|
18
|
-
const n =
|
|
15
|
+
function z(r, e, t, s = !1) {
|
|
16
|
+
if (!r) return null;
|
|
17
|
+
const n = r.map((l) => {
|
|
19
18
|
var i;
|
|
20
|
-
return t === "authored" ? (i =
|
|
21
|
-
}).filter((
|
|
19
|
+
return t === "authored" ? (i = k(l.mass)) == null ? void 0 : i[e] : l[e];
|
|
20
|
+
}).filter((l) => l != null);
|
|
22
21
|
if (!n.length) return null;
|
|
23
|
-
const
|
|
24
|
-
return
|
|
22
|
+
const h = n.every((l) => rt(l, 3) && (e === "centerOfMass" || l.every((i) => i > 0)));
|
|
23
|
+
return A(!0, h, t, h ? s ? "Finite body data is available and the mounted runtime can display its inspection guide." : "Finite body data is available; the mounted runtime does not expose a viewport overlay for it." : "The feature is declared, but its values are incomplete or invalid.", h && s);
|
|
25
24
|
}
|
|
26
|
-
function
|
|
27
|
-
var
|
|
28
|
-
const s =
|
|
25
|
+
function ct(r, e, t) {
|
|
26
|
+
var ce, le, de, he, ue;
|
|
27
|
+
const s = w(r.root, e);
|
|
29
28
|
if (!s) return null;
|
|
30
|
-
const o = s.nodeType === "asset" ?
|
|
31
|
-
var
|
|
32
|
-
return ((
|
|
33
|
-
}) : null, S = Y((
|
|
34
|
-
...
|
|
29
|
+
const o = s.nodeType === "asset" ? r.assets.find((E) => E.revisionId === s.assetRevisionId) : void 0, n = s.nodeType === "visual" ? r.visualAssets.find((E) => E.visualRevisionId === s.visualRevisionId) : void 0, h = s.nodeType !== "asset" || (o == null ? void 0 : o.fileKind) === "glb" || (o == null ? void 0 : o.capabilities.physics) === "none", l = k((ce = t == null ? void 0 : t.visualDiagnostics) == null ? void 0 : ce.usd), i = k(l == null ? void 0 : l.stage), a = k(l == null ? void 0 : l.physics), d = Y(a == null ? void 0 : a.colliders), u = Y(a == null ? void 0 : a.rigidBodies), m = Y(a == null ? void 0 : a.joints), v = t != null && t.physicsRuntime ? t.physicsRuntime.bodies.filter((E) => {
|
|
30
|
+
var pe;
|
|
31
|
+
return ((pe = t.physicsRuntime) == null ? void 0 : pe.worldKind) !== "scene-unified" || E.instanceId === e;
|
|
32
|
+
}) : null, S = Y((le = t == null ? void 0 : t.physicsProperties) == null ? void 0 : le.bodies), c = v != null && v.length ? v.map((E) => ({ centerOfMass: E.centerOfMass, inertia: E.inertia })) : S, f = t == null ? void 0 : t.inspectionOverlays, p = (E) => h || a ? A(!1, !1, "none", `${E} is not present in this node's inspected data.`) : A(null, !1, "unknown", `${E} has not been established; source inspection is unavailable.`), y = ((de = t == null ? void 0 : t.capabilities) == null ? void 0 : de.canToggleCollision) === !0 ? A(!0, !0, "runtime", "The mounted instance supports collision geometry display.", !0) : d ? d.length ? A(!0, !1, "authored", "Collision geometry is authored, but the mounted instance cannot currently display it.") : A(!1, !1, "none", "The inspected asset has no authored collision geometry.") : o != null && o.capabilities.colliderGeometry ? A(!0, !1, "authored", "The asset declares collision geometry; its runtime display is not ready.") : p("Collision geometry"), O = typeof (i == null ? void 0 : i.upAxis) == "string" ? i.upAxis.toUpperCase() : null, D = O === "X" || O === "Y" || O === "Z" ? O : null, N = D ?? (n ? n.upAxis === "y-down" ? "-Y" : n.upAxis.toUpperCase() : null) ?? ((o == null ? void 0 : o.fileKind) === "glb" ? "Y" : null), G = at(i == null ? void 0 : i.metersPerUnit) ? i.metersPerUnit : (o == null ? void 0 : o.fileKind) === "glb" || (n == null ? void 0 : n.format) === "glb" || (n == null ? void 0 : n.format) === "gltf" ? 1 : null, V = D || n ? "authored" : (o == null ? void 0 : o.fileKind) === "glb" ? "format" : "unknown", H = {
|
|
33
|
+
...A(
|
|
35
34
|
N ? !0 : s.nodeType === "asset" ? null : !0,
|
|
36
35
|
!0,
|
|
37
|
-
|
|
36
|
+
V,
|
|
38
37
|
N ? "Source axis and the scene coordinate convention are available. Scene transforms use the scene convention." : "The scene coordinate convention is available; the source asset axis has not been established.",
|
|
39
38
|
// Coordinate axes are drawn by Sim Studio's authoring overlay rather
|
|
40
39
|
// than by a format/runtime inspection session. They are therefore
|
|
@@ -42,44 +41,44 @@ function tt(l, e, t) {
|
|
|
42
41
|
// a pre-mount request is reported as `pending` by the session API.
|
|
43
42
|
s.nodeType !== "domain"
|
|
44
43
|
),
|
|
45
|
-
scene:
|
|
44
|
+
scene: r.coordinateSystem,
|
|
46
45
|
sourceUpAxis: N,
|
|
47
|
-
sourceMetersPerUnit:
|
|
48
|
-
},
|
|
46
|
+
sourceMetersPerUnit: G
|
|
47
|
+
}, L = (m == null ? void 0 : m.filter((E) => E.axis !== void 0 && E.axis !== null)) ?? [], P = L.length ? A(
|
|
49
48
|
!0,
|
|
50
|
-
|
|
49
|
+
L.every((E) => typeof E.axis == "string" && /^[XYZ]$/i.test(E.axis)),
|
|
51
50
|
"authored",
|
|
52
51
|
(f == null ? void 0 : f.jointAxis) === !0 ? "Joint axis declarations and the mounted runtime inspection guide are available." : "Joint axis declarations can be inspected; the mounted runtime does not expose a joint-axis viewport overlay.",
|
|
53
52
|
(f == null ? void 0 : f.jointAxis) === !0
|
|
54
|
-
) : (f == null ? void 0 : f.jointAxis) === !0 ?
|
|
55
|
-
return
|
|
53
|
+
) : (f == null ? void 0 : f.jointAxis) === !0 ? A(!0, !0, "runtime", "The mounted URDF inspection runtime can display joint-axis guides.", !0) : p("Joint axes"), $ = z(c, "centerOfMass", "runtime", (f == null ? void 0 : f.centerOfMass) === !0) ?? z(u, "centerOfMass", "authored", (f == null ? void 0 : f.centerOfMass) === !0) ?? ((f == null ? void 0 : f.centerOfMass) === !0 ? A(!0, !0, "runtime", "The mounted URDF inspection runtime can display center-of-mass guides.", !0) : null) ?? p("Center of mass"), Ae = z(c, "inertia", "runtime", (f == null ? void 0 : f.inertia) === !0) ?? z(u, "diagonalInertia", "authored", (f == null ? void 0 : f.inertia) === !0) ?? ((f == null ? void 0 : f.inertia) === !0 ? A(!0, !0, "runtime", "The mounted URDF inspection runtime can display inertia guides.", !0) : null) ?? p("Inertia"), _ = t == null ? void 0 : t.physics, M = _ == null ? void 0 : _.status, Te = (o == null ? void 0 : o.capabilities.physics) === "authored", ae = ((he = t == null ? void 0 : t.capabilities) == null ? void 0 : he.hasPhysics) === !0 || Te, Ne = M === "unavailable" ? A(ae ? !0 : null, !1, "runtime", (_ == null ? void 0 : _.status) === "unavailable" ? _.issue.message : "Physics runtime is unavailable.") : M === "initializing" ? A(!0, !1, "runtime", "The physics runtime is still initializing.") : M === "not-authored" ? A(!1, !1, "none", "The mounted instance has no authored simulation physics.") : M === "ready" || M === "available" || ((ue = t == null ? void 0 : t.capabilities) == null ? void 0 : ue.hasPhysics) === !0 && t.capabilities.canPlay === !0 ? A(!0, !0, "runtime", "The mounted instance supports physics simulation.") : ae ? A(!0, !1, "authored", "Physics is authored, but the runtime is not ready.") : p("Simulation physics");
|
|
54
|
+
return ie(ne({ nodeId: e, nodeType: s.nodeType, collider: y, coordinateSystem: H, jointAxes: P, centerOfMass: $, inertia: Ae, simulation: Ne }));
|
|
56
55
|
}
|
|
57
|
-
async function
|
|
58
|
-
var
|
|
59
|
-
if (
|
|
56
|
+
async function Ee(r, e, t = {}) {
|
|
57
|
+
var h;
|
|
58
|
+
if (r.kind === "local-package")
|
|
60
59
|
return {
|
|
61
60
|
source: {
|
|
62
61
|
kind: "files",
|
|
63
|
-
entry:
|
|
64
|
-
files:
|
|
65
|
-
const i =
|
|
62
|
+
entry: r.entryPath,
|
|
63
|
+
files: r.files.map((l) => {
|
|
64
|
+
const i = Ye(l.locator);
|
|
66
65
|
if (!i) throw new Error("Local asset source contains a remote resource.");
|
|
67
|
-
return { path: i, file:
|
|
66
|
+
return { path: i, file: l.blob };
|
|
68
67
|
})
|
|
69
68
|
},
|
|
70
|
-
filename:
|
|
69
|
+
filename: r.entryPath,
|
|
71
70
|
...e.length ? { openOptions: { usdVariantSelections: e } } : {}
|
|
72
71
|
};
|
|
73
|
-
const s = t.remoteResolver ?? new
|
|
72
|
+
const s = t.remoteResolver ?? new ye(r), o = await s.entryBlob(t.signal), n = new URL(r.entryUrl).pathname.split("/").pop() || "root.usda";
|
|
74
73
|
return {
|
|
75
74
|
source: {
|
|
76
75
|
kind: "remote-entry",
|
|
77
76
|
entryPath: n,
|
|
78
|
-
entryUrl:
|
|
77
|
+
entryUrl: r.entryUrl,
|
|
79
78
|
entry: o,
|
|
80
|
-
...(
|
|
79
|
+
...(h = t.resourcePaths) != null && h.length ? { resourcePaths: [...new Set(t.resourcePaths)] } : {},
|
|
81
80
|
resourceResolver: {
|
|
82
|
-
resolve: (
|
|
81
|
+
resolve: (l, i) => s.resolve(l, i)
|
|
83
82
|
}
|
|
84
83
|
},
|
|
85
84
|
filename: n,
|
|
@@ -89,8 +88,8 @@ async function ve(l, e, t = {}) {
|
|
|
89
88
|
}
|
|
90
89
|
};
|
|
91
90
|
}
|
|
92
|
-
async function
|
|
93
|
-
const o = await
|
|
91
|
+
async function lt(r, e, t, s = {}) {
|
|
92
|
+
const o = await Ee(r, [], s);
|
|
94
93
|
return {
|
|
95
94
|
...o,
|
|
96
95
|
openOptions: {
|
|
@@ -106,23 +105,23 @@ async function st(l, e, t, s = {}) {
|
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
107
|
}
|
|
109
|
-
function
|
|
110
|
-
const t =
|
|
111
|
-
if (!(t != null && t.addEventListener) || !
|
|
108
|
+
function dt(r, e) {
|
|
109
|
+
const t = r.ownerDocument;
|
|
110
|
+
if (!(t != null && t.addEventListener) || !r.addEventListener) return () => {
|
|
112
111
|
};
|
|
113
|
-
const s =
|
|
114
|
-
s === null && (
|
|
115
|
-
const o =
|
|
116
|
-
const i =
|
|
117
|
-
i ===
|
|
118
|
-
},
|
|
119
|
-
const i =
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
!
|
|
112
|
+
const s = r.getAttribute("tabindex");
|
|
113
|
+
s === null && (r.tabIndex = 0);
|
|
114
|
+
const o = r.closest("[data-viewer-layout-host]") ?? r.parentElement ?? r, n = (l) => {
|
|
115
|
+
const i = l.composedPath()[0], a = typeof (i == null ? void 0 : i.closest) == "function" && i.closest('input,textarea,select,button,a[href],[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="button"],[data-studio-ui-plugin],dialog');
|
|
116
|
+
i === r || i && !a && o.contains(i) ? r.focus({ preventScroll: !0 }) : r.getRootNode().activeElement === r && r.blur();
|
|
117
|
+
}, h = (l) => {
|
|
118
|
+
const i = r.getRootNode();
|
|
119
|
+
if (l.defaultPrevented || l.isComposing || i.activeElement !== r) return;
|
|
120
|
+
const a = l.composedPath();
|
|
121
|
+
!a.includes(r) || a.some((d) => d === r || typeof d.matches != "function" ? !1 : d.matches('input,textarea,select,button,a[href],[contenteditable]:not([contenteditable="false"]),[role="textbox"],[data-studio-ui-plugin],dialog')) || e(l) && (l.preventDefault(), l.stopPropagation());
|
|
123
122
|
};
|
|
124
|
-
return t.addEventListener("pointerdown", n, !0), t.addEventListener("keydown",
|
|
125
|
-
t.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown",
|
|
123
|
+
return t.addEventListener("pointerdown", n, !0), t.addEventListener("keydown", h), () => {
|
|
124
|
+
t.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", h), s === null && r.getAttribute("tabindex") === "0" && r.removeAttribute("tabindex");
|
|
126
125
|
};
|
|
127
126
|
}
|
|
128
127
|
class g extends Error {
|
|
@@ -130,7 +129,7 @@ class g extends Error {
|
|
|
130
129
|
super(t), this.code = e, this.name = "StudioEditorError";
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
|
-
class
|
|
132
|
+
class ht {
|
|
134
133
|
constructor(e, t = {}) {
|
|
135
134
|
I(this, "host");
|
|
136
135
|
I(this, "session");
|
|
@@ -153,14 +152,14 @@ class it {
|
|
|
153
152
|
I(this, "actionControllers", /* @__PURE__ */ new Map());
|
|
154
153
|
I(this, "remoteResolvers", /* @__PURE__ */ new Map());
|
|
155
154
|
I(this, "coreActionBusy", /* @__PURE__ */ new Set());
|
|
156
|
-
I(this, "sceneSessionId", `session_${
|
|
155
|
+
I(this, "sceneSessionId", `session_${T()}`);
|
|
157
156
|
I(this, "selectionVersion", 0);
|
|
158
157
|
I(this, "contextVersion", 0);
|
|
159
158
|
I(this, "overlaySequence", 0);
|
|
160
159
|
I(this, "mode", "translate");
|
|
161
160
|
I(this, "snap", !1);
|
|
162
161
|
I(this, "transactionBounds", /* @__PURE__ */ new Map());
|
|
163
|
-
I(this, "placementPolicy",
|
|
162
|
+
I(this, "placementPolicy", Qe);
|
|
164
163
|
I(this, "transformSpace", "world");
|
|
165
164
|
I(this, "actionVisibility", /* @__PURE__ */ new Map());
|
|
166
165
|
I(this, "transformOrigins", /* @__PURE__ */ new Map());
|
|
@@ -178,7 +177,7 @@ class it {
|
|
|
178
177
|
I(this, "disposal", null);
|
|
179
178
|
I(this, "syncEpoch", 0);
|
|
180
179
|
I(this, "releaseShortcuts");
|
|
181
|
-
var o, n,
|
|
180
|
+
var o, n, h, l;
|
|
182
181
|
this.options = e, this.host = e.host, this.writePolicy = {
|
|
183
182
|
check: (i) => {
|
|
184
183
|
var u;
|
|
@@ -214,162 +213,166 @@ class it {
|
|
|
214
213
|
code: "GESTURE_ACTIVE",
|
|
215
214
|
message: "Finish or cancel the active gesture before writing the scene."
|
|
216
215
|
};
|
|
217
|
-
const
|
|
216
|
+
const a = i.kind === "editorial" ? void 0 : i.targetNodeIds.find((m) => X(
|
|
218
217
|
this.host.document.root,
|
|
219
|
-
|
|
218
|
+
m,
|
|
220
219
|
this.host.getSnapshot().editorial
|
|
221
220
|
));
|
|
222
|
-
if (
|
|
221
|
+
if (a)
|
|
223
222
|
return {
|
|
224
223
|
allowed: !1,
|
|
225
224
|
code: "NODE_LOCKED",
|
|
226
|
-
message: `Scene node is locked: ${
|
|
225
|
+
message: `Scene node is locked: ${a}`
|
|
227
226
|
};
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
227
|
+
const d = i.nextDocument;
|
|
228
|
+
if (d)
|
|
230
229
|
try {
|
|
231
|
-
this.assertProjectionRepresentable(
|
|
232
|
-
} catch (
|
|
233
|
-
if (
|
|
234
|
-
return { allowed: !1, code:
|
|
235
|
-
throw
|
|
230
|
+
this.assertProjectionRepresentable(d.root);
|
|
231
|
+
} catch (m) {
|
|
232
|
+
if (m instanceof g)
|
|
233
|
+
return { allowed: !1, code: m.code, message: m.message };
|
|
234
|
+
throw m;
|
|
236
235
|
}
|
|
237
|
-
if (
|
|
238
|
-
const
|
|
236
|
+
if (d && this.placementPolicy.preventOverlap) {
|
|
237
|
+
const m = Je(
|
|
239
238
|
this.host.document,
|
|
240
|
-
|
|
239
|
+
d,
|
|
241
240
|
this.placementPolicy,
|
|
242
241
|
(v) => {
|
|
243
|
-
var
|
|
242
|
+
var p, b, y;
|
|
244
243
|
const S = this.transactionBounds.get(v.nodeId);
|
|
245
244
|
if (S) return S;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
245
|
+
if (v.nodeType === "asset") {
|
|
246
|
+
const O = (b = (p = this.session).getMeasuredAssetBounds) == null ? void 0 : b.call(p, v.assetRevisionId);
|
|
247
|
+
if (O) return O;
|
|
248
|
+
}
|
|
249
|
+
const c = w(this.host.document.root, v.nodeId);
|
|
250
|
+
return !c || c.nodeType !== v.nodeType || v.nodeType === "asset" && (c.nodeType !== "asset" || v.assetRevisionId !== c.assetRevisionId) || v.nodeType === "visual" && (c.nodeType !== "visual" || v.visualRevisionId !== c.visualRevisionId) || !x(
|
|
251
|
+
C(this.host.document, c),
|
|
252
|
+
C(d, v)
|
|
253
|
+
) ? null : ((y = this.session.getNodeFrame(v.nodeId)) == null ? void 0 : y.localBounds) ?? null;
|
|
251
254
|
},
|
|
252
255
|
new Set(i.allowOverlapNodeIds ?? []),
|
|
253
256
|
i.supportContacts
|
|
254
257
|
);
|
|
255
|
-
if (
|
|
258
|
+
if (m.length)
|
|
256
259
|
return {
|
|
257
260
|
allowed: !1,
|
|
258
|
-
code:
|
|
259
|
-
message:
|
|
261
|
+
code: m[0].code,
|
|
262
|
+
message: m.map((v) => v.message).join("; ")
|
|
260
263
|
};
|
|
261
264
|
}
|
|
262
265
|
return { allowed: !0 };
|
|
263
266
|
}
|
|
264
|
-
}, this.releaseWritePolicy =
|
|
267
|
+
}, this.releaseWritePolicy = it(this.host, this.writePolicy), this.installBuiltInActions();
|
|
265
268
|
const s = e.sessionOptions ?? {};
|
|
266
|
-
this.session = (t.createSession ??
|
|
269
|
+
this.session = (t.createSession ?? st)({
|
|
267
270
|
...s,
|
|
268
271
|
viewport: e.viewport,
|
|
269
272
|
canvas: e.canvas,
|
|
270
|
-
resolveSource: e.resolveSource ?? (async (i,
|
|
273
|
+
resolveSource: e.resolveSource ?? (async (i, a, d, u) => {
|
|
271
274
|
u == null || u.stage("resolving-source", "正在解析资产来源...");
|
|
272
|
-
const
|
|
273
|
-
if (!
|
|
275
|
+
const m = await this.host.resolveAssetSource(i, { signal: d }), v = Object.entries((a == null ? void 0 : a.variantSelections) ?? {}).map(([f, p]) => ({ primPath: "/", setName: f, selection: p }));
|
|
276
|
+
if (!m) return null;
|
|
274
277
|
u == null || u.stage("downloading", "正在读取资产入口...");
|
|
275
|
-
const S = this.remoteResourcePathsFor(i),
|
|
276
|
-
...
|
|
278
|
+
const S = this.remoteResourcePathsFor(i), c = await Ee(m, v, {
|
|
279
|
+
...d ? { signal: d } : {},
|
|
277
280
|
...S.length ? { resourcePaths: S } : {},
|
|
278
|
-
...
|
|
281
|
+
...m.kind === "remote-entry" ? { remoteResolver: this.remoteResolverFor(m) } : {}
|
|
279
282
|
});
|
|
280
|
-
return u == null || u.stage("validating", "正在校验资产入口..."),
|
|
283
|
+
return u == null || u.stage("validating", "正在校验资产入口..."), c;
|
|
281
284
|
}),
|
|
282
|
-
resolveVisualSource: e.resolveVisualSource ?? (async (i,
|
|
285
|
+
resolveVisualSource: e.resolveVisualSource ?? (async (i, a, d, u) => {
|
|
283
286
|
u == null || u.stage("resolving-source", "正在解析视觉资产来源...");
|
|
284
|
-
const [
|
|
285
|
-
this.host.resolveVisualAssetSource(i, { signal:
|
|
286
|
-
Promise.resolve(
|
|
287
|
+
const [m, v] = await Promise.all([
|
|
288
|
+
this.host.resolveVisualAssetSource(i, { signal: d }),
|
|
289
|
+
Promise.resolve(Ge(this.host.document, i))
|
|
287
290
|
]);
|
|
288
|
-
if (!
|
|
291
|
+
if (!m || !v) return null;
|
|
289
292
|
u == null || u.stage("downloading", "正在读取视觉资产入口...");
|
|
290
|
-
const S = await
|
|
291
|
-
...
|
|
292
|
-
...
|
|
293
|
+
const S = await lt(m, v, a, {
|
|
294
|
+
...d ? { signal: d } : {},
|
|
295
|
+
...m.kind === "remote-entry" ? { remoteResolver: this.remoteResolverFor(m) } : {}
|
|
293
296
|
});
|
|
294
297
|
return u == null || u.stage("validating", "正在校验视觉资产入口..."), S;
|
|
295
298
|
}),
|
|
296
|
-
onPick: (i,
|
|
299
|
+
onPick: (i, a, d) => {
|
|
297
300
|
var u;
|
|
298
301
|
if (!this.disposed && !this.previewDocument && (!this.previewMode || this.previewSelection === "inspect")) {
|
|
299
|
-
const
|
|
300
|
-
this.select(v, i && v.includes(i) ? i : void 0), (u = s.onPick) == null || u.call(s, i,
|
|
302
|
+
const m = this.host.getSelection(), v = i === null ? [] : a ? m.instanceIds.includes(i) ? m.instanceIds.filter((S) => S !== i) : [...m.instanceIds, i] : [i];
|
|
303
|
+
this.select(v, i && v.includes(i) ? i : void 0), (u = s.onPick) == null || u.call(s, i, a, d);
|
|
301
304
|
}
|
|
302
305
|
},
|
|
303
|
-
onBoxSelect: (i,
|
|
304
|
-
var
|
|
305
|
-
this.disposed || !this.previewDocument && (!this.previewMode || this.previewSelection === "inspect") && (this.select(
|
|
306
|
+
onBoxSelect: (i, a) => {
|
|
307
|
+
var d;
|
|
308
|
+
this.disposed || !this.previewDocument && (!this.previewMode || this.previewSelection === "inspect") && (this.select(a ? [...this.host.getSelection().instanceIds, ...i] : i), (d = s.onBoxSelect) == null || d.call(s, i, a));
|
|
306
309
|
},
|
|
307
|
-
onTransform: (i,
|
|
310
|
+
onTransform: (i, a, d) => {
|
|
308
311
|
var u;
|
|
309
312
|
if (!this.disposed)
|
|
310
313
|
try {
|
|
311
|
-
this.commitTransform(i,
|
|
312
|
-
} catch (
|
|
313
|
-
this.report(
|
|
314
|
+
this.commitTransform(i, a, !0, d), (u = s.onTransform) == null || u.call(s, i, a);
|
|
315
|
+
} catch (m) {
|
|
316
|
+
this.report(m), this.sync().catch((v) => this.report(v));
|
|
314
317
|
}
|
|
315
318
|
},
|
|
316
|
-
onNodeOriginChange: (i,
|
|
317
|
-
var
|
|
319
|
+
onNodeOriginChange: (i, a) => {
|
|
320
|
+
var d;
|
|
318
321
|
if (!this.disposed)
|
|
319
322
|
try {
|
|
320
|
-
this.setNodeOrigin(i, { local:
|
|
323
|
+
this.setNodeOrigin(i, { local: a }), (d = s.onNodeOriginChange) == null || d.call(s, i, a);
|
|
321
324
|
} catch (u) {
|
|
322
|
-
this.report(u), this.sync().catch((
|
|
325
|
+
this.report(u), this.sync().catch((m) => this.report(m));
|
|
323
326
|
}
|
|
324
327
|
},
|
|
325
|
-
onRegionTransform: (i,
|
|
326
|
-
var
|
|
327
|
-
this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (
|
|
328
|
+
onRegionTransform: (i, a) => {
|
|
329
|
+
var d;
|
|
330
|
+
this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (d = s.onRegionTransform) == null || d.call(s, i, a);
|
|
328
331
|
},
|
|
329
|
-
onRegionShapeChange: (i,
|
|
330
|
-
var
|
|
331
|
-
this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (
|
|
332
|
+
onRegionShapeChange: (i, a) => {
|
|
333
|
+
var d;
|
|
334
|
+
this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (d = s.onRegionShapeChange) == null || d.call(s, i, a);
|
|
332
335
|
},
|
|
333
336
|
onStatus: (i) => {
|
|
334
|
-
var
|
|
335
|
-
this.disposed || (this.sceneStatus = i, this.contextVersion += 1, this.emit("status.change"), this.emit("toolbar.change"), (
|
|
337
|
+
var a;
|
|
338
|
+
this.disposed || (this.sceneStatus = i, this.contextVersion += 1, this.emit("status.change"), this.emit("toolbar.change"), (a = s.onStatus) == null || a.call(s, i));
|
|
336
339
|
},
|
|
337
340
|
onAssetLoadStatus: (i) => {
|
|
338
|
-
var
|
|
339
|
-
this.disposed || (
|
|
341
|
+
var a;
|
|
342
|
+
this.disposed || (a = s.onAssetLoadStatus) == null || a.call(s, i);
|
|
340
343
|
},
|
|
341
344
|
onSelectionOverlayChange: (i) => {
|
|
342
|
-
var
|
|
345
|
+
var a;
|
|
343
346
|
if (!this.disposed) {
|
|
344
347
|
if (!x(this.overlay, i)) {
|
|
345
|
-
const
|
|
346
|
-
this.overlay = i, this.overlaySequence += 1, this.emit("overlay.change"),
|
|
348
|
+
const d = this.overlay.transforming !== i.transforming || this.overlay.hiddenReason === "selecting" != (i.hiddenReason === "selecting");
|
|
349
|
+
this.overlay = i, this.overlaySequence += 1, this.emit("overlay.change"), d && this.changed();
|
|
347
350
|
}
|
|
348
|
-
(
|
|
351
|
+
(a = s.onSelectionOverlayChange) == null || a.call(s, i);
|
|
349
352
|
}
|
|
350
353
|
},
|
|
351
354
|
onError: (i) => {
|
|
352
|
-
var
|
|
353
|
-
this.report(new Error(i)), (
|
|
355
|
+
var a;
|
|
356
|
+
this.report(new Error(i)), (a = s.onError) == null || a.call(s, i);
|
|
354
357
|
}
|
|
355
358
|
}), this.unsubscribeHost = this.host.subscribe((i) => {
|
|
356
|
-
var
|
|
359
|
+
var a, d;
|
|
357
360
|
if (!this.disposed) {
|
|
358
361
|
if (i.type === "selection.change")
|
|
359
362
|
this.selectionVersion += 1, this.overlay = { x: 0, y: 0, visible: !1, transforming: !1, hiddenReason: i.selection.instanceIds.length ? "anchor-unavailable" : "no-selection" }, this.overlaySequence += 1, this.session.select(i.selection.instanceIds, i.selection.primaryId);
|
|
360
363
|
else if (i.type === "document.change" || i.type === "asset.loaded") {
|
|
361
364
|
if (i.type === "document.change" && (i.origin === "open" || i.origin === "replace")) {
|
|
362
|
-
this.sceneSessionId = `session_${
|
|
365
|
+
this.sceneSessionId = `session_${T()}`, this.selectionVersion = 0, this.overlaySequence = 0, this.previewDocument = null;
|
|
363
366
|
for (const u of this.transformOrigins.keys())
|
|
364
|
-
(
|
|
367
|
+
(d = (a = this.session).setTransformOrigin) == null || d.call(a, u, null);
|
|
365
368
|
this.transformOrigins.clear(), this.syncInteractionMode(), this.overlay = { x: 0, y: 0, visible: !1, transforming: !1, hiddenReason: "no-selection" };
|
|
366
369
|
}
|
|
367
370
|
this.sync().catch((u) => this.report(u));
|
|
368
371
|
} else i.type === "editorial.change" && (this.session.setEditorial(i.snapshot.editorial), this.session.select(i.snapshot.selection.instanceIds, i.snapshot.selection.primaryId));
|
|
369
372
|
this.contextVersion += 1, this.emit("toolbar.change"), this.emitEvent({ type: "host.change", snapshot: this.getSnapshot(), event: i });
|
|
370
373
|
}
|
|
371
|
-
}), (n = (o = this.session).setSurfaceSnap) == null || n.call(o, this.placementPolicy.surfaceSnap), (
|
|
372
|
-
} :
|
|
374
|
+
}), (n = (o = this.session).setSurfaceSnap) == null || n.call(o, this.placementPolicy.surfaceSnap), (l = (h = this.session).setOverlapPrevention) == null || l.call(h, this.placementPolicy.preventOverlap), this.releaseShortcuts = e.shortcuts === !1 ? () => {
|
|
375
|
+
} : dt(e.canvas, (i) => this.handleShortcut(i)), this.ready = this.host.ready().then(async () => {
|
|
373
376
|
this.disposed || await this.sync();
|
|
374
377
|
}).catch((i) => {
|
|
375
378
|
if (!this.disposed) throw i;
|
|
@@ -412,16 +415,16 @@ class it {
|
|
|
412
415
|
* feature that is present but whose visualization is not mounted.
|
|
413
416
|
*/
|
|
414
417
|
getNodeFeatures(e) {
|
|
415
|
-
return this.assertActive(),
|
|
418
|
+
return this.assertActive(), ct(this.host.document, e, this.session.getRuntime(e));
|
|
416
419
|
}
|
|
417
420
|
getAssetLoadStatus(e) {
|
|
418
421
|
return this.assertActive(), this.session.getAssetLoadStatus(e);
|
|
419
422
|
}
|
|
420
423
|
remoteResolverFor(e) {
|
|
421
|
-
const t =
|
|
424
|
+
const t = ze(e), s = this.remoteResolvers.get(e.revisionId);
|
|
422
425
|
if ((s == null ? void 0 : s.fingerprint) === t && s.request === e.request)
|
|
423
426
|
return s.resolver;
|
|
424
|
-
const o = this.host.getAsset(e.revisionId) ?? this.host.getVisualAsset(e.revisionId) ?? void 0, n = new
|
|
427
|
+
const o = this.host.getAsset(e.revisionId) ?? this.host.getVisualAsset(e.revisionId) ?? void 0, n = new ye(e, o);
|
|
425
428
|
return this.remoteResolvers.set(e.revisionId, {
|
|
426
429
|
fingerprint: t,
|
|
427
430
|
request: e.request,
|
|
@@ -435,15 +438,15 @@ class it {
|
|
|
435
438
|
captureEditorialState() {
|
|
436
439
|
this.assertActive();
|
|
437
440
|
const e = this.host.getSnapshot(), t = this.session.getCameraState();
|
|
438
|
-
return
|
|
441
|
+
return He({
|
|
439
442
|
document: this.host.document,
|
|
440
443
|
editorial: e.editorial,
|
|
441
444
|
selection: e.selection,
|
|
442
|
-
camera: t ?
|
|
445
|
+
camera: t ? pt(t) : null
|
|
443
446
|
});
|
|
444
447
|
}
|
|
445
448
|
applyEditorialState(e) {
|
|
446
|
-
this.assertActive(), this.assertEditable(),
|
|
449
|
+
this.assertActive(), this.assertEditable(), Xe(e, this.host.document), this.session.cancelActiveGesture();
|
|
447
450
|
const t = Object.fromEntries(e.nodeStates.map((s) => [
|
|
448
451
|
s.nodeId,
|
|
449
452
|
{ hidden: s.hidden, locked: s.locked }
|
|
@@ -477,7 +480,7 @@ class it {
|
|
|
477
480
|
(s = (t = this.actionDefinitions.get(e)) == null ? void 0 : t.cancel) == null || s.call(t), (o = this.actionControllers.get(e)) == null || o.abort(), this.actionControllers.delete(e), this.coreActionBusy.delete(e), this.changed();
|
|
478
481
|
}
|
|
479
482
|
async sync() {
|
|
480
|
-
var o, n,
|
|
483
|
+
var o, n, h, l, i, a;
|
|
481
484
|
this.assertActive();
|
|
482
485
|
const e = ++this.syncEpoch, t = this.previewDocument ?? this.host.document;
|
|
483
486
|
try {
|
|
@@ -486,17 +489,17 @@ class it {
|
|
|
486
489
|
this.host.getSnapshot().editorial,
|
|
487
490
|
((n = (o = this.options).resolveRegionOverlays) == null ? void 0 : n.call(o, t)) ?? []
|
|
488
491
|
);
|
|
489
|
-
} catch (
|
|
492
|
+
} catch (d) {
|
|
490
493
|
if (this.disposed) return;
|
|
491
|
-
throw
|
|
494
|
+
throw d;
|
|
492
495
|
}
|
|
493
496
|
if (this.disposed || e !== this.syncEpoch) return;
|
|
494
|
-
for (const [
|
|
495
|
-
|
|
497
|
+
for (const [d, u] of this.transformOrigins)
|
|
498
|
+
w(t.root, d) && ((l = (h = this.session).setTransformOrigin) == null || l.call(h, d, [...u]));
|
|
496
499
|
if (!this.previewDocument) {
|
|
497
|
-
const
|
|
500
|
+
const d = new Set(R(this.host.document.root).map((u) => u.nodeId));
|
|
498
501
|
for (const u of this.transformOrigins.keys())
|
|
499
|
-
|
|
502
|
+
d.has(u) || (this.transformOrigins.delete(u), (a = (i = this.session).setTransformOrigin) == null || a.call(i, u, null));
|
|
500
503
|
}
|
|
501
504
|
const s = this.host.getSelection();
|
|
502
505
|
this.session.select(s.instanceIds, s.primaryId);
|
|
@@ -520,7 +523,7 @@ class it {
|
|
|
520
523
|
if (this.placementPreviewActive = !1, this.changed(), !s) return null;
|
|
521
524
|
const o = this.host.getAsset(e.revisionId);
|
|
522
525
|
if (!o) throw new g("ASSET_NOT_FOUND", `Asset revision not found: ${e.revisionId}`);
|
|
523
|
-
const n =
|
|
526
|
+
const n = me(o, {
|
|
524
527
|
revisionId: o.revisionId,
|
|
525
528
|
label: e.label,
|
|
526
529
|
role: e.role,
|
|
@@ -530,10 +533,10 @@ class it {
|
|
|
530
533
|
...e.physics ? { physics: e.physics } : {}
|
|
531
534
|
});
|
|
532
535
|
return this.host.commit({
|
|
533
|
-
commands: [
|
|
536
|
+
commands: [fe(n, e.parentNodeId ?? t.document.root.nodeId, {
|
|
534
537
|
label: `Place ${n.label}`,
|
|
535
538
|
source: "human",
|
|
536
|
-
batchId: `batch_${
|
|
539
|
+
batchId: `batch_${T()}`
|
|
537
540
|
})],
|
|
538
541
|
expectedDocumentVersion: t.documentVersion,
|
|
539
542
|
expectedSceneEpoch: t.sceneEpoch
|
|
@@ -557,19 +560,19 @@ class it {
|
|
|
557
560
|
this.assertEditable(t);
|
|
558
561
|
const n = Array.isArray(e) ? e : [e];
|
|
559
562
|
for (const i of n) {
|
|
560
|
-
const
|
|
561
|
-
if (!("nodeId" in
|
|
562
|
-
const u = (
|
|
563
|
+
const a = i.payload;
|
|
564
|
+
if (!("nodeId" in a)) continue;
|
|
565
|
+
const u = (a.type === "node.remove" || a.type === "node.duplicate" || a.type === "node.transform" ? re(w(this.host.document.root, a.nodeId)) : [a.nodeId]).find((m) => this.host.getEditorialState(m).locked);
|
|
563
566
|
if (u)
|
|
564
567
|
throw new g("NODE_LOCKED", `Scene node is locked: ${u}`);
|
|
565
568
|
}
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
const
|
|
569
|
+
const h = _e(this.host.document, n);
|
|
570
|
+
h.diagnostics.some((i) => i.level === "error") || this.assertProjectionRepresentable(h.doc.root);
|
|
571
|
+
const l = this.host.getSnapshot();
|
|
569
572
|
return this.host.commit({
|
|
570
573
|
commands: n,
|
|
571
|
-
expectedDocumentVersion:
|
|
572
|
-
expectedSceneEpoch:
|
|
574
|
+
expectedDocumentVersion: l.documentVersion,
|
|
575
|
+
expectedSceneEpoch: l.sceneEpoch,
|
|
573
576
|
...t ? { gestureCommit: !0 } : {},
|
|
574
577
|
...s.length ? { allowOverlapNodeIds: s } : {},
|
|
575
578
|
...o.length ? { supportContacts: o } : {}
|
|
@@ -589,7 +592,113 @@ class it {
|
|
|
589
592
|
}
|
|
590
593
|
setPlacementPolicy(e) {
|
|
591
594
|
var t, s, o, n;
|
|
592
|
-
this.assertActive(), this.placementPolicy =
|
|
595
|
+
this.assertActive(), this.placementPolicy = qe(e, this.placementPolicy), (s = (t = this.session).setSurfaceSnap) == null || s.call(t, this.placementPolicy.surfaceSnap), (n = (o = this.session).setOverlapPrevention) == null || n.call(o, this.placementPolicy.preventOverlap), this.changed();
|
|
596
|
+
}
|
|
597
|
+
addBoundingBoxPlaceholder(e) {
|
|
598
|
+
var v;
|
|
599
|
+
this.assertEditable();
|
|
600
|
+
const t = this.host.getSnapshot(), s = e.parentNodeId ?? t.document.root.nodeId;
|
|
601
|
+
if (((v = w(t.document.root, s)) == null ? void 0 : v.nodeType) !== "group")
|
|
602
|
+
throw new g(
|
|
603
|
+
"PLACEMENT_PARENT_INVALID",
|
|
604
|
+
"Placeholder parent must be a scene group."
|
|
605
|
+
);
|
|
606
|
+
const o = Re({
|
|
607
|
+
nodeId: "node_placeholder_placement_probe",
|
|
608
|
+
label: e.label,
|
|
609
|
+
dimensions: e.dimensions,
|
|
610
|
+
...e.localUpDirection ? { localUpDirection: e.localUpDirection } : {},
|
|
611
|
+
...e.position ? { position: e.position } : {},
|
|
612
|
+
...e.role ? { role: e.role } : {},
|
|
613
|
+
...e.visible !== void 0 ? { visible: e.visible } : {},
|
|
614
|
+
...e.assetRevisionId ? { assetRevisionId: e.assetRevisionId } : {},
|
|
615
|
+
...e.externalRef ? { externalRef: e.externalRef } : {},
|
|
616
|
+
...e.semantic ? { semantic: e.semantic } : {}
|
|
617
|
+
}), n = C(t.document, o);
|
|
618
|
+
if (!n)
|
|
619
|
+
throw new g(
|
|
620
|
+
"PLACEMENT_BOUNDS_UNAVAILABLE",
|
|
621
|
+
"Placeholder placement requires known bounds."
|
|
622
|
+
);
|
|
623
|
+
const h = R(t.document.root).filter((S) => q(S) && F(t.document.root, S.nodeId, {})).map((S) => {
|
|
624
|
+
var c, f, p;
|
|
625
|
+
return {
|
|
626
|
+
nodeId: S.nodeId,
|
|
627
|
+
bounds: ((c = this.getNodeFrame(S.nodeId)) == null ? void 0 : c.localBounds) ?? (S.nodeType === "asset" ? (p = (f = this.session).getMeasuredAssetBounds) == null ? void 0 : p.call(f, S.assetRevisionId) : null) ?? C(t.document, S),
|
|
628
|
+
transform: Z(t.document.root, S.nodeId),
|
|
629
|
+
container: ee(t.document, S)
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
if (this.placementPolicy.preventOverlap && h.some((S) => !S.bounds))
|
|
633
|
+
throw new g(
|
|
634
|
+
"PLACEMENT_BOUNDS_UNAVAILABLE",
|
|
635
|
+
"Overlap prevention requires known obstacle bounds."
|
|
636
|
+
);
|
|
637
|
+
const l = J(t.document.root, s);
|
|
638
|
+
if (!l)
|
|
639
|
+
throw new g(
|
|
640
|
+
"TRANSFORM_NOT_REPRESENTABLE",
|
|
641
|
+
"Placeholder placement cannot be expressed below this parent."
|
|
642
|
+
);
|
|
643
|
+
const i = ge(l, o.localTransform);
|
|
644
|
+
if (!i)
|
|
645
|
+
throw new g(
|
|
646
|
+
"TRANSFORM_NOT_REPRESENTABLE",
|
|
647
|
+
"Placeholder placement cannot be expressed below this parent."
|
|
648
|
+
);
|
|
649
|
+
const a = {
|
|
650
|
+
...this.placementPolicy,
|
|
651
|
+
gridStepM: 0,
|
|
652
|
+
adaptiveGridSnap: !1,
|
|
653
|
+
surfaceSnap: !1,
|
|
654
|
+
alignToSurface: !1
|
|
655
|
+
}, d = h.flatMap((S) => S.bounds ? [{ ...S, bounds: S.bounds }] : []);
|
|
656
|
+
let u = U({
|
|
657
|
+
bounds: n,
|
|
658
|
+
transform: i,
|
|
659
|
+
policy: a,
|
|
660
|
+
obstacles: d
|
|
661
|
+
});
|
|
662
|
+
if (a.preventOverlap && u.reason === "PLACEMENT_OVERLAP")
|
|
663
|
+
for (const S of Ie(
|
|
664
|
+
n,
|
|
665
|
+
u.transform,
|
|
666
|
+
a.clearanceM
|
|
667
|
+
)) {
|
|
668
|
+
const c = U({
|
|
669
|
+
bounds: n,
|
|
670
|
+
transform: {
|
|
671
|
+
...i,
|
|
672
|
+
position: [
|
|
673
|
+
i.position[0] + S[0],
|
|
674
|
+
i.position[1] + S[1],
|
|
675
|
+
i.position[2] + S[2]
|
|
676
|
+
]
|
|
677
|
+
},
|
|
678
|
+
policy: a,
|
|
679
|
+
obstacles: d
|
|
680
|
+
});
|
|
681
|
+
if (c.valid) {
|
|
682
|
+
u = c;
|
|
683
|
+
break;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (!u.valid)
|
|
687
|
+
throw new g(
|
|
688
|
+
u.reason ?? "PLACEMENT_INVALID",
|
|
689
|
+
"The placeholder placement violates the active policy."
|
|
690
|
+
);
|
|
691
|
+
const m = B(u.transform, l);
|
|
692
|
+
if (!m)
|
|
693
|
+
throw new g(
|
|
694
|
+
"TRANSFORM_NOT_REPRESENTABLE",
|
|
695
|
+
"Placeholder placement cannot be expressed below this parent."
|
|
696
|
+
);
|
|
697
|
+
return this.host.addBoundingBoxPlaceholder({
|
|
698
|
+
...e,
|
|
699
|
+
parentNodeId: s,
|
|
700
|
+
position: m.position
|
|
701
|
+
});
|
|
593
702
|
}
|
|
594
703
|
async prepareAssetPlacement(e) {
|
|
595
704
|
var v, S;
|
|
@@ -597,7 +706,7 @@ class it {
|
|
|
597
706
|
const t = this.host.getSnapshot();
|
|
598
707
|
if (!this.host.getAsset(e.revisionId))
|
|
599
708
|
throw new g("ASSET_NOT_FOUND", "Asset revision is not registered.");
|
|
600
|
-
const s = e.parentNodeId ?? t.document.root.nodeId, o =
|
|
709
|
+
const s = e.parentNodeId ?? t.document.root.nodeId, o = w(t.document.root, s);
|
|
601
710
|
if ((o == null ? void 0 : o.nodeType) !== "group")
|
|
602
711
|
throw new g(
|
|
603
712
|
"PLACEMENT_PARENT_INVALID",
|
|
@@ -606,46 +715,75 @@ class it {
|
|
|
606
715
|
const n = await this.session.measureAssetBounds(e.revisionId);
|
|
607
716
|
if ((S = e.signal) == null || S.throwIfAborted(), this.assertActive(), this.host.getSnapshot().sceneEpoch !== t.sceneEpoch || this.host.getSnapshot().documentVersion !== t.documentVersion)
|
|
608
717
|
throw new g("CONTEXT_STALE", "Scene changed while measuring placement.");
|
|
609
|
-
const
|
|
610
|
-
(
|
|
611
|
-
).map((
|
|
612
|
-
var f;
|
|
718
|
+
const h = R(t.document.root).filter(
|
|
719
|
+
(c) => q(c) && F(t.document.root, c.nodeId, {})
|
|
720
|
+
).map((c) => {
|
|
721
|
+
var f, p, b;
|
|
613
722
|
return {
|
|
614
|
-
nodeId:
|
|
615
|
-
bounds: ((f = this.getNodeFrame(
|
|
616
|
-
transform:
|
|
617
|
-
container:
|
|
723
|
+
nodeId: c.nodeId,
|
|
724
|
+
bounds: ((f = this.getNodeFrame(c.nodeId)) == null ? void 0 : f.localBounds) ?? (c.nodeType === "asset" ? (b = (p = this.session).getMeasuredAssetBounds) == null ? void 0 : b.call(p, c.assetRevisionId) : null) ?? C(t.document, c),
|
|
725
|
+
transform: Z(t.document.root, c.nodeId),
|
|
726
|
+
container: ee(t.document, c)
|
|
618
727
|
};
|
|
619
|
-
}),
|
|
620
|
-
if (
|
|
728
|
+
}), l = e.allowOverlap ? { ...this.placementPolicy, preventOverlap: !1 } : this.placementPolicy;
|
|
729
|
+
if (l.preventOverlap && h.some((c) => !c.bounds))
|
|
621
730
|
throw new g(
|
|
622
731
|
"PLACEMENT_BOUNDS_UNAVAILABLE",
|
|
623
732
|
"Overlap prevention requires known obstacle bounds."
|
|
624
733
|
);
|
|
625
|
-
const i = !e.surface && (!!e.point || !e.worldTransform),
|
|
734
|
+
const i = !e.surface && (!!e.point || !e.worldTransform), a = e.surface ?? (i ? { nodeId: null, point: e.point ?? [0, 0, 0], normal: [0, 0, 1] } : null);
|
|
735
|
+
let d = U({
|
|
626
736
|
bounds: n,
|
|
627
|
-
transform: e.worldTransform ??
|
|
628
|
-
surface:
|
|
629
|
-
policy: i ? { ...
|
|
630
|
-
obstacles:
|
|
631
|
-
(
|
|
737
|
+
transform: e.worldTransform ?? ve(),
|
|
738
|
+
surface: a,
|
|
739
|
+
policy: i ? { ...l, surfaceSnap: !0, alignToSurface: !1 } : l,
|
|
740
|
+
obstacles: h.flatMap(
|
|
741
|
+
(c) => c.bounds ? [{ ...c, bounds: c.bounds }] : []
|
|
632
742
|
)
|
|
633
|
-
})
|
|
634
|
-
if (!
|
|
743
|
+
});
|
|
744
|
+
if (e.autoAvoidOverlap && !e.allowOverlap && a && d.reason === "PLACEMENT_OVERLAP")
|
|
745
|
+
for (const c of Ie(
|
|
746
|
+
n,
|
|
747
|
+
d.transform,
|
|
748
|
+
l.clearanceM
|
|
749
|
+
)) {
|
|
750
|
+
const f = U({
|
|
751
|
+
bounds: n,
|
|
752
|
+
transform: e.worldTransform ?? ve(),
|
|
753
|
+
surface: {
|
|
754
|
+
...a,
|
|
755
|
+
point: [
|
|
756
|
+
a.point[0] + c[0],
|
|
757
|
+
a.point[1] + c[1],
|
|
758
|
+
a.point[2] + c[2]
|
|
759
|
+
]
|
|
760
|
+
},
|
|
761
|
+
policy: i ? { ...l, surfaceSnap: !0, alignToSurface: !1 } : l,
|
|
762
|
+
obstacles: h.flatMap(
|
|
763
|
+
(p) => p.bounds ? [{ ...p, bounds: p.bounds }] : []
|
|
764
|
+
)
|
|
765
|
+
});
|
|
766
|
+
if (f.valid) {
|
|
767
|
+
d = f;
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
const u = J(t.document.root, s), m = u ? B(d.transform, u) : null;
|
|
772
|
+
if (!m)
|
|
635
773
|
throw new g(
|
|
636
774
|
"TRANSFORM_NOT_REPRESENTABLE",
|
|
637
775
|
"Placement requires shear below this parent."
|
|
638
776
|
);
|
|
639
|
-
return
|
|
640
|
-
|
|
777
|
+
return ie(
|
|
778
|
+
ne({
|
|
641
779
|
revisionId: e.revisionId,
|
|
642
780
|
parentNodeId: s,
|
|
643
781
|
sceneEpoch: t.sceneEpoch,
|
|
644
782
|
documentVersion: t.documentVersion,
|
|
645
783
|
policy: this.placementPolicy,
|
|
646
784
|
sourceBounds: n,
|
|
647
|
-
evaluation:
|
|
648
|
-
localTransform:
|
|
785
|
+
evaluation: d,
|
|
786
|
+
localTransform: m
|
|
649
787
|
})
|
|
650
788
|
);
|
|
651
789
|
}
|
|
@@ -661,7 +799,7 @@ class it {
|
|
|
661
799
|
);
|
|
662
800
|
const o = this.host.getAsset(e.revisionId);
|
|
663
801
|
if (!o) throw new g("ASSET_NOT_FOUND", "Asset revision not found.");
|
|
664
|
-
const n =
|
|
802
|
+
const n = me(o, {
|
|
665
803
|
revisionId: o.revisionId,
|
|
666
804
|
label: t.label,
|
|
667
805
|
role: t.role,
|
|
@@ -671,14 +809,14 @@ class it {
|
|
|
671
809
|
this.transactionBounds.set(n.nodeId, e.sourceBounds);
|
|
672
810
|
try {
|
|
673
811
|
return this.applyCommands(
|
|
674
|
-
|
|
812
|
+
fe(n, e.parentNodeId, {
|
|
675
813
|
label: "Place " + t.label,
|
|
676
814
|
source: "human",
|
|
677
|
-
batchId: "batch_" +
|
|
815
|
+
batchId: "batch_" + T()
|
|
678
816
|
}),
|
|
679
817
|
!1,
|
|
680
818
|
[],
|
|
681
|
-
|
|
819
|
+
te(
|
|
682
820
|
n.nodeId,
|
|
683
821
|
e.evaluation.supportNodeId,
|
|
684
822
|
e.evaluation.supportSurfaceZ
|
|
@@ -691,50 +829,50 @@ class it {
|
|
|
691
829
|
prepareNodePlacement(e) {
|
|
692
830
|
var u;
|
|
693
831
|
this.assertEditable();
|
|
694
|
-
const t = this.host.getSnapshot(), s =
|
|
832
|
+
const t = this.host.getSnapshot(), s = w(t.document.root, e.nodeId), o = (u = this.getNodeFrame(e.nodeId)) == null ? void 0 : u.localBounds;
|
|
695
833
|
if (!s || !o)
|
|
696
834
|
throw new g(
|
|
697
835
|
"PLACEMENT_BOUNDS_UNAVAILABLE",
|
|
698
836
|
"Placement requires known source bounds."
|
|
699
837
|
);
|
|
700
|
-
const n = new Set(
|
|
701
|
-
(
|
|
702
|
-
).map((
|
|
838
|
+
const n = new Set(re(s)), h = R(t.document.root).filter(
|
|
839
|
+
(m) => q(m) && !n.has(m.nodeId) && F(t.document.root, m.nodeId, {})
|
|
840
|
+
).map((m) => {
|
|
703
841
|
var v;
|
|
704
842
|
return {
|
|
705
|
-
nodeId:
|
|
706
|
-
bounds: ((v = this.getNodeFrame(
|
|
707
|
-
transform:
|
|
708
|
-
container:
|
|
843
|
+
nodeId: m.nodeId,
|
|
844
|
+
bounds: ((v = this.getNodeFrame(m.nodeId)) == null ? void 0 : v.localBounds) ?? C(t.document, m),
|
|
845
|
+
transform: Z(t.document.root, m.nodeId),
|
|
846
|
+
container: ee(t.document, m)
|
|
709
847
|
};
|
|
710
|
-
}),
|
|
711
|
-
if (
|
|
848
|
+
}), l = e.allowOverlap ? { ...this.placementPolicy, preventOverlap: !1 } : this.placementPolicy;
|
|
849
|
+
if (l.preventOverlap && h.some((m) => !m.bounds))
|
|
712
850
|
throw new g(
|
|
713
851
|
"PLACEMENT_BOUNDS_UNAVAILABLE",
|
|
714
852
|
"An obstacle has no known source bounds."
|
|
715
853
|
);
|
|
716
|
-
const i =
|
|
854
|
+
const i = U({
|
|
717
855
|
bounds: o,
|
|
718
856
|
transform: e.worldTransform,
|
|
719
857
|
surface: e.surface,
|
|
720
|
-
policy:
|
|
721
|
-
obstacles:
|
|
722
|
-
(
|
|
858
|
+
policy: l,
|
|
859
|
+
obstacles: h.flatMap(
|
|
860
|
+
(m) => m.bounds ? [{ ...m, bounds: m.bounds }] : []
|
|
723
861
|
)
|
|
724
|
-
}),
|
|
725
|
-
if (!
|
|
862
|
+
}), a = W(t.document.root, e.nodeId), d = a ? B(i.transform, a) : null;
|
|
863
|
+
if (!d)
|
|
726
864
|
throw new g(
|
|
727
865
|
"TRANSFORM_NOT_REPRESENTABLE",
|
|
728
866
|
"Placement cannot be expressed below this parent."
|
|
729
867
|
);
|
|
730
|
-
return
|
|
731
|
-
|
|
868
|
+
return ie(
|
|
869
|
+
ne({
|
|
732
870
|
nodeId: e.nodeId,
|
|
733
871
|
sceneEpoch: t.sceneEpoch,
|
|
734
872
|
documentVersion: t.documentVersion,
|
|
735
873
|
policy: this.placementPolicy,
|
|
736
874
|
evaluation: i,
|
|
737
|
-
localTransform:
|
|
875
|
+
localTransform: d
|
|
738
876
|
})
|
|
739
877
|
);
|
|
740
878
|
}
|
|
@@ -749,14 +887,14 @@ class it {
|
|
|
749
887
|
"The placement violates the active policy."
|
|
750
888
|
);
|
|
751
889
|
return this.applyCommands(
|
|
752
|
-
|
|
890
|
+
j(t.document, e.nodeId, e.localTransform, {
|
|
753
891
|
label: "Place node",
|
|
754
892
|
source: "human",
|
|
755
|
-
batchId: "batch_" +
|
|
893
|
+
batchId: "batch_" + T()
|
|
756
894
|
}),
|
|
757
895
|
!1,
|
|
758
896
|
[],
|
|
759
|
-
|
|
897
|
+
te(
|
|
760
898
|
e.nodeId,
|
|
761
899
|
e.evaluation.supportNodeId,
|
|
762
900
|
e.evaluation.supportSurfaceZ
|
|
@@ -787,7 +925,7 @@ class it {
|
|
|
787
925
|
}
|
|
788
926
|
setTransformOrigin(e, t) {
|
|
789
927
|
var o, n;
|
|
790
|
-
if (this.assertActive(), !
|
|
928
|
+
if (this.assertActive(), !w(this.host.document.root, e) || !t && t !== null || t && (t.length !== 3 || t.some((h) => !Number.isFinite(h)))) return !1;
|
|
791
929
|
if (this.assertEditable(!0), X(this.host.document.root, e, this.host.getSnapshot().editorial))
|
|
792
930
|
throw new g("NODE_LOCKED", `Scene node is locked: ${e}`);
|
|
793
931
|
return t ? this.transformOrigins.set(e, [...t]) : this.transformOrigins.delete(e), (n = (o = this.session).setTransformOrigin) == null || n.call(o, e, t ? [...t] : null), !0;
|
|
@@ -797,39 +935,39 @@ class it {
|
|
|
797
935
|
return ((t = this.getNodeFrame(e)) == null ? void 0 : t.orientation) ?? null;
|
|
798
936
|
}
|
|
799
937
|
setNodeOrigin(e, t) {
|
|
800
|
-
this.assertEditable(), t &&
|
|
801
|
-
const s =
|
|
938
|
+
this.assertEditable(), t && ut(t);
|
|
939
|
+
const s = w(this.host.document.root, e);
|
|
802
940
|
if (!s) throw new g("NODE_NOT_FOUND", `Scene node not found: ${e}`);
|
|
803
941
|
if (s.nodeId === this.host.document.root.nodeId)
|
|
804
942
|
throw new g("ORIGIN_NOT_EDITABLE", "The scene root does not expose a transform origin.");
|
|
805
943
|
return this.dispatch(
|
|
806
|
-
|
|
944
|
+
De(this.host.document, e, t, {
|
|
807
945
|
label: "Set node origin",
|
|
808
946
|
source: "human",
|
|
809
|
-
batchId: "batch_" +
|
|
947
|
+
batchId: "batch_" + T()
|
|
810
948
|
})
|
|
811
949
|
);
|
|
812
950
|
}
|
|
813
951
|
setNodeUpDirection(e, t) {
|
|
814
952
|
this.assertEditable();
|
|
815
953
|
const s = Math.hypot(...t);
|
|
816
|
-
if (t.length !== 3 || t.some((
|
|
954
|
+
if (t.length !== 3 || t.some((l) => !Number.isFinite(l)) || !Number.isFinite(s) || s <= 1e-12)
|
|
817
955
|
throw new g(
|
|
818
956
|
"ORIENTATION_DIRECTION_INVALID",
|
|
819
957
|
"Orientation direction must be a finite, non-zero three-component vector."
|
|
820
958
|
);
|
|
821
|
-
const o =
|
|
959
|
+
const o = w(this.host.document.root, e);
|
|
822
960
|
if (!o) throw new g("NODE_NOT_FOUND", `Scene node not found: ${e}`);
|
|
823
|
-
const n = t.map((
|
|
961
|
+
const n = t.map((l) => l / s), h = $e(n);
|
|
824
962
|
return this.changeTransform(
|
|
825
963
|
e,
|
|
826
|
-
{ ...o.localTransform, rotation:
|
|
964
|
+
{ ...o.localTransform, rotation: h },
|
|
827
965
|
{ space: "local", scope: "node" }
|
|
828
966
|
);
|
|
829
967
|
}
|
|
830
968
|
getAssetDimensions(e) {
|
|
831
969
|
var t;
|
|
832
|
-
return this.assertActive(),
|
|
970
|
+
return this.assertActive(), et(
|
|
833
971
|
this.host.document,
|
|
834
972
|
e,
|
|
835
973
|
(t = this.session.getNodeFrame(e)) == null ? void 0 : t.localBounds
|
|
@@ -852,48 +990,48 @@ class it {
|
|
|
852
990
|
this.session.setTransformSpace(e), this.transformSpace = e, this.changed();
|
|
853
991
|
}
|
|
854
992
|
setNodeDimensions(e, t, s = {}) {
|
|
855
|
-
var i,
|
|
993
|
+
var i, a;
|
|
856
994
|
this.assertEditable();
|
|
857
|
-
const o = this.getAssetDimensions(e), n =
|
|
995
|
+
const o = this.getAssetDimensions(e), n = w(this.host.document.root, e);
|
|
858
996
|
if (!n || !(o != null && o.editable) || !o.sourceDimensions)
|
|
859
997
|
throw new g(
|
|
860
998
|
(o == null ? void 0 : o.reason) ?? "NODE_NOT_FOUND",
|
|
861
999
|
"Node dimensions cannot be edited: " + e
|
|
862
1000
|
);
|
|
863
|
-
if (t.length !== 3 || t.some((
|
|
1001
|
+
if (t.length !== 3 || t.some((d) => !Number.isFinite(d) || d <= 0))
|
|
864
1002
|
throw new g(
|
|
865
1003
|
"DIMENSIONS_INVALID",
|
|
866
1004
|
"Dimensions must be three positive finite metre values."
|
|
867
1005
|
);
|
|
868
1006
|
if (s.anchor && s.anchor !== "node-origin" && s.anchor !== "bounds-center")
|
|
869
1007
|
throw new g("DIMENSIONS_ANCHOR_INVALID", "Unknown dimensions anchor.");
|
|
870
|
-
const
|
|
871
|
-
(
|
|
1008
|
+
const h = t.map(
|
|
1009
|
+
(d, u) => d / o.sourceDimensions[u]
|
|
872
1010
|
);
|
|
873
|
-
let
|
|
1011
|
+
let l = n.localTransform.position;
|
|
874
1012
|
if (s.anchor === "bounds-center") {
|
|
875
|
-
const
|
|
876
|
-
if (!
|
|
1013
|
+
const d = (i = this.getNodeFrame(e)) == null ? void 0 : i.localBounds;
|
|
1014
|
+
if (!d)
|
|
877
1015
|
throw new g(
|
|
878
1016
|
"BOUNDS_UNAVAILABLE",
|
|
879
1017
|
"A bounds center requires source bounds."
|
|
880
1018
|
);
|
|
881
|
-
const u =
|
|
882
|
-
(
|
|
883
|
-
), S =
|
|
1019
|
+
const u = tt(d), m = ((a = n.origin) == null ? void 0 : a.local) ?? [0, 0, 0], v = u.map(
|
|
1020
|
+
(c, f) => c - m[f]
|
|
1021
|
+
), S = je(
|
|
884
1022
|
n.localTransform.rotation,
|
|
885
1023
|
v.map(
|
|
886
|
-
(
|
|
1024
|
+
(c, f) => c * (n.localTransform.scale[f] - h[f])
|
|
887
1025
|
)
|
|
888
1026
|
);
|
|
889
|
-
|
|
1027
|
+
l = l.map((c, f) => c + S[f]);
|
|
890
1028
|
}
|
|
891
1029
|
return this.dispatch(
|
|
892
|
-
|
|
1030
|
+
j(
|
|
893
1031
|
this.host.document,
|
|
894
1032
|
e,
|
|
895
|
-
{ ...n.localTransform, position:
|
|
896
|
-
{ label: "Set node dimensions", source: "human", batchId: "batch_" +
|
|
1033
|
+
{ ...n.localTransform, position: l, scale: h },
|
|
1034
|
+
{ label: "Set node dimensions", source: "human", batchId: "batch_" + T() }
|
|
897
1035
|
)
|
|
898
1036
|
);
|
|
899
1037
|
}
|
|
@@ -902,16 +1040,16 @@ class it {
|
|
|
902
1040
|
throw new g("VISIBILITY_INVALID", "Authored visibility must be boolean.");
|
|
903
1041
|
const s = /* @__PURE__ */ new Map();
|
|
904
1042
|
for (const n of e) {
|
|
905
|
-
const
|
|
906
|
-
if (!
|
|
1043
|
+
const h = w(this.host.document.root, n);
|
|
1044
|
+
if (!h || n === this.host.document.root.nodeId)
|
|
907
1045
|
throw new g("NODE_NOT_FOUND", "Scene node not found: " + n);
|
|
908
|
-
for (const
|
|
909
|
-
"visible" in
|
|
1046
|
+
for (const l of h.nodeType === "group" ? R(h) : [h])
|
|
1047
|
+
"visible" in l && s.set(l.nodeId, l);
|
|
910
1048
|
}
|
|
911
|
-
const o = "batch_" +
|
|
1049
|
+
const o = "batch_" + T();
|
|
912
1050
|
return this.dispatch(
|
|
913
1051
|
[...s.values()].filter((n) => "visible" in n && n.visible !== t).map(
|
|
914
|
-
(n) =>
|
|
1052
|
+
(n) => Ve(this.host.document, n.nodeId, t, {
|
|
915
1053
|
label: "Set authored visibility",
|
|
916
1054
|
source: "human",
|
|
917
1055
|
batchId: o
|
|
@@ -952,19 +1090,19 @@ class it {
|
|
|
952
1090
|
}
|
|
953
1091
|
setNodePhysics(e, t) {
|
|
954
1092
|
return this.dispatch(
|
|
955
|
-
|
|
1093
|
+
Ce(this.host.document, e, t, {
|
|
956
1094
|
label: "Set node physics",
|
|
957
1095
|
source: "human",
|
|
958
|
-
batchId: "batch_" +
|
|
1096
|
+
batchId: "batch_" + T()
|
|
959
1097
|
})
|
|
960
1098
|
);
|
|
961
1099
|
}
|
|
962
1100
|
setNodeInitialPose(e, t) {
|
|
963
1101
|
return this.dispatch(
|
|
964
|
-
|
|
1102
|
+
Le(this.host.document, e, t, {
|
|
965
1103
|
label: "Set initial joint pose",
|
|
966
1104
|
source: "human",
|
|
967
|
-
batchId: "batch_" +
|
|
1105
|
+
batchId: "batch_" + T()
|
|
968
1106
|
})
|
|
969
1107
|
);
|
|
970
1108
|
}
|
|
@@ -989,68 +1127,68 @@ class it {
|
|
|
989
1127
|
if (s.space && s.space !== "local" && s.space !== "world" || s.scope && s.scope !== "node" && s.scope !== "selection")
|
|
990
1128
|
throw new g("TRANSFORM_OPTIONS_INVALID", "Invalid transform space or scope.");
|
|
991
1129
|
if (s.scope === "node") {
|
|
992
|
-
const n =
|
|
993
|
-
if (!
|
|
1130
|
+
const n = W(this.host.document.root, e), h = s.space === "local" ? t : n ? B(t, n) : null;
|
|
1131
|
+
if (!h)
|
|
994
1132
|
throw new g(
|
|
995
1133
|
"TRANSFORM_NOT_REPRESENTABLE",
|
|
996
1134
|
"Transform cannot be expressed below this parent."
|
|
997
1135
|
);
|
|
998
1136
|
return this.dispatch(
|
|
999
|
-
|
|
1137
|
+
j(this.host.document, e, h, {
|
|
1000
1138
|
label: "Transform node",
|
|
1001
1139
|
source: "human",
|
|
1002
|
-
batchId: "batch_" +
|
|
1140
|
+
batchId: "batch_" + T()
|
|
1003
1141
|
})
|
|
1004
1142
|
);
|
|
1005
1143
|
}
|
|
1006
|
-
const o = s.space === "local" ?
|
|
1144
|
+
const o = s.space === "local" ? ge(W(this.host.document.root, e), t) : t;
|
|
1007
1145
|
if (!o)
|
|
1008
1146
|
throw new g("TRANSFORM_NOT_REPRESENTABLE", "Transform requires shear.");
|
|
1009
1147
|
return this.commitTransform(e, o, !1);
|
|
1010
1148
|
}
|
|
1011
1149
|
commitTransform(e, t, s, o = {}) {
|
|
1012
|
-
if (this.assertEditable(s), !
|
|
1150
|
+
if (this.assertEditable(s), !w(this.host.document.root, e) || K(
|
|
1013
1151
|
this.host.document.root,
|
|
1014
1152
|
e,
|
|
1015
1153
|
this.host.getSnapshot().editorial
|
|
1016
1154
|
))
|
|
1017
1155
|
throw new g("NODE_NOT_EDITABLE", `Scene node is not editable: ${e}`);
|
|
1018
|
-
const
|
|
1019
|
-
...
|
|
1020
|
-
visible:
|
|
1156
|
+
const h = this.host.getSelection(), l = /* @__PURE__ */ new Set([e, ...h.instanceIds]), i = this.sceneInstances().filter((c) => l.has(c.nodeId)).map((c) => ({
|
|
1157
|
+
...c,
|
|
1158
|
+
visible: F(
|
|
1021
1159
|
this.host.document.root,
|
|
1022
|
-
|
|
1160
|
+
c.nodeId,
|
|
1023
1161
|
this.host.getSnapshot().editorial
|
|
1024
1162
|
),
|
|
1025
|
-
localTransform:
|
|
1026
|
-
})),
|
|
1027
|
-
|
|
1028
|
-
|
|
1163
|
+
localTransform: J(this.host.document.root, c.nodeId) ?? c.localTransform
|
|
1164
|
+
})), a = Object.fromEntries(i.map((c) => [
|
|
1165
|
+
c.nodeId,
|
|
1166
|
+
We(
|
|
1029
1167
|
this.host.document.root,
|
|
1030
|
-
|
|
1168
|
+
c.nodeId,
|
|
1031
1169
|
this.host.getSnapshot().editorial
|
|
1032
1170
|
)
|
|
1033
|
-
])),
|
|
1034
|
-
const f =
|
|
1035
|
-
if (!
|
|
1171
|
+
])), d = new Set(this.selectionClosure([...l]).map((c) => c.nodeId)), u = ot(i, e, t, a).filter((c) => d.has(c.nodeId)).flatMap((c) => {
|
|
1172
|
+
const f = W(this.host.document.root, c.nodeId), p = f ? B(c.localTransform, f) : null;
|
|
1173
|
+
if (!p)
|
|
1036
1174
|
throw new g(
|
|
1037
1175
|
"TRANSFORM_NOT_REPRESENTABLE",
|
|
1038
|
-
`World transform cannot be represented below the parent of ${
|
|
1176
|
+
`World transform cannot be represented below the parent of ${c.nodeId}.`
|
|
1039
1177
|
);
|
|
1040
|
-
const b =
|
|
1041
|
-
return b && !x(b.localTransform,
|
|
1042
|
-
}),
|
|
1178
|
+
const b = w(this.host.document.root, c.nodeId);
|
|
1179
|
+
return b && !x(b.localTransform, p) ? [{ nodeId: c.nodeId, localTransform: p }] : [];
|
|
1180
|
+
}), m = `batch_${T()}`, v = o.supportNodeId, S = o.supportSurfaceZ;
|
|
1043
1181
|
return this.applyCommands(
|
|
1044
|
-
u.map((
|
|
1182
|
+
u.map((c) => j(
|
|
1045
1183
|
this.host.document,
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
{ label: "Transform selection", source: "human", batchId:
|
|
1184
|
+
c.nodeId,
|
|
1185
|
+
c.localTransform,
|
|
1186
|
+
{ label: "Transform selection", source: "human", batchId: m }
|
|
1049
1187
|
)),
|
|
1050
1188
|
s,
|
|
1051
|
-
o.allowOverlap === !0 ? [e, ...
|
|
1052
|
-
v && Number.isFinite(S) ? u.flatMap((
|
|
1053
|
-
|
|
1189
|
+
o.allowOverlap === !0 ? [e, ...h.instanceIds] : [],
|
|
1190
|
+
v && Number.isFinite(S) ? u.flatMap((c) => te(
|
|
1191
|
+
c.nodeId,
|
|
1054
1192
|
v,
|
|
1055
1193
|
S
|
|
1056
1194
|
)) : []
|
|
@@ -1058,34 +1196,34 @@ class it {
|
|
|
1058
1196
|
}
|
|
1059
1197
|
duplicateSelection(e = this.host.getSelection().instanceIds) {
|
|
1060
1198
|
this.assertEditable();
|
|
1061
|
-
const t = this.editableTargets(e), s = `batch_${
|
|
1199
|
+
const t = this.editableTargets(e), s = `batch_${T()}`, o = [], n = t.map((l) => {
|
|
1062
1200
|
var u;
|
|
1063
|
-
const i = ((u =
|
|
1064
|
-
if (
|
|
1065
|
-
const
|
|
1066
|
-
return o.push(
|
|
1067
|
-
...
|
|
1068
|
-
position: [
|
|
1201
|
+
const i = ((u = Q(this.host.document.root, l.nodeId)) == null ? void 0 : u.parent.nodeId) ?? this.host.document.root.nodeId, a = Me(this.host.document, l.nodeId, i, { label: "Duplicate selection", source: "human", batchId: s });
|
|
1202
|
+
if (a.payload.type !== "node.duplicate") throw new Error("Invalid duplicate command");
|
|
1203
|
+
const d = a.payload.created;
|
|
1204
|
+
return o.push(d.nodeId), xe({ ...a.payload, created: { ...d, localTransform: {
|
|
1205
|
+
...d.localTransform,
|
|
1206
|
+
position: [d.localTransform.position[0] + 0.25, d.localTransform.position[1] + 0.25, d.localTransform.position[2]]
|
|
1069
1207
|
} } }, { label: "Duplicate selection", source: "human", batchId: s });
|
|
1070
|
-
}),
|
|
1071
|
-
return
|
|
1208
|
+
}), h = this.dispatch(n);
|
|
1209
|
+
return h.changed && this.select(o), h;
|
|
1072
1210
|
}
|
|
1073
1211
|
deleteSelection(e = this.host.getSelection().instanceIds) {
|
|
1074
1212
|
this.assertEditable();
|
|
1075
|
-
const t = `batch_${
|
|
1076
|
-
return this.dispatch(this.editableTargets(e).map((s) =>
|
|
1213
|
+
const t = `batch_${T()}`;
|
|
1214
|
+
return this.dispatch(this.editableTargets(e).map((s) => Fe(this.host.document, s.nodeId, { label: "Delete selection", source: "human", batchId: t })));
|
|
1077
1215
|
}
|
|
1078
1216
|
groupSelection(e = this.host.getSelection().instanceIds) {
|
|
1079
1217
|
this.assertEditable();
|
|
1080
1218
|
const t = this.editableTargets(e);
|
|
1081
1219
|
if (t.length < 2) throw new g("GROUP_REQUIRES_MULTIPLE", "Grouping requires at least two editable nodes.");
|
|
1082
|
-
const s = new Set(t.map((
|
|
1083
|
-
var
|
|
1084
|
-
return ((
|
|
1085
|
-
})), o = s.size === 1 ? [...s][0] : this.host.document.root.nodeId, n = `batch_${
|
|
1086
|
-
return this.dispatch(
|
|
1220
|
+
const s = new Set(t.map((h) => {
|
|
1221
|
+
var l;
|
|
1222
|
+
return ((l = Q(this.host.document.root, h.nodeId)) == null ? void 0 : l.parent.nodeId) ?? this.host.document.root.nodeId;
|
|
1223
|
+
})), o = s.size === 1 ? [...s][0] : this.host.document.root.nodeId, n = `batch_${T()}`;
|
|
1224
|
+
return this.dispatch(Be(
|
|
1087
1225
|
this.host.document,
|
|
1088
|
-
t.map((
|
|
1226
|
+
t.map((h) => h.nodeId),
|
|
1089
1227
|
o,
|
|
1090
1228
|
{
|
|
1091
1229
|
label: "Group selection",
|
|
@@ -1098,30 +1236,30 @@ class it {
|
|
|
1098
1236
|
ungroupSelection(e = this.host.getSelection().instanceIds) {
|
|
1099
1237
|
this.assertEditable();
|
|
1100
1238
|
const t = this.removableGroupIds(
|
|
1101
|
-
this.editableTargets(e).map((
|
|
1239
|
+
this.editableTargets(e).map((h) => h.nodeId)
|
|
1102
1240
|
);
|
|
1103
1241
|
if (t.length === 0)
|
|
1104
1242
|
throw new g(
|
|
1105
1243
|
"NO_PARENT_GROUP",
|
|
1106
1244
|
"The selection does not contain an editable group or child of one."
|
|
1107
1245
|
);
|
|
1108
|
-
const s = `batch_${
|
|
1246
|
+
const s = `batch_${T()}`, o = [];
|
|
1109
1247
|
let n = this.host.document;
|
|
1110
|
-
for (const
|
|
1111
|
-
const
|
|
1248
|
+
for (const h of t) {
|
|
1249
|
+
const l = Ue(n, h, {
|
|
1112
1250
|
label: "Ungroup selection",
|
|
1113
1251
|
source: "human",
|
|
1114
1252
|
batchId: s
|
|
1115
1253
|
});
|
|
1116
|
-
o.push(...
|
|
1117
|
-
const
|
|
1118
|
-
if (
|
|
1254
|
+
o.push(...l), n = l.reduce((i, a) => {
|
|
1255
|
+
const d = ke(i, a.payload);
|
|
1256
|
+
if (d.diagnostics.some((u) => u.level === "error"))
|
|
1119
1257
|
throw new g(
|
|
1120
1258
|
"UNGROUP_REJECTED",
|
|
1121
|
-
|
|
1259
|
+
d.diagnostics.map((u) => u.message).join(`
|
|
1122
1260
|
`)
|
|
1123
1261
|
);
|
|
1124
|
-
return
|
|
1262
|
+
return d.doc;
|
|
1125
1263
|
}, n);
|
|
1126
1264
|
}
|
|
1127
1265
|
return this.dispatch(o);
|
|
@@ -1210,48 +1348,48 @@ class it {
|
|
|
1210
1348
|
return this.syncInteractionMode(), this.changed(), e || t;
|
|
1211
1349
|
}
|
|
1212
1350
|
getNodeActions(e) {
|
|
1213
|
-
const t = [...new Set(e)], s = this.selectionClosure(t), o = s.map((
|
|
1214
|
-
nodeId:
|
|
1215
|
-
reasonCode:
|
|
1351
|
+
const t = [...new Set(e)], s = this.selectionClosure(t), o = s.map((p) => p.nodeId), n = this.editableTargets(o).map((p) => p.nodeId), h = new Set(n), l = o.filter((p) => !h.has(p)).map((p) => ({
|
|
1352
|
+
nodeId: p,
|
|
1353
|
+
reasonCode: K(
|
|
1216
1354
|
this.host.document.root,
|
|
1217
|
-
|
|
1355
|
+
p,
|
|
1218
1356
|
this.host.getSnapshot().editorial
|
|
1219
1357
|
) ? "NODE_LOCKED" : "NODE_NOT_EDITABLE"
|
|
1220
|
-
})), i = s.length > 0,
|
|
1221
|
-
id:
|
|
1358
|
+
})), i = s.length > 0, a = this.editingEnabled && !this.previewMode && !this.previewDocument, d = this.overlay.transforming || this.overlay.hiddenReason === "selecting", u = this.session.isSimulationRunning(), m = (p, b, y = {}) => ({
|
|
1359
|
+
id: p,
|
|
1222
1360
|
scope: "selection",
|
|
1223
1361
|
visible: i,
|
|
1224
|
-
enabled: b &&
|
|
1362
|
+
enabled: b && a && !d && !u,
|
|
1225
1363
|
busy: !1,
|
|
1226
1364
|
targetIds: n,
|
|
1227
1365
|
execution: "eligible-subset",
|
|
1228
|
-
...
|
|
1229
|
-
...u ? { reason: { code: "SIMULATION_RUNNING" } } :
|
|
1230
|
-
...
|
|
1231
|
-
}), v = this.host.getSnapshot().editorial, S = i && s.every((
|
|
1366
|
+
...l.length ? { excludedTargets: l } : {},
|
|
1367
|
+
...u ? { reason: { code: "SIMULATION_RUNNING" } } : a ? d ? { reason: { code: "GESTURE_ACTIVE" } } : b ? {} : { reason: { code: "NO_EDITABLE_TARGETS", nodeIds: o } } : { reason: { code: this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : "EDITING_DISABLED" } },
|
|
1368
|
+
...y
|
|
1369
|
+
}), v = this.host.getSnapshot().editorial, S = i && s.every((p) => K(this.host.document.root, p.nodeId, v)), c = s.some((p) => K(this.host.document.root, p.nodeId, v));
|
|
1232
1370
|
return [
|
|
1233
1371
|
...[
|
|
1234
|
-
...["translate", "rotate", "scale"].map((
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
].filter((
|
|
1372
|
+
...["translate", "rotate", "scale"].map((p) => m(`tools.${p}`, n.length > 0, { active: this.mode === p })),
|
|
1373
|
+
m("nodes.duplicate", n.length > 0),
|
|
1374
|
+
m("nodes.remove", n.length > 0),
|
|
1375
|
+
m("nodes.group", n.length >= 2),
|
|
1376
|
+
m("nodes.ungroup", this.removableGroupIds(n).length > 0),
|
|
1377
|
+
m("nodes.hide", i, { targetIds: s.map((p) => p.nodeId) }),
|
|
1378
|
+
m("nodes.visibility", i, { targetIds: s.map((p) => p.nodeId), valueState: s.every((p) => !("visible" in p) || p.visible) ? "on" : s.every((p) => "visible" in p && !p.visible) ? "off" : "mixed" }),
|
|
1379
|
+
m("camera.focus", i, { enabled: i, targetIds: s.map((p) => p.nodeId) }),
|
|
1380
|
+
m("nodes.lock", i, { targetIds: s.map((p) => p.nodeId), execution: "atomic", excludedTargets: [], active: S, valueState: S ? "on" : c ? "mixed" : "off" })
|
|
1381
|
+
].filter((p) => {
|
|
1244
1382
|
var b;
|
|
1245
|
-
return ((b = this.actionDefinitions.get(
|
|
1383
|
+
return ((b = this.actionDefinitions.get(p.id)) == null ? void 0 : b.scope) === "selection";
|
|
1246
1384
|
}),
|
|
1247
1385
|
...this.registeredToolbarActions("selection", o),
|
|
1248
1386
|
...this.coreToolbarActions("selection", o)
|
|
1249
|
-
].map((
|
|
1387
|
+
].map((p) => this.projectActionVisibility(p));
|
|
1250
1388
|
}
|
|
1251
1389
|
getToolbarState() {
|
|
1252
|
-
var
|
|
1253
|
-
const e = this.host.getSelection(), t = e.instanceIds.length, s = (
|
|
1254
|
-
id:
|
|
1390
|
+
var a, d, u;
|
|
1391
|
+
const e = this.host.getSelection(), t = e.instanceIds.length, s = (m, v, S = {}) => ({
|
|
1392
|
+
id: m,
|
|
1255
1393
|
scope: "scene",
|
|
1256
1394
|
visible: !0,
|
|
1257
1395
|
enabled: v && !this.gestureActive(),
|
|
@@ -1259,10 +1397,10 @@ class it {
|
|
|
1259
1397
|
targetIds: [],
|
|
1260
1398
|
execution: "atomic",
|
|
1261
1399
|
...this.gestureActive() ? { reason: { code: "GESTURE_ACTIVE" } } : v ? {} : { reason: {
|
|
1262
|
-
code:
|
|
1400
|
+
code: m === "camera.fit" ? "SCENE_EMPTY" : this.session.isSimulationRunning() ? "SIMULATION_RUNNING" : this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : this.editingEnabled ? m.startsWith("history.") ? "HISTORY_EMPTY" : "CAPABILITY_UNAVAILABLE" : "EDITING_DISABLED"
|
|
1263
1401
|
} },
|
|
1264
1402
|
...S
|
|
1265
|
-
}), o = this.host.getHistoryState(), n = ((
|
|
1403
|
+
}), o = this.host.getHistoryState(), n = ((a = this.sceneStatus) == null ? void 0 : a.physics.status) === "ready", h = this.session.isSimulationRunning(), l = this.editingEnabled && !this.previewMode && !this.previewDocument && !h, i = {
|
|
1266
1404
|
sceneSessionId: this.sceneSessionId,
|
|
1267
1405
|
selectionVersion: this.selectionVersion,
|
|
1268
1406
|
sequence: this.overlaySequence,
|
|
@@ -1281,23 +1419,23 @@ class it {
|
|
|
1281
1419
|
typeCounts: this.selectionTypeCounts(e.instanceIds)
|
|
1282
1420
|
},
|
|
1283
1421
|
scene: { visible: !0, actions: [
|
|
1284
|
-
s("selection.click",
|
|
1285
|
-
s("selection.box",
|
|
1286
|
-
s("camera.fit", (((
|
|
1287
|
-
s("tools.snap",
|
|
1422
|
+
s("selection.click", l, { active: !this.boxSelectionEnabled }),
|
|
1423
|
+
s("selection.box", l, { active: this.boxSelectionEnabled }),
|
|
1424
|
+
s("camera.fit", (((d = this.sceneStatus) == null ? void 0 : d.instances.length) ?? 0) > 0),
|
|
1425
|
+
s("tools.snap", l, { active: this.snap, valueState: this.snap ? "on" : "off" }),
|
|
1288
1426
|
s("viewport.ground", !0, { active: this.groundVisible, valueState: this.groundVisible ? "on" : "off" }),
|
|
1289
|
-
s("history.undo",
|
|
1290
|
-
s("history.redo",
|
|
1427
|
+
s("history.undo", l && o.canUndo),
|
|
1428
|
+
s("history.redo", l && o.canRedo),
|
|
1291
1429
|
s("viewport.collision", !0, { active: this.collisionVisible, valueState: this.collisionVisible ? "on" : "off" }),
|
|
1292
|
-
s("simulation.play", n && !
|
|
1293
|
-
s("simulation.pause", n &&
|
|
1294
|
-
s("simulation.step", n && !
|
|
1430
|
+
s("simulation.play", n && !h, { active: h }),
|
|
1431
|
+
s("simulation.pause", n && h, { active: !h && n }),
|
|
1432
|
+
s("simulation.step", n && !h),
|
|
1295
1433
|
s("simulation.reset", n),
|
|
1296
|
-
s("simulation.stop", n && (
|
|
1297
|
-
].filter((
|
|
1434
|
+
s("simulation.stop", n && (h || (((u = this.sceneStatus) == null ? void 0 : u.instances.length) ?? 0) > 0))
|
|
1435
|
+
].filter((m) => {
|
|
1298
1436
|
var v;
|
|
1299
|
-
return ((v = this.actionDefinitions.get(
|
|
1300
|
-
}).concat(this.registeredToolbarActions("scene", [])).concat(this.coreToolbarActions("scene", [])).map((
|
|
1437
|
+
return ((v = this.actionDefinitions.get(m.id)) == null ? void 0 : v.scope) === "scene";
|
|
1438
|
+
}).concat(this.registeredToolbarActions("scene", [])).concat(this.coreToolbarActions("scene", [])).map((m) => this.projectActionVisibility(m)) },
|
|
1301
1439
|
object: { actions: this.getNodeActions(e.instanceIds), overlay: i }
|
|
1302
1440
|
};
|
|
1303
1441
|
}
|
|
@@ -1307,7 +1445,7 @@ class it {
|
|
|
1307
1445
|
if (e.expectedSceneSessionId !== t.sceneSessionId)
|
|
1308
1446
|
throw new g("CONTEXT_STALE", "The scene session has changed.");
|
|
1309
1447
|
const s = [...t.scene.actions, ...t.object.actions].find(
|
|
1310
|
-
(
|
|
1448
|
+
(l) => l.id === e.actionId
|
|
1311
1449
|
);
|
|
1312
1450
|
if (s != null && s.busy)
|
|
1313
1451
|
throw new g("ACTION_BUSY", "Action is already running: " + e.actionId);
|
|
@@ -1318,7 +1456,7 @@ class it {
|
|
|
1318
1456
|
);
|
|
1319
1457
|
if (s.scope === "selection" && e.expectedSelectionVersion !== t.selection.version)
|
|
1320
1458
|
throw new g("CONTEXT_STALE", "The selection has changed.");
|
|
1321
|
-
if (!
|
|
1459
|
+
if (!se(e.targetIds, s.targetIds))
|
|
1322
1460
|
throw new g("CONTEXT_STALE", "The action targets have changed.");
|
|
1323
1461
|
const o = this.actionDefinitions.get(e.actionId);
|
|
1324
1462
|
if (o) {
|
|
@@ -1327,23 +1465,23 @@ class it {
|
|
|
1327
1465
|
"ACTION_SCOPE_MISMATCH",
|
|
1328
1466
|
`Action scope changed: ${e.actionId}`
|
|
1329
1467
|
);
|
|
1330
|
-
const
|
|
1331
|
-
this.actionControllers.set(e.actionId,
|
|
1468
|
+
const l = new AbortController();
|
|
1469
|
+
this.actionControllers.set(e.actionId, l), this.changed();
|
|
1332
1470
|
const i = this.getSnapshot();
|
|
1333
|
-
let
|
|
1471
|
+
let a = !1;
|
|
1334
1472
|
try {
|
|
1335
1473
|
return await o.execute(
|
|
1336
1474
|
{
|
|
1337
1475
|
editor: this.actionReader,
|
|
1338
1476
|
snapshot: i,
|
|
1339
|
-
signal:
|
|
1340
|
-
commit: (
|
|
1341
|
-
if (this.assertEditable(),
|
|
1477
|
+
signal: l.signal,
|
|
1478
|
+
commit: (d) => {
|
|
1479
|
+
if (this.assertEditable(), l.signal.aborted || this.actionControllers.get(e.actionId) !== l)
|
|
1342
1480
|
throw new g(
|
|
1343
1481
|
"ACTION_CANCELLED",
|
|
1344
1482
|
"The action has been cancelled or unloaded."
|
|
1345
1483
|
);
|
|
1346
|
-
if (
|
|
1484
|
+
if (a)
|
|
1347
1485
|
throw new g(
|
|
1348
1486
|
"ACTION_ALREADY_COMMITTED",
|
|
1349
1487
|
"An action commits one atomic transaction."
|
|
@@ -1351,49 +1489,49 @@ class it {
|
|
|
1351
1489
|
const u = this.host.getSnapshot();
|
|
1352
1490
|
if (u.sceneEpoch !== i.host.sceneEpoch || u.documentVersion !== i.host.documentVersion)
|
|
1353
1491
|
throw new g("CONTEXT_STALE", "Action document context changed.");
|
|
1354
|
-
if (s.scope === "selection" && (u.selectionVersion !== i.host.selectionVersion || !
|
|
1492
|
+
if (s.scope === "selection" && (u.selectionVersion !== i.host.selectionVersion || !se(
|
|
1355
1493
|
this.host.getSelection().instanceIds,
|
|
1356
1494
|
i.host.selection.instanceIds
|
|
1357
1495
|
)))
|
|
1358
1496
|
throw new g("CONTEXT_STALE", "Action selection changed.");
|
|
1359
|
-
const
|
|
1360
|
-
commands:
|
|
1497
|
+
const m = this.host.commit({
|
|
1498
|
+
commands: d,
|
|
1361
1499
|
expectedSceneEpoch: i.host.sceneEpoch,
|
|
1362
1500
|
expectedDocumentVersion: i.host.documentVersion,
|
|
1363
1501
|
...s.scope === "selection" ? { expectedSelectionVersion: i.host.selectionVersion } : {}
|
|
1364
1502
|
});
|
|
1365
|
-
return
|
|
1503
|
+
return a = m.changed, m;
|
|
1366
1504
|
}
|
|
1367
1505
|
},
|
|
1368
1506
|
e
|
|
1369
1507
|
);
|
|
1370
1508
|
} finally {
|
|
1371
|
-
this.actionControllers.get(e.actionId) ===
|
|
1509
|
+
this.actionControllers.get(e.actionId) === l && this.actionControllers.delete(e.actionId), this.changed();
|
|
1372
1510
|
}
|
|
1373
1511
|
}
|
|
1374
|
-
if (!this.host.getActions().find((
|
|
1512
|
+
if (!this.host.getActions().find((l) => l.id === e.actionId && l.scope === s.scope))
|
|
1375
1513
|
throw new g("ACTION_UNKNOWN", `Unknown action: ${e.actionId}`);
|
|
1376
|
-
const
|
|
1377
|
-
this.actionControllers.set(e.actionId,
|
|
1514
|
+
const h = new AbortController();
|
|
1515
|
+
this.actionControllers.set(e.actionId, h), this.coreActionBusy.add(e.actionId), this.changed();
|
|
1378
1516
|
try {
|
|
1379
|
-
const
|
|
1380
|
-
(
|
|
1517
|
+
const l = this.getToolbarState(), i = [...l.scene.actions, ...l.object.actions].find(
|
|
1518
|
+
(d) => d.id === e.actionId
|
|
1381
1519
|
);
|
|
1382
|
-
if (!(i != null && i.enabled) ||
|
|
1520
|
+
if (!(i != null && i.enabled) || l.sceneSessionId !== e.expectedSceneSessionId || i.scope === "selection" && l.selection.version !== e.expectedSelectionVersion || !se(i.targetIds, e.targetIds))
|
|
1383
1521
|
throw new g(
|
|
1384
1522
|
"CONTEXT_STALE",
|
|
1385
1523
|
"The action context changed before execution."
|
|
1386
1524
|
);
|
|
1387
|
-
const
|
|
1525
|
+
const a = this.getSnapshot().host;
|
|
1388
1526
|
return await this.host.runAction(e.actionId, e, {
|
|
1389
|
-
signal:
|
|
1390
|
-
expectedDocumentVersion:
|
|
1391
|
-
expectedSceneEpoch:
|
|
1392
|
-
expectedSelectionVersion:
|
|
1527
|
+
signal: h.signal,
|
|
1528
|
+
expectedDocumentVersion: a.documentVersion,
|
|
1529
|
+
expectedSceneEpoch: a.sceneEpoch,
|
|
1530
|
+
expectedSelectionVersion: a.selectionVersion,
|
|
1393
1531
|
targetIds: i.targetIds
|
|
1394
1532
|
});
|
|
1395
1533
|
} finally {
|
|
1396
|
-
this.actionControllers.get(e.actionId) ===
|
|
1534
|
+
this.actionControllers.get(e.actionId) === h && this.actionControllers.delete(e.actionId), this.coreActionBusy.delete(e.actionId), this.changed();
|
|
1397
1535
|
}
|
|
1398
1536
|
}
|
|
1399
1537
|
dispose() {
|
|
@@ -1424,10 +1562,10 @@ class it {
|
|
|
1424
1562
|
}
|
|
1425
1563
|
editableTargets(e) {
|
|
1426
1564
|
const t = this.host.getSnapshot().editorial;
|
|
1427
|
-
return this.selectionClosure(e).filter((s) =>
|
|
1565
|
+
return this.selectionClosure(e).filter((s) => F(this.host.document.root, s.nodeId, t) && !X(this.host.document.root, s.nodeId, t));
|
|
1428
1566
|
}
|
|
1429
1567
|
assertProjectionRepresentable(e) {
|
|
1430
|
-
const t = new Set(
|
|
1568
|
+
const t = new Set(Se(this.host.document.root).map(be)), s = Se(e).find((o) => !t.has(be(o)));
|
|
1431
1569
|
if (s)
|
|
1432
1570
|
throw new g(
|
|
1433
1571
|
"TRANSFORM_NOT_REPRESENTABLE",
|
|
@@ -1436,29 +1574,29 @@ class it {
|
|
|
1436
1574
|
}
|
|
1437
1575
|
selectionClosure(e) {
|
|
1438
1576
|
const t = [...new Set(e)], s = new Set(t);
|
|
1439
|
-
return t.map((o) =>
|
|
1577
|
+
return t.map((o) => w(this.host.document.root, o)).filter((o) => o !== null).filter((o) => !Ke(this.host.document.root, o.nodeId).slice(0, -1).some((n) => s.has(n.nodeId)));
|
|
1440
1578
|
}
|
|
1441
1579
|
removableGroupIds(e) {
|
|
1442
1580
|
var s;
|
|
1443
1581
|
const t = /* @__PURE__ */ new Set();
|
|
1444
1582
|
for (const o of e) {
|
|
1445
|
-
const n =
|
|
1583
|
+
const n = w(this.host.document.root, o);
|
|
1446
1584
|
if ((n == null ? void 0 : n.nodeType) === "group") {
|
|
1447
1585
|
t.add(o);
|
|
1448
1586
|
continue;
|
|
1449
1587
|
}
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1588
|
+
const h = (s = Q(this.host.document.root, o)) == null ? void 0 : s.parent;
|
|
1589
|
+
h && h.nodeId !== this.host.document.root.nodeId && h.nodeType === "group" && t.add(h.nodeId);
|
|
1452
1590
|
}
|
|
1453
1591
|
return [...t];
|
|
1454
1592
|
}
|
|
1455
1593
|
sceneInstances() {
|
|
1456
|
-
return
|
|
1594
|
+
return R(this.host.document.root);
|
|
1457
1595
|
}
|
|
1458
1596
|
selectionTypeCounts(e) {
|
|
1459
1597
|
const t = {};
|
|
1460
1598
|
for (const s of e) {
|
|
1461
|
-
const o =
|
|
1599
|
+
const o = w(this.host.document.root, s);
|
|
1462
1600
|
if (!o) continue;
|
|
1463
1601
|
const n = o.nodeType === "group" ? "group" : o.nodeType === "visual" ? "visual-instance" : o.nodeType === "placeholder" ? "placeholder" : o.nodeType === "domain" ? "domain-instance" : "asset-instance";
|
|
1464
1602
|
t[n] = (t[n] ?? 0) + 1;
|
|
@@ -1474,8 +1612,8 @@ class it {
|
|
|
1474
1612
|
};
|
|
1475
1613
|
e("tools.translate", "selection", () => this.setMode("translate")), e("tools.rotate", "selection", () => this.setMode("rotate")), e("tools.scale", "selection", () => this.setMode("scale")), e("nodes.duplicate", "selection", (t, s) => this.duplicateSelection(s.targetIds)), e("nodes.remove", "selection", (t, s) => this.deleteSelection(s.targetIds)), e("nodes.group", "selection", (t, s) => this.groupSelection(s.targetIds)), e("nodes.ungroup", "selection", (t, s) => this.ungroupSelection(s.targetIds)), e("nodes.hide", "selection", (t, s) => this.hideNodes(s.targetIds)), e("nodes.visibility", "selection", (t, s) => {
|
|
1476
1614
|
const o = s.targetIds.flatMap((n) => {
|
|
1477
|
-
const
|
|
1478
|
-
return (
|
|
1615
|
+
const h = w(this.host.document.root, n);
|
|
1616
|
+
return (h == null ? void 0 : h.nodeType) === "group" ? R(h) : h ? [h] : [];
|
|
1479
1617
|
});
|
|
1480
1618
|
return this.setNodesVisible(s.targetIds, !o.filter((n) => "visible" in n).every((n) => "visible" in n && n.visible));
|
|
1481
1619
|
}), e("camera.focus", "selection", (t, s) => this.session.focusNodes(s.targetIds)), e("nodes.lock", "selection", (t, s) => {
|
|
@@ -1494,10 +1632,10 @@ class it {
|
|
|
1494
1632
|
gestureActive: this.gestureActive()
|
|
1495
1633
|
};
|
|
1496
1634
|
return [...this.actionDefinitions.values()].filter((o) => o.scope === e && o.getState).map((o) => {
|
|
1497
|
-
const n = o.getState(s),
|
|
1635
|
+
const n = o.getState(s), h = e === "selection" ? this.selectionClosure(n.targetIds).map((l) => l.nodeId) : n.targetIds;
|
|
1498
1636
|
return {
|
|
1499
1637
|
...n,
|
|
1500
|
-
targetIds:
|
|
1638
|
+
targetIds: h,
|
|
1501
1639
|
busy: n.busy || this.actionControllers.has(o.id)
|
|
1502
1640
|
};
|
|
1503
1641
|
}).filter((o) => o.scope === e);
|
|
@@ -1505,16 +1643,16 @@ class it {
|
|
|
1505
1643
|
coreToolbarActions(e, t) {
|
|
1506
1644
|
const s = this.editingEnabled && !this.previewMode && !this.previewDocument, o = this.gestureActive();
|
|
1507
1645
|
return this.host.getActions().filter((n) => n.scope === e).map((n) => {
|
|
1508
|
-
const
|
|
1646
|
+
const h = e === "selection" ? [...t] : [], l = s && !o && (e === "scene" || h.length > 0);
|
|
1509
1647
|
return {
|
|
1510
1648
|
id: n.id,
|
|
1511
1649
|
scope: e,
|
|
1512
1650
|
visible: !0,
|
|
1513
|
-
enabled:
|
|
1651
|
+
enabled: l,
|
|
1514
1652
|
busy: this.coreActionBusy.has(n.id),
|
|
1515
|
-
targetIds:
|
|
1653
|
+
targetIds: h,
|
|
1516
1654
|
execution: n.scope === "selection" ? "eligible-subset" : "atomic",
|
|
1517
|
-
...
|
|
1655
|
+
...l ? {} : {
|
|
1518
1656
|
reason: {
|
|
1519
1657
|
code: this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : this.editingEnabled ? o ? "GESTURE_ACTIVE" : "NO_EDITABLE_TARGETS" : "EDITING_DISABLED"
|
|
1520
1658
|
}
|
|
@@ -1570,186 +1708,285 @@ class it {
|
|
|
1570
1708
|
}
|
|
1571
1709
|
}
|
|
1572
1710
|
}
|
|
1573
|
-
function
|
|
1574
|
-
return
|
|
1711
|
+
function re(r) {
|
|
1712
|
+
return r ? r.nodeType === "group" ? [r.nodeId, ...r.children.flatMap((e) => re(e))] : [r.nodeId] : [];
|
|
1575
1713
|
}
|
|
1576
|
-
function
|
|
1577
|
-
if (!Array.isArray(
|
|
1714
|
+
function ut(r) {
|
|
1715
|
+
if (!Array.isArray(r.local) || r.local.length !== 3 || r.local.some((e) => !Number.isFinite(e)))
|
|
1578
1716
|
throw new g(
|
|
1579
1717
|
"ORIGIN_OFFSET_INVALID",
|
|
1580
1718
|
"Node origin.local must contain three finite source-content metre values."
|
|
1581
1719
|
);
|
|
1582
1720
|
}
|
|
1583
|
-
function
|
|
1584
|
-
return e && Number.isFinite(t) ? [{ movedNodeId:
|
|
1721
|
+
function te(r, e, t) {
|
|
1722
|
+
return e && Number.isFinite(t) ? [{ movedNodeId: r, supportNodeId: e, surfaceZ: t }] : [];
|
|
1585
1723
|
}
|
|
1586
|
-
function
|
|
1587
|
-
return `${
|
|
1724
|
+
function be(r) {
|
|
1725
|
+
return `${r.parentNodeId}\0${r.nodeId}`;
|
|
1588
1726
|
}
|
|
1589
|
-
function
|
|
1590
|
-
const t = new Set(
|
|
1727
|
+
function se(r, e) {
|
|
1728
|
+
const t = new Set(r), s = new Set(e);
|
|
1591
1729
|
return t.size === s.size && [...t].every((o) => s.has(o));
|
|
1592
1730
|
}
|
|
1593
|
-
function
|
|
1594
|
-
return new
|
|
1731
|
+
function Tt(r, e) {
|
|
1732
|
+
return new ht(r, e);
|
|
1595
1733
|
}
|
|
1596
|
-
function
|
|
1734
|
+
function pt(r) {
|
|
1597
1735
|
return {
|
|
1598
1736
|
schemaVersion: 1,
|
|
1599
|
-
viewMode:
|
|
1600
|
-
...
|
|
1601
|
-
...
|
|
1737
|
+
viewMode: r.viewMode,
|
|
1738
|
+
...r.orbit ? { orbit: { ...r.orbit } } : {},
|
|
1739
|
+
...r.orthographic ? { orthographic: { ...r.orthographic } } : {}
|
|
1602
1740
|
};
|
|
1603
1741
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1742
|
+
function oe(r, e, t = {}) {
|
|
1743
|
+
var o;
|
|
1744
|
+
const s = r.createStateSnapshot();
|
|
1745
|
+
return {
|
|
1746
|
+
format: "sim-studio.session@1",
|
|
1747
|
+
schemaVersion: 1,
|
|
1748
|
+
documentText: s.documentText,
|
|
1749
|
+
documentHash: s.documentHash,
|
|
1750
|
+
editorial: e.captureEditorialState(),
|
|
1751
|
+
assetClosure: ((o = t.assetClosure) == null ? void 0 : o.call(t)) ?? null
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
async function mt(r, e, t, s = {}) {
|
|
1755
|
+
var n, h;
|
|
1756
|
+
we(t), await r.ready(), await e.ready, (n = s.signal) == null || n.throwIfAborted();
|
|
1757
|
+
const o = await r.openSceneText(
|
|
1758
|
+
t.documentText,
|
|
1759
|
+
s.sources ?? [],
|
|
1760
|
+
s.signal ? { signal: s.signal } : {}
|
|
1761
|
+
);
|
|
1762
|
+
if (!o.ok)
|
|
1763
|
+
throw new Error(o.diagnostics.map((l) => l.message).join(`
|
|
1764
|
+
`));
|
|
1765
|
+
(h = s.signal) == null || h.throwIfAborted(), await e.sync(), e.applyEditorialState(t.editorial);
|
|
1766
|
+
}
|
|
1767
|
+
function Nt(r) {
|
|
1768
|
+
let e = null, t = !1, s = null;
|
|
1769
|
+
const o = {
|
|
1770
|
+
adapter: r.adapter,
|
|
1771
|
+
capture: () => oe(r.host, r.editor, {
|
|
1772
|
+
...r.assetClosure ? { assetClosure: r.assetClosure } : {}
|
|
1773
|
+
}),
|
|
1774
|
+
currentSignature: () => Ze(
|
|
1775
|
+
oe(r.host, r.editor, {
|
|
1776
|
+
...r.assetClosure ? { assetClosure: r.assetClosure } : {}
|
|
1777
|
+
})
|
|
1778
|
+
),
|
|
1779
|
+
...r.autosaveDelayMs !== void 0 ? { autosaveDelayMs: r.autosaveDelayMs } : {},
|
|
1780
|
+
...r.now ? { now: r.now } : {},
|
|
1781
|
+
...r.createId ? { createId: r.createId } : {},
|
|
1782
|
+
...r.onState ? { onState: r.onState } : {}
|
|
1783
|
+
}, n = new nt(o), h = () => {
|
|
1784
|
+
e || r.trackEditorChanges === !1 || (e = r.editor.subscribe((a) => {
|
|
1785
|
+
a.type === "host.change" && ft(a.event) && n.scheduleAutosave();
|
|
1786
|
+
}));
|
|
1787
|
+
}, l = async (a = {}) => {
|
|
1788
|
+
var m;
|
|
1789
|
+
await r.editor.ready;
|
|
1790
|
+
const d = await r.adapter.load(
|
|
1791
|
+
a.signal ? { signal: a.signal } : {}
|
|
1792
|
+
);
|
|
1793
|
+
if (!d)
|
|
1794
|
+
return n.restoreBaseline(null), null;
|
|
1795
|
+
we(d.snapshot);
|
|
1796
|
+
const u = a.sources ?? await ((m = r.resolveSources) == null ? void 0 : m.call(r, d, {
|
|
1797
|
+
...a.signal ? { signal: a.signal } : {}
|
|
1798
|
+
})) ?? [];
|
|
1799
|
+
return await mt(r.host, r.editor, d.snapshot, {
|
|
1800
|
+
...a.signal ? { signal: a.signal } : {},
|
|
1801
|
+
sources: u
|
|
1802
|
+
}), n.restoreBaseline(d), d;
|
|
1803
|
+
}, i = (async () => {
|
|
1804
|
+
let a = null;
|
|
1805
|
+
return r.autoRestore !== !1 ? a = await l() : await r.editor.ready, h(), t = !0, a;
|
|
1806
|
+
})();
|
|
1807
|
+
return {
|
|
1808
|
+
controller: n,
|
|
1809
|
+
ready: i,
|
|
1810
|
+
capture: () => oe(r.host, r.editor, {
|
|
1811
|
+
...r.assetClosure ? { assetClosure: r.assetClosure } : {}
|
|
1812
|
+
}),
|
|
1813
|
+
async restore(a) {
|
|
1814
|
+
return await i, l(a);
|
|
1815
|
+
},
|
|
1816
|
+
scheduleAutosave: () => n.scheduleAutosave(),
|
|
1817
|
+
markDirty: () => n.markDirty(),
|
|
1818
|
+
async save(a) {
|
|
1819
|
+
return await i, n.save(a);
|
|
1820
|
+
},
|
|
1821
|
+
async flush(a) {
|
|
1822
|
+
return await i, n.flush(a);
|
|
1823
|
+
},
|
|
1824
|
+
async retry(a) {
|
|
1825
|
+
return await i, n.retry(a);
|
|
1826
|
+
},
|
|
1827
|
+
async dispose(a = {}) {
|
|
1828
|
+
return s || (s = (async () => {
|
|
1829
|
+
e == null || e(), e = null, await i.catch(() => {
|
|
1830
|
+
}), t || n.restoreBaseline(null), await n.dispose(a.closeAdapter ?? !0);
|
|
1831
|
+
})(), s);
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
function ft(r) {
|
|
1836
|
+
return r.type === "document.change" || r.type === "selection.change" || r.type === "editorial.change";
|
|
1837
|
+
}
|
|
1838
|
+
const gt = 1;
|
|
1839
|
+
function Pt(r) {
|
|
1840
|
+
const { editor: e } = r, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1841
|
+
let o = !1, n = !1, h, l = 0;
|
|
1842
|
+
function i(c) {
|
|
1609
1843
|
try {
|
|
1610
|
-
|
|
1844
|
+
r.onError ? r.onError(c) : console.error(`[sim-studio UI plugin ${c.pluginId}] ${c.phase}`, c.error);
|
|
1611
1845
|
} catch {
|
|
1612
1846
|
}
|
|
1613
1847
|
}
|
|
1614
|
-
function
|
|
1848
|
+
function a() {
|
|
1615
1849
|
if (n) throw new Error("The Studio UI plugin host has been disposed.");
|
|
1616
1850
|
}
|
|
1617
|
-
function
|
|
1851
|
+
function d(c, f, p) {
|
|
1618
1852
|
try {
|
|
1619
1853
|
f();
|
|
1620
1854
|
} catch (b) {
|
|
1621
|
-
i({ pluginId:
|
|
1855
|
+
i({ pluginId: c.plugin.id, viewId: p, phase: "dispose", error: b });
|
|
1622
1856
|
}
|
|
1623
1857
|
}
|
|
1624
|
-
function u(
|
|
1625
|
-
if (!
|
|
1626
|
-
|
|
1627
|
-
for (const f of [...
|
|
1628
|
-
|
|
1858
|
+
function u(c) {
|
|
1859
|
+
if (!c.removed) {
|
|
1860
|
+
c.removed = !0, c.active = !1, c.listeners.clear();
|
|
1861
|
+
for (const f of [...c.cleanups].reverse()) d(c, f);
|
|
1862
|
+
c.cleanups.clear(), t.get(c.plugin.id) === c && t.delete(c.plugin.id);
|
|
1629
1863
|
}
|
|
1630
1864
|
}
|
|
1631
|
-
function
|
|
1632
|
-
var
|
|
1633
|
-
if (
|
|
1865
|
+
function m(c, f) {
|
|
1866
|
+
var L;
|
|
1867
|
+
if (c.removed) throw new Error(`Plugin ${c.plugin.id} has been removed.`);
|
|
1634
1868
|
if (!f.id.trim()) throw new Error("UI view IDs must be non-empty.");
|
|
1635
|
-
const
|
|
1636
|
-
if (s.has(
|
|
1637
|
-
const b =
|
|
1869
|
+
const p = JSON.stringify([c.plugin.id, f.id]);
|
|
1870
|
+
if (s.has(p)) throw new Error(`Duplicate UI view ${p}.`);
|
|
1871
|
+
const b = r.slots[f.slot];
|
|
1638
1872
|
if (!b) throw new Error(`No frontend container provided for UI slot ${f.slot}.`);
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1641
|
-
const
|
|
1642
|
-
b.insertBefore(
|
|
1873
|
+
const y = b.ownerDocument.createElement("div");
|
|
1874
|
+
y.dataset.studioUiPlugin = c.plugin.id, y.dataset.studioUiView = f.id, y.dataset.studioUiSlot = f.slot;
|
|
1875
|
+
const O = l++, D = [...s.values()].filter((P) => P.contribution.slot === f.slot).sort((P, $) => (P.contribution.order ?? 0) - ($.contribution.order ?? 0) || P.sequence - $.sequence).find((P) => (P.contribution.order ?? 0) > (f.order ?? 0));
|
|
1876
|
+
b.insertBefore(y, (D == null ? void 0 : D.container) ?? null);
|
|
1643
1877
|
let N;
|
|
1644
1878
|
try {
|
|
1645
|
-
N = f.mount(
|
|
1646
|
-
} catch (
|
|
1647
|
-
throw
|
|
1879
|
+
N = f.mount(y, { editor: e, snapshot: e.getSnapshot() });
|
|
1880
|
+
} catch (P) {
|
|
1881
|
+
throw y.remove(), i({ pluginId: c.plugin.id, viewId: f.id, phase: "mount", error: P }), P;
|
|
1648
1882
|
}
|
|
1649
|
-
let
|
|
1650
|
-
const
|
|
1651
|
-
if (!
|
|
1652
|
-
|
|
1883
|
+
let G = !1;
|
|
1884
|
+
const V = () => {
|
|
1885
|
+
if (!G) {
|
|
1886
|
+
G = !0, s.delete(p), c.cleanups.delete(V);
|
|
1653
1887
|
try {
|
|
1654
1888
|
typeof N == "function" ? N() : N == null || N.dispose();
|
|
1655
1889
|
} finally {
|
|
1656
|
-
|
|
1890
|
+
y.remove();
|
|
1657
1891
|
}
|
|
1658
1892
|
}
|
|
1659
|
-
},
|
|
1660
|
-
owner:
|
|
1893
|
+
}, H = {
|
|
1894
|
+
owner: c,
|
|
1661
1895
|
contribution: f,
|
|
1662
|
-
container:
|
|
1663
|
-
sequence:
|
|
1664
|
-
update: typeof N == "object" && N ? (
|
|
1665
|
-
dispose:
|
|
1896
|
+
container: y,
|
|
1897
|
+
sequence: O,
|
|
1898
|
+
update: typeof N == "object" && N ? (L = N.update) == null ? void 0 : L.bind(N) : void 0,
|
|
1899
|
+
dispose: V
|
|
1666
1900
|
};
|
|
1667
|
-
return s.set(
|
|
1901
|
+
return s.set(p, H), c.cleanups.add(V), () => d(c, V, f.id);
|
|
1668
1902
|
}
|
|
1669
|
-
function v(
|
|
1670
|
-
if (!(
|
|
1671
|
-
|
|
1903
|
+
function v(c) {
|
|
1904
|
+
if (!(c.active || c.removed)) {
|
|
1905
|
+
c.active = !0;
|
|
1672
1906
|
try {
|
|
1673
|
-
const f =
|
|
1907
|
+
const f = c.plugin.activate({
|
|
1674
1908
|
editor: e,
|
|
1675
|
-
contributions: { addView: (
|
|
1909
|
+
contributions: { addView: (p) => m(c, p) },
|
|
1676
1910
|
events: {
|
|
1677
|
-
subscribe(
|
|
1678
|
-
if (
|
|
1679
|
-
return
|
|
1680
|
-
|
|
1911
|
+
subscribe(p) {
|
|
1912
|
+
if (c.removed) throw new Error(`Plugin ${c.plugin.id} has been removed.`);
|
|
1913
|
+
return c.listeners.add(p), () => {
|
|
1914
|
+
c.listeners.delete(p);
|
|
1681
1915
|
};
|
|
1682
1916
|
}
|
|
1683
1917
|
}
|
|
1684
1918
|
});
|
|
1685
|
-
f &&
|
|
1919
|
+
f && c.cleanups.add(f);
|
|
1686
1920
|
} catch (f) {
|
|
1687
|
-
throw u(
|
|
1921
|
+
throw u(c), i({ pluginId: c.plugin.id, phase: "activate", error: f }), f;
|
|
1688
1922
|
}
|
|
1689
1923
|
}
|
|
1690
1924
|
}
|
|
1691
|
-
function S(
|
|
1925
|
+
function S(c) {
|
|
1692
1926
|
if (n) return;
|
|
1693
1927
|
const f = e.getSnapshot();
|
|
1694
|
-
for (const
|
|
1695
|
-
if (!(
|
|
1928
|
+
for (const p of [...s.values()])
|
|
1929
|
+
if (!(p.owner.removed || !p.update))
|
|
1696
1930
|
try {
|
|
1697
|
-
|
|
1931
|
+
p.update({ editor: e, snapshot: f });
|
|
1698
1932
|
} catch (b) {
|
|
1699
|
-
i({ pluginId:
|
|
1933
|
+
i({ pluginId: p.owner.plugin.id, viewId: p.contribution.id, phase: "update", error: b }), d(p.owner, p.dispose, p.contribution.id);
|
|
1700
1934
|
}
|
|
1701
|
-
for (const
|
|
1702
|
-
if (!(!
|
|
1703
|
-
for (const b of [...
|
|
1704
|
-
if (
|
|
1935
|
+
for (const p of [...t.values()])
|
|
1936
|
+
if (!(!p.active || p.removed))
|
|
1937
|
+
for (const b of [...p.listeners]) {
|
|
1938
|
+
if (p.removed) break;
|
|
1705
1939
|
try {
|
|
1706
|
-
b(
|
|
1707
|
-
} catch (
|
|
1708
|
-
i({ pluginId:
|
|
1940
|
+
b(c);
|
|
1941
|
+
} catch (y) {
|
|
1942
|
+
i({ pluginId: p.plugin.id, phase: "event", error: y });
|
|
1709
1943
|
}
|
|
1710
1944
|
}
|
|
1711
1945
|
}
|
|
1712
1946
|
return {
|
|
1713
|
-
register(
|
|
1714
|
-
if (
|
|
1715
|
-
if (
|
|
1716
|
-
throw new Error(`Unsupported UI plugin API version for ${
|
|
1717
|
-
if (t.has(
|
|
1947
|
+
register(c) {
|
|
1948
|
+
if (a(), !c.id.trim()) throw new Error("UI plugin IDs must be non-empty.");
|
|
1949
|
+
if (c.apiVersion !== gt)
|
|
1950
|
+
throw new Error(`Unsupported UI plugin API version for ${c.id}: ${c.apiVersion}.`);
|
|
1951
|
+
if (t.has(c.id)) throw new Error(`Duplicate UI plugin ${c.id}.`);
|
|
1718
1952
|
const f = {
|
|
1719
|
-
plugin:
|
|
1953
|
+
plugin: c,
|
|
1720
1954
|
cleanups: /* @__PURE__ */ new Set(),
|
|
1721
1955
|
listeners: /* @__PURE__ */ new Set(),
|
|
1722
1956
|
active: !1,
|
|
1723
1957
|
removed: !1
|
|
1724
1958
|
};
|
|
1725
|
-
return t.set(
|
|
1959
|
+
return t.set(c.id, f), o && v(f), () => u(f);
|
|
1726
1960
|
},
|
|
1727
1961
|
start() {
|
|
1728
|
-
if (
|
|
1962
|
+
if (a(), o) return;
|
|
1729
1963
|
o = !0;
|
|
1730
|
-
const
|
|
1964
|
+
const c = [];
|
|
1731
1965
|
for (const f of [...t.values()])
|
|
1732
1966
|
try {
|
|
1733
1967
|
v(f);
|
|
1734
|
-
} catch (
|
|
1735
|
-
|
|
1968
|
+
} catch (p) {
|
|
1969
|
+
c.push(p);
|
|
1736
1970
|
}
|
|
1737
|
-
if (
|
|
1971
|
+
if (h = e.subscribe(S), c.length) throw new AggregateError(c, "One or more Studio UI plugins failed to activate.");
|
|
1738
1972
|
},
|
|
1739
1973
|
dispose() {
|
|
1740
1974
|
if (!n) {
|
|
1741
|
-
n = !0,
|
|
1742
|
-
for (const
|
|
1975
|
+
n = !0, h == null || h(), h = void 0;
|
|
1976
|
+
for (const c of [...t.values()].reverse()) u(c);
|
|
1743
1977
|
}
|
|
1744
1978
|
}
|
|
1745
1979
|
};
|
|
1746
1980
|
}
|
|
1747
1981
|
export {
|
|
1748
|
-
|
|
1749
|
-
|
|
1982
|
+
gt as STUDIO_UI_PLUGIN_API_VERSION,
|
|
1983
|
+
ht as StudioEditor,
|
|
1750
1984
|
g as StudioEditorError,
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1985
|
+
oe as captureStudioSessionSnapshot,
|
|
1986
|
+
Tt as createStudioEditor,
|
|
1987
|
+
Nt as createStudioSessionPersistence,
|
|
1988
|
+
Pt as createStudioUiPluginHost,
|
|
1989
|
+
mt as restoreStudioSessionSnapshot,
|
|
1990
|
+
Ee as sceneSourceFromResolution,
|
|
1991
|
+
lt as visualSceneSourceFromResolution
|
|
1755
1992
|
};
|