@iwsdk/xr-input 1.0.0-rc.1 → 1.0.0-rc.2

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.
Files changed (36) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/pointer/filtered-eye-gaze.d.ts +48 -0
  6. package/dist/pointer/filtered-eye-gaze.d.ts.map +1 -0
  7. package/dist/pointer/filtered-eye-gaze.js +118 -0
  8. package/dist/pointer/filtered-eye-gaze.js.map +1 -0
  9. package/dist/pointer/gaze-candidate-provider.d.ts +58 -0
  10. package/dist/pointer/gaze-candidate-provider.d.ts.map +1 -0
  11. package/dist/pointer/gaze-conecaster.d.ts +130 -0
  12. package/dist/pointer/gaze-conecaster.d.ts.map +1 -0
  13. package/dist/pointer/gaze-conecaster.js +456 -0
  14. package/dist/pointer/gaze-conecaster.js.map +1 -0
  15. package/dist/pointer/gaze-pointer.d.ts +266 -0
  16. package/dist/pointer/gaze-pointer.d.ts.map +1 -0
  17. package/dist/pointer/gaze-pointer.js +865 -0
  18. package/dist/pointer/gaze-pointer.js.map +1 -0
  19. package/dist/pointer/multi-pointer.d.ts +21 -6
  20. package/dist/pointer/multi-pointer.d.ts.map +1 -1
  21. package/dist/pointer/multi-pointer.js +52 -12
  22. package/dist/pointer/multi-pointer.js.map +1 -1
  23. package/dist/rig/xr-origin.d.ts +26 -0
  24. package/dist/rig/xr-origin.d.ts.map +1 -1
  25. package/dist/rig/xr-origin.js +25 -1
  26. package/dist/rig/xr-origin.js.map +1 -1
  27. package/dist/version.d.ts +1 -1
  28. package/dist/visual/adapter/hand-visual-adapter.d.ts +9 -0
  29. package/dist/visual/adapter/hand-visual-adapter.d.ts.map +1 -1
  30. package/dist/visual/adapter/hand-visual-adapter.js +47 -9
  31. package/dist/visual/adapter/hand-visual-adapter.js.map +1 -1
  32. package/dist/xr-input-manager.d.ts +57 -1
  33. package/dist/xr-input-manager.d.ts.map +1 -1
  34. package/dist/xr-input-manager.js +285 -15
  35. package/dist/xr-input-manager.js.map +1 -1
  36. package/package.json +1 -1
