@omnidotdev/rdk 0.8.0 → 0.9.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/build/ImmersiveSession-BiX-Du0K.cjs +1 -0
- package/build/ImmersiveSession-CJRYdHjb.js +21 -0
- package/build/WorldAnchor-gszXX9H2.cjs +1 -0
- package/build/WorldAnchor-ur1RjMrN.js +167 -0
- package/build/fiducial.cjs +1 -0
- package/build/fiducial.d.ts +2 -0
- package/build/fiducial.js +7 -0
- package/build/fiducialBackend-Cr8mdwro.cjs +1 -0
- package/build/fiducialBackend-Vj5N1epW.js +180 -0
- package/build/geolocation.cjs +1 -0
- package/build/geolocation.d.ts +2 -0
- package/build/geolocation.js +9 -0
- package/build/geolocationBackend-BkS2-zqx.cjs +1 -0
- package/build/geolocationBackend-BxwE8Vcl.js +338 -0
- package/build/immersive.cjs +1 -0
- package/build/immersive.d.ts +2 -0
- package/build/immersive.js +4 -0
- package/build/index.cjs +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +31 -672
- package/build/lib/types/engine/backend/Backend.interface.d.ts +1 -0
- package/build/lib/types/engine/backend/Backend.interface.d.ts.map +1 -1
- package/build/magic/MagicSession.d.ts +14 -0
- package/build/magic/MagicSession.d.ts.map +1 -0
- package/build/magic/WorldAnchor.d.ts +21 -0
- package/build/magic/WorldAnchor.d.ts.map +1 -0
- package/build/magic/index.d.ts +7 -0
- package/build/magic/index.d.ts.map +1 -0
- package/build/magic/magicBackend.d.ts +57 -0
- package/build/magic/magicBackend.d.ts.map +1 -0
- package/build/magic.cjs +1 -0
- package/build/magic.d.ts +2 -0
- package/build/magic.js +6 -0
- package/build/useXRStore-eThHhTNv.js +149 -0
- package/build/useXRStore-emhiLtDT.cjs +1 -0
- package/package.json +24 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Backend.interface.d.ts","sourceRoot":"","sources":["../../../../../src/lib/types/engine/backend/Backend.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"Backend.interface.d.ts","sourceRoot":"","sources":["../../../../../src/lib/types/engine/backend/Backend.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClD;;;OAGG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;OAGG;IACH,WAAW,IAAI,CAAC,CAAC;CAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { MagicSessionOptions } from './magicBackend';
|
|
3
|
+
export interface MagicSessionProps extends PropsWithChildren {
|
|
4
|
+
/** Magic window session options. */
|
|
5
|
+
options?: MagicSessionOptions;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manage the magic window AR backend.
|
|
9
|
+
* Registers with the XR session provider and provides device orientation
|
|
10
|
+
* tracking with camera passthrough capabilities.
|
|
11
|
+
*/
|
|
12
|
+
declare const MagicSession: ({ options, children }: MagicSessionProps) => import('react').ReactNode;
|
|
13
|
+
export default MagicSession;
|
|
14
|
+
//# sourceMappingURL=MagicSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MagicSession.d.ts","sourceRoot":"","sources":["../../src/magic/MagicSession.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,oCAAoC;IACpC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED;;;;GAIG;AACH,QAAA,MAAM,YAAY,GAAI,uBAA4B,iBAAiB,8BA4ClE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export interface WorldAnchorProps extends PropsWithChildren {
|
|
3
|
+
/** Position offset relative to the initial orientation. */
|
|
4
|
+
position?: [number, number, number];
|
|
5
|
+
/** Rotation offset in radians. */
|
|
6
|
+
rotation?: [number, number, number];
|
|
7
|
+
/** Scale factor. */
|
|
8
|
+
scale?: number | [number, number, number];
|
|
9
|
+
/**
|
|
10
|
+
* Whether the anchor should face the camera every frame.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
isBillboard?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* World anchor that positions children relative to the device's initial orientation.
|
|
17
|
+
* Uses the magic window backend's orientation data for world-space positioning.
|
|
18
|
+
*/
|
|
19
|
+
declare const WorldAnchor: ({ position, rotation, scale, isBillboard, children, }: WorldAnchorProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default WorldAnchor;
|
|
21
|
+
//# sourceMappingURL=WorldAnchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorldAnchor.d.ts","sourceRoot":"","sources":["../../src/magic/WorldAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,kCAAkC;IAClC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,QAAA,MAAM,WAAW,GAAI,uDAMlB,gBAAgB,4CA0ClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as MagicSession } from './MagicSession';
|
|
2
|
+
export { default as createMagicBackend } from './magicBackend';
|
|
3
|
+
export { default as WorldAnchor } from './WorldAnchor';
|
|
4
|
+
export type { MagicSessionProps } from './MagicSession';
|
|
5
|
+
export type { MagicInternal, MagicSessionOptions, } from './magicBackend';
|
|
6
|
+
export type { WorldAnchorProps } from './WorldAnchor';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/magic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Backend } from 'lib/types/engine';
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
/**
|
|
4
|
+
* Internal state exposed by the magic window backend.
|
|
5
|
+
*/
|
|
6
|
+
export interface MagicInternal {
|
|
7
|
+
videoElement: HTMLVideoElement | null;
|
|
8
|
+
videoTexture: THREE.VideoTexture | null;
|
|
9
|
+
stream: MediaStream | null;
|
|
10
|
+
orientationEnabled: boolean;
|
|
11
|
+
orientationPermissionGranted: boolean;
|
|
12
|
+
worldAnchoringEnabled: boolean;
|
|
13
|
+
currentOrientation: {
|
|
14
|
+
alpha: number;
|
|
15
|
+
beta: number;
|
|
16
|
+
gamma: number;
|
|
17
|
+
};
|
|
18
|
+
initialOrientation: {
|
|
19
|
+
alpha: number;
|
|
20
|
+
beta: number;
|
|
21
|
+
gamma: number;
|
|
22
|
+
};
|
|
23
|
+
hasInitialOrientation: boolean;
|
|
24
|
+
/** Request device orientation permission (must be called from user gesture on iOS) */
|
|
25
|
+
requestOrientationPermission: () => Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for the magic window backend.
|
|
29
|
+
*/
|
|
30
|
+
export interface MagicSessionOptions {
|
|
31
|
+
/** Whether to enable device orientation tracking. */
|
|
32
|
+
enableOrientation?: boolean;
|
|
33
|
+
/** Whether to enable world anchoring (orientation-based positioning). */
|
|
34
|
+
enableWorldAnchoring?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Smoothing factor for orientation interpolation (0-1).
|
|
37
|
+
* Lower values produce smoother but more delayed movement.
|
|
38
|
+
* @default 0.15
|
|
39
|
+
*/
|
|
40
|
+
smoothingFactor?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Dead zone threshold in degrees.
|
|
43
|
+
* Orientation changes smaller than this value are ignored to prevent jitter.
|
|
44
|
+
* @default 0.5
|
|
45
|
+
*/
|
|
46
|
+
deadZone?: number;
|
|
47
|
+
/** Custom webcam constraints. */
|
|
48
|
+
webcamConstraints?: MediaStreamConstraints;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a magic window AR backend.
|
|
52
|
+
* Provides device orientation tracking and camera passthrough without
|
|
53
|
+
* requiring WebXR, using standard browser APIs (DeviceOrientation + getUserMedia).
|
|
54
|
+
*/
|
|
55
|
+
declare const createMagicBackend: (options?: MagicSessionOptions) => Backend<MagicInternal>;
|
|
56
|
+
export default createMagicBackend;
|
|
57
|
+
//# sourceMappingURL=magicBackend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magicBackend.d.ts","sourceRoot":"","sources":["../../src/magic/magicBackend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,YAAY,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IACxC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,4BAA4B,EAAE,OAAO,CAAC;IACtC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kBAAkB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,kBAAkB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,sFAAsF;IACtF,4BAA4B,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;CAC5C;AAMD;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,GACtB,UAAU,mBAAmB,KAC5B,OAAO,CAAC,aAAa,CA2avB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/build/magic.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./WorldAnchor-gszXX9H2.cjs");exports.MagicSession=e.MagicSession;exports.WorldAnchor=e.WorldAnchor;exports.createMagicBackend=e.createMagicBackend;
|
package/build/magic.d.ts
ADDED
package/build/magic.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import b from "react";
|
|
2
|
+
const S = {
|
|
3
|
+
FIDUCIAL: "fiducial",
|
|
4
|
+
GEOLOCATION: "geolocation",
|
|
5
|
+
IMMERSIVE: "immersive",
|
|
6
|
+
MAGIC: "magic"
|
|
7
|
+
}, y = (e) => {
|
|
8
|
+
let t;
|
|
9
|
+
const n = /* @__PURE__ */ new Set(), r = (c, d) => {
|
|
10
|
+
const a = typeof c == "function" ? c(t) : c;
|
|
11
|
+
if (!Object.is(a, t)) {
|
|
12
|
+
const m = t;
|
|
13
|
+
t = d ?? (typeof a != "object" || a === null) ? a : Object.assign({}, t, a), n.forEach((f) => f(t, m));
|
|
14
|
+
}
|
|
15
|
+
}, s = () => t, u = { setState: r, getState: s, getInitialState: () => i, subscribe: (c) => (n.add(c), () => n.delete(c)) }, i = t = e(r, s, u);
|
|
16
|
+
return u;
|
|
17
|
+
}, h = ((e) => e ? y(e) : y), w = (e) => e;
|
|
18
|
+
function E(e, t = w) {
|
|
19
|
+
const n = b.useSyncExternalStore(
|
|
20
|
+
e.subscribe,
|
|
21
|
+
b.useCallback(() => t(e.getState()), [e, t]),
|
|
22
|
+
b.useCallback(() => t(e.getInitialState()), [e, t])
|
|
23
|
+
);
|
|
24
|
+
return b.useDebugValue(n), n;
|
|
25
|
+
}
|
|
26
|
+
const j = (e) => {
|
|
27
|
+
const t = h(e), n = (r) => E(t, r);
|
|
28
|
+
return Object.assign(n, t), n;
|
|
29
|
+
}, M = ((e) => j), x = (e) => (t, n, r) => {
|
|
30
|
+
const s = r.subscribe;
|
|
31
|
+
return r.subscribe = ((l, u, i) => {
|
|
32
|
+
let c = l;
|
|
33
|
+
if (u) {
|
|
34
|
+
const d = i?.equalityFn || Object.is;
|
|
35
|
+
let a = l(r.getState());
|
|
36
|
+
c = (m) => {
|
|
37
|
+
const f = l(m);
|
|
38
|
+
if (!d(a, f)) {
|
|
39
|
+
const k = a;
|
|
40
|
+
u(a = f, k);
|
|
41
|
+
}
|
|
42
|
+
}, i?.fireImmediately && u(a, a);
|
|
43
|
+
}
|
|
44
|
+
return s(c);
|
|
45
|
+
}), e(t, n, r);
|
|
46
|
+
}, R = x, p = (e) => Symbol.iterator in e, g = (e) => (
|
|
47
|
+
// HACK: avoid checking entries type
|
|
48
|
+
"entries" in e
|
|
49
|
+
), O = (e, t) => {
|
|
50
|
+
const n = e instanceof Map ? e : new Map(e.entries()), r = t instanceof Map ? t : new Map(t.entries());
|
|
51
|
+
if (n.size !== r.size)
|
|
52
|
+
return !1;
|
|
53
|
+
for (const [s, o] of n)
|
|
54
|
+
if (!r.has(s) || !Object.is(o, r.get(s)))
|
|
55
|
+
return !1;
|
|
56
|
+
return !0;
|
|
57
|
+
}, C = (e, t) => {
|
|
58
|
+
const n = e[Symbol.iterator](), r = t[Symbol.iterator]();
|
|
59
|
+
let s = n.next(), o = r.next();
|
|
60
|
+
for (; !s.done && !o.done; ) {
|
|
61
|
+
if (!Object.is(s.value, o.value))
|
|
62
|
+
return !1;
|
|
63
|
+
s = n.next(), o = r.next();
|
|
64
|
+
}
|
|
65
|
+
return !!s.done && !!o.done;
|
|
66
|
+
};
|
|
67
|
+
function F(e, t) {
|
|
68
|
+
return Object.is(e, t) ? !0 : typeof e != "object" || e === null || typeof t != "object" || t === null || Object.getPrototypeOf(e) !== Object.getPrototypeOf(t) ? !1 : p(e) && p(t) ? g(e) && g(t) ? O(e, t) : C(e, t) : O(
|
|
69
|
+
{ entries: () => Object.entries(e) },
|
|
70
|
+
{ entries: () => Object.entries(t) }
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function T(e) {
|
|
74
|
+
const t = b.useRef(void 0);
|
|
75
|
+
return (n) => {
|
|
76
|
+
const r = e(n);
|
|
77
|
+
return F(t.current, r) ? t.current : t.current = r;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const I = M()(
|
|
81
|
+
R((e, t) => ({
|
|
82
|
+
// initial state
|
|
83
|
+
video: null,
|
|
84
|
+
backends: /* @__PURE__ */ new Map(),
|
|
85
|
+
immersiveStore: null,
|
|
86
|
+
// actions
|
|
87
|
+
registerBackend: async (n, r) => {
|
|
88
|
+
try {
|
|
89
|
+
const s = t(), o = new Set(s.backends.keys()), l = o.has(S.FIDUCIAL) || n.type === S.FIDUCIAL, u = o.has(S.GEOLOCATION) || n.type === S.GEOLOCATION;
|
|
90
|
+
if (l && u) {
|
|
91
|
+
const i = "❌ [RDK] INCOMPATIBLE SESSIONS: fiducial and geolocation backends cannot be used together due to camera/video conflicts between AR.js and LocAR.js libraries. Use only one session type per app.";
|
|
92
|
+
throw console.error(i), new Error(i);
|
|
93
|
+
}
|
|
94
|
+
await n.init({
|
|
95
|
+
scene: r.scene,
|
|
96
|
+
camera: r.camera,
|
|
97
|
+
renderer: r.renderer
|
|
98
|
+
}), e((i) => {
|
|
99
|
+
const c = new Map(i.backends);
|
|
100
|
+
return c.set(n.type, n), { backends: c };
|
|
101
|
+
});
|
|
102
|
+
} catch (s) {
|
|
103
|
+
throw console.error("[XRStore] Failed to register backend:", s), s;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
unregisterBackend: (n) => {
|
|
107
|
+
e((r) => {
|
|
108
|
+
const s = new Map(r.backends);
|
|
109
|
+
s.delete(n.type);
|
|
110
|
+
try {
|
|
111
|
+
n.dispose?.();
|
|
112
|
+
} catch (o) {
|
|
113
|
+
console.error("[XRStore] Error disposing backend:", o);
|
|
114
|
+
}
|
|
115
|
+
return { backends: s };
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
setVideo: (n) => {
|
|
119
|
+
e({ video: n });
|
|
120
|
+
},
|
|
121
|
+
updateBackends: (n) => {
|
|
122
|
+
const { backends: r } = t();
|
|
123
|
+
for (const s of r.values())
|
|
124
|
+
try {
|
|
125
|
+
s.update?.(n);
|
|
126
|
+
} catch (o) {
|
|
127
|
+
console.error("[XRStore] Backend update error:", o);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
setImmersiveStore: (n) => {
|
|
131
|
+
e({ immersiveStore: n });
|
|
132
|
+
}
|
|
133
|
+
}))
|
|
134
|
+
), D = () => I.getState(), L = I.subscribe, N = (e) => I(
|
|
135
|
+
T((n) => {
|
|
136
|
+
const r = {
|
|
137
|
+
...n,
|
|
138
|
+
isImmersive: n.backends.has(S.IMMERSIVE),
|
|
139
|
+
immersive: n.immersiveStore || null
|
|
140
|
+
};
|
|
141
|
+
return e ? e(r) : r;
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
export {
|
|
145
|
+
S as B,
|
|
146
|
+
D as g,
|
|
147
|
+
L as s,
|
|
148
|
+
N as u
|
|
149
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("react"),b={FIDUCIAL:"fiducial",GEOLOCATION:"geolocation",IMMERSIVE:"immersive",MAGIC:"magic"},y=e=>{let t;const r=new Set,n=(c,d)=>{const a=typeof c=="function"?c(t):c;if(!Object.is(a,t)){const m=t;t=d??(typeof a!="object"||a===null)?a:Object.assign({},t,a),r.forEach(f=>f(t,m))}},s=()=>t,u={setState:n,getState:s,getInitialState:()=>i,subscribe:c=>(r.add(c),()=>r.delete(c))},i=t=e(n,s,u);return u},E=(e=>e?y(e):y),h=e=>e;function w(e,t=h){const r=l.useSyncExternalStore(e.subscribe,l.useCallback(()=>t(e.getState()),[e,t]),l.useCallback(()=>t(e.getInitialState()),[e,t]));return l.useDebugValue(r),r}const j=e=>{const t=E(e),r=n=>w(t,n);return Object.assign(r,t),r},R=(e=>j),M=e=>(t,r,n)=>{const s=n.subscribe;return n.subscribe=((S,u,i)=>{let c=S;if(u){const d=i?.equalityFn||Object.is;let a=S(n.getState());c=m=>{const f=S(m);if(!d(a,f)){const k=a;u(a=f,k)}},i?.fireImmediately&&u(a,a)}return s(c)}),e(t,r,n)},C=M,g=e=>Symbol.iterator in e,p=e=>"entries"in e,O=(e,t)=>{const r=e instanceof Map?e:new Map(e.entries()),n=t instanceof Map?t:new Map(t.entries());if(r.size!==n.size)return!1;for(const[s,o]of r)if(!n.has(s)||!Object.is(o,n.get(s)))return!1;return!0},x=(e,t)=>{const r=e[Symbol.iterator](),n=t[Symbol.iterator]();let s=r.next(),o=n.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=r.next(),o=n.next()}return!!s.done&&!!o.done};function X(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:g(e)&&g(t)?p(e)&&p(t)?O(e,t):x(e,t):O({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function T(e){const t=l.useRef(void 0);return r=>{const n=e(r);return X(t.current,n)?t.current:t.current=n}}const I=R()(C((e,t)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(r,n)=>{try{const s=t(),o=new Set(s.backends.keys()),S=o.has(b.FIDUCIAL)||r.type===b.FIDUCIAL,u=o.has(b.GEOLOCATION)||r.type===b.GEOLOCATION;if(S&&u){const i="❌ [RDK] INCOMPATIBLE SESSIONS: fiducial and geolocation backends cannot be used together due to camera/video conflicts between AR.js and LocAR.js libraries. Use only one session type per app.";throw console.error(i),new Error(i)}await r.init({scene:n.scene,camera:n.camera,renderer:n.renderer}),e(i=>{const c=new Map(i.backends);return c.set(r.type,r),{backends:c}})}catch(s){throw console.error("[XRStore] Failed to register backend:",s),s}},unregisterBackend:r=>{e(n=>{const s=new Map(n.backends);s.delete(r.type);try{r.dispose?.()}catch(o){console.error("[XRStore] Error disposing backend:",o)}return{backends:s}})},setVideo:r=>{e({video:r})},updateBackends:r=>{const{backends:n}=t();for(const s of n.values())try{s.update?.(r)}catch(o){console.error("[XRStore] Backend update error:",o)}},setImmersiveStore:r=>{e({immersiveStore:r})}}))),D=()=>I.getState(),F=I.subscribe,N=e=>I(T(r=>{const n={...r,isImmersive:r.backends.has(b.IMMERSIVE),immersive:r.immersiveStore||null};return e?e(n):n}));exports.BACKEND_TYPES=b;exports.getXRStore=D;exports.subscribeToXRStore=F;exports.useXRStore=N;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnidotdev/rdk",
|
|
3
3
|
"description": "AR.js with react-three-fiber",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
9
9
|
"types": "build/index.d.ts",
|
|
10
|
-
"homepage": "https://github.com/omnidotdev/rdk#readme",
|
|
10
|
+
"homepage": "https://github.com/omnidotdev/rdk-framework#readme",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/omnidotdev/rdk.git"
|
|
13
|
+
"url": "git+https://github.com/omnidotdev/rdk-framework.git"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/omnidotdev/rdk/issues"
|
|
16
|
+
"url": "https://github.com/omnidotdev/rdk-framework/issues"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"build/"
|
|
@@ -31,6 +31,26 @@
|
|
|
31
31
|
"types": "./build/index.d.ts",
|
|
32
32
|
"import": "./build/index.js",
|
|
33
33
|
"require": "./build/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./fiducial": {
|
|
36
|
+
"types": "./build/fiducial.d.ts",
|
|
37
|
+
"import": "./build/fiducial.js",
|
|
38
|
+
"require": "./build/fiducial.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./geolocation": {
|
|
41
|
+
"types": "./build/geolocation.d.ts",
|
|
42
|
+
"import": "./build/geolocation.js",
|
|
43
|
+
"require": "./build/geolocation.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./immersive": {
|
|
46
|
+
"types": "./build/immersive.d.ts",
|
|
47
|
+
"import": "./build/immersive.js",
|
|
48
|
+
"require": "./build/immersive.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./magic": {
|
|
51
|
+
"types": "./build/magic.d.ts",
|
|
52
|
+
"import": "./build/magic.js",
|
|
53
|
+
"require": "./build/magic.cjs"
|
|
34
54
|
}
|
|
35
55
|
},
|
|
36
56
|
"scripts": {
|