@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/types.d.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/** Session kind: a windowed tracking-only session, or an immersive headset session. */
|
|
2
|
+
export type XRMode = 'inline' | 'immersive-vr' | 'immersive-ar';
|
|
3
|
+
/** An opaque WebXR reference or pose space. */
|
|
4
|
+
export type XRSpace = object;
|
|
5
|
+
/** A tracked pose: a matrix, its inverse, and position and orientation. */
|
|
6
|
+
export interface XRPose {
|
|
7
|
+
transform: {
|
|
8
|
+
matrix: Float32Array;
|
|
9
|
+
inverse: {
|
|
10
|
+
matrix: Float32Array;
|
|
11
|
+
};
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
z: number;
|
|
16
|
+
w: number;
|
|
17
|
+
};
|
|
18
|
+
orientation: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
z: number;
|
|
22
|
+
w: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
emulatedPosition: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** One eye of a viewer pose. */
|
|
28
|
+
export interface XRView {
|
|
29
|
+
eye: 'left' | 'right' | 'none';
|
|
30
|
+
projectionMatrix: Float32Array;
|
|
31
|
+
transform: XRPose['transform'];
|
|
32
|
+
}
|
|
33
|
+
/** The viewer pose, with one view per eye. */
|
|
34
|
+
export interface XRViewerPose extends XRPose {
|
|
35
|
+
views: readonly XRView[];
|
|
36
|
+
}
|
|
37
|
+
/** A controller, hand, gaze or screen input. */
|
|
38
|
+
export interface XRInputSource {
|
|
39
|
+
handedness: 'left' | 'right' | 'none';
|
|
40
|
+
targetRayMode: 'gaze' | 'tracked-pointer' | 'screen' | 'transient-pointer';
|
|
41
|
+
targetRaySpace: XRSpace;
|
|
42
|
+
gripSpace?: XRSpace;
|
|
43
|
+
gamepad?: Gamepad;
|
|
44
|
+
profiles: readonly string[];
|
|
45
|
+
hand?: ReadonlyMap<string, XRSpace>;
|
|
46
|
+
}
|
|
47
|
+
/** One XR animation frame, as the browser provides it. */
|
|
48
|
+
export interface XRNativeFrame {
|
|
49
|
+
session: XRNativeSession;
|
|
50
|
+
getViewerPose(space: XRSpace): XRViewerPose | null;
|
|
51
|
+
getPose(space: XRSpace, relativeTo: XRSpace): XRPose | null;
|
|
52
|
+
getJointPose?(space: XRSpace, relativeTo: XRSpace): XRPose | null;
|
|
53
|
+
/** WebXR Body Tracking Module (session feature 'body-tracking'): the tracked body, or null/absent without it. */
|
|
54
|
+
readonly body?: XRBodyLike | null;
|
|
55
|
+
/** WebXR Hit Test Module: this frame's results for a hit test source, nearest first. */
|
|
56
|
+
getHitTestResults?(source: XRHitTestSource): readonly XRHitTestResult[];
|
|
57
|
+
/** WebXR Hit Test Module: this frame's results for a transient-input source, one entry per input source. */
|
|
58
|
+
getHitTestResultsForTransientInput?(source: XRTransientInputHitTestSource): readonly XRTransientInputHitTestResult[];
|
|
59
|
+
}
|
|
60
|
+
/** WebXR Body Tracking Module: an XRBody, one tracked space per joint. */
|
|
61
|
+
export interface XRBodyLike {
|
|
62
|
+
readonly size: number;
|
|
63
|
+
get(joint: string): XRSpace | undefined;
|
|
64
|
+
}
|
|
65
|
+
/** WebXR Hit Test Module: what the real world a ray is tested against. */
|
|
66
|
+
export type XRHitTestTrackableType = 'point' | 'plane' | 'mesh';
|
|
67
|
+
/** A ray offset from its space's origin, as the browser's `XRRay` (origin and direction in that space). */
|
|
68
|
+
export interface XRRayLike {
|
|
69
|
+
origin: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
z: number;
|
|
73
|
+
w: number;
|
|
74
|
+
};
|
|
75
|
+
direction: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
z: number;
|
|
79
|
+
w: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** A subscription to hit tests along a space's ray; `cancel()` ends it. */
|
|
83
|
+
export interface XRHitTestSource {
|
|
84
|
+
cancel(): void;
|
|
85
|
+
}
|
|
86
|
+
/** A subscription to hit tests along the rays of transient inputs (screen taps) of one profile. */
|
|
87
|
+
export interface XRTransientInputHitTestSource {
|
|
88
|
+
cancel(): void;
|
|
89
|
+
}
|
|
90
|
+
/** One intersection of a hit-test ray with the real world. */
|
|
91
|
+
export interface XRHitTestResult {
|
|
92
|
+
getPose(baseSpace: XRSpace): XRPose | null;
|
|
93
|
+
/** WebXR Anchors Module, where supported. */
|
|
94
|
+
createAnchor?(): Promise<XRAnchor>;
|
|
95
|
+
}
|
|
96
|
+
/** The results of one transient input source. */
|
|
97
|
+
export interface XRTransientInputHitTestResult {
|
|
98
|
+
readonly inputSource: XRInputSource;
|
|
99
|
+
readonly results: readonly XRHitTestResult[];
|
|
100
|
+
}
|
|
101
|
+
/** WebXR Anchors Module: a pose the device keeps tracking as its understanding of the world improves. */
|
|
102
|
+
export interface XRAnchor {
|
|
103
|
+
readonly anchorSpace: XRSpace;
|
|
104
|
+
delete(): void;
|
|
105
|
+
}
|
|
106
|
+
/** The browser XRSession, as far as Margo uses it. */
|
|
107
|
+
export interface XRNativeSession extends EventTarget {
|
|
108
|
+
inputSources: readonly XRInputSource[];
|
|
109
|
+
enabledFeatures?: readonly string[];
|
|
110
|
+
/** WebXR Hit Test Module (session feature 'hit-test'). */
|
|
111
|
+
requestHitTestSource?(options: {
|
|
112
|
+
space: XRSpace;
|
|
113
|
+
entityTypes?: XRHitTestTrackableType[];
|
|
114
|
+
offsetRay?: XRRayLike;
|
|
115
|
+
}): Promise<XRHitTestSource>;
|
|
116
|
+
/** WebXR Hit Test Module (session feature 'hit-test'). */
|
|
117
|
+
requestHitTestSourceForTransientInput?(options: {
|
|
118
|
+
profile: string;
|
|
119
|
+
entityTypes?: XRHitTestTrackableType[];
|
|
120
|
+
offsetRay?: XRRayLike;
|
|
121
|
+
}): Promise<XRTransientInputHitTestSource>;
|
|
122
|
+
requestReferenceSpace(type: string): Promise<XRSpace>;
|
|
123
|
+
updateRenderState(state: {
|
|
124
|
+
/** The projection layer, and with the WebXR Layers module any composition layers around it. */
|
|
125
|
+
layers?: readonly object[];
|
|
126
|
+
baseLayer?: unknown;
|
|
127
|
+
/** Runtime foveation, from zero to one; null or absent when unsupported. */
|
|
128
|
+
fixedFoveation?: number | null;
|
|
129
|
+
depthNear?: number;
|
|
130
|
+
depthFar?: number;
|
|
131
|
+
}): void;
|
|
132
|
+
requestAnimationFrame(callback: (time: number, frame: XRNativeFrame) => void): number;
|
|
133
|
+
cancelAnimationFrame(handle: number): void;
|
|
134
|
+
end(): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/** The browser `navigator.xr`, as far as Margo uses it. */
|
|
137
|
+
export interface XRSystem {
|
|
138
|
+
isSessionSupported(mode: XRMode): Promise<boolean>;
|
|
139
|
+
requestSession(mode: XRMode, init: {
|
|
140
|
+
requiredFeatures: string[];
|
|
141
|
+
optionalFeatures: string[];
|
|
142
|
+
}): Promise<XRNativeSession>;
|
|
143
|
+
}
|
|
144
|
+
/** A WebGPU projection layer; destroy it when the session ends. */
|
|
145
|
+
export interface XRProjectionLayer {
|
|
146
|
+
/** The XRWebGLLayer to show instead of this layer, on a binding that draws through one. */
|
|
147
|
+
baseLayer?: unknown;
|
|
148
|
+
/** Runtime foveation, from zero to one; null or absent when unsupported. */
|
|
149
|
+
fixedFoveation?: number | null;
|
|
150
|
+
destroy(): void;
|
|
151
|
+
}
|
|
152
|
+
/** The texture and viewport of one eye in a projection layer. */
|
|
153
|
+
export interface XRSubImage {
|
|
154
|
+
colorTexture: GPUTexture;
|
|
155
|
+
depthStencilTexture: GPUTexture | null;
|
|
156
|
+
viewport: {
|
|
157
|
+
x: number;
|
|
158
|
+
y: number;
|
|
159
|
+
width: number;
|
|
160
|
+
height: number;
|
|
161
|
+
};
|
|
162
|
+
getViewDescriptor(): GPUTextureViewDescriptor;
|
|
163
|
+
}
|
|
164
|
+
/** The WebGPU XR binding (`XRGPUBinding`) that creates layers and sub-images. */
|
|
165
|
+
export interface XRBinding {
|
|
166
|
+
getPreferredColorFormat(): GPUTextureFormat;
|
|
167
|
+
createProjectionLayer(init: {
|
|
168
|
+
colorFormat: GPUTextureFormat;
|
|
169
|
+
depthStencilFormat: GPUTextureFormat;
|
|
170
|
+
/** Projection scale, defaults to the runtime recommendation. */
|
|
171
|
+
scaleFactor?: number;
|
|
172
|
+
}): XRProjectionLayer;
|
|
173
|
+
getViewSubImage(layer: XRProjectionLayer, view: XRView): XRSubImage;
|
|
174
|
+
/** The view's projection, where the session's differs from clip space with z in [0, 1]. */
|
|
175
|
+
projection?(view: XRView): ArrayLike<number>;
|
|
176
|
+
/** Shows the frame's sub-images, on a binding that does not draw straight into the session's layer. */
|
|
177
|
+
present?(layer: XRProjectionLayer): void;
|
|
178
|
+
/**
|
|
179
|
+
* GPU-optimized depth for `view` (WebXR Depth Sensing Module, XRGPUDepthInformation), on a session started with
|
|
180
|
+
* usagePreference ['gpu-optimized']; null while the device has none this frame.
|
|
181
|
+
*/
|
|
182
|
+
getDepthInformation?(view: XRView): XRGPUDepthLike | null;
|
|
183
|
+
/**
|
|
184
|
+
* The probe's reflection cube map (WebXR Lighting Estimation, `getReflectionCubeMap`), where the binding gives it as a
|
|
185
|
+
* WebGPU texture: 6 array layers, `rgba16float`; null while the device has none.
|
|
186
|
+
*/
|
|
187
|
+
getReflectionCubeMap?(probe: object): GPUTexture | null;
|
|
188
|
+
}
|
|
189
|
+
/** The browser's XRGPUDepthInformation, as far as Margo reads it: an r32float or r16uint texture valid this frame. */
|
|
190
|
+
export interface XRGPUDepthLike {
|
|
191
|
+
readonly width: number;
|
|
192
|
+
readonly height: number;
|
|
193
|
+
readonly rawValueToMeters: number;
|
|
194
|
+
readonly normDepthBufferFromNormView: {
|
|
195
|
+
readonly matrix: Float32Array;
|
|
196
|
+
};
|
|
197
|
+
readonly texture: GPUTexture;
|
|
198
|
+
getViewDescriptor?(): GPUTextureViewDescriptor;
|
|
199
|
+
/** XRViewGeometry of the sensor, where it differs from the view. */
|
|
200
|
+
readonly projectionMatrix?: Float32Array;
|
|
201
|
+
readonly transform?: {
|
|
202
|
+
readonly matrix: Float32Array;
|
|
203
|
+
readonly inverse: {
|
|
204
|
+
readonly matrix: Float32Array;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/** One input source with its target-ray and grip poses. */
|
|
209
|
+
export interface XRInputPose {
|
|
210
|
+
source: XRInputSource;
|
|
211
|
+
targetRay: XRPose | null;
|
|
212
|
+
grip: XRPose | null;
|
|
213
|
+
}
|
|
214
|
+
/** State passed to `onFrame`; the object is reused, so copy what you keep. */
|
|
215
|
+
export interface XRFrameState {
|
|
216
|
+
time: number;
|
|
217
|
+
delta: number;
|
|
218
|
+
frame: XRNativeFrame;
|
|
219
|
+
viewer: XRViewerPose | null;
|
|
220
|
+
inputs: XRInputPose[];
|
|
221
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,154 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@margoengine/xr",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Optional WebGPU WebXR sessions, input poses and stereo rendering for Margo Engine, with real-device runs (./device-check).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"webgpu",
|
|
8
|
+
"3d",
|
|
9
|
+
"webxr",
|
|
10
|
+
"vr",
|
|
11
|
+
"ar"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://margoengine.com",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
20
|
+
"directory": "packages/xr"
|
|
21
|
+
},
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"author": "Scott Campbell",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node ../../scripts/build-optional.js xr",
|
|
30
|
+
"test": "npm run build && node --test tests/*.test.js",
|
|
31
|
+
"prepack": "npm run build",
|
|
32
|
+
"test:gpu:pointers": "cd ../.. && node packages/xr/tests/pointer.browser.mjs",
|
|
33
|
+
"test:gpu:locomotion": "cd ../.. && node packages/xr/tests/locomotion.browser.mjs",
|
|
34
|
+
"test:gpu:hands": "cd ../.. && node packages/xr/tests/hands.browser.mjs",
|
|
35
|
+
"test:gpu:ar-extra": "cd ../.. && node packages/xr/tests/ar-extra.browser.mjs",
|
|
36
|
+
"test:gpu:performance": "cd ../.. && node packages/xr/tests/performance.browser.mjs",
|
|
37
|
+
"test:gpu:view-layers": "cd ../.. && node packages/xr/tests/view-layers.browser.mjs",
|
|
38
|
+
"test:gpu:ar-effects": "cd ../.. && node packages/xr/tests/ar-effects.browser.mjs",
|
|
39
|
+
"test:gpu:occlusion": "cd ../.. && node packages/xr/tests/occlusion.browser.mjs",
|
|
40
|
+
"test:gpu:reflection": "cd ../.. && node packages/xr/tests/reflection.browser.mjs"
|
|
41
|
+
},
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"import": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./device-check": {
|
|
49
|
+
"types": "./dist/device-check.d.ts",
|
|
50
|
+
"import": "./dist/device-check.js"
|
|
51
|
+
},
|
|
52
|
+
"./models": {
|
|
53
|
+
"types": "./dist/models.d.ts",
|
|
54
|
+
"import": "./dist/models.js"
|
|
55
|
+
},
|
|
56
|
+
"./ar": {
|
|
57
|
+
"types": "./dist/ar.d.ts",
|
|
58
|
+
"import": "./dist/ar.js"
|
|
59
|
+
},
|
|
60
|
+
"./occlusion": {
|
|
61
|
+
"types": "./dist/occlusion.d.ts",
|
|
62
|
+
"import": "./dist/occlusion.js"
|
|
63
|
+
},
|
|
64
|
+
"./session": {
|
|
65
|
+
"types": "./dist/session.d.ts",
|
|
66
|
+
"import": "./dist/session.js"
|
|
67
|
+
},
|
|
68
|
+
"./launch": {
|
|
69
|
+
"types": "./dist/launch.d.ts",
|
|
70
|
+
"import": "./dist/launch.js"
|
|
71
|
+
},
|
|
72
|
+
"./reflection": {
|
|
73
|
+
"types": "./dist/reflection.d.ts",
|
|
74
|
+
"import": "./dist/reflection.js"
|
|
75
|
+
},
|
|
76
|
+
"./layers": {
|
|
77
|
+
"types": "./dist/layers.d.ts",
|
|
78
|
+
"import": "./dist/layers.js"
|
|
79
|
+
},
|
|
80
|
+
"./interaction": {
|
|
81
|
+
"types": "./dist/interaction.d.ts",
|
|
82
|
+
"import": "./dist/interaction.js"
|
|
83
|
+
},
|
|
84
|
+
"./pointer": {
|
|
85
|
+
"types": "./dist/pointer.d.ts",
|
|
86
|
+
"import": "./dist/pointer.js"
|
|
87
|
+
},
|
|
88
|
+
"./locomotion": {
|
|
89
|
+
"types": "./dist/locomotion.d.ts",
|
|
90
|
+
"import": "./dist/locomotion.js"
|
|
91
|
+
},
|
|
92
|
+
"./hands": {
|
|
93
|
+
"types": "./dist/hands.d.ts",
|
|
94
|
+
"import": "./dist/hands.js"
|
|
95
|
+
},
|
|
96
|
+
"./ar-extra": {
|
|
97
|
+
"types": "./dist/ar-extra.d.ts",
|
|
98
|
+
"import": "./dist/ar-extra.js"
|
|
99
|
+
},
|
|
100
|
+
"./body": {
|
|
101
|
+
"types": "./dist/body.d.ts",
|
|
102
|
+
"import": "./dist/body.js"
|
|
103
|
+
},
|
|
104
|
+
"./performance": {
|
|
105
|
+
"types": "./dist/performance.d.ts",
|
|
106
|
+
"import": "./dist/performance.js"
|
|
107
|
+
},
|
|
108
|
+
"./near": {
|
|
109
|
+
"types": "./dist/near.d.ts",
|
|
110
|
+
"import": "./dist/near.js"
|
|
111
|
+
},
|
|
112
|
+
"./gizmo": {
|
|
113
|
+
"types": "./dist/gizmo.d.ts",
|
|
114
|
+
"import": "./dist/gizmo.js"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"files": [
|
|
118
|
+
"dist",
|
|
119
|
+
"NOTICE"
|
|
120
|
+
],
|
|
121
|
+
"peerDependencies": {
|
|
122
|
+
"@margoengine/core": "^1.0.0",
|
|
123
|
+
"@margoengine/selection": "^1.0.0",
|
|
124
|
+
"@margoengine/animation": "^1.0.0",
|
|
125
|
+
"@margoengine/gltf": "^1.0.0",
|
|
126
|
+
"@margoengine/geometry": "^1.0.0"
|
|
127
|
+
},
|
|
128
|
+
"dependencies": {
|
|
129
|
+
"@margoengine/math": "^1.0.0"
|
|
130
|
+
},
|
|
131
|
+
"peerDependenciesMeta": {
|
|
132
|
+
"@margoengine/selection": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"@margoengine/animation": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"@margoengine/gltf": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"@margoengine/geometry": {
|
|
142
|
+
"optional": true
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"margo": {
|
|
146
|
+
"gpuTestTimeoutMinutes": {
|
|
147
|
+
"test:gpu:pointers": 3,
|
|
148
|
+
"test:gpu:locomotion": 3,
|
|
149
|
+
"test:gpu:hands": 3,
|
|
150
|
+
"test:gpu:ar-extra": 3,
|
|
151
|
+
"test:gpu:performance": 3
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|