@displayxr/inline3d 1.2.1 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@displayxr/inline3d",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Turn any HTML <canvas> into a glasses-free-3D window on a DisplayXR display, inside an ordinary web page. Dependency-free; progressive enhancement (falls back to plain 2D everywhere else).",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
@@ -26,11 +26,16 @@
26
26
  "./model": {
27
27
  "types": "./model.d.ts",
28
28
  "import": "./js/inline3d-model.js"
29
+ },
30
+ "./undock": {
31
+ "types": "./index.d.ts",
32
+ "import": "./js/inline3d-undock.js"
29
33
  }
30
34
  },
31
35
  "sideEffects": false,
32
36
  "files": [
33
37
  "js/inline3d.js",
38
+ "js/inline3d-undock.js",
34
39
  "js/inline3d-three.js",
35
40
  "js/inline3d-viewer.js",
36
41
  "js/inline3d-splat.js",
package/three.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // These take your imported THREE namespace as a constructor arg, so the SDK never
3
3
  // bundles three.js (it is an optional peer dependency).
4
4
 
5
+ import type { XRViewRigInit } from './index.js';
6
+
5
7
  /**
6
8
  * A reusable three.js camera driven directly by an XRView's matrices. Construct once with your
7
9
  * THREE namespace and reuse across frames/windows. Read `.camera` and render it as-is — author
@@ -27,8 +29,84 @@ export class EyeCamera {
27
29
  projectionMatrix: ArrayLike<number>,
28
30
  transformMatrix: ArrayLike<number>,
29
31
  ): void;
32
+ /** Set the projection + LOCAL pose from an XRView — the attach pattern (see below). */
33
+ setLocalFromView(view: XRView): void;
34
+ /**
35
+ * Like {@link EyeCamera.setFromMatrices}, but the transform becomes the camera's **local**
36
+ * matrix and three composes `matrixWorld` from the parent — for the attach pattern: send an
37
+ * identity-posed camera rig, parent the eye cameras under your app camera, and the scene graph
38
+ * supplies this frame's world pose instead of the rig's one-frame-old one.
39
+ *
40
+ * `matrixAutoUpdate` is false but world composition still runs, so the eyes must be reached by
41
+ * a normal traversal: `renderer.render(scene, eye.camera)` auto-updates a camera only when its
42
+ * `parent` is null, so keep the app camera IN the scene (or call `scene.updateMatrixWorld()`).
43
+ */
44
+ setLocalFromMatrices(
45
+ projectionMatrix: ArrayLike<number>,
46
+ transformMatrix: ArrayLike<number>,
47
+ ): void;
48
+ }
49
+
50
+ /** Options for {@link cameraRigFromCamera}. */
51
+ export interface CameraRigOptions {
52
+ /** Zero-disparity distance in WORLD units — content there sits on the glass. 0 = infinity. */
53
+ convergence?: number;
54
+ /** Emit an IDENTITY pose for the attach pattern ({@link EyeCamera.setLocalFromMatrices}). */
55
+ attach?: boolean;
56
+ /** Eye separation, ABSOLUTE on a camera rig (default 1); 0 collapses to mono. */
57
+ ipdFactor?: number;
58
+ /** Head-tracking response, absolute likewise (default 1). */
59
+ parallaxFactor?: number;
60
+ /** Metres → world units on the eye (default 1). */
61
+ metersToVirtual?: number;
62
+ /** A descriptor to overwrite instead of allocating one (for a per-frame call). */
63
+ out?: XRViewRigInit;
30
64
  }
31
65
 
66
+ /** Options for {@link displayRig}. */
67
+ export interface DisplayRigOptions {
68
+ /** Metres of virtual display — the zoom knob (default 0.24). */
69
+ virtualDisplayHeight?: number;
70
+ /** Rig pose in app world units (default 0,0,0). */
71
+ position?: { x?: number; y?: number; z?: number };
72
+ /** Rig orientation quaternion (default identity). */
73
+ orientation?: { x?: number; y?: number; z?: number; w?: number };
74
+ /** Eye separation as a RELATIVE `[0,1]` multiplier (default 1). */
75
+ ipdFactor?: number;
76
+ /** Head-tracking response, `[0,1]` (default 1). */
77
+ parallaxFactor?: number;
78
+ /** Off-axis skew strength, `[0.1,10]` (default 1) — an effect, not a correctness knob. */
79
+ perspectiveFactor?: number;
80
+ /** A descriptor to overwrite instead of allocating one. */
81
+ out?: XRViewRigInit;
82
+ }
83
+
84
+ /**
85
+ * Build a CAMERA-rig descriptor from a `THREE.PerspectiveCamera` for `handle.setViewRig()`: the
86
+ * runtime keeps the camera's vertical FOV, offsets the eyes and skews each frustum so
87
+ * `convergence` lands on the zero-disparity plane. The pose is decomposed from `matrixWorld`
88
+ * (so a camera parented under a dolly still reports world space) unless `attach` is set, which
89
+ * emits identity instead.
90
+ *
91
+ * Comfort rule, from the runtime: `ipdFactor × metersToVirtual × convergenceDiopters × N <= 1`
92
+ * (N ≈ 0.5 m nominal viewing distance). Nothing here enforces it; the runtime clamps.
93
+ *
94
+ * @param THREE your imported three.js module namespace.
95
+ * @param camera a `THREE.PerspectiveCamera` (`.fov` degrees, `.matrixWorld`).
96
+ */
97
+ export function cameraRigFromCamera(
98
+ THREE: unknown,
99
+ camera: unknown,
100
+ opts?: CameraRigOptions,
101
+ ): XRViewRigInit;
102
+
103
+ /**
104
+ * Build a DISPLAY-rig descriptor — the default rig, made explicit and posable: the canvas is a
105
+ * portal onto a virtual display `virtualDisplayHeight` metres tall. Adds what the scalar
106
+ * `SceneOptions.virtualDisplayHeight` cannot say: a pose, and the three factors.
107
+ */
108
+ export function displayRig(opts?: DisplayRigOptions): XRViewRigInit;
109
+
32
110
  /**
33
111
  * Fade a rendered eye's edges to transparent, so a 3D window dissolves into the page instead of
34
112
  * ending at a hard rectangle. Call once per eye, straight after `renderer.render(scene, eye.camera)`,