@nebula-spatial/studio 0.1.1 → 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/{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-DMNRhgL9.js → export-evidence-z2Ne7Trf.js} +654 -972
- package/dist/generalization.js +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +226 -219
- package/dist/{mjcf-visual-Bt4bUxd1.js → mjcf-visual-IOy-ucto.js} +1 -1
- 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-Cy6vDJ1l.js → scene-session-PhoFXFCY.js} +3365 -3340
- package/dist/scene.js +2 -2
- package/dist/{session-BRBrCLdd.js → session-2bp8YOA4.js} +2 -2
- package/dist/{session-q3uuG7OP.js → session-B3WbC7Y2.js} +1 -1
- package/dist/session-B9kEf4xN.js +915 -0
- package/dist/{session-DI5tPJxn.js → session-DYThdzLZ.js} +4 -4
- 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 +1422 -1220
- package/dist/{urdf-session-CQir2nb2.js → urdf-session-CRXL4bHf.js} +3 -3
- package/dist/{usd-session-DZJnEEOs.js → usd-session-CTzInpNy.js} +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/view/scene-session.d.ts +5 -1
- package/dist/{xacro-DLRXyk60.js → xacro-IpPHTMYs.js} +1 -1
- package/package.json +1 -1
- package/dist/asset-source-BExlEcRt.js +0 -444
- package/dist/editorial-BkAFWfbg.js +0 -83
- package/dist/remote-asset-resolver-Cb8cfNmw.js +0 -136
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as g, f as K, h as b, e as x } from "./physics-facts-
|
|
1
|
+
import { a as k, d as P, a4 as O, $ as w, a5 as v, a6 as q, w as H, W as B, Z as y, z as S, s as E, M as Z, u as W } from "./scene-graph-DVOXjMmp.js";
|
|
2
|
+
import { t as g, f as K, h as b, e as x, i as J } from "./physics-facts-D-URIBrt.js";
|
|
3
3
|
const h = {
|
|
4
4
|
translate: 0.05,
|
|
5
5
|
// 15 degrees.
|
|
@@ -14,11 +14,11 @@ function I(n, t) {
|
|
|
14
14
|
function _(n) {
|
|
15
15
|
return n === "x" ? 0 : n === "y" ? 1 : 2;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function nn(n, t, e = h) {
|
|
18
18
|
const o = [...n.position], s = _(t.axis);
|
|
19
19
|
return o[s] = I(o[s] + t.amount, e.translate ?? h.translate), { ...n, position: o };
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function tn(n, t, e = h) {
|
|
22
22
|
const o = I(t.amount, e.rotate ?? h.rotate);
|
|
23
23
|
if (o === 0) return n;
|
|
24
24
|
const s = o / 2, r = [0, 0, 0];
|
|
@@ -29,68 +29,68 @@ function nn(n, t, e = h) {
|
|
|
29
29
|
r[2] * Math.sin(s),
|
|
30
30
|
Math.cos(s)
|
|
31
31
|
];
|
|
32
|
-
return { ...n, rotation:
|
|
32
|
+
return { ...n, rotation: Q(sn(a, n.rotation)) };
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function on(n, t, e = h) {
|
|
35
35
|
const o = _(t.axis), s = n.scale[o], r = I(s + t.amount, e.scale ?? h.scale), a = r <= 0 ? 1e-4 : r, d = [...n.scale];
|
|
36
36
|
return d[o] = a, { ...n, scale: d };
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function xn(n, t, e) {
|
|
39
39
|
const o = [(n.min[0] + n.max[0]) / 2, (n.min[1] + n.max[1]) / 2], s = [(n.max[0] - n.min[0]) / 2, (n.max[1] - n.min[1]) / 2];
|
|
40
40
|
let r = null;
|
|
41
41
|
for (const a of t) {
|
|
42
|
-
const d = [(a.min[0] + a.max[0]) / 2, (a.min[1] + a.max[1]) / 2],
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
|
|
42
|
+
const d = [(a.min[0] + a.max[0]) / 2, (a.min[1] + a.max[1]) / 2], u = Math.min(n.max[1], a.max[1]) - Math.max(n.min[1], a.min[1]), p = Math.min(n.max[0], a.max[0]) - Math.max(n.min[0], a.min[0]), f = u > 0 ? o[1] : d[1], i = p > 0 ? o[0] : d[0], c = [];
|
|
43
|
+
if (u > 0 || Math.abs(o[1] - d[1]) <= e) {
|
|
44
|
+
const l = a.min[0] - s[0], m = a.max[0] + s[0];
|
|
45
|
+
c.push({ position: [l, f], dx: l - o[0], dy: f - o[1] }), c.push({ position: [m, f], dx: m - o[0], dy: f - o[1] });
|
|
46
46
|
}
|
|
47
47
|
if (p > 0 || Math.abs(o[0] - d[0]) <= e) {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const l = a.min[1] - s[1], m = a.max[1] + s[1];
|
|
49
|
+
c.push({ position: [i, l], dx: i - o[0], dy: l - o[1] }), c.push({ position: [i, m], dx: i - o[0], dy: m - o[1] });
|
|
50
50
|
}
|
|
51
|
-
for (const
|
|
52
|
-
const
|
|
53
|
-
|
|
51
|
+
for (const l of c) {
|
|
52
|
+
const m = Math.hypot(l.dx, l.dy);
|
|
53
|
+
m > e || (!r || m < r.distance) && (r = { targetId: a.id, position: l.position, distance: m });
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
return r;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
const e = t.translate ?? 0, o = t.rotate ?? 0, s = t.scale ?? 0, r = e > 0 ? n.position.map((
|
|
58
|
+
function vn(n, t = h) {
|
|
59
|
+
const e = t.translate ?? 0, o = t.rotate ?? 0, s = t.scale ?? 0, r = e > 0 ? n.position.map((u) => I(u, e)) : [...n.position], a = s > 0 ? n.scale.map((u) => Math.max(1e-4, I(u, s))) : [...n.scale], d = o > 0 ? en(n.rotation, o) : n.rotation;
|
|
60
60
|
return { position: r, rotation: d, scale: a };
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function en(n, t) {
|
|
63
63
|
const e = Math.min(1, Math.max(-1, n[3])), o = 2 * Math.acos(e);
|
|
64
64
|
if (!Number.isFinite(o) || o < 1e-9) return [0, 0, 0, 1];
|
|
65
65
|
const s = Math.sqrt(Math.max(0, 1 - e * e));
|
|
66
66
|
if (s < 1e-9) return n;
|
|
67
67
|
const r = [n[0] / s, n[1] / s, n[2] / s], d = I(o, t) / 2;
|
|
68
|
-
return
|
|
68
|
+
return Q([r[0] * Math.sin(d), r[1] * Math.sin(d), r[2] * Math.sin(d), Math.cos(d)]);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function Nn(n, t, e, o = h) {
|
|
71
71
|
switch (n) {
|
|
72
72
|
case "translate":
|
|
73
|
-
return J(t, e, o);
|
|
74
|
-
case "rotate":
|
|
75
73
|
return nn(t, e, o);
|
|
76
|
-
case "
|
|
74
|
+
case "rotate":
|
|
77
75
|
return tn(t, e, o);
|
|
76
|
+
case "scale":
|
|
77
|
+
return on(t, e, o);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const [e, o, s, r] = n, [a, d,
|
|
80
|
+
function sn(n, t) {
|
|
81
|
+
const [e, o, s, r] = n, [a, d, u, p] = t;
|
|
82
82
|
return [
|
|
83
|
-
r * a + e * p + o *
|
|
84
|
-
r * d - e *
|
|
85
|
-
r *
|
|
86
|
-
r * p - e * a - o * d - s *
|
|
83
|
+
r * a + e * p + o * u - s * d,
|
|
84
|
+
r * d - e * u + o * p + s * a,
|
|
85
|
+
r * u + e * d - o * a + s * p,
|
|
86
|
+
r * p - e * a - o * d - s * u
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function Q(n) {
|
|
90
90
|
const t = Math.hypot(n[0], n[1], n[2], n[3]);
|
|
91
91
|
return !Number.isFinite(t) || t < 1e-12 ? [0, 0, 0, 1] : [n[0] / t, n[1] / t, n[2] / t, n[3] / t];
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function an(n, t, e = {}) {
|
|
94
94
|
const o = e.floorZ ?? 0, s = Math.min(t.min[2], t.max[2]);
|
|
95
95
|
if (!Number.isFinite(s)) return n;
|
|
96
96
|
const r = o - s;
|
|
@@ -98,24 +98,24 @@ function sn(n, t, e = {}) {
|
|
|
98
98
|
const a = [...n.position];
|
|
99
99
|
return a[2] = Number((a[2] + r).toFixed(9)), { ...n, position: a };
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function gn(n, t, e = 0) {
|
|
102
102
|
const o = Math.min(t.min[2], t.max[2]);
|
|
103
103
|
if (!Number.isFinite(o) || o >= e - 1e-9) return n;
|
|
104
104
|
const s = [...n.position];
|
|
105
105
|
return s[2] = Number((s[2] + (e - o)).toFixed(9)), { ...n, position: s };
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
const s = o.snap ?? h.translate, r = I(e[0], s), a = I(e[1], s), d = (t.min[0] + t.max[0]) / 2,
|
|
107
|
+
function yn(n, t, e, o = {}) {
|
|
108
|
+
const s = o.snap ?? h.translate, r = I(e[0], s), a = I(e[1], s), d = (t.min[0] + t.max[0]) / 2, u = (t.min[1] + t.max[1]) / 2, p = [
|
|
109
109
|
Number((n.position[0] + r - d).toFixed(9)),
|
|
110
|
-
Number((n.position[1] + a -
|
|
110
|
+
Number((n.position[1] + a - u).toFixed(9)),
|
|
111
111
|
n.position[2]
|
|
112
112
|
], f = { ...n, position: p };
|
|
113
|
-
return o.keepHeight ? f :
|
|
113
|
+
return o.keepHeight ? f : an(f, t, o);
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Sn(n, t, e = 1e-6) {
|
|
116
116
|
return n.min[0] < t.max[0] - e && t.min[0] < n.max[0] - e && n.min[1] < t.max[1] - e && t.min[1] < n.max[1] - e;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function An(n) {
|
|
119
119
|
if (n.length === 0) return null;
|
|
120
120
|
const t = [1 / 0, 1 / 0, 1 / 0], e = [-1 / 0, -1 / 0, -1 / 0];
|
|
121
121
|
for (const o of n)
|
|
@@ -123,7 +123,7 @@ function yn(n) {
|
|
|
123
123
|
t[s] = Math.min(t[s], o.min[s], o.max[s]), e[s] = Math.max(e[s], o.min[s], o.max[s]);
|
|
124
124
|
return { min: t, max: e };
|
|
125
125
|
}
|
|
126
|
-
const
|
|
126
|
+
const j = Object.freeze({
|
|
127
127
|
gridStepM: 0,
|
|
128
128
|
adaptiveGridSnap: !1,
|
|
129
129
|
surfaceSnap: !0,
|
|
@@ -131,10 +131,10 @@ const D = Object.freeze({
|
|
|
131
131
|
preventOverlap: !0,
|
|
132
132
|
clearanceM: 0,
|
|
133
133
|
toleranceM: 1e-6
|
|
134
|
-
}),
|
|
135
|
-
function
|
|
134
|
+
}), rn = 0.85, cn = 1e-3;
|
|
135
|
+
function dn(n, t = j) {
|
|
136
136
|
const e = { ...t, ...n };
|
|
137
|
-
if (Object.keys(n).some((o) => !(o in
|
|
137
|
+
if (Object.keys(n).some((o) => !(o in j)) || ["gridStepM", "clearanceM", "toleranceM"].some(
|
|
138
138
|
(o) => !Number.isFinite(e[o]) || e[o] < 0
|
|
139
139
|
) || ["adaptiveGridSnap", "surfaceSnap", "alignToSurface", "preventOverlap"].some(
|
|
140
140
|
(o) => typeof e[o] != "boolean"
|
|
@@ -144,58 +144,73 @@ function cn(n, t = D) {
|
|
|
144
144
|
});
|
|
145
145
|
return Object.freeze(e);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function ln(n) {
|
|
148
148
|
const t = [
|
|
149
149
|
n.max[0] - n.min[0],
|
|
150
150
|
n.max[1] - n.min[1],
|
|
151
151
|
n.max[2] - n.min[2]
|
|
152
|
-
], e = Math.max(...t.map((
|
|
152
|
+
], e = Math.max(...t.map((u) => Math.abs(u))), o = Math.max(0.01, e / 20), r = 10 ** Math.floor(Math.log10(o)), a = o / r, d = a <= 1 ? 1 : a <= 2 ? 2 : a <= 5 ? 5 : 10;
|
|
153
153
|
return Math.max(0.01, Math.min(2, d * r));
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
return t.gridStepM > 0 ? t.gridStepM : t.adaptiveGridSnap ?
|
|
155
|
+
function D(n, t) {
|
|
156
|
+
return t.gridStepM > 0 ? t.gridStepM : t.adaptiveGridSnap ? ln(n) : 0;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function bn(n, t, e = 0, o = 12) {
|
|
159
|
+
if (!Number.isInteger(o) || o < 1) return [];
|
|
160
|
+
const s = J(n, {
|
|
161
|
+
...t,
|
|
162
|
+
position: [0, 0, 0]
|
|
163
|
+
}), r = Math.max(0.1, e), a = Math.max(0.5, s.max[0] - s.min[0] + r), d = Math.max(0.5, s.max[1] - s.min[1] + r), u = [];
|
|
164
|
+
for (let p = 1; p <= o; p += 1) {
|
|
165
|
+
const f = [];
|
|
166
|
+
for (let i = -p; i <= p; i += 1)
|
|
167
|
+
for (let c = -p; c <= p; c += 1)
|
|
168
|
+
Math.max(Math.abs(i), Math.abs(c)) === p && f.push([i * a, c * d, 0]);
|
|
169
|
+
f.sort((i, c) => i[0] * i[0] + i[1] * i[1] - (c[0] * c[0] + c[1] * c[1])), u.push(...f);
|
|
170
|
+
}
|
|
171
|
+
return P(u);
|
|
172
|
+
}
|
|
173
|
+
function un(n) {
|
|
159
174
|
const t = Math.hypot(...n);
|
|
160
|
-
return Number.isFinite(t) && t > 1e-12 && n[2] / t >=
|
|
175
|
+
return Number.isFinite(t) && t > 1e-12 && n[2] / t >= rn;
|
|
161
176
|
}
|
|
162
177
|
const A = (n, t) => [
|
|
163
178
|
n[1] * t[2] - n[2] * t[1],
|
|
164
179
|
n[2] * t[0] - n[0] * t[2],
|
|
165
180
|
n[0] * t[1] - n[1] * t[0]
|
|
166
|
-
],
|
|
181
|
+
], Y = (n) => [
|
|
167
182
|
[1, 0, 0],
|
|
168
183
|
[0, 1, 0],
|
|
169
184
|
[0, 0, 1]
|
|
170
185
|
].map((t) => w(n.rotation, t));
|
|
171
|
-
function
|
|
172
|
-
if (n.container &&
|
|
173
|
-
const o =
|
|
174
|
-
for (const
|
|
175
|
-
if (Math.hypot(...
|
|
176
|
-
const p =
|
|
186
|
+
function X(n, t, e = 1e-6) {
|
|
187
|
+
if (n.container && G(n, t, e) || t.container && G(t, n, e)) return !1;
|
|
188
|
+
const o = Y(n.transform), s = Y(t.transform), r = [...o, ...s, ...o.flatMap((u) => s.map((p) => A(u, p)))], a = b(n.bounds).map((u) => g(u, n.transform)), d = b(t.bounds).map((u) => g(u, t.transform));
|
|
189
|
+
for (const u of r) {
|
|
190
|
+
if (Math.hypot(...u) < 1e-10) continue;
|
|
191
|
+
const p = O(u), f = a.map((c) => v(c, p)), i = d.map((c) => v(c, p));
|
|
177
192
|
if (Math.min(Math.max(...f), Math.max(...i)) - Math.max(Math.min(...f), Math.min(...i)) <= e)
|
|
178
193
|
return !1;
|
|
179
194
|
}
|
|
180
195
|
return !0;
|
|
181
196
|
}
|
|
182
|
-
function
|
|
183
|
-
const [o, s, r, a] = n.transform.rotation, d = [-o, -s, -r, a],
|
|
197
|
+
function G(n, t, e) {
|
|
198
|
+
const [o, s, r, a] = n.transform.rotation, d = [-o, -s, -r, a], u = n.transform.scale.map((p) => Math.abs(p) > 1e-12 ? 1 / p : 0);
|
|
184
199
|
return b(t.bounds).every((p) => {
|
|
185
200
|
const i = g(p, t.transform).map(
|
|
186
|
-
(
|
|
201
|
+
(l, m) => l - n.transform.position[m]
|
|
187
202
|
);
|
|
188
203
|
return w(d, i).map(
|
|
189
|
-
(
|
|
190
|
-
).every((
|
|
204
|
+
(l, m) => l * u[m]
|
|
205
|
+
).every((l, m) => l >= n.bounds.min[m] - e && l <= n.bounds.max[m] + e);
|
|
191
206
|
});
|
|
192
207
|
}
|
|
193
|
-
function
|
|
194
|
-
const t =
|
|
195
|
-
let e =
|
|
208
|
+
function En(n) {
|
|
209
|
+
const t = dn(n.policy ?? {});
|
|
210
|
+
let e = k(n.transform);
|
|
196
211
|
const o = n.surface;
|
|
197
212
|
if (t.surfaceSnap && !o)
|
|
198
|
-
return
|
|
213
|
+
return P({
|
|
199
214
|
valid: !1,
|
|
200
215
|
transform: e,
|
|
201
216
|
precision: "oriented-bounds",
|
|
@@ -210,9 +225,9 @@ function Sn(n) {
|
|
|
210
225
|
new Error("A placement surface requires a finite point and nonzero normal."),
|
|
211
226
|
{ code: "PLACEMENT_SURFACE_INVALID" }
|
|
212
227
|
);
|
|
213
|
-
const a =
|
|
214
|
-
if (!
|
|
215
|
-
return
|
|
228
|
+
const a = O(o.normal);
|
|
229
|
+
if (!un(a))
|
|
230
|
+
return P({
|
|
216
231
|
valid: !1,
|
|
217
232
|
transform: e,
|
|
218
233
|
precision: "oriented-bounds",
|
|
@@ -222,25 +237,25 @@ function Sn(n) {
|
|
|
222
237
|
reason: "PLACEMENT_SURFACE_NOT_SUPPORTING"
|
|
223
238
|
});
|
|
224
239
|
if (t.alignToSurface) {
|
|
225
|
-
const i = w(e.rotation, [0, 0, 1]),
|
|
240
|
+
const i = w(e.rotation, [0, 0, 1]), c = Math.max(-1, Math.min(1, v(i, a))), l = c < -1 + 1e-10 ? [...w(e.rotation, [1, 0, 0]), 0] : [...A(i, a), 1 + c], m = Math.hypot(...l);
|
|
226
241
|
e = {
|
|
227
242
|
...e,
|
|
228
243
|
rotation: q(
|
|
229
|
-
|
|
244
|
+
l.map((M) => M / m),
|
|
230
245
|
e.rotation
|
|
231
246
|
)
|
|
232
247
|
};
|
|
233
248
|
}
|
|
234
249
|
let d = o.point;
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
const i = Math.abs(a[2]) > 0.99 ?
|
|
238
|
-
d = [0, 1, 2].map((N) => i[N] *
|
|
250
|
+
const u = D(n.bounds, t);
|
|
251
|
+
if (u > 0) {
|
|
252
|
+
const i = Math.abs(a[2]) > 0.99 ? O(A([0, 1, 0], a)) : O(A([0, 0, 1], a)), c = A(a, i), l = u, m = Math.round(v(d, i) / l) * l, M = Math.round(v(d, c) / l) * l, L = v(d, a);
|
|
253
|
+
d = [0, 1, 2].map((N) => i[N] * m + c[N] * M + a[N] * L);
|
|
239
254
|
}
|
|
240
255
|
const p = g(K(n.bounds), e), f = Math.min(
|
|
241
256
|
...b(n.bounds).map(
|
|
242
257
|
(i) => v(
|
|
243
|
-
g(i, e).map((
|
|
258
|
+
g(i, e).map((c, l) => c - p[l]),
|
|
244
259
|
a
|
|
245
260
|
)
|
|
246
261
|
)
|
|
@@ -248,11 +263,11 @@ function Sn(n) {
|
|
|
248
263
|
e = {
|
|
249
264
|
...e,
|
|
250
265
|
position: e.position.map(
|
|
251
|
-
(i,
|
|
266
|
+
(i, c) => i + d[c] - p[c] + a[c] * (t.clearanceM - f)
|
|
252
267
|
)
|
|
253
268
|
};
|
|
254
269
|
} else {
|
|
255
|
-
const a =
|
|
270
|
+
const a = D(n.bounds, t);
|
|
256
271
|
a > 0 && (e = {
|
|
257
272
|
...e,
|
|
258
273
|
position: e.position.map(
|
|
@@ -260,7 +275,7 @@ function Sn(n) {
|
|
|
260
275
|
)
|
|
261
276
|
});
|
|
262
277
|
}
|
|
263
|
-
const s = { nodeId: "", bounds: n.bounds, transform: e }, r = t.preventOverlap ? (n.obstacles ?? []).filter((a) => !(o != null && o.nodeId && a.nodeId === o.nodeId &&
|
|
278
|
+
const s = { nodeId: "", bounds: n.bounds, transform: e }, r = t.preventOverlap ? (n.obstacles ?? []).filter((a) => !(o != null && o.nodeId && a.nodeId === o.nodeId && R(
|
|
264
279
|
s,
|
|
265
280
|
a,
|
|
266
281
|
{
|
|
@@ -269,8 +284,8 @@ function Sn(n) {
|
|
|
269
284
|
surfaceZ: o.point[2]
|
|
270
285
|
},
|
|
271
286
|
t
|
|
272
|
-
)) &&
|
|
273
|
-
return
|
|
287
|
+
)) && X(s, a, t.toleranceM)).map((a) => a.nodeId) : [];
|
|
288
|
+
return P({
|
|
274
289
|
valid: r.length === 0,
|
|
275
290
|
transform: e,
|
|
276
291
|
precision: "oriented-bounds",
|
|
@@ -280,43 +295,43 @@ function Sn(n) {
|
|
|
280
295
|
reason: r.length ? "PLACEMENT_OVERLAP" : null
|
|
281
296
|
});
|
|
282
297
|
}
|
|
283
|
-
function
|
|
298
|
+
function R(n, t, e, o) {
|
|
284
299
|
if (n.nodeId !== e.movedNodeId || t.nodeId !== e.supportNodeId || !Number.isFinite(e.surfaceZ))
|
|
285
300
|
return !1;
|
|
286
301
|
const s = b(n.bounds).reduce(
|
|
287
|
-
(d,
|
|
302
|
+
(d, u) => Math.min(d, g(u, n.transform)[2]),
|
|
288
303
|
1 / 0
|
|
289
304
|
);
|
|
290
305
|
if (!Number.isFinite(s)) return !1;
|
|
291
|
-
const r = e.surfaceZ + Math.max(0, o.clearanceM), a = Math.max(o.toleranceM,
|
|
306
|
+
const r = e.surfaceZ + Math.max(0, o.clearanceM), a = Math.max(o.toleranceM, cn);
|
|
292
307
|
return Math.abs(s - r) <= a;
|
|
293
308
|
}
|
|
294
|
-
function
|
|
309
|
+
function Tn(n, t, e, o, s = /* @__PURE__ */ new Set(), r = []) {
|
|
295
310
|
if (!e.preventOverlap) return [];
|
|
296
311
|
const a = new Map(
|
|
297
312
|
r.map((i) => [
|
|
298
|
-
|
|
313
|
+
$(i.movedNodeId, i.supportNodeId),
|
|
299
314
|
i
|
|
300
315
|
])
|
|
301
316
|
), d = H(t.root).filter(
|
|
302
|
-
(i) => i
|
|
303
|
-
),
|
|
317
|
+
(i) => fn(i) && B(t.root, i.nodeId, {})
|
|
318
|
+
), u = d.map((i) => ({
|
|
304
319
|
nodeId: i.nodeId,
|
|
305
320
|
bounds: (o == null ? void 0 : o(i)) ?? x(t, i),
|
|
306
321
|
transform: y(t.root, i.nodeId),
|
|
307
|
-
container:
|
|
322
|
+
container: pn(t, i)
|
|
308
323
|
})), p = new Set(
|
|
309
324
|
d.filter((i) => {
|
|
310
|
-
const
|
|
311
|
-
return !
|
|
325
|
+
const c = S(n.root, i.nodeId);
|
|
326
|
+
return !c || !B(n.root, i.nodeId, {}) || !E(
|
|
312
327
|
y(n.root, i.nodeId),
|
|
313
328
|
y(t.root, i.nodeId)
|
|
314
|
-
) || !E(x(n,
|
|
329
|
+
) || !E(x(n, c), x(t, i)) || "assetRevisionId" in i && (!("assetRevisionId" in c) || c.assetRevisionId !== i.assetRevisionId) || "visualRevisionId" in i && (!("visualRevisionId" in c) || c.visualRevisionId !== i.visualRevisionId);
|
|
315
330
|
}).map((i) => i.nodeId)
|
|
316
331
|
);
|
|
317
332
|
if (!p.size) return [];
|
|
318
333
|
const f = [];
|
|
319
|
-
for (const i of
|
|
334
|
+
for (const i of u)
|
|
320
335
|
i.bounds || f.push({
|
|
321
336
|
code: "PLACEMENT_BOUNDS_UNAVAILABLE",
|
|
322
337
|
level: "error",
|
|
@@ -324,82 +339,87 @@ function An(n, t, e, o, s = /* @__PURE__ */ new Set(), r = []) {
|
|
|
324
339
|
message: "Overlap prevention requires known source bounds: " + i.nodeId
|
|
325
340
|
});
|
|
326
341
|
if (f.length) return f;
|
|
327
|
-
for (let i = 0; i <
|
|
328
|
-
for (let
|
|
329
|
-
const
|
|
330
|
-
if (!p.has(
|
|
331
|
-
const M = a.get(
|
|
332
|
-
if (M ?
|
|
333
|
-
{ ...
|
|
334
|
-
{ ...
|
|
342
|
+
for (let i = 0; i < u.length; i++)
|
|
343
|
+
for (let c = i + 1; c < u.length; c++) {
|
|
344
|
+
const l = u[i], m = u[c];
|
|
345
|
+
if (!p.has(l.nodeId) && !p.has(m.nodeId) || s.has(l.nodeId) || s.has(m.nodeId)) continue;
|
|
346
|
+
const M = a.get($(l.nodeId, m.nodeId));
|
|
347
|
+
if (M ? l.nodeId === M.movedNodeId ? R(
|
|
348
|
+
{ ...l, bounds: l.bounds },
|
|
349
|
+
{ ...m, bounds: m.bounds },
|
|
335
350
|
M,
|
|
336
351
|
e
|
|
337
|
-
) :
|
|
338
|
-
{ ...
|
|
339
|
-
{ ...
|
|
352
|
+
) : R(
|
|
353
|
+
{ ...m, bounds: m.bounds },
|
|
354
|
+
{ ...l, bounds: l.bounds },
|
|
340
355
|
M,
|
|
341
356
|
e
|
|
342
357
|
) : !1) continue;
|
|
343
|
-
const N = y(n.root,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
) ||
|
|
348
|
-
{ ...
|
|
349
|
-
{ ...
|
|
358
|
+
const N = y(n.root, l.nodeId), z = y(n.root, m.nodeId), C = S(n.root, l.nodeId), F = S(n.root, m.nodeId), U = S(t.root, l.nodeId), V = S(t.root, m.nodeId);
|
|
359
|
+
C && F && E(x(n, C), x(t, U)) && E(x(n, F), x(t, V)) && T(C) === T(U) && T(F) === T(V) && N && z && mn(
|
|
360
|
+
Z(N, z),
|
|
361
|
+
Z(l.transform, m.transform)
|
|
362
|
+
) || X(
|
|
363
|
+
{ ...l, bounds: l.bounds },
|
|
364
|
+
{ ...m, bounds: m.bounds },
|
|
350
365
|
e.toleranceM
|
|
351
366
|
) && f.push({
|
|
352
367
|
code: "PLACEMENT_OVERLAP",
|
|
353
368
|
level: "error",
|
|
354
|
-
instanceId:
|
|
355
|
-
message: "Placement intersects " +
|
|
356
|
-
detail: { otherNodeId:
|
|
369
|
+
instanceId: l.nodeId,
|
|
370
|
+
message: "Placement intersects " + m.nodeId,
|
|
371
|
+
detail: { otherNodeId: m.nodeId, precision: "oriented-bounds" }
|
|
357
372
|
});
|
|
358
373
|
}
|
|
359
374
|
return f;
|
|
360
375
|
}
|
|
361
|
-
function
|
|
376
|
+
function $(n, t) {
|
|
362
377
|
return n < t ? `${n}\0${t}` : `${t}\0${n}`;
|
|
363
378
|
}
|
|
364
|
-
function
|
|
379
|
+
function mn(n, t) {
|
|
365
380
|
return !!n && !!t && [...n.position, ...n.rotation, ...n.scale].every(
|
|
366
381
|
(e, o) => Math.abs(e - [...t.position, ...t.rotation, ...t.scale][o]) < 1e-9
|
|
367
382
|
);
|
|
368
383
|
}
|
|
369
|
-
function
|
|
384
|
+
function T(n) {
|
|
370
385
|
return n.nodeType === "asset" ? n.assetRevisionId : n.nodeType === "visual" ? n.visualRevisionId : null;
|
|
371
386
|
}
|
|
372
|
-
function
|
|
387
|
+
function pn(n, t) {
|
|
373
388
|
var o, s;
|
|
374
389
|
if (t.nodeType !== "asset") return !1;
|
|
375
390
|
const e = W(n, t.assetRevisionId);
|
|
376
391
|
return (e == null ? void 0 : e.category) === "container" || ((s = (o = e == null ? void 0 : e.semantic) == null ? void 0 : o.tags) == null ? void 0 : s.some((r) => /^(container|receptacle|集装箱|容器|可容纳)$/i.test(r))) === !0;
|
|
377
392
|
}
|
|
393
|
+
function fn(n) {
|
|
394
|
+
return n.nodeType === "asset" || n.nodeType === "placeholder" || n.nodeType === "domain";
|
|
395
|
+
}
|
|
378
396
|
export {
|
|
379
|
-
D,
|
|
380
|
-
|
|
397
|
+
j as D,
|
|
398
|
+
cn as S,
|
|
381
399
|
h as a,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
400
|
+
ln as b,
|
|
401
|
+
Nn as c,
|
|
402
|
+
tn as d,
|
|
403
|
+
on as e,
|
|
404
|
+
nn as f,
|
|
405
|
+
D as g,
|
|
406
|
+
En as h,
|
|
407
|
+
Sn as i,
|
|
408
|
+
un as j,
|
|
409
|
+
Q as k,
|
|
410
|
+
X as l,
|
|
411
|
+
sn as m,
|
|
412
|
+
dn as n,
|
|
395
413
|
I as o,
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
414
|
+
yn as p,
|
|
415
|
+
fn as q,
|
|
416
|
+
pn as r,
|
|
417
|
+
an as s,
|
|
418
|
+
bn as t,
|
|
419
|
+
An as u,
|
|
420
|
+
Tn as v,
|
|
421
|
+
xn as w,
|
|
422
|
+
vn as x,
|
|
423
|
+
gn as y,
|
|
424
|
+
R as z
|
|
405
425
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StudioStateSnapshot } from '../persist/snapshot';
|
|
1
|
+
import type { StudioSessionSnapshot, StudioStateSnapshot } from '../persist/snapshot';
|
|
2
2
|
export interface StudioPersistenceAdapter {
|
|
3
3
|
/** Canonical scene state only. Asset bytes are resolved through the asset source port. */
|
|
4
4
|
load(): Promise<StudioStateSnapshot | null>;
|
|
@@ -27,3 +27,47 @@ export interface StudioPersistenceReceipt {
|
|
|
27
27
|
readonly documentHash: string;
|
|
28
28
|
readonly savedAt: string;
|
|
29
29
|
}
|
|
30
|
+
export type StudioSessionPersistenceSaveMode = 'autosave' | 'checkpoint' | 'publish';
|
|
31
|
+
export interface StudioLoadedSession {
|
|
32
|
+
readonly snapshot: StudioSessionSnapshot;
|
|
33
|
+
readonly revision: string;
|
|
34
|
+
readonly etag: string;
|
|
35
|
+
readonly savedAt: string;
|
|
36
|
+
}
|
|
37
|
+
export interface StudioSessionPersistenceConflict {
|
|
38
|
+
readonly expectedRevision: string | null;
|
|
39
|
+
readonly expectedEtag: string | null;
|
|
40
|
+
readonly actualRevision: string;
|
|
41
|
+
readonly actualEtag: string;
|
|
42
|
+
readonly savedAt: string;
|
|
43
|
+
}
|
|
44
|
+
export type StudioSessionPersistenceSaveResult = {
|
|
45
|
+
readonly status: 'saved';
|
|
46
|
+
readonly revision: string;
|
|
47
|
+
readonly etag: string;
|
|
48
|
+
readonly savedAt: string;
|
|
49
|
+
readonly snapshotDigest: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly status: 'conflict';
|
|
52
|
+
readonly conflict: StudioSessionPersistenceConflict;
|
|
53
|
+
};
|
|
54
|
+
export interface StudioSessionPersistenceLoadOptions {
|
|
55
|
+
readonly signal?: AbortSignal;
|
|
56
|
+
}
|
|
57
|
+
export interface StudioSessionPersistenceSaveOptions {
|
|
58
|
+
readonly mode: StudioSessionPersistenceSaveMode;
|
|
59
|
+
readonly expectedRevision: string | null;
|
|
60
|
+
readonly expectedEtag: string | null;
|
|
61
|
+
readonly idempotencyKey: string;
|
|
62
|
+
readonly signal?: AbortSignal;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Storage port for complete editor sessions. Implementations own transport,
|
|
66
|
+
* authentication and server revision/ETag handling, but not project policy,
|
|
67
|
+
* permissions, publication workflow or asset catalog business rules.
|
|
68
|
+
*/
|
|
69
|
+
export interface StudioSessionPersistenceAdapter {
|
|
70
|
+
load(options?: StudioSessionPersistenceLoadOptions): Promise<StudioLoadedSession | null>;
|
|
71
|
+
save(snapshot: StudioSessionSnapshot, options: StudioSessionPersistenceSaveOptions): Promise<StudioSessionPersistenceSaveResult>;
|
|
72
|
+
close?(): void | Promise<void>;
|
|
73
|
+
}
|
|
@@ -263,8 +263,11 @@ export interface LoadedScenePackage {
|
|
|
263
263
|
export interface RemoteResourceResolver {
|
|
264
264
|
resolve(locator: StudioAssetResourceLocator): Promise<Uint8Array | ArrayBuffer | Blob | null>;
|
|
265
265
|
}
|
|
266
|
+
export type ScenePackageResourceReadMode = 'all' | 'embedded' | 'none';
|
|
266
267
|
export interface ScenePackageReadPorts {
|
|
267
268
|
readonly remoteResolver?: RemoteResourceResolver;
|
|
269
|
+
/** Controls whether resource bytes are loaded while inspecting package documents. */
|
|
270
|
+
readonly resourceReadMode?: ScenePackageResourceReadMode;
|
|
268
271
|
}
|
|
269
272
|
export interface ScenePackageHostSource {
|
|
270
273
|
readonly document: import('../doc/schema').SceneDocument;
|