@vincentt-xr/sdk 2.0.0-alpha.2 → 2.0.0-alpha.4
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/GROUNDING.md +67 -9
- package/dist/{DebuggerUI-Cq28c18s.js → DebuggerUI-DhKTXTY2.js} +1 -1
- package/dist/{DebuggerUI-B45_Gb9d.cjs → DebuggerUI-bnGHSSOb.cjs} +1 -1
- package/dist/{FaceMeshRenderer-6t8OsQhK.js → FaceMeshRenderer-B2i2NW71.js} +3 -3
- package/dist/{FaceMeshRenderer-lQLhYIW-.cjs → FaceMeshRenderer-BSOq1OnG.cjs} +1 -1
- package/dist/{FaceRetouch-CDrL0pXg.js → FaceRetouch-Bg-OBU4n.js} +30 -30
- package/dist/{FaceRetouch-DtNl8-4e.cjs → FaceRetouch-TZeBGIqW.cjs} +1 -1
- package/dist/components/MeshRenderer/index.d.ts +1 -0
- package/dist/components/ScreenImage/source.d.ts +3 -0
- package/dist/contexts-B2_NsTnk.js +660 -0
- package/dist/contexts-BgWfyxre.cjs +1 -0
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui.cjs +3 -3
- package/dist/debug-ui.js +1246 -1205
- package/dist/entries/low-level.d.ts +5 -0
- package/dist/face-effects.cjs +1 -1
- package/dist/face-effects.js +4 -4
- package/dist/{getFaceInfo-hUKMLFcr.js → getFaceInfo-4DhcPZDJ.js} +1 -1
- package/dist/{getFaceInfo-CyPAKh3h.cjs → getFaceInfo-QOQ_dc-W.cjs} +1 -1
- package/dist/hooks/selectors.d.ts +2 -4
- package/dist/hooks/useXRModel.d.ts +5 -0
- package/dist/hooks/useXRSession/reason.d.ts +19 -0
- package/dist/hooks/useXRSession/store.d.ts +12 -4
- package/dist/index-72Wb15Ca.js +214 -0
- package/dist/{index-JygePOwo.js → index-BMeBJ0dV.js} +322 -299
- package/dist/index-C9yQVzAh.cjs +1 -0
- package/dist/index-CNGzE49z.cjs +17 -0
- package/dist/{index-Di70KWuY.js → index-Cj3fGDtZ.js} +844 -825
- package/dist/{index-BgQAX8rs.js → index-D1kj6uc-.js} +123 -120
- package/dist/{index-D4bLzBr6.cjs → index-Da7uycur.cjs} +1 -1
- package/dist/{index-DSpzjuqd.cjs → index-WPPnlFO1.cjs} +1 -1
- package/dist/index-ZaDEzDtR.cjs +1 -0
- package/dist/{index-UC0Ux38E.js → index-g250Tqme.js} +1 -1
- package/dist/{internal-DuMPpcbp.js → internal-34pb7djs.js} +3 -3
- package/dist/{internal-i2JkM85N.cjs → internal-Dtvo4WYo.cjs} +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +1 -1
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +399 -490
- package/dist/main.cjs +1 -1
- package/dist/main.js +28 -28
- package/dist/{renderGroups-C9QJrAXu.js → renderGroups-CPWUX6z9.js} +1 -1
- package/dist/{renderGroups-Dvm1J4lW.cjs → renderGroups-jSUOY1Oq.cjs} +1 -1
- package/dist/{renderPasses-CjgG_6kQ.js → renderPasses-CLlYRdMk.js} +5 -5
- package/dist/{renderPasses-CT5iBwtg.cjs → renderPasses-KUJUSevp.cjs} +2 -2
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/{selectors-Dw3C-gSk.js → selectors-DLxL8Q66.js} +4 -4
- package/dist/{selectors-2QvO5RYY.cjs → selectors-S8g25ke9.cjs} +1 -1
- package/dist/{session-C1StwN0f.js → session-CbtvwiaD.js} +1 -1
- package/dist/{session-BChR4TgK.cjs → session-DP8AF7Rg.cjs} +1 -1
- package/dist/texture/animatedTexture.d.ts +2 -0
- package/dist/texture/gifReader.d.ts +17 -0
- package/dist/texture/gifTextureSource.d.ts +16 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +9 -9
- package/dist/{useFaceInfo-C-WfMlYp.cjs → useFaceInfo-BvZeUBsL.cjs} +1 -1
- package/dist/{useFaceInfo-CwsHZedC.js → useFaceInfo-C06EyScd.js} +3 -3
- package/dist/{useFaceResults-CkFc1egZ.js → useFaceResults-C1Ppc8rS.js} +1 -1
- package/dist/{useFaceResults-VcFdOUFV.cjs → useFaceResults-CCNiH7VZ.cjs} +1 -1
- package/docs/api/screen-image.mdx +27 -3
- package/docs/api/texture-sources.mdx +25 -6
- package/docs/texture-api-consumer.md +26 -0
- package/package.json +4 -3
- package/dist/contexts-BKvTIayr.cjs +0 -1
- package/dist/contexts-Bk5zz_VR.js +0 -214
- package/dist/index-82aENaRq.cjs +0 -1
- package/dist/index-CEc1CAmB.cjs +0 -1
- package/dist/index-CTHeBQOs.js +0 -178
- package/dist/index-DzEzkBIH.cjs +0 -17
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var Ae = Object.defineProperty;
|
|
2
|
-
var be = (
|
|
3
|
-
var h = (
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useRef as oe, useMemo as $, useEffect as Ee, useContext as ce, useCallback as
|
|
2
|
+
var be = (n, s, e) => s in n ? Ae(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
|
|
3
|
+
var h = (n, s, e) => be(n, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
import { jsx as ae } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as oe, useMemo as $, useEffect as Ee, useContext as ce, useCallback as ie, createElement as Ie, createContext as he } from "react";
|
|
6
6
|
import { FilesetResolver as V, PoseLandmarker as De, FaceLandmarker as _e, GestureRecognizer as Pe, HandLandmarker as Oe, ImageSegmenter as Ue, DrawingUtils as ze } from "@mediapipe/tasks-vision";
|
|
7
7
|
import * as E from "three";
|
|
8
8
|
import { RGBAFormat as de, LinearFilter as q, CanvasTexture as ue, SRGBColorSpace as Le } from "three";
|
|
9
|
-
var F = /* @__PURE__ */ ((
|
|
9
|
+
var F = /* @__PURE__ */ ((n) => (n.WEBCAM = "webcam", n.STREAM = "stream", n.CANVAS = "canvas", n))(F || {}), z = /* @__PURE__ */ ((n) => (n.HAND_TRACKER = "vincentt.xr.hand-tracker", n.GESTURE_TRACKER = "vincentt.xr.gesture-tracker", n.FACE_TRACKER = "vincentt.xr.face-tracker", n.BODY_TRACKER = "vincentt.xr.body-tracker", n.BACKGROUND_SEGMENTATION = "vincentt.xr.background-segmentation", n))(z || {});
|
|
10
10
|
class b extends Error {
|
|
11
11
|
constructor(s) {
|
|
12
12
|
super(s), this.name = "VincenttXRError";
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const Be = (
|
|
15
|
+
const Be = (n, s) => s, I = {
|
|
16
16
|
apiBaseUrl: Be(void 0, "https://api.vincentt.studio"),
|
|
17
17
|
// Pinned to the CDN, NOT build-env-driven: a stale VITE_ASSET_STORAGE_ENDPOINT
|
|
18
18
|
// baked a now-deleted CloudFront domain into every published bundle, breaking
|
|
@@ -41,11 +41,11 @@ class Ve {
|
|
|
41
41
|
e && console.error(t, ...s);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const O = (
|
|
45
|
-
j.set((
|
|
44
|
+
const O = (n) => n * 2 - 1, j = new E.Vector3(), Y = new E.Vector3(), H = ({ x: n, y: s, z: e }, t, i) => {
|
|
45
|
+
j.set((n - 0.5) * 2, (0.5 - s) * 2, -e), j.unproject(t), Y.copy(j).sub(t.position).normalize();
|
|
46
46
|
const r = -t.position.z / Y.z;
|
|
47
|
-
return
|
|
48
|
-
},
|
|
47
|
+
return i.copy(t.position).addScaledVector(Y, r), i;
|
|
48
|
+
}, _t = (n, s) => H(n, s, new E.Vector3()), Ke = (n, s, e = 0.2) => e * s + (1 - e) * n;
|
|
49
49
|
class Z {
|
|
50
50
|
constructor(s) {
|
|
51
51
|
h(this, "canvas");
|
|
@@ -57,9 +57,9 @@ class Z {
|
|
|
57
57
|
* 2D context can't be obtained). The returned canvas is reused across calls.
|
|
58
58
|
*/
|
|
59
59
|
draw(s) {
|
|
60
|
-
const e = s.width, t = s.height,
|
|
61
|
-
if (
|
|
62
|
-
const r = Math.max(1, Math.round(e *
|
|
60
|
+
const e = s.width, t = s.height, i = Math.min(1, this.maxDimension / Math.max(e, t));
|
|
61
|
+
if (i >= 1) return s;
|
|
62
|
+
const r = Math.max(1, Math.round(e * i)), o = Math.max(1, Math.round(t * i));
|
|
63
63
|
(!this.canvas || this.canvas.width !== r || this.canvas.height !== o) && (this.canvas = new OffscreenCanvas(r, o));
|
|
64
64
|
const u = this.canvas.getContext("2d");
|
|
65
65
|
return u ? (u.setTransform(1, 0, 0, 1, 0, 0), u.clearRect(0, 0, r, o), u.drawImage(s, 0, 0, r, o), this.canvas) : s;
|
|
@@ -78,47 +78,47 @@ const Ne = {
|
|
|
78
78
|
"/assets/sdk/face/v1/canonical_face_model.obj": "sha384-xP8YM/72TXKvbMptXB9a8JUlUf3MZQ8uLurExrsZc05v6/P5RrsaNGMUYS/BZx8A",
|
|
79
79
|
"/opencv/facial_expression_recognition/resolve/main/facial_expression_recognition_mobilefacenet_2022july_int8.onnx": "sha384-g8mtFubiIc/yhqi591RsxD76AJLw2CfYgKhKbVkIiFlwBmIyG7ZAIVyGPXafrDGB"
|
|
80
80
|
};
|
|
81
|
-
async function He(
|
|
82
|
-
const s = await fetch(
|
|
81
|
+
async function He(n) {
|
|
82
|
+
const s = await fetch(n);
|
|
83
83
|
if (!s.ok)
|
|
84
|
-
throw new Error(`fetchAndVerify: ${s.status} ${
|
|
85
|
-
const e = await s.arrayBuffer(), t = Ge(
|
|
84
|
+
throw new Error(`fetchAndVerify: ${s.status} ${n}`);
|
|
85
|
+
const e = await s.arrayBuffer(), t = Ge(n);
|
|
86
86
|
if (!t) {
|
|
87
|
-
if (qe(
|
|
88
|
-
throw new Error(`[xr-sdk integrity] no SRI hash for SDK asset ${
|
|
89
|
-
return console.warn(`[xr-sdk integrity] no SRI hash for ${
|
|
87
|
+
if (qe(n))
|
|
88
|
+
throw new Error(`[xr-sdk integrity] no SRI hash for SDK asset ${n}`);
|
|
89
|
+
return console.warn(`[xr-sdk integrity] no SRI hash for ${n} — passing through`), e;
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
91
|
+
const i = await We(e);
|
|
92
|
+
if (i !== t)
|
|
93
93
|
throw new Error(
|
|
94
|
-
`[xr-sdk integrity] SRI mismatch for ${
|
|
94
|
+
`[xr-sdk integrity] SRI mismatch for ${n}: expected ${t}, got ${i}`
|
|
95
95
|
);
|
|
96
96
|
return e;
|
|
97
97
|
}
|
|
98
|
-
function qe(
|
|
98
|
+
function qe(n) {
|
|
99
99
|
try {
|
|
100
|
-
return new URL(
|
|
100
|
+
return new URL(n).origin === new URL(I.assetStorageEndpoint).origin;
|
|
101
101
|
} catch {
|
|
102
102
|
return !1;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
async function K(
|
|
106
|
-
const s = await He(
|
|
105
|
+
async function K(n) {
|
|
106
|
+
const s = await He(n);
|
|
107
107
|
return new Uint8Array(s);
|
|
108
108
|
}
|
|
109
|
-
function Ge(
|
|
109
|
+
function Ge(n) {
|
|
110
110
|
try {
|
|
111
|
-
const s = new URL(
|
|
111
|
+
const s = new URL(n);
|
|
112
112
|
return Ne[s.pathname];
|
|
113
113
|
} catch {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
async function We(
|
|
118
|
-
const s = await crypto.subtle.digest("SHA-384",
|
|
117
|
+
async function We(n) {
|
|
118
|
+
const s = await crypto.subtle.digest("SHA-384", n), e = new Uint8Array(s);
|
|
119
119
|
let t = "";
|
|
120
|
-
for (let
|
|
121
|
-
t += String.fromCharCode(e[
|
|
120
|
+
for (let i = 0; i < e.byteLength; i++)
|
|
121
|
+
t += String.fromCharCode(e[i]);
|
|
122
122
|
return `sha384-${btoa(t)}`;
|
|
123
123
|
}
|
|
124
124
|
class N {
|
|
@@ -196,9 +196,9 @@ class je extends N {
|
|
|
196
196
|
async getBodyData() {
|
|
197
197
|
if (!this.landmarker || !this.sourceCanvas)
|
|
198
198
|
return;
|
|
199
|
-
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(),
|
|
199
|
+
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(), i = this.landmarker.detectForVideo(e, t), r = performance.now();
|
|
200
200
|
this.processingTime = r - t;
|
|
201
|
-
const o =
|
|
201
|
+
const o = i.landmarks, u = [];
|
|
202
202
|
if (o)
|
|
203
203
|
return o.forEach((m, d) => {
|
|
204
204
|
u[d] || (u[d] = []), m.forEach((S) => {
|
|
@@ -238,12 +238,12 @@ class je extends N {
|
|
|
238
238
|
async initialize(e) {
|
|
239
239
|
const t = await V.forVisionTasks(
|
|
240
240
|
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
241
|
-
),
|
|
241
|
+
), i = await K(
|
|
242
242
|
new URL("/assets/xr/models/body_tracking.task", I.assetStorageEndpoint).toString()
|
|
243
243
|
);
|
|
244
244
|
this.landmarker = await De.createFromOptions(t, {
|
|
245
245
|
baseOptions: {
|
|
246
|
-
modelAssetBuffer:
|
|
246
|
+
modelAssetBuffer: i,
|
|
247
247
|
delegate: "GPU"
|
|
248
248
|
},
|
|
249
249
|
runningMode: "VIDEO",
|
|
@@ -265,7 +265,7 @@ class je extends N {
|
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
const Ye = 0.11, Qe = 4e-3, $e = (
|
|
268
|
+
const Ye = 0.11, Qe = 4e-3, $e = (n, s) => s.set(n.x, -n.y, n.z);
|
|
269
269
|
class Ze extends N {
|
|
270
270
|
constructor() {
|
|
271
271
|
super();
|
|
@@ -303,7 +303,7 @@ class Ze extends N {
|
|
|
303
303
|
return t ? (this.landmarkScratch.x = 1 - e.x, this.landmarkScratch.y = e.y, this.landmarkScratch.z = e.z, this.landmarkScratch.visibility = e.visibility, this.landmarkScratch) : e;
|
|
304
304
|
}
|
|
305
305
|
extractAndUpdateFaceData(e) {
|
|
306
|
-
var
|
|
306
|
+
var i;
|
|
307
307
|
if (!e.faceLandmarks.length) {
|
|
308
308
|
this.faces = [];
|
|
309
309
|
return;
|
|
@@ -321,7 +321,7 @@ class Ze extends N {
|
|
|
321
321
|
for (let r = 0; r < t; r += 1) {
|
|
322
322
|
if (!this.cameras[r])
|
|
323
323
|
continue;
|
|
324
|
-
const o = this.faces[r], u = (
|
|
324
|
+
const o = this.faces[r], u = (i = this.getSource) == null ? void 0 : i.call(this), m = !(u === "webcam" || !u), d = e.faceLandmarks[r], S = e.facialTransformationMatrixes[r];
|
|
325
325
|
this.rotMatrixScratch.fromArray(S.data), this.rotQuatScratch.setFromRotationMatrix(this.rotMatrixScratch), this.rotQuatScratch.set(
|
|
326
326
|
-this.rotQuatScratch.x,
|
|
327
327
|
this.rotQuatScratch.y,
|
|
@@ -340,11 +340,11 @@ class Ze extends N {
|
|
|
340
340
|
this.cameras[r],
|
|
341
341
|
this.rightCheekScratch[r]
|
|
342
342
|
);
|
|
343
|
-
const M = this.leftCheekScratch[r].distanceTo(this.rightCheekScratch[r]) * Ye, x = Math.abs(E.MathUtils.radToDeg(this.rotEulerScratch.y)),
|
|
343
|
+
const M = this.leftCheekScratch[r].distanceTo(this.rightCheekScratch[r]) * Ye, x = Math.abs(E.MathUtils.radToDeg(this.rotEulerScratch.y)), l = M + x * Qe, f = o.transform.scale.x, v = Ke(
|
|
344
344
|
isNaN(f) ? 0 : f,
|
|
345
|
-
|
|
345
|
+
l
|
|
346
346
|
);
|
|
347
|
-
o.transform.scale.set(
|
|
347
|
+
o.transform.scale.set(v, v, v);
|
|
348
348
|
const p = o.gestures, k = e.faceBlendshapes[r].categories;
|
|
349
349
|
for (const C of k)
|
|
350
350
|
p[C.categoryName] = C.score;
|
|
@@ -357,7 +357,7 @@ class Ze extends N {
|
|
|
357
357
|
this.rafId = requestAnimationFrame(this.processFaceTracking.bind(this));
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
|
-
const e = Je(this.numFaces), t = this.sourceCanvas.width,
|
|
360
|
+
const e = Je(this.numFaces), t = this.sourceCanvas.width, i = this.sourceCanvas.height, r = Math.min(1, e / Math.max(t, i)), o = Math.max(1, Math.round(t * r)), u = Math.max(1, Math.round(i * r));
|
|
361
361
|
(!this.analysisCanvas || this.analysisCanvas.width !== o || this.analysisCanvas.height !== u) && (this.analysisCanvas = new OffscreenCanvas(o, u));
|
|
362
362
|
const m = this.analysisCanvas.getContext("2d");
|
|
363
363
|
if (!m) {
|
|
@@ -388,11 +388,11 @@ class Ze extends N {
|
|
|
388
388
|
return this.detectionResults;
|
|
389
389
|
}
|
|
390
390
|
getRawFaceTrackingData(e = 0) {
|
|
391
|
-
var t,
|
|
391
|
+
var t, i, r, o;
|
|
392
392
|
if (this.detectionResults)
|
|
393
393
|
return {
|
|
394
394
|
landmarks: (t = this.detectionResults.faceLandmarks) == null ? void 0 : t[e],
|
|
395
|
-
blendshapes: (r = (
|
|
395
|
+
blendshapes: (r = (i = this.detectionResults.faceBlendshapes) == null ? void 0 : i[e]) == null ? void 0 : r.categories,
|
|
396
396
|
transformationMatrix: (o = this.detectionResults.facialTransformationMatrixes) == null ? void 0 : o[e]
|
|
397
397
|
};
|
|
398
398
|
}
|
|
@@ -400,11 +400,11 @@ class Ze extends N {
|
|
|
400
400
|
this.numFaces = (e == null ? void 0 : e.numFaces) || 1;
|
|
401
401
|
const t = await V.forVisionTasks(
|
|
402
402
|
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
403
|
-
),
|
|
403
|
+
), i = await K(
|
|
404
404
|
new URL("/assets/xr/models/face_tracking.task", I.assetStorageEndpoint).toString()
|
|
405
405
|
), r = await _e.createFromOptions(t, {
|
|
406
406
|
baseOptions: {
|
|
407
|
-
modelAssetBuffer:
|
|
407
|
+
modelAssetBuffer: i,
|
|
408
408
|
delegate: "GPU"
|
|
409
409
|
},
|
|
410
410
|
// Keep detection permissive for calibration workflows with dark webcam input.
|
|
@@ -422,8 +422,8 @@ class Ze extends N {
|
|
|
422
422
|
}
|
|
423
423
|
this.landmarker = r;
|
|
424
424
|
}
|
|
425
|
-
async run({ sourceCanvas: e, getSource: t, targetFps:
|
|
426
|
-
this.sourceCanvas = e, this.getSource = t, this.setTargetFps(
|
|
425
|
+
async run({ sourceCanvas: e, getSource: t, targetFps: i }) {
|
|
426
|
+
this.sourceCanvas = e, this.getSource = t, this.setTargetFps(i), this.analysisCanvas = void 0, this.rafId === null && this.processFaceTracking();
|
|
427
427
|
}
|
|
428
428
|
getModelNode() {
|
|
429
429
|
const e = this;
|
|
@@ -434,8 +434,8 @@ class Ze extends N {
|
|
|
434
434
|
getDetectionResults: this.getDetectionResults.bind(this),
|
|
435
435
|
getFace: this.getFace.bind(this),
|
|
436
436
|
getRawFaceTrackingData: this.getRawFaceTrackingData.bind(this),
|
|
437
|
-
setCamera: (
|
|
438
|
-
this.cameras[r] =
|
|
437
|
+
setCamera: (i, r = 0) => {
|
|
438
|
+
this.cameras[r] = i;
|
|
439
439
|
}
|
|
440
440
|
};
|
|
441
441
|
}
|
|
@@ -446,8 +446,8 @@ class Ze extends N {
|
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
const Je = (
|
|
450
|
-
var D = /* @__PURE__ */ ((
|
|
449
|
+
const Je = (n) => n > 1 ? 1024 : 512;
|
|
450
|
+
var D = /* @__PURE__ */ ((n) => (n.ClosedFist = "closed_fist", n.OpenPalm = "open_palm", n.PointingUp = "pointing_up", n.ThumbDown = "thumb_down", n.ThumbUp = "thumb_up", n.Victory = "victory", n.ILoveYou = "i_love_you", n.None = "none", n))(D || {});
|
|
451
451
|
const et = 512, tt = {
|
|
452
452
|
Closed_Fist: D.ClosedFist,
|
|
453
453
|
Open_Palm: D.OpenPalm,
|
|
@@ -458,7 +458,7 @@ const et = 512, tt = {
|
|
|
458
458
|
ILoveYou: D.ILoveYou,
|
|
459
459
|
None: D.None
|
|
460
460
|
}, st = 15;
|
|
461
|
-
class
|
|
461
|
+
class nt extends N {
|
|
462
462
|
constructor() {
|
|
463
463
|
super();
|
|
464
464
|
h(this, "landmarker", null);
|
|
@@ -471,11 +471,11 @@ class it extends N {
|
|
|
471
471
|
async getGestureData() {
|
|
472
472
|
if (!this.landmarker || !this.sourceCanvas)
|
|
473
473
|
return;
|
|
474
|
-
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(),
|
|
474
|
+
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(), i = this.landmarker.recognizeForVideo(e, t), r = performance.now();
|
|
475
475
|
this.processingTime = r - t;
|
|
476
|
-
const o =
|
|
476
|
+
const o = i.landmarks[0], u = [];
|
|
477
477
|
if (o) {
|
|
478
|
-
const m =
|
|
478
|
+
const m = i.gestures[0][0].categoryName;
|
|
479
479
|
return o.forEach((d) => {
|
|
480
480
|
u.push({
|
|
481
481
|
x: O(d.x),
|
|
@@ -516,7 +516,7 @@ class it extends N {
|
|
|
516
516
|
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
517
517
|
), t = await K(
|
|
518
518
|
new URL("/assets/xr/models/gesture_tracking.task", I.assetStorageEndpoint).toString()
|
|
519
|
-
),
|
|
519
|
+
), i = await Pe.createFromOptions(e, {
|
|
520
520
|
baseOptions: {
|
|
521
521
|
modelAssetBuffer: t,
|
|
522
522
|
delegate: "GPU"
|
|
@@ -524,7 +524,7 @@ class it extends N {
|
|
|
524
524
|
runningMode: "VIDEO",
|
|
525
525
|
numHands: 1
|
|
526
526
|
});
|
|
527
|
-
this.landmarker =
|
|
527
|
+
this.landmarker = i;
|
|
528
528
|
}
|
|
529
529
|
async run({ sourceCanvas: e, targetFps: t }) {
|
|
530
530
|
this.sourceCanvas = e, this.setTargetFps(t ?? st), this.rafId === null && await this.processGestureTracking();
|
|
@@ -547,8 +547,8 @@ class it extends N {
|
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
|
-
const
|
|
551
|
-
class
|
|
550
|
+
const at = 512;
|
|
551
|
+
class it extends N {
|
|
552
552
|
constructor() {
|
|
553
553
|
super();
|
|
554
554
|
h(this, "landmarker", null);
|
|
@@ -558,24 +558,24 @@ class at extends N {
|
|
|
558
558
|
h(this, "gesture");
|
|
559
559
|
h(this, "handedness");
|
|
560
560
|
h(this, "sourceCanvas");
|
|
561
|
-
h(this, "downscaler", new Z(
|
|
561
|
+
h(this, "downscaler", new Z(at));
|
|
562
562
|
}
|
|
563
563
|
async getHandData() {
|
|
564
564
|
if (!this.landmarker || !this.sourceCanvas)
|
|
565
565
|
return;
|
|
566
|
-
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(),
|
|
566
|
+
const e = this.downscaler.draw(this.sourceCanvas), t = performance.now(), i = this.landmarker.detectForVideo(e, t), r = performance.now();
|
|
567
567
|
this.processingTime = r - t;
|
|
568
|
-
const o = [], u =
|
|
569
|
-
if (
|
|
570
|
-
var f,
|
|
568
|
+
const o = [], u = i.handedness ?? i.handednesses ?? [];
|
|
569
|
+
if (i.landmarks.forEach((d, S) => {
|
|
570
|
+
var f, v, p;
|
|
571
571
|
if (!d || d.length === 0)
|
|
572
572
|
return;
|
|
573
573
|
const R = d.map((k) => ({
|
|
574
574
|
x: O(k.x),
|
|
575
575
|
y: O(1 - k.y),
|
|
576
576
|
z: -k.z
|
|
577
|
-
})), M = (p = (
|
|
578
|
-
o.push({ coordinates: R, gesture:
|
|
577
|
+
})), M = (p = (v = (f = u[S]) == null ? void 0 : f[0]) == null ? void 0 : v.categoryName) == null ? void 0 : p.toLowerCase(), x = M === "left" || M === "right" ? M : void 0, l = d[0].z < 0 ? "closed_fist" : "open_palm";
|
|
578
|
+
o.push({ coordinates: R, gesture: l, handedness: x });
|
|
579
579
|
}), !o.length)
|
|
580
580
|
return {
|
|
581
581
|
hands: void 0,
|
|
@@ -618,7 +618,7 @@ class at extends N {
|
|
|
618
618
|
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
619
619
|
), t = await K(
|
|
620
620
|
new URL("/assets/xr/models/hand_tracking.task", I.assetStorageEndpoint).toString()
|
|
621
|
-
),
|
|
621
|
+
), i = await Oe.createFromOptions(e, {
|
|
622
622
|
baseOptions: {
|
|
623
623
|
modelAssetBuffer: t,
|
|
624
624
|
delegate: "GPU"
|
|
@@ -626,7 +626,7 @@ class at extends N {
|
|
|
626
626
|
runningMode: "VIDEO",
|
|
627
627
|
numHands: 2
|
|
628
628
|
});
|
|
629
|
-
this.landmarker =
|
|
629
|
+
this.landmarker = i;
|
|
630
630
|
}
|
|
631
631
|
async run({ sourceCanvas: e, targetFps: t }) {
|
|
632
632
|
this.sourceCanvas = e, this.setTargetFps(t), this.rafId === null && await this.processHandTracking();
|
|
@@ -733,8 +733,8 @@ class ht extends N {
|
|
|
733
733
|
return e.videoWidth > 0 ? { width: e.videoWidth, height: e.videoHeight } : void 0;
|
|
734
734
|
if (e instanceof HTMLImageElement)
|
|
735
735
|
return e.naturalWidth > 0 ? { width: e.naturalWidth, height: e.naturalHeight } : void 0;
|
|
736
|
-
const t = e.width,
|
|
737
|
-
return typeof t == "number" && t > 0 && typeof
|
|
736
|
+
const t = e.width, i = e.height;
|
|
737
|
+
return typeof t == "number" && t > 0 && typeof i == "number" && i > 0 ? { width: t, height: i } : void 0;
|
|
738
738
|
}
|
|
739
739
|
/**
|
|
740
740
|
* Size the process canvas to the override input's aspect ratio, bounded by
|
|
@@ -747,8 +747,8 @@ class ht extends N {
|
|
|
747
747
|
const e = this.readIntrinsicSize(this.inputSource);
|
|
748
748
|
if (!e) return;
|
|
749
749
|
this.inputSourceSize = e;
|
|
750
|
-
const t = Math.min(1, ot / Math.max(e.width, e.height)),
|
|
751
|
-
this.processCanvas.width ===
|
|
750
|
+
const t = Math.min(1, ot / Math.max(e.width, e.height)), i = Math.max(1, Math.round(e.width * t)), r = Math.max(1, Math.round(e.height * t));
|
|
751
|
+
this.processCanvas.width === i && this.processCanvas.height === r || (this.processCanvas.width = i, this.processCanvas.height = r, this.glCanvas && (this.glCanvas.width = i, this.glCanvas.height = r), this.maskImageData = void 0);
|
|
752
752
|
}
|
|
753
753
|
async processSegmentation() {
|
|
754
754
|
if (this.disposed || !this.isProcessing || !this.maskCanvas || !this.processCanvas)
|
|
@@ -766,14 +766,14 @@ class ht extends N {
|
|
|
766
766
|
}
|
|
767
767
|
const t = performance.now();
|
|
768
768
|
this.ensureProcessCanvasForInput();
|
|
769
|
-
const
|
|
770
|
-
if (
|
|
769
|
+
const i = this.processCanvas.getContext("2d");
|
|
770
|
+
if (i) {
|
|
771
771
|
const u = this.processCanvas.width, m = this.processCanvas.height;
|
|
772
|
-
if (
|
|
772
|
+
if (i.clearRect(0, 0, u, m), this.inputSource && this.inputSourceSize) {
|
|
773
773
|
const { width: d, height: S } = this.inputSourceSize, R = Math.min(u / d, m / S), M = d * R, x = S * R;
|
|
774
|
-
|
|
774
|
+
i.drawImage(this.inputSource, (u - M) / 2, (m - x) / 2, M, x);
|
|
775
775
|
} else
|
|
776
|
-
|
|
776
|
+
i.drawImage(e, 0, 0, u, m);
|
|
777
777
|
}
|
|
778
778
|
const o = this.segmenter.segmentForVideo(
|
|
779
779
|
this.processCanvas,
|
|
@@ -811,9 +811,9 @@ class ht extends N {
|
|
|
811
811
|
* background→opaque convention (green carries the signal for the alphaMap).
|
|
812
812
|
*/
|
|
813
813
|
readMaskToImageData(e) {
|
|
814
|
-
const t = e.getAsUint8Array(), { width:
|
|
815
|
-
if (!t ||
|
|
816
|
-
(!this.maskImageData || this.maskImageData.width !==
|
|
814
|
+
const t = e.getAsUint8Array(), { width: i, height: r } = e;
|
|
815
|
+
if (!t || i <= 0 || r <= 0) return null;
|
|
816
|
+
(!this.maskImageData || this.maskImageData.width !== i || this.maskImageData.height !== r) && (this.maskImageData = new ImageData(i, r));
|
|
817
817
|
const o = this.maskImageData.data;
|
|
818
818
|
for (let u = 0; u < t.length; u += 1) {
|
|
819
819
|
const m = t[u] === 255 ? 0 : 255;
|
|
@@ -828,10 +828,10 @@ class ht extends N {
|
|
|
828
828
|
*/
|
|
829
829
|
blitImageDataToMask(e) {
|
|
830
830
|
if (!this.maskCanvas || !this.filterCanvas) return;
|
|
831
|
-
const t = this.maskCanvas.getContext("2d"),
|
|
832
|
-
if (!t || !
|
|
831
|
+
const t = this.maskCanvas.getContext("2d"), i = this.filterCanvas.getContext("2d");
|
|
832
|
+
if (!t || !i) return;
|
|
833
833
|
const r = this.getStagingCanvas(e.width, e.height), o = r.getContext("2d");
|
|
834
|
-
o && (o.putImageData(e, 0, 0),
|
|
834
|
+
o && (o.putImageData(e, 0, 0), i.filter = "blur(0.5px)", i.clearRect(0, 0, this.filterCanvas.width, this.filterCanvas.height), i.drawImage(r, 0, 0, this.filterCanvas.width, this.filterCanvas.height), t.clearRect(0, 0, this.maskCanvas.width, this.maskCanvas.height), t.drawImage(this.filterCanvas, 0, 0, this.maskCanvas.width, this.maskCanvas.height));
|
|
835
835
|
}
|
|
836
836
|
getStagingCanvas(e, t) {
|
|
837
837
|
return this.stagingCanvas || (this.stagingCanvas = document.createElement("canvas")), this.stagingCanvas.width !== e && (this.stagingCanvas.width = e), this.stagingCanvas.height !== t && (this.stagingCanvas.height = t), this.stagingCanvas;
|
|
@@ -860,7 +860,7 @@ class ht extends N {
|
|
|
860
860
|
this.quality = (e == null ? void 0 : e.quality) ?? "low";
|
|
861
861
|
const t = await V.forVisionTasks(
|
|
862
862
|
new URL("/assets/xr/wasm", I.assetStorageEndpoint).toString()
|
|
863
|
-
),
|
|
863
|
+
), i = await K(
|
|
864
864
|
new URL("/assets/xr/models/segmentation.tflite", I.assetStorageEndpoint).toString()
|
|
865
865
|
);
|
|
866
866
|
this.glCanvas = new OffscreenCanvas(1, 1);
|
|
@@ -869,7 +869,7 @@ class ht extends N {
|
|
|
869
869
|
});
|
|
870
870
|
this.segmenter = await Ue.createFromOptions(t, {
|
|
871
871
|
baseOptions: {
|
|
872
|
-
modelAssetBuffer:
|
|
872
|
+
modelAssetBuffer: i,
|
|
873
873
|
delegate: "GPU"
|
|
874
874
|
},
|
|
875
875
|
...r ? { canvas: this.glCanvas } : {},
|
|
@@ -881,7 +881,7 @@ class ht extends N {
|
|
|
881
881
|
async run({
|
|
882
882
|
sourceCanvas: e,
|
|
883
883
|
renderWidth: t,
|
|
884
|
-
renderHeight:
|
|
884
|
+
renderHeight: i,
|
|
885
885
|
targetFps: r
|
|
886
886
|
}) {
|
|
887
887
|
var u;
|
|
@@ -889,7 +889,7 @@ class ht extends N {
|
|
|
889
889
|
return;
|
|
890
890
|
this.setTargetFps(r ?? rt), this.isProcessing = !1, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
891
891
|
const o = this.getQualityScaleFactor();
|
|
892
|
-
this.sourceCanvas = e, this.processCanvas = document.createElement("canvas"), this.processCanvas.width = e.width * o, this.processCanvas.height = e.height * o, this.glCanvas && (this.glCanvas.width = this.processCanvas.width, this.glCanvas.height = this.processCanvas.height), this.maskImageData = void 0, this.maskCanvas = document.createElement("canvas"), this.maskCanvas.width = t, this.maskCanvas.height =
|
|
892
|
+
this.sourceCanvas = e, this.processCanvas = document.createElement("canvas"), this.processCanvas.width = e.width * o, this.processCanvas.height = e.height * o, this.glCanvas && (this.glCanvas.width = this.processCanvas.width, this.glCanvas.height = this.processCanvas.height), this.maskImageData = void 0, this.maskCanvas = document.createElement("canvas"), this.maskCanvas.width = t, this.maskCanvas.height = i, this.filterCanvas = document.createElement("canvas"), this.filterCanvas.width = t, this.filterCanvas.height = i, (u = this.segmentationMaskTexture) == null || u.dispose(), this.segmentationMaskTexture = new ue(this.maskCanvas), this.isMaskSetup = !1, this.rawCache = null, this.isProcessing = !0, this.lastInferenceMs = 0, this.rafId = requestAnimationFrame(this.processSegmentation.bind(this));
|
|
893
893
|
}
|
|
894
894
|
/**
|
|
895
895
|
* Lazily read the single-channel mask back to a Uint8Array. Only invoked when
|
|
@@ -926,116 +926,139 @@ class ht extends N {
|
|
|
926
926
|
}
|
|
927
927
|
const re = {
|
|
928
928
|
[z.BACKGROUND_SEGMENTATION]: ht,
|
|
929
|
-
[z.HAND_TRACKER]:
|
|
930
|
-
[z.GESTURE_TRACKER]:
|
|
929
|
+
[z.HAND_TRACKER]: it,
|
|
930
|
+
[z.GESTURE_TRACKER]: nt,
|
|
931
931
|
[z.FACE_TRACKER]: Ze,
|
|
932
932
|
[z.BODY_TRACKER]: je
|
|
933
|
-
}, dt = async (
|
|
933
|
+
}, dt = async (n) => {
|
|
934
934
|
const s = document.createElement("video");
|
|
935
|
-
s.srcObject =
|
|
935
|
+
s.srcObject = n, s.muted = !0, s.playsInline = !0, s.autoplay = !0, await new Promise((t) => {
|
|
936
936
|
s.onloadedmetadata = () => {
|
|
937
937
|
s.play(), t();
|
|
938
938
|
};
|
|
939
939
|
});
|
|
940
940
|
const e = s;
|
|
941
941
|
return await new Promise((t) => {
|
|
942
|
-
const
|
|
943
|
-
clearTimeout(
|
|
942
|
+
const i = setTimeout(t, 150), r = () => {
|
|
943
|
+
clearTimeout(i), t();
|
|
944
944
|
};
|
|
945
945
|
typeof e.requestVideoFrameCallback == "function" ? e.requestVideoFrameCallback(r) : requestAnimationFrame(() => requestAnimationFrame(() => r()));
|
|
946
946
|
}), s;
|
|
947
|
-
}, ut = (
|
|
948
|
-
const s = new ue(
|
|
947
|
+
}, ut = (n) => {
|
|
948
|
+
const s = new ue(n);
|
|
949
949
|
return s.colorSpace = Le, s.format = de, s.minFilter = q, s.magFilter = q, s.generateMipmaps = !1, s.needsUpdate = !0, s;
|
|
950
|
-
}, lt = (
|
|
951
|
-
const e =
|
|
950
|
+
}, lt = (n, s) => {
|
|
951
|
+
const e = n.videoWidth, t = n.videoHeight;
|
|
952
952
|
e > 0 && t > 0 && (s.width !== e && (s.width = e), s.height !== t && (s.height = t));
|
|
953
|
-
const
|
|
953
|
+
const i = s.getContext("2d", {
|
|
954
954
|
colorSpace: "srgb"
|
|
955
955
|
});
|
|
956
|
-
|
|
957
|
-
}, gt = (
|
|
956
|
+
i.save(), i.scale(-1, 1), i.drawImage(n, -s.width, 0, s.width, s.height), i.restore();
|
|
957
|
+
}, gt = (n, s, e = 1) => {
|
|
958
958
|
const t = s.getContext("2d", {
|
|
959
959
|
colorSpace: "srgb"
|
|
960
|
-
}),
|
|
960
|
+
}), i = s.width / s.height, r = n.width / n.height;
|
|
961
961
|
let o, u;
|
|
962
|
-
r >
|
|
962
|
+
r > i ? (u = s.height, o = n.width * (s.height / n.height)) : (o = s.width, u = n.height * (s.width / n.width));
|
|
963
963
|
const m = Number.isFinite(e) && e > 0 ? e : 1;
|
|
964
964
|
o *= m, u *= m;
|
|
965
965
|
const d = (s.width - o) / 2, S = (s.height - u) / 2;
|
|
966
966
|
t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, s.width, s.height), t.drawImage(
|
|
967
|
-
|
|
967
|
+
n,
|
|
968
968
|
0,
|
|
969
969
|
0,
|
|
970
|
-
|
|
971
|
-
|
|
970
|
+
n.width,
|
|
971
|
+
n.height,
|
|
972
972
|
d,
|
|
973
973
|
S,
|
|
974
974
|
o,
|
|
975
975
|
u
|
|
976
976
|
);
|
|
977
|
-
}, mt = (
|
|
977
|
+
}, mt = (n) => {
|
|
978
|
+
switch (n instanceof DOMException ? n.name : "") {
|
|
979
|
+
case "NotAllowedError":
|
|
980
|
+
case "PermissionDeniedError":
|
|
981
|
+
return "permission-denied";
|
|
982
|
+
case "NotReadableError":
|
|
983
|
+
case "TrackStartError":
|
|
984
|
+
return "camera-in-use";
|
|
985
|
+
case "NotFoundError":
|
|
986
|
+
case "DevicesNotFoundError":
|
|
987
|
+
return "no-camera";
|
|
988
|
+
case "NotSupportedError":
|
|
989
|
+
case "SecurityError":
|
|
990
|
+
return "unsupported";
|
|
991
|
+
default:
|
|
992
|
+
return n instanceof TypeError ? "unsupported" : "unknown";
|
|
993
|
+
}
|
|
994
|
+
}, ft = {
|
|
995
|
+
"permission-denied": "Camera access was blocked. Allow camera permissions in your browser, then refresh.",
|
|
996
|
+
"camera-in-use": "Camera is already in use by another app or browser tab. Close it and refresh.",
|
|
997
|
+
"no-camera": "No camera was found on this device.",
|
|
998
|
+
unsupported: "Unable to access camera. Allow camera permissions in your browser, then refresh.",
|
|
999
|
+
unknown: "Unable to access camera. Allow camera permissions in your browser, then refresh."
|
|
1000
|
+
}, pt = (n, s, e) => {
|
|
978
1001
|
const t = /* @__PURE__ */ new Map();
|
|
979
|
-
let
|
|
980
|
-
const r = (
|
|
981
|
-
var
|
|
1002
|
+
let i = !1;
|
|
1003
|
+
const r = (l, f) => {
|
|
1004
|
+
var v;
|
|
982
1005
|
try {
|
|
983
|
-
(
|
|
1006
|
+
(v = f.dispose) == null || v.call(f);
|
|
984
1007
|
} catch (p) {
|
|
985
|
-
console.warn(`[xr-sdk registry] dispose threw for ${
|
|
1008
|
+
console.warn(`[xr-sdk registry] dispose threw for ${l}`, p);
|
|
986
1009
|
}
|
|
987
1010
|
};
|
|
988
|
-
return { acquire: async (
|
|
989
|
-
let p = t.get(
|
|
1011
|
+
return { acquire: async (l, f, v) => {
|
|
1012
|
+
let p = t.get(l);
|
|
990
1013
|
if (p)
|
|
991
1014
|
return p.refs.add(f), p.activeRefs.add(f), p.initPromise;
|
|
992
|
-
const k = s[
|
|
1015
|
+
const k = s[l];
|
|
993
1016
|
if (!k)
|
|
994
|
-
throw new Error(`Invalid model: ${
|
|
1017
|
+
throw new Error(`Invalid model: ${l}`);
|
|
995
1018
|
const C = new k(), L = /* @__PURE__ */ new Set([f]), U = /* @__PURE__ */ new Set([f]), _ = (async () => {
|
|
996
|
-
await C.initialize(
|
|
997
|
-
const B = t.get(
|
|
1019
|
+
await C.initialize(v);
|
|
1020
|
+
const B = t.get(l);
|
|
998
1021
|
if (!B || B.model !== C || B.refs.size === 0)
|
|
999
|
-
return r(
|
|
1000
|
-
e && await e(
|
|
1001
|
-
const T = t.get(
|
|
1002
|
-
return T && T.refs.size > 0 &&
|
|
1022
|
+
return r(l, C), C;
|
|
1023
|
+
e && await e(l, C);
|
|
1024
|
+
const T = t.get(l);
|
|
1025
|
+
return T && T.refs.size > 0 && n.setPipeline((P) => P.set(l, C)), C;
|
|
1003
1026
|
})();
|
|
1004
|
-
return p = { model: C, refs: L, activeRefs: U, initPromise: _, options:
|
|
1005
|
-
t.get(
|
|
1027
|
+
return p = { model: C, refs: L, activeRefs: U, initPromise: _, options: v }, t.set(l, p), _.catch(() => {
|
|
1028
|
+
t.get(l) === p && (t.delete(l), n.setPipeline((T) => T.delete(l))), r(l, C);
|
|
1006
1029
|
}), _;
|
|
1007
|
-
}, release: (
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
}, setActive: (
|
|
1011
|
-
const p = t.get(
|
|
1030
|
+
}, release: (l, f) => {
|
|
1031
|
+
const v = t.get(l);
|
|
1032
|
+
v && (v.refs.delete(f), v.activeRefs.delete(f) && v.refs.size > 0 && v.activeRefs.size === 0 && v.model.pause(), !(v.refs.size > 0) && (t.delete(l), r(l, v.model), n.setPipeline((p) => p.delete(l))));
|
|
1033
|
+
}, setActive: (l, f, v) => {
|
|
1034
|
+
const p = t.get(l);
|
|
1012
1035
|
if (!p || !p.refs.has(f)) return;
|
|
1013
1036
|
const k = p.activeRefs.size > 0;
|
|
1014
|
-
|
|
1037
|
+
v ? p.activeRefs.add(f) : p.activeRefs.delete(f);
|
|
1015
1038
|
const C = p.activeRefs.size > 0;
|
|
1016
|
-
k !== C && (C && !
|
|
1039
|
+
k !== C && (C && !i ? p.model.resume() : p.model.pause());
|
|
1017
1040
|
}, suspendAll: () => {
|
|
1018
|
-
|
|
1019
|
-
for (const
|
|
1020
|
-
|
|
1041
|
+
i = !0;
|
|
1042
|
+
for (const l of t.values())
|
|
1043
|
+
l.model.pause();
|
|
1021
1044
|
}, resumeActive: () => {
|
|
1022
|
-
|
|
1023
|
-
for (const
|
|
1024
|
-
|
|
1025
|
-
}, get: (
|
|
1045
|
+
i = !1;
|
|
1046
|
+
for (const l of t.values())
|
|
1047
|
+
l.activeRefs.size > 0 && l.model.resume();
|
|
1048
|
+
}, get: (l) => {
|
|
1026
1049
|
var f;
|
|
1027
|
-
return (f = t.get(
|
|
1028
|
-
}, getOptions: (
|
|
1050
|
+
return (f = t.get(l)) == null ? void 0 : f.model;
|
|
1051
|
+
}, getOptions: (l) => {
|
|
1029
1052
|
var f;
|
|
1030
|
-
return (f = t.get(
|
|
1053
|
+
return (f = t.get(l)) == null ? void 0 : f.options;
|
|
1031
1054
|
}, releaseAll: () => {
|
|
1032
|
-
for (const
|
|
1033
|
-
const f = t.get(
|
|
1034
|
-
f && (f.refs.clear(), t.delete(
|
|
1055
|
+
for (const l of Array.from(t.keys())) {
|
|
1056
|
+
const f = t.get(l);
|
|
1057
|
+
f && (f.refs.clear(), t.delete(l), r(l, f.model));
|
|
1035
1058
|
}
|
|
1036
|
-
|
|
1059
|
+
n.setPipeline((l) => l.clear());
|
|
1037
1060
|
} };
|
|
1038
|
-
},
|
|
1061
|
+
}, wt = {
|
|
1039
1062
|
lifecycle: "idle",
|
|
1040
1063
|
ready: !1,
|
|
1041
1064
|
error: void 0,
|
|
@@ -1045,73 +1068,73 @@ const re = {
|
|
|
1045
1068
|
source: void 0,
|
|
1046
1069
|
sourceKind: void 0,
|
|
1047
1070
|
pipeline: /* @__PURE__ */ new Map()
|
|
1048
|
-
},
|
|
1049
|
-
let
|
|
1071
|
+
}, vt = () => {
|
|
1072
|
+
let n = { ...wt, pipeline: /* @__PURE__ */ new Map() };
|
|
1050
1073
|
const s = /* @__PURE__ */ new Set(), e = () => {
|
|
1051
1074
|
s.forEach((t) => t());
|
|
1052
1075
|
};
|
|
1053
1076
|
return {
|
|
1054
|
-
getSnapshot: () =>
|
|
1077
|
+
getSnapshot: () => n,
|
|
1055
1078
|
set: (t) => {
|
|
1056
|
-
let
|
|
1079
|
+
let i = !1;
|
|
1057
1080
|
for (const r of Object.keys(t))
|
|
1058
|
-
if (t[r] !==
|
|
1059
|
-
|
|
1081
|
+
if (t[r] !== n[r]) {
|
|
1082
|
+
i = !0;
|
|
1060
1083
|
break;
|
|
1061
1084
|
}
|
|
1062
|
-
|
|
1085
|
+
i && (n = { ...n, ...t }, e());
|
|
1063
1086
|
},
|
|
1064
1087
|
setPipeline: (t) => {
|
|
1065
|
-
const
|
|
1066
|
-
return t(
|
|
1088
|
+
const i = new Map(n.pipeline);
|
|
1089
|
+
return t(i), n = { ...n, pipeline: i }, e(), i;
|
|
1067
1090
|
},
|
|
1068
1091
|
subscribe: (t) => (s.add(t), () => {
|
|
1069
1092
|
s.delete(t);
|
|
1070
1093
|
})
|
|
1071
1094
|
};
|
|
1072
|
-
},
|
|
1073
|
-
renderHeight:
|
|
1095
|
+
}, Ct = ({
|
|
1096
|
+
renderHeight: n,
|
|
1074
1097
|
renderWidth: s,
|
|
1075
1098
|
videoHeight: e,
|
|
1076
1099
|
videoWidth: t
|
|
1077
1100
|
}) => ({
|
|
1078
|
-
height:
|
|
1101
|
+
height: n || e,
|
|
1079
1102
|
width: s || t
|
|
1080
|
-
}),
|
|
1081
|
-
const s = new Ve({ verbose: !0 }), e =
|
|
1082
|
-
let t =
|
|
1083
|
-
const
|
|
1084
|
-
var
|
|
1085
|
-
const c = (
|
|
1103
|
+
}), St = (n) => {
|
|
1104
|
+
const s = new Ve({ verbose: !0 }), e = vt();
|
|
1105
|
+
let t = n;
|
|
1106
|
+
const i = (a) => {
|
|
1107
|
+
var g;
|
|
1108
|
+
const c = (g = T.getOptions(a)) == null ? void 0 : g.targetFps;
|
|
1086
1109
|
return typeof c == "number" ? c : t == null ? void 0 : t.targetFps;
|
|
1087
1110
|
};
|
|
1088
|
-
let r, o, u, m, d, S, R, M, x,
|
|
1089
|
-
const C = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), U = (
|
|
1111
|
+
let r, o, u, m, d, S, R, M, x, l, f, v = !1, p = !1, k = 0;
|
|
1112
|
+
const C = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), U = (a) => {
|
|
1090
1113
|
const c = e.getSnapshot().cameraTexture;
|
|
1091
1114
|
c && c.dispose();
|
|
1092
|
-
const
|
|
1093
|
-
return e.set({ cameraTexture:
|
|
1094
|
-
}, _ = async (
|
|
1095
|
-
if (C.has(
|
|
1096
|
-
C.add(
|
|
1097
|
-
const
|
|
1115
|
+
const g = ut(a);
|
|
1116
|
+
return e.set({ cameraTexture: g }), g;
|
|
1117
|
+
}, _ = async (a, c) => {
|
|
1118
|
+
if (C.has(a) || e.getSnapshot().lifecycle !== "running" || !d) return;
|
|
1119
|
+
C.add(a);
|
|
1120
|
+
const g = k;
|
|
1098
1121
|
try {
|
|
1099
1122
|
await c.run({
|
|
1100
1123
|
sourceCanvas: d,
|
|
1101
1124
|
renderWidth: e.getSnapshot().renderWidth,
|
|
1102
1125
|
renderHeight: e.getSnapshot().renderHeight,
|
|
1103
1126
|
getSource: () => e.getSnapshot().sourceKind,
|
|
1104
|
-
targetFps: a
|
|
1105
|
-
}), p && (await new Promise((
|
|
1106
|
-
} catch (
|
|
1107
|
-
throw C.delete(
|
|
1127
|
+
targetFps: i(a)
|
|
1128
|
+
}), p && (await new Promise((w) => requestAnimationFrame(() => w())), await new Promise((w) => requestAnimationFrame(() => w())), p && k === g && T.suspendAll());
|
|
1129
|
+
} catch (w) {
|
|
1130
|
+
throw C.delete(a), w;
|
|
1108
1131
|
}
|
|
1109
|
-
}, T =
|
|
1132
|
+
}, T = pt(e, re, (a, c) => _(a, c));
|
|
1110
1133
|
e.subscribe(() => {
|
|
1111
1134
|
if (e.getSnapshot().lifecycle !== "running") return;
|
|
1112
|
-
const
|
|
1113
|
-
for (const [c,
|
|
1114
|
-
C.has(c) || _(c,
|
|
1135
|
+
const a = e.getSnapshot().pipeline;
|
|
1136
|
+
for (const [c, g] of a.entries())
|
|
1137
|
+
C.has(c) || _(c, g);
|
|
1115
1138
|
});
|
|
1116
1139
|
const P = () => {
|
|
1117
1140
|
if (f !== void 0 && (cancelAnimationFrame(f), f = void 0), o) {
|
|
@@ -1127,37 +1150,37 @@ const re = {
|
|
|
1127
1150
|
}
|
|
1128
1151
|
if (u) {
|
|
1129
1152
|
try {
|
|
1130
|
-
u.getTracks().forEach((
|
|
1153
|
+
u.getTracks().forEach((a) => a.stop());
|
|
1131
1154
|
} catch {
|
|
1132
1155
|
}
|
|
1133
1156
|
u = void 0;
|
|
1134
1157
|
}
|
|
1135
1158
|
}, G = () => {
|
|
1136
|
-
if (
|
|
1137
|
-
const
|
|
1138
|
-
if (
|
|
1159
|
+
if (v || !o || !m || !d) return;
|
|
1160
|
+
const a = window.__xr_debugger_metrics;
|
|
1161
|
+
if (a != null && a.trackCameraFrame && a.trackCameraFrame(), (e.getSnapshot().sourceKind ?? "webcam") === "webcam")
|
|
1139
1162
|
lt(o, m);
|
|
1140
1163
|
else {
|
|
1141
|
-
const
|
|
1142
|
-
if (!
|
|
1164
|
+
const w = m.getContext("2d");
|
|
1165
|
+
if (!w) return;
|
|
1143
1166
|
const y = o.videoWidth, A = o.videoHeight;
|
|
1144
|
-
m.width !== y && (m.width = y), m.height !== A && (m.height = A),
|
|
1167
|
+
m.width !== y && (m.width = y), m.height !== A && (m.height = A), w.setTransform(1, 0, 0, 1, 0, 0), w.clearRect(0, 0, y, A), w.drawImage(o, 0, 0, y, A);
|
|
1145
1168
|
}
|
|
1146
1169
|
gt(m, d, (t == null ? void 0 : t.cameraZoom) ?? 1.2);
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1170
|
+
const g = e.getSnapshot().cameraTexture;
|
|
1171
|
+
g && (g.needsUpdate = !0);
|
|
1149
1172
|
}, J = () => {
|
|
1150
1173
|
if (!o || !m || !d) return;
|
|
1151
1174
|
if (p) {
|
|
1152
1175
|
G();
|
|
1153
1176
|
return;
|
|
1154
1177
|
}
|
|
1155
|
-
const
|
|
1156
|
-
f = requestAnimationFrame(
|
|
1178
|
+
const a = () => {
|
|
1179
|
+
f = requestAnimationFrame(a), G();
|
|
1157
1180
|
};
|
|
1158
|
-
f = requestAnimationFrame(
|
|
1159
|
-
}, pe = async (
|
|
1160
|
-
if (
|
|
1181
|
+
f = requestAnimationFrame(a);
|
|
1182
|
+
}, pe = async (a) => {
|
|
1183
|
+
if (a.source === F.WEBCAM)
|
|
1161
1184
|
try {
|
|
1162
1185
|
const c = t != null && t.camRes && t.camRes > 0 ? t.camRes : 960;
|
|
1163
1186
|
return await navigator.mediaDevices.getUserMedia({
|
|
@@ -1168,39 +1191,39 @@ const re = {
|
|
|
1168
1191
|
}
|
|
1169
1192
|
});
|
|
1170
1193
|
} catch (c) {
|
|
1171
|
-
const
|
|
1172
|
-
throw e.set({ error: { error: "PermissionError", message:
|
|
1194
|
+
const g = mt(c), w = ft[g];
|
|
1195
|
+
throw e.set({ error: { error: "PermissionError", message: w, reason: g } }), new b(c instanceof Error ? c.message : "getUserMedia failed");
|
|
1173
1196
|
}
|
|
1174
|
-
return
|
|
1175
|
-
}, W = async (
|
|
1176
|
-
const c = await pe(
|
|
1197
|
+
return a.stream;
|
|
1198
|
+
}, W = async (a) => {
|
|
1199
|
+
const c = await pe(a);
|
|
1177
1200
|
u = c;
|
|
1178
|
-
const
|
|
1179
|
-
o =
|
|
1180
|
-
const { renderWidth:
|
|
1181
|
-
renderWidth:
|
|
1201
|
+
const g = await dt(c);
|
|
1202
|
+
o = g, m = new OffscreenCanvas(g.videoWidth, g.videoHeight);
|
|
1203
|
+
const { renderWidth: w, renderHeight: y } = e.getSnapshot(), A = Ct({
|
|
1204
|
+
renderWidth: w,
|
|
1182
1205
|
renderHeight: y,
|
|
1183
|
-
videoWidth:
|
|
1184
|
-
videoHeight:
|
|
1206
|
+
videoWidth: g.videoWidth,
|
|
1207
|
+
videoHeight: g.videoHeight
|
|
1185
1208
|
});
|
|
1186
1209
|
d ? (d.width !== A.width || d.height !== A.height) && (d.width = A.width, d.height = A.height, U(d)) : (d = new OffscreenCanvas(A.width, A.height), U(d));
|
|
1187
|
-
const
|
|
1188
|
-
p =
|
|
1210
|
+
const ne = a.source === F.STREAM ? a.static === !0 : !1;
|
|
1211
|
+
p = ne, r = a.source === F.WEBCAM ? { source: F.WEBCAM, sourceKind: "webcam" } : {
|
|
1189
1212
|
source: F.STREAM,
|
|
1190
|
-
stream:
|
|
1191
|
-
static:
|
|
1192
|
-
sourceKind:
|
|
1213
|
+
stream: a.stream,
|
|
1214
|
+
static: ne,
|
|
1215
|
+
sourceKind: a.sourceKind ?? "webcam"
|
|
1193
1216
|
}, e.set({
|
|
1194
|
-
source:
|
|
1217
|
+
source: a.source,
|
|
1195
1218
|
sourceKind: r.sourceKind,
|
|
1196
1219
|
error: void 0
|
|
1197
1220
|
});
|
|
1198
|
-
}, X = async (
|
|
1199
|
-
const c =
|
|
1200
|
-
d =
|
|
1201
|
-
const
|
|
1221
|
+
}, X = async (a) => {
|
|
1222
|
+
const c = a.sourceKind ?? "webcam";
|
|
1223
|
+
d = a.canvas;
|
|
1224
|
+
const g = U(d);
|
|
1202
1225
|
e.set({
|
|
1203
|
-
cameraTexture:
|
|
1226
|
+
cameraTexture: g,
|
|
1204
1227
|
source: F.CANVAS,
|
|
1205
1228
|
sourceKind: c,
|
|
1206
1229
|
renderWidth: d.width,
|
|
@@ -1208,110 +1231,110 @@ const re = {
|
|
|
1208
1231
|
error: void 0
|
|
1209
1232
|
}), r = {
|
|
1210
1233
|
source: F.CANVAS,
|
|
1211
|
-
canvas:
|
|
1234
|
+
canvas: a.canvas,
|
|
1212
1235
|
sourceKind: c
|
|
1213
1236
|
};
|
|
1214
|
-
},
|
|
1237
|
+
}, we = (a, c) => !c || a.source !== c.source ? !1 : a.source === F.STREAM && c.source === F.STREAM ? a.stream === c.stream && (a.sourceKind ?? "webcam") === c.sourceKind : !0, ve = async () => {
|
|
1215
1238
|
if (!d) return;
|
|
1216
|
-
const
|
|
1217
|
-
for (const [,
|
|
1218
|
-
|
|
1219
|
-
await new Promise((
|
|
1220
|
-
}, Ce = (
|
|
1221
|
-
const c =
|
|
1239
|
+
const a = k, c = e.getSnapshot().pipeline;
|
|
1240
|
+
for (const [, g] of c.entries())
|
|
1241
|
+
g.resume();
|
|
1242
|
+
await new Promise((g) => requestAnimationFrame(() => g())), await new Promise((g) => requestAnimationFrame(() => g())), p && k === a && T.suspendAll();
|
|
1243
|
+
}, Ce = (a, c) => !c || c.source !== F.CANVAS ? !1 : a.canvas === c.canvas && (a.sourceKind ?? "webcam") === c.sourceKind, Se = async (a) => {
|
|
1244
|
+
const c = a.source;
|
|
1222
1245
|
if (c !== F.WEBCAM && c !== F.STREAM)
|
|
1223
1246
|
throw new b(`Invalid media source: ${String(c)}`);
|
|
1224
|
-
if (
|
|
1247
|
+
if (we(a, r)) {
|
|
1225
1248
|
s.log("Media source unchanged, skipping rebind.");
|
|
1226
1249
|
return;
|
|
1227
1250
|
}
|
|
1228
1251
|
k += 1;
|
|
1229
|
-
const { lifecycle:
|
|
1230
|
-
if (
|
|
1231
|
-
await W(
|
|
1252
|
+
const { lifecycle: g } = e.getSnapshot();
|
|
1253
|
+
if (g === "idle" || g === "stopped") {
|
|
1254
|
+
await W(a), e.set({ lifecycle: "media-bound" }), s.log("Media source set to:", a.source);
|
|
1232
1255
|
return;
|
|
1233
1256
|
}
|
|
1234
|
-
if (
|
|
1235
|
-
P(), await W(
|
|
1257
|
+
if (g === "media-bound") {
|
|
1258
|
+
P(), await W(a), s.log("Media source rebound to:", a.source);
|
|
1236
1259
|
return;
|
|
1237
1260
|
}
|
|
1238
|
-
|
|
1239
|
-
}, ke = async (
|
|
1240
|
-
if (Ce(
|
|
1261
|
+
v = !0, await new Promise((w) => requestAnimationFrame(() => w())), P(), await W(a), v = !1, J(), p ? await ve() : T.resumeActive(), s.log("Media source swapped to:", a.source);
|
|
1262
|
+
}, ke = async (a) => {
|
|
1263
|
+
if (Ce(a, r)) {
|
|
1241
1264
|
s.log("Frame source unchanged, skipping rebind.");
|
|
1242
1265
|
return;
|
|
1243
1266
|
}
|
|
1244
1267
|
k += 1;
|
|
1245
1268
|
const { lifecycle: c } = e.getSnapshot();
|
|
1246
1269
|
if (c === "idle" || c === "stopped") {
|
|
1247
|
-
await X(
|
|
1270
|
+
await X(a), e.set({ lifecycle: "media-bound" }), s.log("Frame source set to canvas.");
|
|
1248
1271
|
return;
|
|
1249
1272
|
}
|
|
1250
1273
|
if (c === "media-bound") {
|
|
1251
|
-
P(), await X(
|
|
1274
|
+
P(), await X(a), s.log("Frame source rebound to canvas.");
|
|
1252
1275
|
return;
|
|
1253
1276
|
}
|
|
1254
|
-
|
|
1277
|
+
v = !0, await new Promise((g) => requestAnimationFrame(() => g())), P(), await X(a), v = !1, s.log("Frame source swapped to canvas.");
|
|
1255
1278
|
}, ye = async () => {
|
|
1256
|
-
const { lifecycle:
|
|
1257
|
-
if (
|
|
1258
|
-
if (
|
|
1279
|
+
const { lifecycle: a } = e.getSnapshot();
|
|
1280
|
+
if (a === "running") return;
|
|
1281
|
+
if (a === "idle")
|
|
1259
1282
|
throw new b("session.start() called before setMediaSource — call setMediaSource first");
|
|
1260
1283
|
if (!d)
|
|
1261
1284
|
throw new b("session.start(): media source not bound");
|
|
1262
1285
|
const c = (r == null ? void 0 : r.source) === F.CANVAS;
|
|
1263
1286
|
if (!c && (!o || !m))
|
|
1264
|
-
throw
|
|
1287
|
+
throw a === "stopped" ? new b(
|
|
1265
1288
|
"session.start() called from stopped state without a media source — call setMediaSource first"
|
|
1266
1289
|
) : new b("session.start(): media source not bound");
|
|
1267
|
-
c || J(), T.resumeActive(), e.set({ lifecycle: "running" }), await new Promise((
|
|
1268
|
-
const
|
|
1269
|
-
for (const [
|
|
1270
|
-
await _(
|
|
1290
|
+
c || J(), T.resumeActive(), e.set({ lifecycle: "running" }), await new Promise((w) => requestAnimationFrame(() => w()));
|
|
1291
|
+
const g = e.getSnapshot().pipeline;
|
|
1292
|
+
for (const [w, y] of g.entries())
|
|
1293
|
+
await _(w, y);
|
|
1271
1294
|
e.set({ ready: !0 }), s.log("XR session started.");
|
|
1272
1295
|
}, ee = async () => {
|
|
1273
|
-
const { lifecycle:
|
|
1274
|
-
|
|
1296
|
+
const { lifecycle: a } = e.getSnapshot();
|
|
1297
|
+
a === "stopped" || a === "idle" || (P(), T.suspendAll(), e.set({ lifecycle: "stopped", ready: !1 }), s.log("XR session stopped."));
|
|
1275
1298
|
}, Me = async () => {
|
|
1276
1299
|
await ee(), T.releaseAll(), L.clear();
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1300
|
+
const a = e.getSnapshot().cameraTexture;
|
|
1301
|
+
a && a.dispose(), C.clear(), r = void 0, k += 1, d = void 0, m = void 0, p = !1, e.set({
|
|
1279
1302
|
lifecycle: "idle",
|
|
1280
1303
|
cameraTexture: void 0,
|
|
1281
1304
|
source: void 0
|
|
1282
1305
|
}), s.log("XR session reset.");
|
|
1283
|
-
}, Re = async (
|
|
1284
|
-
const c = "legacy:registerXRPipeline",
|
|
1306
|
+
}, Re = async (a) => {
|
|
1307
|
+
const c = "legacy:registerXRPipeline", g = [];
|
|
1285
1308
|
await Promise.all(
|
|
1286
|
-
|
|
1287
|
-
const { model: y } =
|
|
1309
|
+
a.map(async (w) => {
|
|
1310
|
+
const { model: y } = w;
|
|
1288
1311
|
if (!re[y])
|
|
1289
1312
|
throw new b(`Invalid model: ${y}`);
|
|
1290
|
-
L.has(y) ||
|
|
1291
|
-
const A = "options" in
|
|
1313
|
+
L.has(y) || g.push(y);
|
|
1314
|
+
const A = "options" in w ? w.options : void 0;
|
|
1292
1315
|
await T.acquire(y, c, A);
|
|
1293
1316
|
})
|
|
1294
|
-
),
|
|
1295
|
-
}, Te = (
|
|
1296
|
-
const c = T.get(
|
|
1317
|
+
), g.length > 0 && (g.forEach((w) => L.add(w)), s.log("XR pipeline registered."));
|
|
1318
|
+
}, Te = (a) => {
|
|
1319
|
+
const c = T.get(a);
|
|
1297
1320
|
if (!c)
|
|
1298
|
-
throw new b(`Model ${
|
|
1321
|
+
throw new b(`Model ${a} is not registered in the pipeline`);
|
|
1299
1322
|
return c.getModelNode();
|
|
1300
|
-
}, te = async (
|
|
1301
|
-
|
|
1302
|
-
}, xe = async (
|
|
1323
|
+
}, te = async (a, c) => {
|
|
1324
|
+
a <= 0 || c <= 0 || (e.set({ renderWidth: a, renderHeight: c }), d && (d.width !== a || d.height !== c) && (d.width = a, d.height = c, U(d), p && G()), s.log(`Source canvas set. Render size: ${a}x${c}`));
|
|
1325
|
+
}, xe = async (a) => {
|
|
1303
1326
|
var y;
|
|
1304
|
-
S =
|
|
1305
|
-
const c = (y =
|
|
1306
|
-
await te(
|
|
1307
|
-
}, Fe = (
|
|
1308
|
-
R =
|
|
1327
|
+
S = a;
|
|
1328
|
+
const c = (y = a.getBoundingClientRect) == null ? void 0 : y.call(a), g = c && c.width > 0 ? Math.round(c.width) : a.clientWidth, w = c && c.height > 0 ? Math.round(c.height) : a.clientHeight;
|
|
1329
|
+
await te(g, w);
|
|
1330
|
+
}, Fe = (a) => {
|
|
1331
|
+
R = a.renderer, M = a.scene, x = a.camera, l = a.renderFrame;
|
|
1309
1332
|
}, se = () => {
|
|
1310
1333
|
if (!R || !M || !x)
|
|
1311
1334
|
throw new b(
|
|
1312
1335
|
"XR frame render requested before the R3F state was bound — make sure <XRScene> is mounted"
|
|
1313
1336
|
);
|
|
1314
|
-
|
|
1337
|
+
l ? l() : R.render(M, x);
|
|
1315
1338
|
};
|
|
1316
1339
|
return {
|
|
1317
1340
|
store: e,
|
|
@@ -1340,59 +1363,59 @@ const re = {
|
|
|
1340
1363
|
_setR3FState: Fe,
|
|
1341
1364
|
_renderFrame: se,
|
|
1342
1365
|
_getVideoElement: () => o,
|
|
1343
|
-
_setPerf: (
|
|
1344
|
-
if (t =
|
|
1366
|
+
_setPerf: (a) => {
|
|
1367
|
+
if (t = a, e.getSnapshot().lifecycle !== "running" || !d) return;
|
|
1345
1368
|
const c = e.getSnapshot().pipeline;
|
|
1346
|
-
for (const [
|
|
1347
|
-
|
|
1369
|
+
for (const [g, w] of c.entries())
|
|
1370
|
+
w.run({
|
|
1348
1371
|
sourceCanvas: d,
|
|
1349
1372
|
renderWidth: e.getSnapshot().renderWidth,
|
|
1350
1373
|
renderHeight: e.getSnapshot().renderHeight,
|
|
1351
1374
|
getSource: () => e.getSnapshot().sourceKind,
|
|
1352
|
-
targetFps:
|
|
1375
|
+
targetFps: i(g)
|
|
1353
1376
|
});
|
|
1354
1377
|
}
|
|
1355
1378
|
};
|
|
1356
|
-
},
|
|
1357
|
-
const s = oe(
|
|
1379
|
+
}, kt = (n) => {
|
|
1380
|
+
const s = oe(n), e = $(() => St(s.current), []), t = JSON.stringify(n ?? {});
|
|
1358
1381
|
return Ee(() => {
|
|
1359
|
-
e._setPerf(
|
|
1382
|
+
e._setPerf(n);
|
|
1360
1383
|
}, [e, t]), e;
|
|
1361
|
-
}, Q = /* @__PURE__ */ new Map(),
|
|
1362
|
-
register: (
|
|
1363
|
-
s ? Q.set(
|
|
1384
|
+
}, Q = /* @__PURE__ */ new Map(), yt = () => ({
|
|
1385
|
+
register: (n, s) => {
|
|
1386
|
+
s ? Q.set(n, s) : Q.delete(n);
|
|
1364
1387
|
},
|
|
1365
|
-
resolve: (
|
|
1366
|
-
}), le =
|
|
1367
|
-
const s = oe(/* @__PURE__ */ new Map()), e =
|
|
1388
|
+
resolve: (n) => n ? Q.get(n) ?? null : null
|
|
1389
|
+
}), le = yt(), ge = he(null), Mt = ({ children: n }) => {
|
|
1390
|
+
const s = oe(/* @__PURE__ */ new Map()), e = ie((r, o) => {
|
|
1368
1391
|
o ? s.current.set(r, o) : s.current.delete(r);
|
|
1369
|
-
}, []), t =
|
|
1392
|
+
}, []), t = ie(
|
|
1370
1393
|
(r) => r ? s.current.get(r) ?? null : null,
|
|
1371
1394
|
[]
|
|
1372
|
-
),
|
|
1373
|
-
return Ie(ge.Provider, { value:
|
|
1374
|
-
}, me = () => ce(ge) ?? le,
|
|
1395
|
+
), i = $(() => ({ register: e, resolve: t }), [e, t]);
|
|
1396
|
+
return Ie(ge.Provider, { value: i }, n);
|
|
1397
|
+
}, me = () => ce(ge) ?? le, Pt = () => me().register, Ot = () => me().resolve;
|
|
1375
1398
|
le.register;
|
|
1376
|
-
const fe = he(void 0),
|
|
1377
|
-
const
|
|
1378
|
-
if (!
|
|
1399
|
+
const fe = he(void 0), Ut = () => {
|
|
1400
|
+
const n = ce(fe);
|
|
1401
|
+
if (!n)
|
|
1379
1402
|
throw new b(
|
|
1380
1403
|
"XR context can only be used inside XRProvider, did you forget to wrap your app in <XRProvider>?"
|
|
1381
1404
|
);
|
|
1382
|
-
return
|
|
1383
|
-
},
|
|
1384
|
-
const e =
|
|
1385
|
-
return /* @__PURE__ */
|
|
1405
|
+
return n;
|
|
1406
|
+
}, zt = ({ children: n, perf: s }) => {
|
|
1407
|
+
const e = kt(s), t = $(() => ({ session: e }), [e]);
|
|
1408
|
+
return /* @__PURE__ */ ae(fe.Provider, { value: t, children: /* @__PURE__ */ ae(Mt, { children: n }) });
|
|
1386
1409
|
};
|
|
1387
1410
|
export {
|
|
1388
1411
|
z as X,
|
|
1389
1412
|
H as a,
|
|
1390
|
-
|
|
1413
|
+
_t as b,
|
|
1391
1414
|
F as c,
|
|
1392
|
-
|
|
1393
|
-
|
|
1415
|
+
zt as d,
|
|
1416
|
+
Ot as e,
|
|
1394
1417
|
He as f,
|
|
1395
|
-
|
|
1418
|
+
Pt as g,
|
|
1396
1419
|
I as l,
|
|
1397
|
-
|
|
1420
|
+
Ut as u
|
|
1398
1421
|
};
|