@margoengine/xr 0.0.0-stage → 1.0.0
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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +842 -2
- package/dist/ar-extra.d.ts +232 -0
- package/dist/ar-extra.js +315 -0
- package/dist/ar.d.ts +177 -0
- package/dist/ar.js +195 -0
- package/dist/body.d.ts +58 -0
- package/dist/body.js +134 -0
- package/dist/controller.d.ts +32 -0
- package/dist/device-check.d.ts +39 -0
- package/dist/device-check.js +155 -0
- package/dist/errors-XvcwUnU4.js +7 -0
- package/dist/eye-target.d.ts +25 -0
- package/dist/eyes.d.ts +45 -0
- package/dist/gizmo.d.ts +165 -0
- package/dist/gizmo.js +198 -0
- package/dist/hands.d.ts +48 -0
- package/dist/hands.js +198 -0
- package/dist/hit-test.d.ts +69 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +1103 -0
- package/dist/interaction.d.ts +136 -0
- package/dist/interaction.js +205 -0
- package/dist/launch.d.ts +65 -0
- package/dist/launch.js +54 -0
- package/dist/layers-BTUTAawG.js +391 -0
- package/dist/layers.d.ts +247 -0
- package/dist/layers.js +1 -0
- package/dist/locomotion.d.ts +63 -0
- package/dist/locomotion.js +184 -0
- package/dist/models.d.ts +136 -0
- package/dist/models.js +335 -0
- package/dist/near.d.ts +465 -0
- package/dist/near.js +643 -0
- package/dist/occlusion.d.ts +49 -0
- package/dist/occlusion.js +218 -0
- package/dist/performance.d.ts +67 -0
- package/dist/performance.js +78 -0
- package/dist/pointer.d.ts +93 -0
- package/dist/pointer.js +205 -0
- package/dist/reflection.d.ts +70 -0
- package/dist/reflection.js +147 -0
- package/dist/renderer.d.ts +21 -0
- package/dist/scene-owner-BRObO-WJ.js +15 -0
- package/dist/scene-owner.d.ts +3 -0
- package/dist/scene-scope-DufD_3B6.js +42 -0
- package/dist/session.d.ts +60 -0
- package/dist/session.js +68 -0
- package/dist/shared/xr-run.d.ts +64 -0
- package/dist/types.d.ts +221 -0
- package/package.json +152 -4
package/dist/near.js
ADDED
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
|
+
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
+
|
|
4
|
+
import { Quaternion as e } from "@margoengine/math/quaternion";
|
|
5
|
+
import { Vector3 as t } from "@margoengine/math/vector3";
|
|
6
|
+
//#region src/near.ts
|
|
7
|
+
function n(n, r = {}) {
|
|
8
|
+
let i = r.position ?? [
|
|
9
|
+
n.position.x,
|
|
10
|
+
n.position.y,
|
|
11
|
+
n.position.z
|
|
12
|
+
], a = r.orientation ?? [
|
|
13
|
+
0,
|
|
14
|
+
0,
|
|
15
|
+
0,
|
|
16
|
+
1
|
|
17
|
+
], o = r.scale ?? [
|
|
18
|
+
1,
|
|
19
|
+
1,
|
|
20
|
+
1
|
|
21
|
+
], s = {
|
|
22
|
+
mesh: n,
|
|
23
|
+
position: new t(i[0], i[1], i[2]),
|
|
24
|
+
orientation: new e(a[0], a[1], a[2], a[3]),
|
|
25
|
+
scale: new t(o[0], o[1], o[2]),
|
|
26
|
+
radius: r.radius ?? .1,
|
|
27
|
+
apply() {
|
|
28
|
+
n.setPosition([
|
|
29
|
+
s.position.x,
|
|
30
|
+
s.position.y,
|
|
31
|
+
s.position.z
|
|
32
|
+
]), n.setQuaternion([
|
|
33
|
+
s.orientation.x,
|
|
34
|
+
s.orientation.y,
|
|
35
|
+
s.orientation.z,
|
|
36
|
+
s.orientation.w
|
|
37
|
+
]), n.setScale([
|
|
38
|
+
s.scale.x,
|
|
39
|
+
s.scale.y,
|
|
40
|
+
s.scale.z
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return s.apply(), s;
|
|
45
|
+
}
|
|
46
|
+
var r = class {
|
|
47
|
+
constructor() {
|
|
48
|
+
this.stops = [], this.done = !1;
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
if (!this.done) {
|
|
52
|
+
this.done = !0;
|
|
53
|
+
for (let e of this.stops.splice(0)) e();
|
|
54
|
+
this.release();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
[Symbol.dispose ?? Symbol()]() {
|
|
58
|
+
this.dispose();
|
|
59
|
+
}
|
|
60
|
+
release() {}
|
|
61
|
+
}, i = 4, a = 9, o = Math.PI / 180, s = (e, t) => e > 0 ? 1 - Math.exp(-e * Math.max(0, t)) : 1, c = (e, t) => {
|
|
62
|
+
if (!(t > 0)) throw RangeError(`${e} must be a positive number; got ${t}`);
|
|
63
|
+
};
|
|
64
|
+
function l(e, t, n) {
|
|
65
|
+
if (!e.handTracked[t]) return !1;
|
|
66
|
+
let r = t * 16 + 12;
|
|
67
|
+
return n.set(e.handMatrices[r], e.handMatrices[r + 1], e.handMatrices[r + 2]), !0;
|
|
68
|
+
}
|
|
69
|
+
var u = (e) => e.viewer?.transform ?? null, d = class n extends r {
|
|
70
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
71
|
+
return new n(e, t);
|
|
72
|
+
}
|
|
73
|
+
constructor(n, r) {
|
|
74
|
+
if (super(), this.options = r, this.visible = !1, this.controller = null, this.p = new t(), this.n = new t(), this.w = new t(), this.goal = new t(), this.q = new e(), this.r = new e(Math.SQRT1_2, 0, 0, Math.SQRT1_2).multiply(new e(0, 0, 1, 0)), this.placed = !1, this.t = {
|
|
75
|
+
hand: r.hand ?? "either",
|
|
76
|
+
joint: r.joint ?? 0,
|
|
77
|
+
offset: r.offset ?? [
|
|
78
|
+
0,
|
|
79
|
+
-.1,
|
|
80
|
+
0
|
|
81
|
+
],
|
|
82
|
+
showAngle: r.showAngle ?? 45,
|
|
83
|
+
hideAngle: r.hideAngle ?? 60,
|
|
84
|
+
facing: r.facing ?? "viewer",
|
|
85
|
+
orientation: r.orientation ?? "hand",
|
|
86
|
+
rate: r.rate ?? 14
|
|
87
|
+
}, !(this.t.joint >= 0 && this.t.joint < 25 && Number.isInteger(this.t.joint))) throw RangeError("HandConstraint joint must be a WebXR hand joint index 0 to 24; pass { joint: 0 }");
|
|
88
|
+
if (c("HandConstraint showAngle", this.t.showAngle), !(this.t.hideAngle >= this.t.showAngle)) throw RangeError("HandConstraint hideAngle must be at least showAngle; pass { showAngle: 45, hideAngle: 60 }");
|
|
89
|
+
r.target.visible = !1, this.stops.push(n.onFrame((e) => this.frame(n.controllers, e)));
|
|
90
|
+
}
|
|
91
|
+
release() {
|
|
92
|
+
this.set(!1, null);
|
|
93
|
+
}
|
|
94
|
+
set(e, t) {
|
|
95
|
+
let n = this.visible;
|
|
96
|
+
this.visible = e, this.controller = e ? t : null, this.options.target.visible = e, e && !n && t && this.options.onShow?.(t), !e && n && this.options.onHide?.();
|
|
97
|
+
}
|
|
98
|
+
frame(e, t) {
|
|
99
|
+
let n = u(t)?.position, { joint: r, hand: i, facing: a, showAngle: c, hideAngle: d } = this.t, f = null, p = Infinity;
|
|
100
|
+
for (let t of e) {
|
|
101
|
+
if (i !== "either" && t.source?.handedness !== i || !l(t, r, this.p)) continue;
|
|
102
|
+
let e = t.handMatrices, s = r * 16;
|
|
103
|
+
this.n.set(-e[s + 4], -e[s + 5], -e[s + 6]).normalize();
|
|
104
|
+
let u = 0;
|
|
105
|
+
if (a === "viewer") {
|
|
106
|
+
if (!n) continue;
|
|
107
|
+
this.w.set(n.x - this.p.x, n.y - this.p.y, n.z - this.p.z).normalize(), u = Math.acos(Math.max(-1, Math.min(1, this.n.dot(this.w)))) / o;
|
|
108
|
+
}
|
|
109
|
+
u <= (t === this.controller ? d : c) && u < p && (f = t, p = u);
|
|
110
|
+
}
|
|
111
|
+
if (!f) return this.set(!1, null);
|
|
112
|
+
let m = f, h = m.handMatrices, g = this.t.joint * 16, _ = this.options.target;
|
|
113
|
+
l(m, this.t.joint, this.p), this.q.setFromRotationMatrix({ elements: h.subarray(g, g + 16) });
|
|
114
|
+
let [v, y, b] = this.t.offset;
|
|
115
|
+
this.goal.set(v, y, b).applyQuaternion(this.q).add(this.p), this.t.orientation === "hand" ? this.q.multiply(this.r) : n && this.q.setFromAxisAngle({
|
|
116
|
+
x: 0,
|
|
117
|
+
y: 1,
|
|
118
|
+
z: 0
|
|
119
|
+
}, Math.atan2(n.x - this.goal.x, n.z - this.goal.z));
|
|
120
|
+
let x = this.placed && this.visible ? s(this.t.rate, t.delta) : 1;
|
|
121
|
+
this.placed = !0, _.position.lerp(this.goal, x), _.orientation.slerp(this.q, x), this.set(!0, m), _.apply?.();
|
|
122
|
+
}
|
|
123
|
+
}, f = class n extends r {
|
|
124
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
125
|
+
return new n(e, t);
|
|
126
|
+
}
|
|
127
|
+
constructor(n, r) {
|
|
128
|
+
if (super(), this.options = r, this.enabled = !0, this.d = new t(), this.f = new t(), this.goal = new t(), this.q = new e(), this.s = new e(), this.o = {
|
|
129
|
+
maxViewDegrees: r.maxViewDegrees ?? 25,
|
|
130
|
+
minDistance: r.minDistance ?? .4,
|
|
131
|
+
maxDistance: r.maxDistance ?? 1.2,
|
|
132
|
+
distance: r.distance ?? .7,
|
|
133
|
+
rate: r.rate ?? 5,
|
|
134
|
+
billboard: r.billboard ?? "yaw",
|
|
135
|
+
snapOnStart: r.snapOnStart ?? !0
|
|
136
|
+
}, c("FollowInView maxViewDegrees", this.o.maxViewDegrees), c("FollowInView minDistance", this.o.minDistance), !(this.o.maxDistance >= this.o.minDistance)) throw RangeError("FollowInView maxDistance must be at least minDistance; pass { minDistance: 0.4, maxDistance: 1.2 }");
|
|
137
|
+
this.snapNext = this.o.snapOnStart, this.stops.push(n.onFrame((e) => this.frame(e)));
|
|
138
|
+
}
|
|
139
|
+
snap() {
|
|
140
|
+
this.snapNext = !0;
|
|
141
|
+
}
|
|
142
|
+
frame(e) {
|
|
143
|
+
let t = u(e);
|
|
144
|
+
if (!t || !this.enabled) return;
|
|
145
|
+
let n = this.options.target, { x: r, y: i, z: a } = t.position;
|
|
146
|
+
this.q.set(t.orientation.x, t.orientation.y, t.orientation.z, t.orientation.w), this.f.set(0, 0, -1).applyQuaternion(this.q);
|
|
147
|
+
let c = s(this.o.rate, e.delta);
|
|
148
|
+
if (this.snapNext) this.snapNext = !1, this.goal.set(r, i, a).addScaledVector(this.f, this.o.distance), c = 1;
|
|
149
|
+
else {
|
|
150
|
+
this.d.set(n.position.x - r, n.position.y - i, n.position.z - a);
|
|
151
|
+
let e = this.d.length();
|
|
152
|
+
e < 1e-6 ? this.d.copy(this.f) : this.d.divideScalar(e);
|
|
153
|
+
let t = Math.acos(Math.max(-1, Math.min(1, this.d.dot(this.f)))), s = this.o.maxViewDegrees * o;
|
|
154
|
+
t > s && (this.s.set(0, 0, 0, 1).slerp(this.q.setFromUnitVectors(this.d, this.f), (t - s) / t), this.d.applyQuaternion(this.s));
|
|
155
|
+
let l = Math.min(this.o.maxDistance, Math.max(this.o.minDistance, e || this.o.distance));
|
|
156
|
+
if (this.goal.set(r, i, a).addScaledVector(this.d, l), t <= s && l === e) {
|
|
157
|
+
this.face(n, r, i, a, c);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
n.position.lerp(this.goal, c), this.face(n, r, i, a, c);
|
|
162
|
+
}
|
|
163
|
+
face(e, t, n, r, i) {
|
|
164
|
+
let a = t - e.position.x, o = n - e.position.y, s = r - e.position.z;
|
|
165
|
+
if (this.o.billboard === "yaw") this.q.setFromAxisAngle({
|
|
166
|
+
x: 0,
|
|
167
|
+
y: 1,
|
|
168
|
+
z: 0
|
|
169
|
+
}, Math.atan2(a, s));
|
|
170
|
+
else if (this.o.billboard === "full") {
|
|
171
|
+
let e = Math.hypot(a, o, s);
|
|
172
|
+
if (e < 1e-6) return;
|
|
173
|
+
this.q.setFromUnitVectors({
|
|
174
|
+
x: 0,
|
|
175
|
+
y: 0,
|
|
176
|
+
z: 1
|
|
177
|
+
}, {
|
|
178
|
+
x: a / e,
|
|
179
|
+
y: o / e,
|
|
180
|
+
z: s / e
|
|
181
|
+
});
|
|
182
|
+
} else return e.apply?.();
|
|
183
|
+
e.orientation.slerp(this.q, i), e.apply?.();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function p(e) {
|
|
187
|
+
let t = e.matrix;
|
|
188
|
+
return {
|
|
189
|
+
point: [
|
|
190
|
+
t[12],
|
|
191
|
+
t[13],
|
|
192
|
+
t[14]
|
|
193
|
+
],
|
|
194
|
+
normal: [
|
|
195
|
+
t[4],
|
|
196
|
+
t[5],
|
|
197
|
+
t[6]
|
|
198
|
+
]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
var m = (e, t) => e[0] * t.x + e[1] * t.y + e[2] * t.z, h = (e, t, n, r) => t === "none" ? !1 : t === "upright" ? e === "y" || Math.hypot(n.x, n.z) < 1e-6 ? !1 : (r.setFromAxisAngle({
|
|
202
|
+
x: 0,
|
|
203
|
+
y: 1,
|
|
204
|
+
z: 0
|
|
205
|
+
}, Math.atan2(n.x, n.z)), !0) : (r.setFromUnitVectors(e === "y" ? {
|
|
206
|
+
x: 0,
|
|
207
|
+
y: 1,
|
|
208
|
+
z: 0
|
|
209
|
+
} : {
|
|
210
|
+
x: 0,
|
|
211
|
+
y: 0,
|
|
212
|
+
z: 1
|
|
213
|
+
}, n), !0);
|
|
214
|
+
function g(n) {
|
|
215
|
+
let r = typeof n.surfaces == "function" ? n.surfaces() : n.surfaces, i = n.snapDistance ?? .1, a = n.target.position, o = new t(), s = null, c = Infinity;
|
|
216
|
+
for (let e of r) {
|
|
217
|
+
let t = (a.x - e.point[0]) * e.normal[0] + (a.y - e.point[1]) * e.normal[1] + (a.z - e.point[2]) * e.normal[2];
|
|
218
|
+
Math.abs(t) <= i && Math.abs(t) < c && (s = e, c = Math.abs(t));
|
|
219
|
+
}
|
|
220
|
+
if (!s) return null;
|
|
221
|
+
let l = Math.sign((a.x - s.point[0]) * s.normal[0] + (a.y - s.point[1]) * s.normal[1] + (a.z - s.point[2]) * s.normal[2]) || 1, u = n.offset ?? .005;
|
|
222
|
+
o.set(s.normal[0] * l, s.normal[1] * l, s.normal[2] * l);
|
|
223
|
+
let d = (a.x - s.point[0]) * o.x + (a.y - s.point[1]) * o.y + (a.z - s.point[2]) * o.z;
|
|
224
|
+
a.addScaledVector(o, u - d);
|
|
225
|
+
let f = new e();
|
|
226
|
+
return h(n.normalAxis ?? "y", n.alignment ?? "normal", o, f) && n.target.orientation.copy(f), n.target.apply?.(), s;
|
|
227
|
+
}
|
|
228
|
+
var _ = class n extends r {
|
|
229
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
230
|
+
return new n(e, t);
|
|
231
|
+
}
|
|
232
|
+
constructor(n, r) {
|
|
233
|
+
super(), this.xr = n, this.options = r, this.surface = null, this.enabled = !0, this.ro = new t(), this.rd = new t(), this.n = new t(), this.goal = new t(), this.q = new e(), this.placed = !1, this.o = {
|
|
234
|
+
maxDistance: r.maxDistance ?? 3,
|
|
235
|
+
offset: r.offset ?? .005,
|
|
236
|
+
normalAxis: r.normalAxis ?? "y",
|
|
237
|
+
alignment: r.alignment ?? "normal",
|
|
238
|
+
rate: r.rate ?? 18
|
|
239
|
+
}, c("SurfaceMagnetism maxDistance", this.o.maxDistance), this.stops.push(n.onFrame((e) => this.frame(e)));
|
|
240
|
+
}
|
|
241
|
+
aim(e) {
|
|
242
|
+
let t = this.options.source ?? "gaze", n;
|
|
243
|
+
return n = t === "gaze" ? u(e) : (typeof t == "number" ? this.xr.controllers[t] : t)?.targetRay?.transform, n ? (this.ro.set(n.position.x, n.position.y, n.position.z), this.q.set(n.orientation.x, n.orientation.y, n.orientation.z, n.orientation.w), this.rd.set(0, 0, -1).applyQuaternion(this.q), !0) : !1;
|
|
244
|
+
}
|
|
245
|
+
frame(e) {
|
|
246
|
+
if (!this.enabled || !this.aim(e)) return;
|
|
247
|
+
let t = typeof this.options.surfaces == "function" ? this.options.surfaces() : this.options.surfaces, n = null, r = this.o.maxDistance;
|
|
248
|
+
for (let e of t) {
|
|
249
|
+
let t = m(e.normal, this.rd);
|
|
250
|
+
if (t >= 0) continue;
|
|
251
|
+
let i = ((e.point[0] - this.ro.x) * e.normal[0] + (e.point[1] - this.ro.y) * e.normal[1] + (e.point[2] - this.ro.z) * e.normal[2]) / t;
|
|
252
|
+
i > 0 && i <= r && (n = e, r = i);
|
|
253
|
+
}
|
|
254
|
+
if (this.surface = n, !n) return;
|
|
255
|
+
this.n.set(n.normal[0], n.normal[1], n.normal[2]), this.goal.copy(this.ro).addScaledVector(this.rd, r).addScaledVector(this.n, this.o.offset);
|
|
256
|
+
let i = this.placed ? s(this.o.rate, e.delta) : 1, a = this.options.target;
|
|
257
|
+
this.placed = !0, a.position.lerp(this.goal, i), h(this.o.normalAxis, this.o.alignment, this.n, this.q) && a.orientation.slerp(this.q, i), a.apply?.();
|
|
258
|
+
}
|
|
259
|
+
}, v = class n extends r {
|
|
260
|
+
static attach(e, t = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
261
|
+
return new n(e, t);
|
|
262
|
+
}
|
|
263
|
+
constructor(n, r) {
|
|
264
|
+
if (super(), this.xr = n, this.frames = /* @__PURE__ */ new Map(), this.sessions = [], this.a = new t(), this.b = new t(), this.c = new t(), this.qa = new e(), this.qb = new e(), this.draggables = r.draggables ?? [], this.o = {
|
|
265
|
+
pinch: r.pinch ?? .02,
|
|
266
|
+
ray: r.ray ?? !0,
|
|
267
|
+
rayLength: r.rayLength ?? 5,
|
|
268
|
+
translate: r.translate ?? !0,
|
|
269
|
+
lock: r.lock ?? {},
|
|
270
|
+
rotate: r.rotate ?? "follow",
|
|
271
|
+
scale: r.scale ?? !0,
|
|
272
|
+
scaleLimits: r.scaleLimits ?? [.1, 10]
|
|
273
|
+
}, c("Manipulator pinch", this.o.pinch), c("Manipulator rayLength", this.o.rayLength), !(this.o.scaleLimits[0] > 0 && this.o.scaleLimits[1] >= this.o.scaleLimits[0])) throw RangeError("Manipulator scaleLimits must be [min, max] with 0 < min <= max; pass { scaleLimits: [0.1, 10] }");
|
|
274
|
+
this.stops.push(n.onFrame(() => this.frame()));
|
|
275
|
+
}
|
|
276
|
+
get active() {
|
|
277
|
+
return this.sessions.map((e) => e.object);
|
|
278
|
+
}
|
|
279
|
+
release() {
|
|
280
|
+
for (let e of this.sessions.splice(0)) this.end(e);
|
|
281
|
+
this.frames.clear();
|
|
282
|
+
}
|
|
283
|
+
read(n) {
|
|
284
|
+
let r = n.grip ?? n.targetRay;
|
|
285
|
+
if (!r) return null;
|
|
286
|
+
let o = this.frames.get(n);
|
|
287
|
+
o || (o = {
|
|
288
|
+
p: new t(),
|
|
289
|
+
q: new e(),
|
|
290
|
+
ro: new t(),
|
|
291
|
+
rd: new t(),
|
|
292
|
+
active: !1,
|
|
293
|
+
was: !1,
|
|
294
|
+
ray: !1
|
|
295
|
+
}, this.frames.set(n, o)), o.was = o.active;
|
|
296
|
+
let s = r.transform.orientation;
|
|
297
|
+
if (o.q.set(s.x, s.y, s.z, s.w), n.handTracked[i] && n.handTracked[a]) l(n, i, this.a), l(n, a, this.b), o.active = this.a.distanceTo(this.b) <= this.o.pinch, o.p.lerpVectors(this.a, this.b, .5);
|
|
298
|
+
else {
|
|
299
|
+
let e = r.transform.position;
|
|
300
|
+
o.p.set(e.x, e.y, e.z), o.active = n.source?.gamepad?.mapping === "xr-standard" && n.buttonCount > 1 && n.buttons[4] === 1;
|
|
301
|
+
}
|
|
302
|
+
if (o.ray = !1, n.targetRay) {
|
|
303
|
+
let e = n.targetRay.transform;
|
|
304
|
+
o.ro.set(e.position.x, e.position.y, e.position.z), this.qa.set(e.orientation.x, e.orientation.y, e.orientation.z, e.orientation.w), o.rd.set(0, 0, -1).applyQuaternion(this.qa), o.ray = !0;
|
|
305
|
+
}
|
|
306
|
+
return o;
|
|
307
|
+
}
|
|
308
|
+
frame() {
|
|
309
|
+
let e = this.xr.controllers;
|
|
310
|
+
for (let t of this.frames.keys()) e.includes(t) || this.frames.delete(t);
|
|
311
|
+
for (let t of e) this.read(t);
|
|
312
|
+
for (let e of [...this.sessions]) for (let t of [...e.holds]) {
|
|
313
|
+
let n = this.frames.get(t.controller);
|
|
314
|
+
(!n || !n.active) && this.drop(e, t);
|
|
315
|
+
}
|
|
316
|
+
for (let t of e) {
|
|
317
|
+
let e = this.frames.get(t);
|
|
318
|
+
e?.active && !e.was && !this.sessions.some((e) => e.holds.some((e) => e.controller === t)) && this.pick(t, e);
|
|
319
|
+
}
|
|
320
|
+
for (let e of this.sessions) this.update(e);
|
|
321
|
+
}
|
|
322
|
+
pick(n, r) {
|
|
323
|
+
let i = null, a = Infinity, o = !1, s = (e) => {
|
|
324
|
+
if (e.enabled === !1) return !1;
|
|
325
|
+
let t = this.sessions.find((t) => t.object === e);
|
|
326
|
+
return !t || this.o.scale && t.holds.length < 2;
|
|
327
|
+
};
|
|
328
|
+
for (let e of this.draggables) {
|
|
329
|
+
if (!s(e)) continue;
|
|
330
|
+
let t = e.position.distanceTo(r.p);
|
|
331
|
+
t <= e.radius && t < a && (i = e, a = t);
|
|
332
|
+
}
|
|
333
|
+
if (!i && this.o.ray && r.ray) for (let e of this.draggables) {
|
|
334
|
+
if (!s(e)) continue;
|
|
335
|
+
let t = y(r.ro, r.rd, e.position, e.radius);
|
|
336
|
+
t !== null && t <= this.o.rayLength && t < a && (i = e, a = t, o = !0);
|
|
337
|
+
}
|
|
338
|
+
if (!i) return;
|
|
339
|
+
let c = this.sessions.find((e) => e.object === i), l = !c;
|
|
340
|
+
c || (c = {
|
|
341
|
+
object: i,
|
|
342
|
+
holds: [],
|
|
343
|
+
p0: new t(),
|
|
344
|
+
q0: new e(),
|
|
345
|
+
s0: new t(1, 1, 1),
|
|
346
|
+
f0: new t(),
|
|
347
|
+
fq0: new e(),
|
|
348
|
+
rel0: new t(),
|
|
349
|
+
axis0: new t(),
|
|
350
|
+
mid0: new t(),
|
|
351
|
+
dist0: 1,
|
|
352
|
+
start: i.position.clone()
|
|
353
|
+
}, this.sessions.push(c)), c.holds.push({
|
|
354
|
+
controller: n,
|
|
355
|
+
ray: o
|
|
356
|
+
}), this.rebase(c), (l || c.holds.length === 2) && i.onDragStart?.({
|
|
357
|
+
controller: n,
|
|
358
|
+
ray: o,
|
|
359
|
+
pointers: c.holds.length
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
drop(e, t) {
|
|
363
|
+
if (e.holds.splice(e.holds.indexOf(t), 1), e.holds.length) return this.rebase(e);
|
|
364
|
+
this.sessions.splice(this.sessions.indexOf(e), 1), this.end(e, t);
|
|
365
|
+
}
|
|
366
|
+
end(e, t = e.holds[0]) {
|
|
367
|
+
t && e.object.onDragEnd?.({
|
|
368
|
+
controller: t.controller,
|
|
369
|
+
ray: t.ray,
|
|
370
|
+
pointers: Math.max(1, e.holds.length)
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
rebase(e) {
|
|
374
|
+
let t = e.object;
|
|
375
|
+
e.p0.copy(t.position), e.q0.copy(t.orientation), t.scale && e.s0.copy(t.scale);
|
|
376
|
+
let n = this.frames.get(e.holds[0].controller);
|
|
377
|
+
if (e.f0.copy(n.p), e.fq0.copy(n.q), e.rel0.copy(t.position).sub(n.p), e.holds.length > 1) {
|
|
378
|
+
let r = this.frames.get(e.holds[1].controller);
|
|
379
|
+
e.mid0.lerpVectors(n.p, r.p, .5), e.axis0.copy(r.p).sub(n.p), e.dist0 = e.axis0.length(), e.dist0 > 1e-6 && e.axis0.divideScalar(e.dist0), e.rel0.copy(t.position).sub(e.mid0);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
update(e) {
|
|
383
|
+
let t = e.object, n = this.frames.get(e.holds[0].controller), r = this.a, i = this.qa, a = 1;
|
|
384
|
+
if (e.holds.length === 1) i.copy(e.fq0).invert().premultiply(n.q), this.restrict(i), r.copy(e.rel0).applyQuaternion(i).add(n.p);
|
|
385
|
+
else {
|
|
386
|
+
let o = this.frames.get(e.holds[1].controller);
|
|
387
|
+
this.b.copy(o.p).sub(n.p);
|
|
388
|
+
let s = this.b.length();
|
|
389
|
+
if (!(s > 1e-6) || !(e.dist0 > 1e-6)) return;
|
|
390
|
+
if (this.b.divideScalar(s), this.c.copy(e.axis0), this.o.rotate === "none") i.identity();
|
|
391
|
+
else if (this.o.rotate === "yaw") {
|
|
392
|
+
let e = Math.atan2(this.c.x, this.c.z), t = Math.atan2(this.b.x, this.b.z);
|
|
393
|
+
i.setFromAxisAngle({
|
|
394
|
+
x: 0,
|
|
395
|
+
y: 1,
|
|
396
|
+
z: 0
|
|
397
|
+
}, t - e);
|
|
398
|
+
} else i.setFromUnitVectors(this.c, this.b);
|
|
399
|
+
if (t.scale) {
|
|
400
|
+
let [n, r] = this.o.scaleLimits;
|
|
401
|
+
a = Math.min(r / e.s0.x, Math.max(n / e.s0.x, s / e.dist0)), t.scale.copy(e.s0).multiplyScalar(a);
|
|
402
|
+
}
|
|
403
|
+
r.copy(e.rel0).multiplyScalar(a).applyQuaternion(i).add(this.c.lerpVectors(n.p, o.p, .5));
|
|
404
|
+
}
|
|
405
|
+
if (this.o.translate) {
|
|
406
|
+
let { x: n, y: i, z: a } = this.o.lock;
|
|
407
|
+
t.position.set(n ? e.start.x : r.x, i ? e.start.y : r.y, a ? e.start.z : r.z);
|
|
408
|
+
}
|
|
409
|
+
this.o.rotate !== "none" && t.orientation.copy(i).multiply(e.q0), t.apply?.();
|
|
410
|
+
}
|
|
411
|
+
restrict(e) {
|
|
412
|
+
if (this.o.rotate !== "follow") {
|
|
413
|
+
if (this.o.rotate === "none") e.identity();
|
|
414
|
+
else {
|
|
415
|
+
let t = Math.hypot(e.y, e.w);
|
|
416
|
+
t < 1e-9 ? e.identity() : e.set(0, e.y / t, 0, e.w / t);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
function y(e, t, n, r) {
|
|
422
|
+
let i = n.x - e.x, a = n.y - e.y, o = n.z - e.z, s = i * t.x + a * t.y + o * t.z, c = i * i + a * a + o * o - s * s;
|
|
423
|
+
return i * i + a * a + o * o <= r * r ? 0 : s < 0 || c > r * r ? null : s - Math.sqrt(r * r - c);
|
|
424
|
+
}
|
|
425
|
+
var b = class extends r {
|
|
426
|
+
constructor(n, r) {
|
|
427
|
+
super(), this.position = new t(), this.orientation = new e(), this.size = [0, 0], this.enabled = !0, this.hovered = -1, this.pressed = -1, this.poking = /* @__PURE__ */ new Map(), this.tip = new t(), this.inv = new e(), this.buttons = [...n.buttons ?? []], this.onSelect = n.onSelect, this.cfg = {
|
|
428
|
+
columns: Math.max(1, Math.floor(n.columns ?? r)),
|
|
429
|
+
button: n.buttonSize ?? .05,
|
|
430
|
+
spacing: n.spacing ?? .008,
|
|
431
|
+
padding: n.padding ?? .01
|
|
432
|
+
}, c("buttonSize", this.cfg.button), this.poke_ = n.poke === !1 ? null : {
|
|
433
|
+
hover: n.poke?.hover ?? .06,
|
|
434
|
+
touch: n.poke?.touch ?? .012,
|
|
435
|
+
through: n.poke?.through ?? .03
|
|
436
|
+
}, this.relayout();
|
|
437
|
+
}
|
|
438
|
+
relayout() {
|
|
439
|
+
let { columns: e, button: t, spacing: n, padding: r } = this.cfg, i = Math.max(1, this.buttons.length), a = Math.min(e, i), o = Math.ceil(i / a);
|
|
440
|
+
this.size = [a * t + (a - 1) * n + 2 * r, o * t + (o - 1) * n + 2 * r];
|
|
441
|
+
}
|
|
442
|
+
layout() {
|
|
443
|
+
this.relayout();
|
|
444
|
+
let { columns: e, button: t, spacing: n } = this.cfg, r = Math.min(e, Math.max(1, this.buttons.length)), [i, a] = this.size;
|
|
445
|
+
return this.buttons.map((e, o) => ({
|
|
446
|
+
id: e.id,
|
|
447
|
+
label: e.label,
|
|
448
|
+
enabled: e.enabled !== !1,
|
|
449
|
+
hovered: o === this.hovered,
|
|
450
|
+
pressed: o === this.pressed,
|
|
451
|
+
x: -i / 2 + this.cfg.padding + t / 2 + o % r * (t + n),
|
|
452
|
+
y: a / 2 - this.cfg.padding - t / 2 - Math.floor(o / r) * (t + n),
|
|
453
|
+
width: t,
|
|
454
|
+
height: t
|
|
455
|
+
}));
|
|
456
|
+
}
|
|
457
|
+
at(e, t) {
|
|
458
|
+
let [n, r] = this.size, i = (e - .5) * n, a = (.5 - t) * r, o = this.layout();
|
|
459
|
+
for (let e = 0; e < o.length; e++) {
|
|
460
|
+
let t = o[e];
|
|
461
|
+
if (Math.abs(i - t.x) <= t.width / 2 && Math.abs(a - t.y) <= t.height / 2) return e;
|
|
462
|
+
}
|
|
463
|
+
return -1;
|
|
464
|
+
}
|
|
465
|
+
onPointer(e) {
|
|
466
|
+
if (this.relayout(), e.type === "leave") {
|
|
467
|
+
this.hovered = this.pressed = -1;
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
let t = this.at(e.u, e.v), n = t >= 0 && this.buttons[t].enabled !== !1 ? t : -1;
|
|
471
|
+
if (this.hovered = n, e.type === "down" && (this.pressed = n), e.type === "up") {
|
|
472
|
+
let e = this.pressed;
|
|
473
|
+
this.pressed = -1, e >= 0 && e === n && this.select(e);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
select(e) {
|
|
477
|
+
this.onSelect?.(this.buttons[e].id);
|
|
478
|
+
}
|
|
479
|
+
pokeAll(e) {
|
|
480
|
+
let t = this.poke_;
|
|
481
|
+
if (!t || !this.enabled) return;
|
|
482
|
+
this.relayout(), this.inv.copy(this.orientation).invert();
|
|
483
|
+
let [n, r] = this.size;
|
|
484
|
+
for (let i of e) {
|
|
485
|
+
let e = this.poking.get(i);
|
|
486
|
+
e || this.poking.set(i, e = {
|
|
487
|
+
inside: !1,
|
|
488
|
+
touching: !1
|
|
489
|
+
});
|
|
490
|
+
let o = l(i, a, this.tip), s = 0, c = 0, u = Infinity, d = !1;
|
|
491
|
+
o && (this.tip.sub(this.position).applyQuaternion(this.inv), u = this.tip.z, s = this.tip.x / n + .5, c = .5 - this.tip.y / r, d = s >= 0 && s <= 1 && c >= 0 && c <= 1 && u <= t.hover && u >= -t.through);
|
|
492
|
+
let f = (e) => this.onPointer({
|
|
493
|
+
type: e,
|
|
494
|
+
u: s,
|
|
495
|
+
v: c,
|
|
496
|
+
distance: u,
|
|
497
|
+
controller: i
|
|
498
|
+
});
|
|
499
|
+
d && !e.inside ? f("enter") : d && f("move"), d && !e.touching && u <= t.touch ? (e.touching = !0, f("down")) : e.touching && (!d || u > t.touch + .01) && (e.touching = !1, d ? f("up") : this.pressed = -1), !d && e.inside && f("leave"), e.inside = d;
|
|
500
|
+
}
|
|
501
|
+
for (let t of this.poking.keys()) e.includes(t) || this.poking.delete(t);
|
|
502
|
+
}
|
|
503
|
+
}, x = [{
|
|
504
|
+
id: "remove",
|
|
505
|
+
label: "Remove"
|
|
506
|
+
}, {
|
|
507
|
+
id: "adjust",
|
|
508
|
+
label: "Adjust"
|
|
509
|
+
}], S = class e extends b {
|
|
510
|
+
static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
511
|
+
return new e(t, n);
|
|
512
|
+
}
|
|
513
|
+
constructor(e, n) {
|
|
514
|
+
super({
|
|
515
|
+
...n,
|
|
516
|
+
buttons: n.buttons ?? x
|
|
517
|
+
}, 99), this.visible = !1, this.p = new t(), this.a = n, c("AppBar showDistance", n.showDistance ?? .6), this.enabled = !1, this.stops.push(e.onFrame((t) => this.frame(e.controllers, t)));
|
|
518
|
+
}
|
|
519
|
+
frame(e, t) {
|
|
520
|
+
let n = this.a.target, r = (this.a.showDistance ?? .6) + (this.visible ? .1 : 0), i = this.a.alwaysVisible === !0;
|
|
521
|
+
for (let t of e) {
|
|
522
|
+
if (i) break;
|
|
523
|
+
let e = t.grip?.transform.position;
|
|
524
|
+
(e && n.position.distanceTo(e) <= r || l(t, a, this.p) && n.position.distanceTo(this.p) <= r) && (i = !0);
|
|
525
|
+
}
|
|
526
|
+
if (this.visible = i, this.enabled = i, !i) {
|
|
527
|
+
this.hovered = this.pressed = -1;
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
let o = (this.a.extent?.[1] ?? .3) * (n.scale?.y ?? 1) / 2;
|
|
531
|
+
this.p.set(0, -(o + (this.a.gap ?? .03) + this.size[1] / 2), 0);
|
|
532
|
+
let s = u(t)?.position;
|
|
533
|
+
this.a.billboard !== !1 && s ? this.orientation.setFromAxisAngle({
|
|
534
|
+
x: 0,
|
|
535
|
+
y: 1,
|
|
536
|
+
z: 0
|
|
537
|
+
}, Math.atan2(s.x - n.position.x, s.z - n.position.z)) : this.orientation.copy(n.orientation), this.position.copy(this.p).add(n.position), this.pokeAll(e);
|
|
538
|
+
}
|
|
539
|
+
}, C = class e extends b {
|
|
540
|
+
static attach(t, n = {}) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
541
|
+
return new e(t, n);
|
|
542
|
+
}
|
|
543
|
+
constructor(e, t) {
|
|
544
|
+
super(t, 3), this.custom = [...t.buttons ?? []], this.pin = t.pinButton ?? !0, this.pinnedNow = t.pinned ?? !1, this.sync(), this.following = f.attach(e, {
|
|
545
|
+
...t.follow,
|
|
546
|
+
target: this
|
|
547
|
+
}), this.following.enabled = !this.pinnedNow, this.stops.push(() => this.following.dispose(), e.onFrame(() => this.pokeAll(e.controllers)));
|
|
548
|
+
}
|
|
549
|
+
get pinned() {
|
|
550
|
+
return this.pinnedNow;
|
|
551
|
+
}
|
|
552
|
+
set pinned(e) {
|
|
553
|
+
this.pinnedNow = e, this.following.enabled = !e, this.sync();
|
|
554
|
+
}
|
|
555
|
+
setButtons(e) {
|
|
556
|
+
this.custom = [...e], this.sync();
|
|
557
|
+
}
|
|
558
|
+
recenter() {
|
|
559
|
+
this.following.snap();
|
|
560
|
+
}
|
|
561
|
+
select(e) {
|
|
562
|
+
this.buttons[e].id === "pin" ? this.pinned = !this.pinnedNow : super.select(e);
|
|
563
|
+
}
|
|
564
|
+
sync() {
|
|
565
|
+
this.buttons = this.pin ? [...this.custom, {
|
|
566
|
+
id: "pin",
|
|
567
|
+
label: this.pinnedNow ? "Unpin" : "Pin"
|
|
568
|
+
}] : [...this.custom];
|
|
569
|
+
}
|
|
570
|
+
}, w = class extends r {
|
|
571
|
+
constructor(n = {}) {
|
|
572
|
+
super(), this.enabled = !0, this.contentOffset = [0, 0], this.contentZoom = 1, this.dragging = null, this.d = new t(), this.owner = null, this.grab = {
|
|
573
|
+
u: 0,
|
|
574
|
+
v: 0,
|
|
575
|
+
w: 0,
|
|
576
|
+
h: 0,
|
|
577
|
+
x: 0,
|
|
578
|
+
y: 0,
|
|
579
|
+
moved: 0
|
|
580
|
+
}, this.o = n;
|
|
581
|
+
let r = n.position ?? [
|
|
582
|
+
0,
|
|
583
|
+
1.4,
|
|
584
|
+
-.8
|
|
585
|
+
], i = n.orientation ?? [
|
|
586
|
+
0,
|
|
587
|
+
0,
|
|
588
|
+
0,
|
|
589
|
+
1
|
|
590
|
+
];
|
|
591
|
+
this.position = new t(r[0], r[1], r[2]), this.orientation = new e(i[0], i[1], i[2], i[3]), this.size = n.size ?? [.4, .3], this.title = n.title ?? "";
|
|
592
|
+
let [a, o] = n.minSize ?? [.15, .1], [s, c] = n.maxSize ?? [1.6, 1.2];
|
|
593
|
+
if (!(a > 0 && o > 0 && s >= a && c >= o)) throw RangeError("Slate minSize must be positive and not above maxSize; pass { minSize: [0.15, 0.1], maxSize: [1.6, 1.2] }");
|
|
594
|
+
}
|
|
595
|
+
regionAt(e, t) {
|
|
596
|
+
let [n, r] = this.size, i = this.o.titleHeight ?? .04, a = this.o.handle ?? .03;
|
|
597
|
+
if (e < 0 || e > 1 || t < 0 || t > 1) return null;
|
|
598
|
+
let o = e * n, s = t * r;
|
|
599
|
+
return s <= i ? this.o.onClose && o >= n - i ? "close" : "title" : a > 0 && o >= n - a && s >= r - a ? "handle" : "content";
|
|
600
|
+
}
|
|
601
|
+
zoomBy(e, t = .25, n = 4) {
|
|
602
|
+
this.contentZoom = Math.min(n, Math.max(t, this.contentZoom * e));
|
|
603
|
+
}
|
|
604
|
+
onPointer(e) {
|
|
605
|
+
if (this.owner && e.controller !== this.owner) return;
|
|
606
|
+
let [t, n] = this.size, r = this.grab;
|
|
607
|
+
if (e.type === "down") {
|
|
608
|
+
let r = this.regionAt(e.u, e.v);
|
|
609
|
+
if (!r) return;
|
|
610
|
+
this.owner = e.controller, this.dragging = r, this.grab = {
|
|
611
|
+
u: e.u,
|
|
612
|
+
v: e.v,
|
|
613
|
+
w: t,
|
|
614
|
+
h: n,
|
|
615
|
+
x: this.contentOffset[0],
|
|
616
|
+
y: this.contentOffset[1],
|
|
617
|
+
moved: 0
|
|
618
|
+
}, r === "content" && this.o.panContent === !1 && this.content("down", e);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (!this.dragging) return;
|
|
622
|
+
let i = (e.u - r.u) * t, a = -(e.v - r.v) * n;
|
|
623
|
+
if (e.type === "move") r.moved = Math.max(r.moved, Math.hypot(i, a)), this.dragging === "title" ? (this.position.add(this.d.set(i, a, 0).applyQuaternion(this.orientation)), this.o.onMove?.(this)) : this.dragging === "handle" ? this.resize(e.u * t + (r.w - r.u * r.w), e.v * n + (r.h - r.v * r.h)) : this.dragging === "content" && (this.o.panContent === !1 ? this.content("move", e) : (this.contentOffset[0] = r.x + i, this.contentOffset[1] = r.y + a));
|
|
624
|
+
else if (e.type === "up" || e.type === "leave") {
|
|
625
|
+
let t = this.dragging;
|
|
626
|
+
this.dragging = null, this.owner = null, t === "close" && e.type === "up" && this.regionAt(e.u, e.v) === "close" && this.o.onClose?.(this), t === "content" && e.type === "up" && (this.o.panContent === !1 ? this.content("up", e) : r.moved < .01 && this.content("tap", e));
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
content(e, t) {
|
|
630
|
+
let [n, r] = this.size, i = this.o.titleHeight ?? .04;
|
|
631
|
+
this.o.onContent?.({
|
|
632
|
+
type: e,
|
|
633
|
+
x: (t.u * n - this.contentOffset[0]) / this.contentZoom,
|
|
634
|
+
y: (t.v * r - i + this.contentOffset[1]) / this.contentZoom
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
resize(e, t) {
|
|
638
|
+
let [n, r] = this.o.minSize ?? [.15, .1], [i, a] = this.o.maxSize ?? [1.6, 1.2], o = Math.min(i, Math.max(n, e)), s = Math.min(a, Math.max(r, t));
|
|
639
|
+
this.position.add(this.d.set((o - this.size[0]) / 2, -(s - this.size[1]) / 2, 0).applyQuaternion(this.orientation)), this.size = [o, s], this.o.onResize?.(this);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
//#endregion
|
|
643
|
+
export { S as AppBar, b as ButtonPanel, f as FollowInView, d as HandConstraint, v as Manipulator, r as NearBehavior, C as NearMenu, w as Slate, _ as SurfaceMagnetism, n as nearTarget, g as snapToSurface, p as surfaceFromHit };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { XREyeTarget } from './eye-target.js';
|
|
2
|
+
import type { XRFrameState, XRNativeSession } from './types.js';
|
|
3
|
+
/** What {@link AROcclusion.create} needs of an `XR`: its session, frames and eyes. */
|
|
4
|
+
export interface AROcclusionHost {
|
|
5
|
+
readonly session: XRNativeSession | null;
|
|
6
|
+
onFrame(callback: (state: XRFrameState) => void): () => void;
|
|
7
|
+
onEye(callback: (target: XREyeTarget) => void): () => void;
|
|
8
|
+
}
|
|
9
|
+
/** Options for {@link AROcclusion.create}. */
|
|
10
|
+
export interface AROcclusionOptions {
|
|
11
|
+
/** Metres over which a surface fades from shown to hidden around equal depth; 0 is a hard edge. Default 0.05. */
|
|
12
|
+
feather?: number;
|
|
13
|
+
/** Start on. Default true. */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
type Real = 'r32float' | 'r16uint';
|
|
17
|
+
/** WGSL of the occlusion pass for one real-depth format and scene sample count. */
|
|
18
|
+
export declare function occlusionShader(real: Real, samples: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Hides the scene where the real world is in front of it, in an AR session started with the 'depth-sensing' feature,
|
|
21
|
+
* from CPU-optimized depth (uploaded each frame) or GPU-optimized depth (read where the browser leaves it). Works on
|
|
22
|
+
* both XR routes and on the WebGL2 layer's CPU depth.
|
|
23
|
+
* @throws MargoError 'state' without a session, 'unsupported' without depth sensing or with GPU 'luminance-alpha' depth.
|
|
24
|
+
*/
|
|
25
|
+
export declare class AROcclusion {
|
|
26
|
+
private readonly session;
|
|
27
|
+
private feather_;
|
|
28
|
+
/** False skips the pass; the scene draws over the real world as before. */
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
private frame;
|
|
31
|
+
private readonly stops;
|
|
32
|
+
private readonly eyes;
|
|
33
|
+
private readonly pipelines;
|
|
34
|
+
private device?;
|
|
35
|
+
private disposed;
|
|
36
|
+
private constructor();
|
|
37
|
+
static create(xr: AROcclusionHost, options?: AROcclusionOptions): AROcclusion;
|
|
38
|
+
/** Metres over which a surface fades from shown to hidden around equal depth; 0 is a hard edge. */
|
|
39
|
+
get feather(): number;
|
|
40
|
+
set feather(value: number);
|
|
41
|
+
/** This frame's depth for `view`: the GPU texture where the session keeps depth on the GPU, else the CPU data. */
|
|
42
|
+
private information;
|
|
43
|
+
private draw;
|
|
44
|
+
private reset;
|
|
45
|
+
/** Stops the pass and frees its buffers and textures. */
|
|
46
|
+
dispose(): void;
|
|
47
|
+
[Symbol.dispose](): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|