@driftengine/xr 4.7.3 → 4.7.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/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # @driftengine/xr
2
2
 
3
- WebXR sessions, stereo views, controller input and hand joints, over both backends.
3
+ WebXR sessions, each eye's view and projection, controller input and hand joints, with a layer on
4
+ either backend. **Drawing into a headset is not built yet**: see below.
4
5
 
5
6
  **A package and not part of core**, so a game that never enters a session carries none of it. It
6
7
  supplies views to a camera; nothing in core reaches back for a session.
7
8
 
8
9
  ```ts
9
10
  import { startLoop } from '@driftengine/core';
10
- import { aimCameraAtEye, enterXr, eyeViews, probeXrSupport } from '@driftengine/xr';
11
+ import { aimCameraAtEye, enterXr, eyeViews } from '@driftengine/xr';
12
+ import type { XrFrame } from '@driftengine/xr';
11
13
 
12
14
  // From a click. requestSession needs a user gesture and no wrapper can change that.
13
15
  const entered = await enterXr({ sources: { gl }, optionalFeatures: ['hand-tracking'] });
@@ -22,11 +24,10 @@ const stop = startLoop(
22
24
  simulate: (dt, tick) => world.step(dt, tick),
23
25
  render: (alpha, dt, wallDt, frame) => {
24
26
  const pose = (frame as XrFrame).getViewerPose(run.referenceSpace);
25
- if (pose === null) return; // Tracking lost. Draw nothing rather than draw it wrong.
27
+ if (pose === null || pose === undefined) return; // Tracking lost.
26
28
  for (const eye of eyeViews(pose, run.layer.baseLayer)) {
27
29
  aimCameraAtEye(camera, eye);
28
- renderer.setViewport(eye.viewport);
29
- renderer.draw(scene, camera);
30
+ // Drawing `camera` into `eye.viewport` of the layer is the step the renderer lacks.
30
31
  }
31
32
  },
32
33
  },
@@ -36,6 +37,15 @@ const stop = startLoop(
36
37
  run.onEnd(stop);
37
38
  ```
38
39
 
40
+ ## Drawing into a headset is not built
41
+
42
+ A session composites a layer: on WebGL2 the `XRWebGLLayer`'s framebuffer, one viewport an eye, and
43
+ on WebGPU a texture an eye from the binding. Core's renderer draws into its own canvas and has no
44
+ call that points a frame at either, and it does not hand out the WebGL2 context or GPU device that
45
+ `sources` asks for. So a session can be entered and read, poses, controllers and hands included,
46
+ and the headset shows nothing. `docs/IMPROVEMENTS.md` in the engine repository records what it
47
+ would take.
48
+
39
49
  ## The camera is supplied, not configured
40
50
 
41
51
  `Camera` derives its view from yaw and pitch and its projection from `mat4.perspective`, and it
@@ -122,12 +122,6 @@ export function syntheticXr(options = {}) {
122
122
  hand,
123
123
  };
124
124
  });
125
- const viewport = (index) => ({
126
- x: index * 512,
127
- y: 0,
128
- width: 512,
129
- height: 512,
130
- });
131
125
  const frameFor = (session) => ({
132
126
  session,
133
127
  getViewerPose() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftengine/xr",
3
- "version": "4.7.3",
3
+ "version": "4.7.4",
4
4
  "description": "WebXR sessions, stereo views, controller input and hand joints, over both backends",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "gl-matrix": "^3.4.3"
31
31
  },
32
32
  "peerDependencies": {
33
- "@driftengine/core": "4.7.3"
33
+ "@driftengine/core": "4.7.4"
34
34
  },
35
35
  "author": "Drift Technologies",
36
36
  "repository": {
@@ -182,13 +182,6 @@ export function syntheticXr(options: SyntheticOptions = {}): SyntheticSystem {
182
182
  };
183
183
  });
184
184
 
185
- const viewport = (index: number): XrViewport => ({
186
- x: index * 512,
187
- y: 0,
188
- width: 512,
189
- height: 512,
190
- });
191
-
192
185
  const frameFor = (session: SyntheticSession): XrFrame => ({
193
186
  session,
194
187
  getViewerPose(): XrViewerPose | null {