@@ -0,0 +1,456 @@
1
+ import { Sphere, Box3, Matrix4, Vector3 } from 'three';
2
+ import { isObjectTreeVisible } from './visibility.js';
3
+
4
+ /**
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ const ANGLE_EPSILON = 0.5 * (Math.PI / 180); // 0.5°
11
+ // Rays aimed at an exact triangle/quad edge are numerically ambiguous. Move a
12
+ // cone-assisted aim point a visually negligible distance inside the OBB before
13
+ // falling back to its center, so boundary jitter cannot make the reticle jump.
14
+ const OBB_EDGE_INSET_FRACTION = 1e-3;
15
+ /**
16
+ * Default comparer: closer-by-angle wins, then closer-by-distance.
17
+ */
18
+ const defaultGazeComparer = (a, b) => {
19
+ const dAngle = a.angularDistance - b.angularDistance;
20
+ if (Math.abs(dAngle) > ANGLE_EPSILON) {
21
+ return dAngle;
22
+ }
23
+ return a.intersection.distance - b.intersection.distance;
24
+ };
25
+ /**
26
+ * Default candidate provider: cone-membership filter + pointer-compatible
27
+ * surface resolution + time-weighted dwell consensus.
28
+ *
29
+ * @remarks
30
+ * - **Membership**: a coarse sphere distance reject prunes far candidates,
31
+ * then a precise OBB closest-point test admits the candidate iff the angle
32
+ * from the gaze direction to the closest point on its oriented bounding
33
+ * box (its local AABB transformed by `matrixWorld`) is within `coneAngle`.
34
+ * This avoids the bounding-sphere overestimation that would let large flat
35
+ * panels register hover from far past their visible silhouette.
36
+ * - **Geometry**: survivors are resolved by the callback supplied in
37
+ * {@link GazeCandidateContext}, so the exact same pointer-event eligibility
38
+ * and ordering rules are used for acquisition and dispatch.
39
+ * - **Comparer**: per-frame best is chosen by `comparer` (default angle ->
40
+ * distance).
41
+ * - **Dwell**: per-frame winners are appended to a ring buffer; samples older
42
+ * than `dwellWindowSeconds` are dropped; the object with the largest
43
+ * cumulative dt inside the window wins.
44
+ *
45
+ * @category Pointer
46
+ */
47
+ class GazeConecaster {
48
+ constructor(opts = {}) {
49
+ var _a, _b, _c, _d;
50
+ this.sphere = new Sphere();
51
+ this.box = new Box3();
52
+ this.localBox = new Box3();
53
+ this.invWorld = new Matrix4();
54
+ this.tmpMat = new Matrix4();
55
+ this.tmpBox = new Box3();
56
+ this.toCandidate = new Vector3();
57
+ this.sphereCenter = new Vector3();
58
+ this.localOrigin = new Vector3();
59
+ this.localDirection = new Vector3();
60
+ this.localBoxClosest = new Vector3();
61
+ this.localRayClosest = new Vector3();
62
+ this.worldBoxClosest = new Vector3();
63
+ this.worldBoxCenter = new Vector3();
64
+ this.localBoxCenter = new Vector3();
65
+ this.pointBoundsFallback = false;
66
+ /** Ring of dwell samples (reused). */
67
+ this.dwellRing = [];
68
+ this.dwellHead = 0;
69
+ this.dwellSize = 0;
70
+ /** Last reported dwell winner for the public `getDwellWinner()`. */
71
+ this.currentDwellWinner = null;
72
+ this.coneAngle = (_a = opts.coneAngle) !== null && _a !== void 0 ? _a : 5 * (Math.PI / 180);
73
+ this.coneLength = (_b = opts.coneLength) !== null && _b !== void 0 ? _b : 30;
74
+ this.dwellWindowSeconds = (_c = opts.dwellWindowSeconds) !== null && _c !== void 0 ? _c : 0.15;
75
+ this.comparer = (_d = opts.comparer) !== null && _d !== void 0 ? _d : defaultGazeComparer;
76
+ // Preallocate ring capacity for ~120 Hz over ~1 second of dwell history.
77
+ // Window-based pruning keeps the *used* size small; this is just an upper
78
+ // bound to avoid reallocation.
79
+ this.dwellCapacity = 256;
80
+ for (let i = 0; i < this.dwellCapacity; i++) {
81
+ this.dwellRing.push({
82
+ object: null,
83
+ time: 0,
84
+ dt: 0,
85
+ });
86
+ }
87
+ }
88
+ update(time, dt, ctx) {
89
+ const frameBest = this.findFrameBest(ctx);
90
+ if (frameBest) {
91
+ this.recordDwell(frameBest.object, time, dt);
92
+ }
93
+ this.pruneDwell(time);
94
+ this.currentDwellWinner = this.resolveDwellWinner(ctx);
95
+ return this.currentDwellWinner;
96
+ }
97
+ reset() {
98
+ for (let i = 0; i < this.dwellSize; i++) {
99
+ this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);
100
+ }
101
+ this.dwellHead = 0;
102
+ this.dwellSize = 0;
103
+ this.currentDwellWinner = null;
104
+ }
105
+ /** Internal: scan all candidates and return the best in-cone hit, or null. */
106
+ findFrameBest(ctx) {
107
+ const { origin, direction, candidates } = ctx;
108
+ const cosCone = Math.cos(this.coneAngle);
109
+ let bestHit = null;
110
+ for (let i = 0; i < candidates.length; i++) {
111
+ const obj = candidates[i];
112
+ if (!obj || !isObjectTreeVisible(obj)) {
113
+ continue;
114
+ }
115
+ this.computeBounds(obj);
116
+ if (this.sphere.radius < 0) {
117
+ continue;
118
+ }
119
+ // Coarse distance reject (sphere radius is the only cheap upper bound).
120
+ this.sphereCenter.copy(this.sphere.center);
121
+ this.toCandidate.copy(this.sphereCenter).sub(origin);
122
+ const distToCenter = this.toCandidate.length();
123
+ if (distToCenter <= 1e-6) {
124
+ continue;
125
+ }
126
+ if (distToCenter - this.sphere.radius > this.coneLength) {
127
+ continue;
128
+ }
129
+ // Precise cone-membership test against the candidate's OBB instead of
130
+ // its enclosing sphere. A 0.5 m UIKit panel has a sphere radius of
131
+ // ~0.35 m and so would qualify ~16° off-axis even at arm's length —
132
+ // the panel ended up "dominating" gaze from far past where it's
133
+ // actually being looked at. OBB closest-point gives the true angular
134
+ // distance from the gaze axis to the object's silhouette (~0 when the
135
+ // ray passes through the panel area, growing with off-axis offset).
136
+ this.closestPointOnObb(obj, origin, direction, this.worldBoxClosest);
137
+ this.toCandidate.copy(this.worldBoxClosest).sub(origin);
138
+ const distToObb = this.toCandidate.length();
139
+ if (distToObb <= 1e-6) {
140
+ // Gaze origin sits inside the OBB — treat as fully on-axis.
141
+ this.toCandidate.copy(direction);
142
+ }
143
+ else {
144
+ this.toCandidate.divideScalar(distToObb);
145
+ }
146
+ const cosObbAngle = this.toCandidate.dot(direction);
147
+ if (cosObbAngle < cosCone) {
148
+ continue;
149
+ }
150
+ const obbAngle = Math.acos(Math.max(-1, Math.min(1, cosObbAngle)));
151
+ const hit = this.resolveSurface(obj, ctx, obbAngle);
152
+ if (hit && (!bestHit || this.comparer(hit, bestHit) < 0)) {
153
+ bestHit = hit;
154
+ }
155
+ }
156
+ return bestHit;
157
+ }
158
+ /**
159
+ * Resolve a real pointer-events intersection for one in-cone target. The raw
160
+ * gaze ray wins when it already hits. Otherwise the ray bends first just
161
+ * inside the closest point on the candidate OBB, then tries the exact point,
162
+ * and finally its center.
163
+ */
164
+ resolveSurface(object, ctx, angularDistance) {
165
+ let intersection = ctx.intersectCandidate(object, ctx.direction);
166
+ if (intersection && intersection.distance <= this.coneLength) {
167
+ return { object, intersection, angularDistance: 0 };
168
+ }
169
+ this.localBox.getCenter(this.localBoxCenter);
170
+ this.worldBoxCenter
171
+ .copy(this.localBoxCenter)
172
+ .applyMatrix4(object.matrixWorld);
173
+ // The closest point commonly lies exactly on a flat target's edge. A
174
+ // triangle raycast can accept or reject that boundary across adjacent
175
+ // floating-point poses, which previously alternated between the edge hit
176
+ // and the center fallback. Try a sub-pixel inset first so the assisted
177
+ // intersection remains close to the gaze while landing inside the face.
178
+ this.toCandidate
179
+ .copy(this.worldBoxClosest)
180
+ .lerp(this.worldBoxCenter, OBB_EDGE_INSET_FRACTION)
181
+ .sub(ctx.origin);
182
+ if (this.toCandidate.lengthSq() > 1e-12) {
183
+ this.toCandidate.normalize();
184
+ intersection = ctx.intersectCandidate(object, this.toCandidate);
185
+ if (intersection && intersection.distance <= this.coneLength) {
186
+ return { object, intersection, angularDistance };
187
+ }
188
+ }
189
+ this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);
190
+ if (this.toCandidate.lengthSq() > 1e-12) {
191
+ this.toCandidate.normalize();
192
+ intersection = ctx.intersectCandidate(object, this.toCandidate);
193
+ if (intersection && intersection.distance <= this.coneLength) {
194
+ return { object, intersection, angularDistance };
195
+ }
196
+ }
197
+ this.toCandidate.copy(this.worldBoxCenter).sub(ctx.origin);
198
+ if (this.toCandidate.lengthSq() <= 1e-12) {
199
+ return null;
200
+ }
201
+ this.toCandidate.normalize();
202
+ intersection = ctx.intersectCandidate(object, this.toCandidate);
203
+ return intersection && intersection.distance <= this.coneLength
204
+ ? { object, intersection, angularDistance }
205
+ : null;
206
+ }
207
+ /**
208
+ * Build both the world-space enclosing sphere (used for cone-membership)
209
+ * and a candidate-local AABB (used by the OBB fallback) in a single subtree
210
+ * walk. The local AABB is tighter than the world AABB for rotated objects:
211
+ * the cone-ring + OBB fallback uses it to produce a much better silhouette
212
+ * point than a sphere when the on-axis raycast misses.
213
+ *
214
+ * Results land on `this.sphere` and `this.localBox`. The local AABB is
215
+ * meaningful in `obj`'s local frame and must be transformed by
216
+ * `obj.matrixWorld` to land in world space.
217
+ */
218
+ computeBounds(obj) {
219
+ this.box.makeEmpty();
220
+ this.localBox.makeEmpty();
221
+ this.pointBoundsFallback = false;
222
+ obj.updateWorldMatrix(true, true);
223
+ const determinant = obj.matrixWorld.determinant();
224
+ if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-12) {
225
+ // A singular candidate transform cannot be inverted into candidate-local
226
+ // space. Treat it as a tiny point at its world origin instead of letting
227
+ // NaNs make cone ordering non-deterministic.
228
+ this.invWorld.identity();
229
+ obj.getWorldPosition(this.sphereCenter);
230
+ if (!Number.isFinite(this.sphereCenter.x) ||
231
+ !Number.isFinite(this.sphereCenter.y) ||
232
+ !Number.isFinite(this.sphereCenter.z)) {
233
+ this.sphere.makeEmpty();
234
+ return;
235
+ }
236
+ this.sphere.center.copy(this.sphereCenter);
237
+ this.sphere.radius = 0.001;
238
+ this.localBox.min.setScalar(-5e-4);
239
+ this.localBox.max.setScalar(0.0005);
240
+ this.pointBoundsFallback = true;
241
+ return;
242
+ }
243
+ this.invWorld.copy(obj.matrixWorld).invert();
244
+ this.expandSafely(obj, this.box, this.localBox);
245
+ if (this.box.isEmpty()) {
246
+ // Last-resort fallback: treat the candidate as a point sphere at its
247
+ // world origin so the conecaster still considers it for hover. Mirror
248
+ // the empty-box guard with a tiny local AABB centered on the origin.
249
+ obj.getWorldPosition(this.sphereCenter);
250
+ this.sphere.center.copy(this.sphereCenter);
251
+ this.sphere.radius = 0.001;
252
+ this.localBox.min.setScalar(-5e-4);
253
+ this.localBox.max.setScalar(0.0005);
254
+ return;
255
+ }
256
+ this.box.getBoundingSphere(this.sphere);
257
+ }
258
+ /**
259
+ * Manual `expandByObject` that swallows per-node failures (missing
260
+ * position attribute, null bounding box, etc.) instead of letting one bad
261
+ * descendant abort the whole subtree. Accumulates BOTH the world-space
262
+ * AABB (for cone-membership) and the candidate-local AABB (for the OBB
263
+ * fallback) in the same traversal.
264
+ */
265
+ expandSafely(obj, worldBox, localBox) {
266
+ const candidate = obj;
267
+ const geometry = candidate.geometry;
268
+ if (geometry) {
269
+ try {
270
+ if (geometry.getAttribute &&
271
+ geometry.getAttribute('position') !== undefined) {
272
+ if (geometry.boundingBox === null && geometry.computeBoundingBox) {
273
+ geometry.computeBoundingBox();
274
+ }
275
+ if (geometry.boundingBox) {
276
+ // World AABB: geometry-local -> world via the leaf's own matrix.
277
+ this.tmpBox.copy(geometry.boundingBox);
278
+ this.tmpBox.applyMatrix4(obj.matrixWorld);
279
+ worldBox.union(this.tmpBox);
280
+ // Candidate-local AABB: geometry-local -> world -> candidate-local.
281
+ this.tmpMat.copy(this.invWorld).multiply(obj.matrixWorld);
282
+ this.tmpBox.copy(geometry.boundingBox).applyMatrix4(this.tmpMat);
283
+ localBox.union(this.tmpBox);
284
+ }
285
+ }
286
+ }
287
+ catch (_a) {
288
+ // ignore: degenerate geometry shouldn't disqualify the candidate
289
+ }
290
+ }
291
+ const children = obj.children;
292
+ for (let i = 0; i < children.length; i++) {
293
+ this.expandSafely(children[i], worldBox, localBox);
294
+ }
295
+ }
296
+ /**
297
+ * Closest point on the candidate's oriented bounding box (its local AABB
298
+ * transformed by `obj.matrixWorld`) to the gaze ray, in world space.
299
+ *
300
+ * Works in local space to avoid building 12 oriented edges in world: bring
301
+ * the ray into the candidate's frame, run iterative AABB-vs-line refinement
302
+ * (a few passes is plenty — it converges quadratically), then map the point
303
+ * back to world.
304
+ */
305
+ closestPointOnObb(obj, origin, direction, out) {
306
+ if (this.pointBoundsFallback) {
307
+ out.copy(this.sphere.center);
308
+ return;
309
+ }
310
+ // Ray -> local space. invWorld was just refreshed in `computeBounds`.
311
+ this.localOrigin.copy(origin).applyMatrix4(this.invWorld);
312
+ // transformDirection normalizes and ignores translation; preserves
313
+ // rotation. Scale baked into the world matrix is lost — that's fine for a
314
+ // closest-point query (we re-measure in world afterwards).
315
+ this.localDirection.copy(direction).transformDirection(this.invWorld);
316
+ // Seed with the box center, projected onto the ray.
317
+ this.localBox.getCenter(this.localBoxCenter);
318
+ this.localBoxClosest.copy(this.localBoxCenter);
319
+ for (let iter = 0; iter < 3; iter++) {
320
+ // Closest point on ray to current box-point estimate (t clamped to >= 0
321
+ // so we never march behind the gaze origin).
322
+ const t = Math.max(0, this.localRayClosest
323
+ .copy(this.localBoxClosest)
324
+ .sub(this.localOrigin)
325
+ .dot(this.localDirection));
326
+ this.localRayClosest
327
+ .copy(this.localDirection)
328
+ .multiplyScalar(t)
329
+ .add(this.localOrigin);
330
+ // Closest point on box to that ray point.
331
+ this.localBoxClosest
332
+ .copy(this.localRayClosest)
333
+ .clamp(this.localBox.min, this.localBox.max);
334
+ }
335
+ out.copy(this.localBoxClosest).applyMatrix4(obj.matrixWorld);
336
+ }
337
+ recordDwell(object, time, dt) {
338
+ const slot = this.dwellRing[(this.dwellHead + this.dwellSize) % this.dwellCapacity];
339
+ slot.object = object;
340
+ slot.time = time;
341
+ slot.dt = dt;
342
+ if (this.dwellSize < this.dwellCapacity) {
343
+ this.dwellSize++;
344
+ }
345
+ else {
346
+ // Ring full — advance head and overwrite the oldest slot in-place.
347
+ this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;
348
+ }
349
+ }
350
+ pruneDwell(now) {
351
+ const cutoff = now - this.dwellWindowSeconds;
352
+ while (this.dwellSize > 0) {
353
+ const head = this.dwellRing[this.dwellHead];
354
+ if (head.time >= cutoff) {
355
+ break;
356
+ }
357
+ this.clearDwellSlot(this.dwellHead);
358
+ this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;
359
+ this.dwellSize--;
360
+ }
361
+ }
362
+ electDwellWinner() {
363
+ if (this.dwellSize === 0) {
364
+ return null;
365
+ }
366
+ // Find max-cumulative-dt object. Ring is short (~9 at 60 Hz), so
367
+ // O(N^2) over the window stays cheap and avoids a Map allocation.
368
+ let bestObject = null;
369
+ let bestDt = -1;
370
+ for (let i = 0; i < this.dwellSize; i++) {
371
+ const idx = (this.dwellHead + i) % this.dwellCapacity;
372
+ const sample = this.dwellRing[idx];
373
+ const obj = sample.object;
374
+ if (!obj) {
375
+ continue;
376
+ }
377
+ let sumDt = 0;
378
+ for (let j = i; j < this.dwellSize; j++) {
379
+ const jIdx = (this.dwellHead + j) % this.dwellCapacity;
380
+ const s = this.dwellRing[jIdx];
381
+ if (s.object === obj) {
382
+ sumDt += s.dt;
383
+ }
384
+ }
385
+ if (sumDt > bestDt) {
386
+ bestDt = sumDt;
387
+ bestObject = obj;
388
+ }
389
+ }
390
+ return bestObject;
391
+ }
392
+ /** Resolve the elected object against the current pose, never a stale hit. */
393
+ resolveDwellWinner(ctx) {
394
+ while (this.dwellSize > 0) {
395
+ const object = this.electDwellWinner();
396
+ if (!object) {
397
+ return null;
398
+ }
399
+ if (isObjectTreeVisible(object) && ctx.candidates.includes(object)) {
400
+ this.computeBounds(object);
401
+ if (this.sphere.radius >= 0) {
402
+ this.closestPointOnObb(object, ctx.origin, ctx.direction, this.worldBoxClosest);
403
+ this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);
404
+ const distance = this.toCandidate.length();
405
+ const angularDistance = distance <= 1e-6
406
+ ? 0
407
+ : Math.acos(Math.max(-1, Math.min(1, this.toCandidate
408
+ .divideScalar(distance)
409
+ .dot(ctx.direction))));
410
+ const hit = this.resolveSurface(object, ctx, angularDistance);
411
+ if (hit) {
412
+ return hit;
413
+ }
414
+ }
415
+ }
416
+ this.removeDwellObject(object);
417
+ }
418
+ return null;
419
+ }
420
+ removeDwellObject(object) {
421
+ const previousSize = this.dwellSize;
422
+ let write = 0;
423
+ for (let read = 0; read < this.dwellSize; read++) {
424
+ const readIndex = (this.dwellHead + read) % this.dwellCapacity;
425
+ const sample = this.dwellRing[readIndex];
426
+ if (sample.object === object) {
427
+ continue;
428
+ }
429
+ const writeIndex = (this.dwellHead + write) % this.dwellCapacity;
430
+ if (writeIndex !== readIndex) {
431
+ const destination = this.dwellRing[writeIndex];
432
+ destination.object = sample.object;
433
+ destination.time = sample.time;
434
+ destination.dt = sample.dt;
435
+ }
436
+ write++;
437
+ }
438
+ for (let i = write; i < previousSize; i++) {
439
+ this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);
440
+ }
441
+ this.dwellSize = write;
442
+ }
443
+ clearDwellSlot(index) {
444
+ const slot = this.dwellRing[index];
445
+ slot.object = null;
446
+ slot.time = 0;
447
+ slot.dt = 0;
448
+ }
449
+ /** Current dwell winner, or null. */
450
+ getDwellWinner() {
451
+ return this.currentDwellWinner;
452
+ }
453
+ }
454
+
455
+ export { GazeConecaster, defaultGazeComparer };
456
+ //# sourceMappingURL=gaze-conecaster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gaze-conecaster.js","sources":["../../src/pointer/gaze-conecaster.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Box3, Matrix4, Object3D, Sphere, Vector3 } from 'three';\nimport type {\n GazeCandidateContext,\n GazeCandidateProvider,\n GazeHit,\n} from './gaze-candidate-provider.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\n/**\n * Comparator over two `GazeHit` candidates. Return < 0 if `a` wins, > 0 if `b`\n * wins, 0 for unchanged. The conecaster keeps the running best by comparing\n * each new candidate against the current winner.\n */\nexport type GazeComparer = (a: GazeHit, b: GazeHit) => number;\n\nconst ANGLE_EPSILON = 0.5 * (Math.PI / 180); // 0.5°\n// Rays aimed at an exact triangle/quad edge are numerically ambiguous. Move a\n// cone-assisted aim point a visually negligible distance inside the OBB before\n// falling back to its center, so boundary jitter cannot make the reticle jump.\nconst OBB_EDGE_INSET_FRACTION = 1e-3;\n\n/**\n * Default comparer: closer-by-angle wins, then closer-by-distance.\n */\nexport const defaultGazeComparer: GazeComparer = (a, b) => {\n const dAngle = a.angularDistance - b.angularDistance;\n if (Math.abs(dAngle) > ANGLE_EPSILON) {\n return dAngle;\n }\n return a.intersection.distance - b.intersection.distance;\n};\n\nexport interface GazeConecasterOptions {\n /** Cone half-angle in radians. */\n coneAngle?: number;\n /** Cone length in meters. */\n coneLength?: number;\n /** Dwell-consensus window in seconds. */\n dwellWindowSeconds?: number;\n /** Custom comparer; defaults to {@link defaultGazeComparer}. */\n comparer?: GazeComparer;\n}\n\ninterface DwellSample {\n object: Object3D | null;\n time: number;\n dt: number;\n}\n\n/**\n * Default candidate provider: cone-membership filter + pointer-compatible\n * surface resolution + time-weighted dwell consensus.\n *\n * @remarks\n * - **Membership**: a coarse sphere distance reject prunes far candidates,\n * then a precise OBB closest-point test admits the candidate iff the angle\n * from the gaze direction to the closest point on its oriented bounding\n * box (its local AABB transformed by `matrixWorld`) is within `coneAngle`.\n * This avoids the bounding-sphere overestimation that would let large flat\n * panels register hover from far past their visible silhouette.\n * - **Geometry**: survivors are resolved by the callback supplied in\n * {@link GazeCandidateContext}, so the exact same pointer-event eligibility\n * and ordering rules are used for acquisition and dispatch.\n * - **Comparer**: per-frame best is chosen by `comparer` (default angle ->\n * distance).\n * - **Dwell**: per-frame winners are appended to a ring buffer; samples older\n * than `dwellWindowSeconds` are dropped; the object with the largest\n * cumulative dt inside the window wins.\n *\n * @category Pointer\n */\nexport class GazeConecaster implements GazeCandidateProvider {\n public coneAngle: number;\n public coneLength: number;\n public dwellWindowSeconds: number;\n public comparer: GazeComparer;\n\n private readonly sphere = new Sphere();\n private readonly box = new Box3();\n private readonly localBox = new Box3();\n private readonly invWorld = new Matrix4();\n private readonly tmpMat = new Matrix4();\n private readonly tmpBox = new Box3();\n private readonly toCandidate = new Vector3();\n private readonly sphereCenter = new Vector3();\n private readonly localOrigin = new Vector3();\n private readonly localDirection = new Vector3();\n private readonly localBoxClosest = new Vector3();\n private readonly localRayClosest = new Vector3();\n private readonly worldBoxClosest = new Vector3();\n private readonly worldBoxCenter = new Vector3();\n private readonly localBoxCenter = new Vector3();\n private pointBoundsFallback = false;\n\n /** Ring of dwell samples (reused). */\n private readonly dwellRing: DwellSample[] = [];\n private dwellHead = 0;\n private dwellSize = 0;\n private readonly dwellCapacity: number;\n\n /** Last reported dwell winner for the public `getDwellWinner()`. */\n private currentDwellWinner: GazeHit | null = null;\n\n constructor(opts: GazeConecasterOptions = {}) {\n this.coneAngle = opts.coneAngle ?? 5 * (Math.PI / 180);\n this.coneLength = opts.coneLength ?? 30;\n this.dwellWindowSeconds = opts.dwellWindowSeconds ?? 0.15;\n this.comparer = opts.comparer ?? defaultGazeComparer;\n\n // Preallocate ring capacity for ~120 Hz over ~1 second of dwell history.\n // Window-based pruning keeps the *used* size small; this is just an upper\n // bound to avoid reallocation.\n this.dwellCapacity = 256;\n for (let i = 0; i < this.dwellCapacity; i++) {\n this.dwellRing.push({\n object: null,\n time: 0,\n dt: 0,\n });\n }\n }\n\n update(time: number, dt: number, ctx: GazeCandidateContext): GazeHit | null {\n const frameBest = this.findFrameBest(ctx);\n if (frameBest) {\n this.recordDwell(frameBest.object, time, dt);\n }\n this.pruneDwell(time);\n this.currentDwellWinner = this.resolveDwellWinner(ctx);\n return this.currentDwellWinner;\n }\n\n reset(): void {\n for (let i = 0; i < this.dwellSize; i++) {\n this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);\n }\n this.dwellHead = 0;\n this.dwellSize = 0;\n this.currentDwellWinner = null;\n }\n\n /** Internal: scan all candidates and return the best in-cone hit, or null. */\n private findFrameBest(ctx: GazeCandidateContext): GazeHit | null {\n const { origin, direction, candidates } = ctx;\n const cosCone = Math.cos(this.coneAngle);\n let bestHit: GazeHit | null = null;\n\n for (let i = 0; i < candidates.length; i++) {\n const obj = candidates[i];\n if (!obj || !isObjectTreeVisible(obj)) {\n continue;\n }\n\n this.computeBounds(obj);\n if (this.sphere.radius < 0) {\n continue;\n }\n\n // Coarse distance reject (sphere radius is the only cheap upper bound).\n this.sphereCenter.copy(this.sphere.center);\n this.toCandidate.copy(this.sphereCenter).sub(origin);\n const distToCenter = this.toCandidate.length();\n if (distToCenter <= 1e-6) {\n continue;\n }\n if (distToCenter - this.sphere.radius > this.coneLength) {\n continue;\n }\n\n // Precise cone-membership test against the candidate's OBB instead of\n // its enclosing sphere. A 0.5 m UIKit panel has a sphere radius of\n // ~0.35 m and so would qualify ~16° off-axis even at arm's length —\n // the panel ended up \"dominating\" gaze from far past where it's\n // actually being looked at. OBB closest-point gives the true angular\n // distance from the gaze axis to the object's silhouette (~0 when the\n // ray passes through the panel area, growing with off-axis offset).\n this.closestPointOnObb(obj, origin, direction, this.worldBoxClosest);\n this.toCandidate.copy(this.worldBoxClosest).sub(origin);\n const distToObb = this.toCandidate.length();\n if (distToObb <= 1e-6) {\n // Gaze origin sits inside the OBB — treat as fully on-axis.\n this.toCandidate.copy(direction);\n } else {\n this.toCandidate.divideScalar(distToObb);\n }\n const cosObbAngle = this.toCandidate.dot(direction);\n if (cosObbAngle < cosCone) {\n continue;\n }\n const obbAngle = Math.acos(Math.max(-1, Math.min(1, cosObbAngle)));\n\n const hit = this.resolveSurface(obj, ctx, obbAngle);\n if (hit && (!bestHit || this.comparer(hit, bestHit) < 0)) {\n bestHit = hit;\n }\n }\n\n return bestHit;\n }\n\n /**\n * Resolve a real pointer-events intersection for one in-cone target. The raw\n * gaze ray wins when it already hits. Otherwise the ray bends first just\n * inside the closest point on the candidate OBB, then tries the exact point,\n * and finally its center.\n */\n private resolveSurface(\n object: Object3D,\n ctx: GazeCandidateContext,\n angularDistance: number,\n ): GazeHit | null {\n let intersection = ctx.intersectCandidate(object, ctx.direction);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance: 0 };\n }\n\n this.localBox.getCenter(this.localBoxCenter);\n this.worldBoxCenter\n .copy(this.localBoxCenter)\n .applyMatrix4(object.matrixWorld);\n\n // The closest point commonly lies exactly on a flat target's edge. A\n // triangle raycast can accept or reject that boundary across adjacent\n // floating-point poses, which previously alternated between the edge hit\n // and the center fallback. Try a sub-pixel inset first so the assisted\n // intersection remains close to the gaze while landing inside the face.\n this.toCandidate\n .copy(this.worldBoxClosest)\n .lerp(this.worldBoxCenter, OBB_EDGE_INSET_FRACTION)\n .sub(ctx.origin);\n if (this.toCandidate.lengthSq() > 1e-12) {\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance };\n }\n }\n\n this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);\n if (this.toCandidate.lengthSq() > 1e-12) {\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance };\n }\n }\n\n this.toCandidate.copy(this.worldBoxCenter).sub(ctx.origin);\n if (this.toCandidate.lengthSq() <= 1e-12) {\n return null;\n }\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n return intersection && intersection.distance <= this.coneLength\n ? { object, intersection, angularDistance }\n : null;\n }\n\n /**\n * Build both the world-space enclosing sphere (used for cone-membership)\n * and a candidate-local AABB (used by the OBB fallback) in a single subtree\n * walk. The local AABB is tighter than the world AABB for rotated objects:\n * the cone-ring + OBB fallback uses it to produce a much better silhouette\n * point than a sphere when the on-axis raycast misses.\n *\n * Results land on `this.sphere` and `this.localBox`. The local AABB is\n * meaningful in `obj`'s local frame and must be transformed by\n * `obj.matrixWorld` to land in world space.\n */\n private computeBounds(obj: Object3D): void {\n this.box.makeEmpty();\n this.localBox.makeEmpty();\n this.pointBoundsFallback = false;\n obj.updateWorldMatrix(true, true);\n const determinant = obj.matrixWorld.determinant();\n if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-12) {\n // A singular candidate transform cannot be inverted into candidate-local\n // space. Treat it as a tiny point at its world origin instead of letting\n // NaNs make cone ordering non-deterministic.\n this.invWorld.identity();\n obj.getWorldPosition(this.sphereCenter);\n if (\n !Number.isFinite(this.sphereCenter.x) ||\n !Number.isFinite(this.sphereCenter.y) ||\n !Number.isFinite(this.sphereCenter.z)\n ) {\n this.sphere.makeEmpty();\n return;\n }\n this.sphere.center.copy(this.sphereCenter);\n this.sphere.radius = 0.001;\n this.localBox.min.setScalar(-0.0005);\n this.localBox.max.setScalar(0.0005);\n this.pointBoundsFallback = true;\n return;\n }\n this.invWorld.copy(obj.matrixWorld).invert();\n this.expandSafely(obj, this.box, this.localBox);\n if (this.box.isEmpty()) {\n // Last-resort fallback: treat the candidate as a point sphere at its\n // world origin so the conecaster still considers it for hover. Mirror\n // the empty-box guard with a tiny local AABB centered on the origin.\n obj.getWorldPosition(this.sphereCenter);\n this.sphere.center.copy(this.sphereCenter);\n this.sphere.radius = 0.001;\n this.localBox.min.setScalar(-0.0005);\n this.localBox.max.setScalar(0.0005);\n return;\n }\n this.box.getBoundingSphere(this.sphere);\n }\n\n /**\n * Manual `expandByObject` that swallows per-node failures (missing\n * position attribute, null bounding box, etc.) instead of letting one bad\n * descendant abort the whole subtree. Accumulates BOTH the world-space\n * AABB (for cone-membership) and the candidate-local AABB (for the OBB\n * fallback) in the same traversal.\n */\n private expandSafely(obj: Object3D, worldBox: Box3, localBox: Box3): void {\n const candidate = obj as Object3D & {\n geometry?: {\n boundingBox: Box3 | null;\n getAttribute?: (name: string) => unknown;\n computeBoundingBox?: () => void;\n };\n };\n const geometry = candidate.geometry;\n if (geometry) {\n try {\n if (\n geometry.getAttribute &&\n geometry.getAttribute('position') !== undefined\n ) {\n if (geometry.boundingBox === null && geometry.computeBoundingBox) {\n geometry.computeBoundingBox();\n }\n if (geometry.boundingBox) {\n // World AABB: geometry-local -> world via the leaf's own matrix.\n this.tmpBox.copy(geometry.boundingBox);\n this.tmpBox.applyMatrix4(obj.matrixWorld);\n worldBox.union(this.tmpBox);\n // Candidate-local AABB: geometry-local -> world -> candidate-local.\n this.tmpMat.copy(this.invWorld).multiply(obj.matrixWorld);\n this.tmpBox.copy(geometry.boundingBox).applyMatrix4(this.tmpMat);\n localBox.union(this.tmpBox);\n }\n }\n } catch {\n // ignore: degenerate geometry shouldn't disqualify the candidate\n }\n }\n const children = obj.children;\n for (let i = 0; i < children.length; i++) {\n this.expandSafely(children[i], worldBox, localBox);\n }\n }\n\n /**\n * Closest point on the candidate's oriented bounding box (its local AABB\n * transformed by `obj.matrixWorld`) to the gaze ray, in world space.\n *\n * Works in local space to avoid building 12 oriented edges in world: bring\n * the ray into the candidate's frame, run iterative AABB-vs-line refinement\n * (a few passes is plenty — it converges quadratically), then map the point\n * back to world.\n */\n private closestPointOnObb(\n obj: Object3D,\n origin: Vector3,\n direction: Vector3,\n out: Vector3,\n ): void {\n if (this.pointBoundsFallback) {\n out.copy(this.sphere.center);\n return;\n }\n // Ray -> local space. invWorld was just refreshed in `computeBounds`.\n this.localOrigin.copy(origin).applyMatrix4(this.invWorld);\n // transformDirection normalizes and ignores translation; preserves\n // rotation. Scale baked into the world matrix is lost — that's fine for a\n // closest-point query (we re-measure in world afterwards).\n this.localDirection.copy(direction).transformDirection(this.invWorld);\n\n // Seed with the box center, projected onto the ray.\n this.localBox.getCenter(this.localBoxCenter);\n this.localBoxClosest.copy(this.localBoxCenter);\n for (let iter = 0; iter < 3; iter++) {\n // Closest point on ray to current box-point estimate (t clamped to >= 0\n // so we never march behind the gaze origin).\n const t = Math.max(\n 0,\n this.localRayClosest\n .copy(this.localBoxClosest)\n .sub(this.localOrigin)\n .dot(this.localDirection),\n );\n this.localRayClosest\n .copy(this.localDirection)\n .multiplyScalar(t)\n .add(this.localOrigin);\n // Closest point on box to that ray point.\n this.localBoxClosest\n .copy(this.localRayClosest)\n .clamp(this.localBox.min, this.localBox.max);\n }\n out.copy(this.localBoxClosest).applyMatrix4(obj.matrixWorld);\n }\n\n private recordDwell(object: Object3D, time: number, dt: number): void {\n const slot =\n this.dwellRing[(this.dwellHead + this.dwellSize) % this.dwellCapacity];\n slot.object = object;\n slot.time = time;\n slot.dt = dt;\n if (this.dwellSize < this.dwellCapacity) {\n this.dwellSize++;\n } else {\n // Ring full — advance head and overwrite the oldest slot in-place.\n this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;\n }\n }\n\n private pruneDwell(now: number): void {\n const cutoff = now - this.dwellWindowSeconds;\n while (this.dwellSize > 0) {\n const head = this.dwellRing[this.dwellHead];\n if (head.time >= cutoff) {\n break;\n }\n this.clearDwellSlot(this.dwellHead);\n this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;\n this.dwellSize--;\n }\n }\n\n private electDwellWinner(): Object3D | null {\n if (this.dwellSize === 0) {\n return null;\n }\n\n // Find max-cumulative-dt object. Ring is short (~9 at 60 Hz), so\n // O(N^2) over the window stays cheap and avoids a Map allocation.\n let bestObject: Object3D | null = null;\n let bestDt = -1;\n for (let i = 0; i < this.dwellSize; i++) {\n const idx = (this.dwellHead + i) % this.dwellCapacity;\n const sample = this.dwellRing[idx];\n const obj = sample.object;\n if (!obj) {\n continue;\n }\n\n let sumDt = 0;\n for (let j = i; j < this.dwellSize; j++) {\n const jIdx = (this.dwellHead + j) % this.dwellCapacity;\n const s = this.dwellRing[jIdx];\n if (s.object === obj) {\n sumDt += s.dt;\n }\n }\n\n if (sumDt > bestDt) {\n bestDt = sumDt;\n bestObject = obj;\n }\n }\n return bestObject;\n }\n\n /** Resolve the elected object against the current pose, never a stale hit. */\n private resolveDwellWinner(ctx: GazeCandidateContext): GazeHit | null {\n while (this.dwellSize > 0) {\n const object = this.electDwellWinner();\n if (!object) {\n return null;\n }\n if (isObjectTreeVisible(object) && ctx.candidates.includes(object)) {\n this.computeBounds(object);\n if (this.sphere.radius >= 0) {\n this.closestPointOnObb(\n object,\n ctx.origin,\n ctx.direction,\n this.worldBoxClosest,\n );\n this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);\n const distance = this.toCandidate.length();\n const angularDistance =\n distance <= 1e-6\n ? 0\n : Math.acos(\n Math.max(\n -1,\n Math.min(\n 1,\n this.toCandidate\n .divideScalar(distance)\n .dot(ctx.direction),\n ),\n ),\n );\n const hit = this.resolveSurface(object, ctx, angularDistance);\n if (hit) {\n return hit;\n }\n }\n }\n this.removeDwellObject(object);\n }\n return null;\n }\n\n private removeDwellObject(object: Object3D): void {\n const previousSize = this.dwellSize;\n let write = 0;\n for (let read = 0; read < this.dwellSize; read++) {\n const readIndex = (this.dwellHead + read) % this.dwellCapacity;\n const sample = this.dwellRing[readIndex];\n if (sample.object === object) {\n continue;\n }\n const writeIndex = (this.dwellHead + write) % this.dwellCapacity;\n if (writeIndex !== readIndex) {\n const destination = this.dwellRing[writeIndex];\n destination.object = sample.object;\n destination.time = sample.time;\n destination.dt = sample.dt;\n }\n write++;\n }\n for (let i = write; i < previousSize; i++) {\n this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);\n }\n this.dwellSize = write;\n }\n\n private clearDwellSlot(index: number): void {\n const slot = this.dwellRing[index];\n slot.object = null;\n slot.time = 0;\n slot.dt = 0;\n }\n\n /** Current dwell winner, or null. */\n getDwellWinner(): GazeHit | null {\n return this.currentDwellWinner;\n }\n}\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAiBH,MAAM,aAAa,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC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