@displayxr/inline3d 1.43.1 → 1.45.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/three.d.ts CHANGED
@@ -143,7 +143,19 @@ export class EdgeFeather {
143
143
  ): void;
144
144
  }
145
145
 
146
- import type { CursorAnchorMode, CursorPlacement, CursorView } from './cursor-depth.js';
146
+ import type { CursorAnchorMode, CursorPlacement, CursorShape, CursorShapeHit, CursorShapeOption, CursorSoftenOption, CursorSoftenParams, CursorSoftening, CursorView } from './cursor-depth.js';
147
+
148
+ /** One second of `debug` stats: each figure as `{ mean, p95, max, n }`. */
149
+ export interface CursorDebugSummary {
150
+ frames: number;
151
+ seconds: number;
152
+ updateMs: { mean: number; p95: number; max: number; n: number };
153
+ rays: { mean: number; p95: number; max: number; n: number };
154
+ frameMs: { mean: number; p95: number; max: number; n: number };
155
+ /** Age of the pointer sample a frame used, on frames where it was new. */
156
+ pointerAgeMs: { mean: number; p95: number; max: number; n: number };
157
+ samplesPerFrame: number;
158
+ }
147
159
 
148
160
  /**
149
161
  * A hit test for {@link DepthCursor} that raycasts three.js objects (recursively): the first hit
@@ -179,22 +191,49 @@ export class DepthCursor {
179
191
  height?: number;
180
192
  /** Fill colour of the arrow (default 0xffffff; the outline is always dark). */
181
193
  color?: number;
182
- /** How far in front of out-of-screen content it floats, in eye-baseline units (default 0.03 ≈ 2 mm at a 65 mm IPD). */
194
+ /** How far in front of out-of-screen content it floats, in eye-baseline units (default 0.015 ≈ 1 mm at a 63-65 mm IPD). */
183
195
  margin?: number;
184
196
  /** Default `'hybrid'`: exact while the pointer moves, world-fixed (parallaxing) while it is still. */
185
197
  anchor?: CursorAnchorMode;
186
198
  /** `'window'`: keep the cursor over DOM layered on the canvas; hides the CSS cursor page-wide meanwhile. */
187
199
  pointerScope?: 'canvas' | 'window';
188
- /** An EXPENSIVE hit test: N rays a frame from the first eye, cycling the footprint (0 = all). */
200
+ /** 0 (default): the whole footprint every frame. N: amortised — N rays a frame cycling the footprint (both eyes); the arrow still follows the newest pointer each frame. */
189
201
  raysPerFrame?: number;
202
+ /**
203
+ * Crosstalk softening of the LIFTED arrow (runtime ADR-046 Amendment 2 §B.7), in the arrow's own
204
+ * shader: blur = 0.1 × its ghost offset (capped at 6% of its height, 8 px), opacity easing to
205
+ * 0.5 over 0.03 baselines of lift; both zero on the glass. Default `'both'`; `'off'` = the crisp arrow.
206
+ */
207
+ soften?: CursorSoftenOption;
208
+ /**
209
+ * The sprite. Default `'auto'`: what the browser would show — the page's computed CSS cursor
210
+ * under the pointer: every standard keyword has a sprite, `url(…)` images are drawn as
211
+ * images, `none` draws nothing. A sprite name (or `'none'`) fixes it. `color` tints the arrow only.
212
+ */
213
+ shape?: CursorShapeOption;
214
+ /** Per-frame override while the sprite draws: a shape name, or nothing for `shape`'s answer. */
215
+ shapeFor?: (hit: CursorShapeHit) => CursorShape | 'none' | 'auto' | null | undefined;
190
216
  /** Attach pattern: the Object3D the eye cameras hang off; its world matrix carries the views to world. */
191
217
  viewSpace?: unknown;
218
+ /** `true`: log update() cost, rays a frame and the frame interval once a second; `'both'`: also keep the OS cursor visible. */
219
+ debug?: boolean | 'both';
192
220
  },
193
221
  );
194
- /** The arrow (a `THREE.Mesh`: dark outline, white fill, tip at its origin; depth test off, drawn last). Add it to the scene root. */
222
+ /** With `debug` only (else null): the rolling stats; `last` is the newest one-second summary, `history` the last 120. */
223
+ readonly debugStats: { last: CursorDebugSummary | null; history: CursorDebugSummary[] } | null;
224
+ /**
225
+ * The arrow (a `THREE.Mesh`: dark outline, white fill, tip at its origin; depth test off, drawn last). Add it to the scene root.
226
+ * While it is softened its geometry and material are a padded quad and the soft-arrow shader; otherwise the crisp mesh.
227
+ */
195
228
  readonly object: unknown;
196
229
  /** The last placement, for diagnostics. */
197
230
  readonly placement: CursorPlacement | { active: false };
231
+ /** The resolved softening parameters. */
232
+ readonly soften: CursorSoftenParams;
233
+ /** The last drawn frame's softening (diagnostics); null while nothing is drawn. */
234
+ readonly softening: CursorSoftening | null;
235
+ /** The sprite drawn last: a name, 'none' or 'image'. */
236
+ readonly shape: CursorShape | 'none' | 'image';
198
237
  /** Place the sprite for this frame — call with the views you are about to render, before rendering. */
199
238
  update(views: ArrayLike<XRView | CursorView>, nowMs?: number): CursorPlacement | { active: false };
200
239
  /** Set the pointer directly (canvas-normalised, v down), or null — for scripted input. */