@realitycollective/webxr-interactions 0.1.1-preview.2 → 0.1.1-preview.3

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/CHANGELOG.md CHANGED
@@ -8,6 +8,17 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
8
8
 
9
9
  ### Added
10
10
 
11
+ - `@realitycollective/webxr-interactions` - the near-pointer rule, IWSDK 1.0.0's pointer stack restated as one core decision every binding runs (`near-pointer.ts`, `NEAR_POINTER_DEFAULTS`): a fingertip (or a controller's ray origin) within 0.15 m of a target's surface owns the source as the touch pointer (hysteresis out to 0.2 m), presses at 0.02 m arriving from outside and releases on the way out, never pressing from inside or behind; the grip is a 0.07 m grab sphere; per source the first of touch, grab, ray with a candidate is the active pointer, locked while it presses or grabs; and `InteractionRuntime` publishes per-source `PointerVisuals` (`onPointerVisuals`, `getPointerVisuals`, `getActivePointer`): the ray and its cursor show only while the ray owns the source or nothing does, with the cursor at the active pointer's hit. `InteractableDescriptor.pokeRadius` is now the touch hover enter distance for that target (default 0.15 m, was a 0.05 m proximity trigger). `nearPointerContractCases()` is the shared suite, run on every platform's hit tester.
12
+ - `@realitycollective/webxr-interactions` - the physics contract (`physics.ts`): `PhysicsFacility`, the platform physics behind one set of semantics and IWSDK 1.0.0's defaults (`PHYSICS_DEFAULTS`: gravity `[0, -9.81, 0]`, 60 steps per second with interpolation, a dynamic body with no damping and gravity factor 1, an auto shape with density 1, restitution 0 and friction 0.5), static and kinematic states, suspend for a hold, resume with the release velocity, teleport with velocity cleared. `physicsFacilityContractCases()` proves a facility falls and rests, bounces, holds, throws, teleports and disposes; `MemoryPhysicsFacility` is the engine-free reference. Every binding names a default engine and takes an app's own facility instead: `createThreeInteractions({ physics: { rapier } })` (Rapier, `RapierPhysicsFacility`, proved against the real engine), `connectXRBlocksInteractions({ physics: { rapier } })` (the Rapier XR Blocks bundles), `registerInteractions` (Havok through IWSDK's components, `IWSDKPhysicsFacility`), `createBabylonInteractions({ physics: { kit } })` (Havok, `BabylonPhysicsFacility`, proved against a fake), and the native `physics` slice (`NativePhysicsHost`, Jolt on Quest and Android, RealityKit on visionOS, with every obligation stated in `native-types.ts` and the whole shared suite in the host conformance kit). A registered object with a body drives the held pose through its facility; `register` takes `body` and `shape` specs.
13
+ - `@realitycollective/native-interactions` - `NativeInputHost.applyPointerVisuals(sourceId, visuals)`: the host is told each frame whether to draw a source's ray and where its cursor sits, and draws exactly that; the earlier rule that the host draws a cursor at every ray hit is withdrawn. The kit gains `input/the ray and cursor are drawn exactly as told`, the whole `nearPointerContractCases()` suite over the host's own queries, and the physics cases.
14
+ - `@realitycollective/iwsdk-interactions` - `test/near-pointer-reference.test.ts` reads the touch and grab constants off IWSDK 1.0.0's own pointer classes and drives the core touch machine beside `@pmndrs/pointer-events`' press rule, recording the one frame they differ on by design (a fingertip first seen inside the press band).
15
+ - `@realitycollective/xrblocks-interactions` - the provider reads the XR Blocks camera's head pose through real three.js scratch objects; a plain object handed to `getWorldPosition` threw against the real camera.
16
+ - Eye gaze and pinch, on every platform, following Meta IWSDK 1.0.0's gaze-and-pinch interaction (the primary input on Meta VR Glasses). The provider half of the rule is `@realitycollective/webxr-input` 0.1.7's `EyeGazeInput`; this repository applies it in every provider and adds the targeting half to the core. `@realitycollective/webxr-interactions` - `HitTester` gains an optional `hitCone(ray, halfAngle, maxLength)`, IWSDK's `GazeConecaster` query (a target the ray reaches wins outright, otherwise the nearest to the axis within the cone, the nearer on a tie within half a degree), with `coneHitForSpheres` for sphere-based testers and `GazeConsensus`, the time-weighted dwell vote over IWSDK's 0.15 s window. `InteractionRuntime` takes `eyeGaze` options (`EYE_GAZE_DEFAULTS`: 5 degree cone, 30 m, 0.15 s, suppression on, follow the hand on) and, when the provider reports `capabilities.eyeGaze`, targets the gaze source through the cone and the consensus, targets nothing while a hand's near pointer is hovering or grabbing, satisfies `gaze.required` and dwell from the eye gaze, presses or grabs the gazed target when the owning hand pinches, and from the next frame drives the gaze source's ray from the pinching hand aimed at the gaze hit (`selectorPose`), so `onSample` listeners such as the pointer bridge and every behaviour see a drag that follows the hand. `hitTesterContractCases()` gains five `hitCone` cases that run when a tester has one. Without `eyeGaze` nothing changes: a gaze-kind source still targets by plain ray as head gaze does.
17
+ - `@realitycollective/iwsdk-interactions` - `IWSDKInputProvider` reports `eyeGaze` when the session carries a gaze input source, reads IWSDK's own sampled eye pose (`xrOrigin.eyeSpace` while `gazeOrigin` is `"tracked"`) and applies `EyeGazeInput`, so it hands far targeting to gaze exactly when IWSDK's `GazePointer` does; `EntityHitTester` answers `hitCone` over its spheres. `test/gaze-reference.test.ts` drives IWSDK's `FilteredEyeGaze` and `GazeConecaster` side by side with the core's filter and consensus.
18
+ - `@realitycollective/threejs-interactions` (reused by `@realitycollective/xrblocks-interactions`) - `WebXRInputProvider` finds the `targetRayMode === "gaze"` source, poses it against the reference space and applies `EyeGazeInput`; `ThreeHitTester.hitCone` tries the raycast first and then the cone over the registered roots' bounding spheres.
19
+ - `@realitycollective/babylon-interactions` - `BabylonInputProvider` reads the `xr-eye-tracking` feature (`WebXREyeTracking.getEyeGaze()`) when the app enabled it and applies `EyeGazeInput`; `BabylonHitTester.hitCone` runs the cone over its spheres.
20
+ - `@realitycollective/native-interactions` - `NativeInputFacts.eyeTracking` (an eye-gaze source is present: OpenXR `XR_EXT_eye_gaze_interaction` bound and active) and `NativeInputHost.getEyeGazePose()` (this frame's gaze target-ray pose, world space, or null) let a native host report the facts while the binding applies the rule: `eyeGaze` is derived, far rays are dropped, the pinch selects, and the selector pose is built from the hand's ray. The `interactions` slice gains an optional `hitCone` the host answers over its own scene, forwarded by `NativeHitTester`. The host conformance kit gains `input/eye gaze` cases: a host that reports eye tracking must pose the gaze, and a hidden target never answers a cone query.
21
+
11
22
  - `@realitycollective/webxr-interactions` - three `hitTesterContractCases()` that hold every platform to IWSDK's hit-test semantics: `hitProximity` reports the distance to the target's SURFACE, clamped at zero (a point 3 cm outside a 10 cm target reports 0.03 within 1 mm, not 0.13); it misses a target whose surface is farther than the query radius; and a ray that passes a target farther than its radius misses it. Every platform in the repository already passed them. The `HitTester` and `TransformPort.setEffect` docs now state those semantics, and the effect rule: `scale` multiplies the rest scale, `emissive` adds to the base intensity, and the last write wins.
12
23
  - `@realitycollective/native-interactions` - `nativeInteractionsHostConformanceCases()`, the host conformance kit a native app runs on its device against its real slices: the core's whole `hitTesterContractCases()` run against the host itself, the 0.1 m default target radius, the release velocity reaching `endHold`, live-session capabilities, presence hiding the models only per side, `"auto"` following the live modality, and presence never hiding the cursors. The host provides the test readbacks of the new `NativeInteractionsTestHost` type. The kit fails a host that measures proximity to a target's centre, ignores the radius it is handed, loses a release velocity, or draws the wrong presence.
13
24
  - `@realitycollective/webxr-interactions` - shared conformance suites for `HitTester` and `TransformPort`, `hitTesterContractCases()` and `transformPortContractCases()`, alongside the existing `inputProviderContractCases()` from `@realitycollective/webxr-input`. Runner-free data, the same pattern as WebXR-UIExtensions' `windowHostContractCases()`: each case throws a plain `Error` naming what a platform's ray/proximity query or transform read/write broke, and asserts only what `ports.ts` documents - a ray or proximity query answers null or an id with a positive distance and a point near the query, the nearer of two targets wins, an offset round-trips, `getWorldPose()` is finite with a unit quaternion, `getRestWorldPose()` is the registration pose and stays put, `getWorldPose()` follows `setLocalOffset`, `setLocalRotation` and `setWorldPose` from that rest frame, every returned tuple is a fresh value the caller owns and no tuple passed in is kept, and the optional `setEffect` accepts its shape without throwing. Each platform's subject starts away from the origin and turned, so a port that ignores its rest frame fails. Run against all five platforms in `packages/iwsdk-interactions/test/port-parity.test.ts`, next to the provider parity suite; every platform passes every case.
package/README.md CHANGED
@@ -16,6 +16,7 @@ npm install @realitycollective/webxr-interactions
16
16
  | --- | --- |
17
17
  | **Behaviours** | Ready-made interaction types: `press` (with an optional latching mode that stays down until pressed again), `pulse`, `hinge`, `dial`, `slide`, `grab`, and `tossScore` for throw-and-catch scoring |
18
18
  | **Gaze** | Optional look-to-activate. Require the user to be looking before an object responds, or let a sustained look trigger the press by itself |
19
+ | **Eye gaze and pinch** | With a provider that reports `capabilities.eyeGaze`, the runtime targets the gaze source through a 5 degree cone (`HitTester.hitCone`) and a 0.15 s dwell consensus, targets nothing while a near pointer is active, presses or grabs on the owning hand's pinch, and drives a gaze-started drag from the hand (IWSDK 1.0.0 gaze-and-pinch, on every platform) |
19
20
  | **Targeting** | Picks one target per hand, trying the platform's own answer first, then a close-range touch, then a pointing ray. A short delay stops the target flickering between two objects on a boundary |
20
21
  | **Capability checks** | If the headset cannot do what a behaviour needs, the behaviour switches itself off and reports `behaviourDisabled`, rather than silently doing nothing |
21
22
  | **Events** | The core never calls into your code. It emits events and you subscribe |
@@ -24,6 +24,9 @@ const AWAY_RAY = { origin: [0, 0, 0], direction: [0, 0, 1] };
24
24
  */
25
25
  /** A surface distance is exact up to 1 mm, the tolerance the master row states. */
26
26
  const SURFACE_EPS = 1e-3;
27
+ function degrees(value) {
28
+ return (value * Math.PI) / 180;
29
+ }
27
30
  function slack(radius) {
28
31
  return radius + 0.05;
29
32
  }
@@ -154,6 +157,69 @@ const HIT_TESTER_CASES = [
154
157
  }
155
158
  },
156
159
  },
160
+ {
161
+ name: "hitCone, when present, answers a ray that reaches a target with that target at angular distance zero",
162
+ run({ hitTester, driver }) {
163
+ if (!hitTester.hitCone)
164
+ return;
165
+ driver.place("cone-direct", [0, 0, -2], 0.1);
166
+ const hit = hitTester.hitCone(DOWN_RAY, degrees(5), 30);
167
+ assert(hit !== null, "hitCone answered null for a target on the ray");
168
+ assert(hit.interactableId === "cone-direct", `hitCone named "${hit.interactableId}", expected "cone-direct"`);
169
+ assert(hit.distance > 0 && hit.distance <= 2 + slack(0.1), `hitCone reported distance ${String(hit.distance)}, expected about 2`);
170
+ assert(dist(hit.point, [0, 0, -2]) <= slack(0.1), "hitCone's point is not on the target");
171
+ },
172
+ },
173
+ {
174
+ name: "hitCone, when present, finds a target inside the cone that the ray itself misses",
175
+ run({ hitTester, driver }) {
176
+ if (!hitTester.hitCone)
177
+ return;
178
+ // 2 m ahead and 0.2 m to the side: its silhouette (radius 0.1) is about
179
+ // 2.9 degrees off axis, inside a 5 degree cone, outside the ray.
180
+ driver.place("cone-near", [0.2, 0, -2], 0.1);
181
+ assert(hitTester.hitRay(DOWN_RAY) === null, "the ray itself must miss the offset target");
182
+ const hit = hitTester.hitCone(DOWN_RAY, degrees(5), 30);
183
+ assert(hit !== null && hit.interactableId === "cone-near", "hitCone did not find the target inside the cone");
184
+ assert(dist(hit.point, [0.2, 0, -2]) <= slack(0.1), "hitCone's point is not on the target");
185
+ },
186
+ },
187
+ {
188
+ name: "hitCone, when present, ignores a target outside the cone and one beyond the length",
189
+ run({ hitTester, driver }) {
190
+ if (!hitTester.hitCone)
191
+ return;
192
+ driver.place("cone-wide", [0.5, 0, -2], 0.1);
193
+ driver.place("cone-far", [0, 0, -40], 0.1);
194
+ assert(hitTester.hitCone(DOWN_RAY, degrees(5), 30) === null, "hitCone answered with a target outside the cone or beyond the length");
195
+ },
196
+ },
197
+ {
198
+ name: "hitCone, when present, prefers the target nearer the axis, and the nearer of two on the axis",
199
+ run({ hitTester, driver }) {
200
+ if (!hitTester.hitCone)
201
+ return;
202
+ driver.place("cone-off", [0.15, 0, -2], 0.05);
203
+ driver.place("cone-on", [0.05, 0, -3], 0.05);
204
+ const byAngle = hitTester.hitCone(DOWN_RAY, degrees(8), 30);
205
+ assert(byAngle !== null && byAngle.interactableId === "cone-on", "hitCone did not prefer the target nearer the axis");
206
+ driver.place("cone-nearer", [0, 0, -1], 0.05);
207
+ const nearer = hitTester.hitCone(DOWN_RAY, degrees(8), 30);
208
+ assert(nearer !== null && nearer.interactableId === "cone-nearer", "with two targets on the axis, hitCone did not prefer the nearer");
209
+ },
210
+ },
211
+ {
212
+ name: "hitCone, when present, never answers with a target hidden by visible alone, when the driver can toggle it",
213
+ run({ hitTester, driver }) {
214
+ if (!hitTester.hitCone || !driver.setVisible)
215
+ return;
216
+ driver.place("cone-hidden", [0, 0, -2], 0.1);
217
+ driver.setVisible("cone-hidden", false);
218
+ assert(hitTester.hitCone(DOWN_RAY, degrees(5), 30) === null, "hitCone answered with a hidden target");
219
+ driver.setVisible("cone-hidden", true);
220
+ assert(hitTester.hitCone(DOWN_RAY, degrees(5), 30)?.interactableId === "cone-hidden", "hitCone lost the target after it was shown again");
221
+ },
222
+ },
157
223
  ];
158
224
  /**
159
225
  * The shared `TransformPort` conformance suite. An adapter's test file is a
@@ -372,6 +438,9 @@ function assert(condition, message) {
372
438
  if (!condition)
373
439
  throw new Error(message);
374
440
  }
441
+ function dist(a, b) {
442
+ return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
443
+ }
375
444
  function closeTo(a, b, eps) {
376
445
  return Math.abs(a - b) <= eps;
377
446
  }
@@ -1 +1 @@
1
- {"version":3,"file":"contract-cases.js","sourceRoot":"","sources":["../src/contract-cases.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAkD3D;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,QAAQ,GAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACxE,MAAM,QAAQ,GAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAEvE;;;;;;;;GAQG;AACH,mFAAmF;AACnF,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,SAAS,KAAK,CAAC,MAAc;IAC3B,OAAO,MAAM,GAAG,IAAI,CAAC;AACvB,CAAC;AAED,MAAM,gBAAgB,GAA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Ae,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;IAClF,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,KAAK,aAAa,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,UAAU,CAAC,CAAY;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * Shared `HitTester` and `TransformPort` conformance suites, shipped as data\n * rather than as tests - the same idea as `windowHostContractCases()` in\n * WebXR-UIExtensions and `inputProviderContractCases()` in\n * `@realitycollective/webxr-input`. Five adapters implement these two ports\n * against five different scene graphs; running the same checks against every\n * one is what stops an adapter quietly dropping a documented rule.\n *\n * The suites are runner-free on purpose. Every adapter repository already has\n * its own test runner, and an adapter written outside this repository cannot\n * reach into this one's `test/` folder, so the checks ship as plain objects\n * that throw an `Error` on failure and the adapter iterates them.\n *\n * Both suites assert only what `ports.ts` documents, including two rules\n * every platform now shares:\n * - `getWorldPose()` is the LIVE pose and `getRestWorldPose()` the rest pose\n * offsets are measured from.\n * - Every tuple a port returns is fresh and owned by the caller, and a tuple\n * passed in is not kept.\n */\nimport type { PoseTuple, QuatTuple, RayTuple, Vec3Tuple } from \"@realitycollective/webxr-input\";\nimport { quatMultiply, vAdd, vApplyQuat } from \"./math.js\";\nimport type { HitTester, HoldRelease, TransformPort } from \"./ports.js\";\n\n// ---------------------------------------------------------------------------\n// HitTester\n// ---------------------------------------------------------------------------\n\n/**\n * Places (or replaces) one target for a case to query against. Build a FRESH\n * subject per case: cases place targets of their own and do not clean up.\n */\nexport interface HitTesterContractDriver {\n /**\n * Register a target at `position` with an interaction radius of `radius`,\n * however the platform registers a target - a mesh, a node, an entity.\n */\n place(id: string, position: Vec3Tuple, radius: number): void;\n /**\n * Register a target at `position` with NO declared radius - a bare node\n * with no geometry of its own - on a platform that can register one\n * without a radius (three.js, XR Blocks, Babylon, IWSDK). `hitProximity`\n * must then treat it as a 0.1 m sphere, `ports.ts`'s documented default.\n * Leave this out on a platform whose registration always takes an\n * explicit radius (native); the case that needs it skips without running.\n */\n placeBare?(id: string, position: Vec3Tuple): void;\n /**\n * Hide, or show again, a placed target using the platform's own ordinary\n * visibility flag alone - three.js `Object3D.visible`, Babylon\n * `isVisible`/`setEnabled`, and so on - never by unregistering it. A hit\n * tester must never answer with a target hidden this way, even on an\n * engine whose own raycast ignores that flag by design (three.js's\n * `Raycaster`; see `ThreeHitTester.hitRay`'s own comment). Leave this out\n * on a platform with no such flag to toggle; the case that needs it skips.\n */\n setVisible?(id: string, visible: boolean): void;\n}\n\n/** The tester under test, plus the means of putting targets into its scene. */\nexport interface HitTesterContractSubject {\n hitTester: HitTester;\n driver: HitTesterContractDriver;\n}\n\n/** One check a {@link HitTester} implementation must pass. */\nexport interface HitTesterContractCase {\n name: string;\n run(subject: HitTesterContractSubject): void;\n}\n\n/**\n * The shared `HitTester` conformance suite. An adapter's test file is a loop:\n *\n * ```ts\n * for (const contractCase of hitTesterContractCases()) {\n * it(contractCase.name, () => contractCase.run(makeSubject()));\n * }\n * ```\n */\nexport function hitTesterContractCases(): readonly HitTesterContractCase[] {\n return HIT_TESTER_CASES;\n}\n\nconst DOWN_RAY: RayTuple = { origin: [0, 0, 0], direction: [0, 0, -1] };\nconst AWAY_RAY: RayTuple = { origin: [0, 0, 0], direction: [0, 0, 1] };\n\n/**\n * A ray-based query only has to land WITHIN the target's own radius:\n * `ports.ts` documents `point` as \"world-space hit or closest point\", so a\n * mesh-accurate ray tester (three.js) reporting the surface it actually hit\n * is as conforming as a sphere tester (Babylon, IWSDK) reporting the target's\n * centre. Placing the target exactly on the ray's line makes both answers\n * the same point when a tester has no radius-shaped slack, and this is the\n * tolerance for testers that do.\n */\n/** A surface distance is exact up to 1 mm, the tolerance the master row states. */\nconst SURFACE_EPS = 1e-3;\n\nfunction slack(radius: number): number {\n return radius + 0.05;\n}\n\nconst HIT_TESTER_CASES: readonly HitTesterContractCase[] = [\n {\n name: \"an empty scene answers a ray with null\",\n run({ hitTester }) {\n assert(hitTester.hitRay(DOWN_RAY) === null, \"hitRay over an empty scene must return null\");\n },\n },\n {\n name: \"a ray through a placed target returns its id, a positive distance and a point near the ray\",\n run({ hitTester, driver }) {\n const radius = 0.15;\n driver.place(\"target\", [0, 0, -2], radius);\n const hit = hitTester.hitRay(DOWN_RAY);\n assert(hit !== null, \"a ray through a placed target must not miss\");\n assert(hit.interactableId === \"target\", `expected interactableId \"target\", got \"${hit.interactableId}\"`);\n assert(hit.distance > 0, `distance must be positive, got ${hit.distance}`);\n const eps = slack(radius);\n assert(closeTo(hit.distance, 2, eps), `distance must be close to 2, got ${hit.distance}`);\n assertVec3Close(hit.point, [0, 0, -2], eps, \"point\");\n },\n },\n {\n name: \"a ray pointing away from the target returns null\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.15);\n assert(hitTester.hitRay(AWAY_RAY) === null, \"a ray pointing away from every target must return null\");\n },\n },\n {\n name: \"hitProximity finds a target inside its radius and misses outside it\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.1);\n const inside = hitTester.hitProximity([0, 0, -2], 0.5);\n assert(inside !== null, \"hitProximity at the target's own position must find it\");\n assert(\n inside.interactableId === \"target\",\n `expected interactableId \"target\", got \"${inside.interactableId}\"`,\n );\n const outside = hitTester.hitProximity([5, 5, 5], 0.05);\n assert(outside === null, \"hitProximity far from every target must return null\");\n },\n },\n {\n name: \"hitProximity reports the distance to the target's SURFACE, clamped at zero\",\n run({ hitTester, driver }) {\n // The master row: a point 3 cm outside a 10 cm target reports 0.03, not\n // 0.13. A tester that reports the distance to the centre removes every\n // near interaction, because no fingertip is ever within 5 cm of a\n // target's centre.\n driver.place(\"target\", [0, 0, -2], 0.1);\n const outside = hitTester.hitProximity([0.13, 0, -2], 0.5);\n assert(outside !== null, \"a point 3 cm outside a 10 cm target must be found within 0.5 m\");\n assert(\n closeTo(outside.distance, 0.03, SURFACE_EPS),\n `distance must be to the surface, 0.03 within 1 mm, got ${outside.distance}`,\n );\n const inside = hitTester.hitProximity([0.02, 0, -2], 0.5);\n assert(inside !== null && inside.distance === 0, `a point inside the target is at distance 0, got ${inside?.distance}`);\n },\n },\n {\n name: \"hitProximity misses a target whose surface is farther than the query radius\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.1);\n assert(\n hitTester.hitProximity([0.13, 0, -2], 0.02) === null,\n \"a surface 3 cm away is outside a 2 cm query and must not be found\",\n );\n assert(\n hitTester.hitProximity([0.13, 0, -2], 0.04) !== null,\n \"a surface 3 cm away is inside a 4 cm query and must be found\",\n );\n },\n },\n {\n name: \"a ray that passes a target farther than its radius misses it\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0.5, 0, -2], 0.1);\n assert(hitTester.hitRay(DOWN_RAY) === null, \"a ray 0.5 m from a 0.1 m target must miss it\");\n },\n },\n {\n name: \"with two targets on one ray, the nearer one wins\",\n run({ hitTester, driver }) {\n const radius = 0.1;\n driver.place(\"far\", [0, 0, -3], radius);\n driver.place(\"near\", [0, 0, -1], radius);\n const hit = hitTester.hitRay(DOWN_RAY);\n assert(hit !== null, \"a ray through two targets must not miss\");\n assert(hit.interactableId === \"near\", `the nearer target must win, got \"${hit.interactableId}\"`);\n assert(closeTo(hit.distance, 1, slack(radius)), `distance must be close to 1, got ${hit.distance}`);\n },\n },\n {\n name: \"hitProximity treats a target with no declared radius as a 0.1 m sphere, when the driver can register one\",\n run({ hitTester, driver }) {\n if (!driver.placeBare) return;\n driver.placeBare(\"bare\", [0, 0, -2]);\n // 0.12 m from the centre is 0.02 m outside a 0.1 m default radius -\n // found within a 0.05 m query, and NOT the 0.12 m a zero-radius\n // reading would report.\n const found = hitTester.hitProximity([0.12, 0, -2], 0.05);\n assert(\n found !== null,\n \"a point 0.12 m from a bare target's centre must be found within a 0.05 m query, given the 0.1 m default radius\",\n );\n assert(\n closeTo(found.distance, 0.02, SURFACE_EPS),\n `distance must be to the default 0.1 m surface, 0.02 within 1 mm, got ${found.distance}`,\n );\n },\n },\n {\n name: \"an object hidden by visible alone is never hit, when the driver can toggle it\",\n run({ hitTester, driver }) {\n if (!driver.setVisible) return;\n driver.place(\"target\", [0, 0, -2], 0.15);\n driver.setVisible(\"target\", false);\n assert(\n hitTester.hitRay(DOWN_RAY) === null,\n \"a ray must not hit a target hidden by visible alone\",\n );\n assert(\n hitTester.hitProximity([0, 0, -2], 0.5) === null,\n \"hitProximity must not find a target hidden by visible alone\",\n );\n driver.setVisible(\"target\", true);\n assert(\n hitTester.hitRay(DOWN_RAY) !== null,\n \"showing the target again must restore the hit\",\n );\n },\n },\n {\n name: \"each hit and its point are fresh values the caller owns\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.15);\n for (const [label, query] of [\n [\"hitRay\", () => hitTester.hitRay(DOWN_RAY)],\n [\"hitProximity\", () => hitTester.hitProximity([0, 0, -2], 0.5)],\n ] as const) {\n const first = query();\n const second = query();\n assert(first !== null && second !== null, `${label} must find the placed target`);\n assert(second !== first && second.point !== first.point, `${label} must return a new hit and point each call`);\n const expected = first.point[2];\n first.point[2] = 1e6;\n const third = query();\n assert(\n third !== null && closeTo(third.point[2], expected, POSE_EPS),\n `writing to a returned point must not change the next ${label} answer`,\n );\n }\n },\n },\n];\n\n// ---------------------------------------------------------------------------\n// TransformPort\n// ---------------------------------------------------------------------------\n\n/**\n * Advances a subject's physics simulation - a real engine step where a\n * platform's physics can run in a test, otherwise a fake that faithfully\n * reproduces the one behaviour these cases check: gravity moves the object\n * unless held, and a release velocity carries it.\n */\nexport interface TransformPortPhysicsDriver {\n step(dtSeconds: number): void;\n}\n\n/** The port under test, over one object. Build a FRESH one per case. */\nexport interface TransformPortContractSubject {\n port: TransformPort;\n /**\n * The world pose the object sat at when the port captured its rest. Place\n * it away from the origin and turned, under no parent or an unscaled one,\n * so a port that ignores its rest frame cannot pass by accident.\n */\n rest: PoseTuple;\n /**\n * Present only when the object has a physics body - the same condition\n * that gives the port `beginHold`/`endHold`. The held/released/reset\n * cases below skip without one, since there is nothing for them to check.\n */\n physics?: TransformPortPhysicsDriver;\n}\n\n/** One check a {@link TransformPort} implementation must pass. */\nexport interface TransformPortContractCase {\n name: string;\n run(subject: TransformPortContractSubject): void;\n}\n\n/**\n * The shared `TransformPort` conformance suite. An adapter's test file is a\n * loop, the same shape as {@link hitTesterContractCases}.\n */\nexport function transformPortContractCases(): readonly TransformPortContractCase[] {\n return TRANSFORM_PORT_CASES;\n}\n\nconst POSE_EPS = 1e-3;\n// A quarter turn about Y - a non-identity unit quaternion, so the case\n// cannot pass by accident on a port that ignores its argument.\nconst QUARTER_TURN_Y: QuatTuple = [0, Math.SQRT1_2, 0, Math.SQRT1_2];\n\n// ---------------------------------------------------------------------------\n// Held / released / reset - the \"held pose\" rule, checked only when the\n// subject carries a physics driver. One fixed step size and a looser\n// position tolerance than POSE_EPS: real engines differ slightly in their\n// integrator, and a held/reset case allows for up to one step of gravity\n// (see PHYSICS_POSE_EPS's own comment), where the plain pose cases above\n// never touch physics at all.\n// ---------------------------------------------------------------------------\n\nconst PHYSICS_DT = 1 / 60;\nconst HELD_STEPS = 5;\n/** metres/second - small enough that one step's drift is easy to read, large enough not to vanish into PHYSICS_POSE_EPS. */\nconst RELEASE_SPEED = 2;\n/** metres/second - about 25x RELEASE_SPEED, so \"kept the old velocity\" and \"one step of gravity\" cannot be confused. */\nconst LARGE_PRIOR_SPEED = 50;\n/**\n * 2 cm. One step of gravity at PHYSICS_DT droops roughly\n * `0.5 * 9.8 * PHYSICS_DT^2` ≈ 1.4 mm, well inside this; a full step of\n * LARGE_PRIOR_SPEED (≈ 0.83 m) or RELEASE_SPEED (≈ 33 mm) is well outside it.\n */\nconst PHYSICS_POSE_EPS = 0.02;\n\nfunction assertPhysicsPoseClose(value: PoseTuple, expected: PoseTuple, label: string): void {\n assertVec3Close(value.position, expected.position, PHYSICS_POSE_EPS, `${label}.position`);\n assertQuatClose(value.quaternion, expected.quaternion, `${label}.quaternion`);\n}\n\nconst TRANSFORM_PORT_CASES: readonly TransformPortContractCase[] = [\n {\n name: \"setLocalOffset then getLocalOffset returns the same offset\",\n run({ port }) {\n const offset: Vec3Tuple = [0.3, -0.1, 0.05];\n port.setLocalOffset(offset);\n assertVec3Close(port.getLocalOffset(), offset, POSE_EPS, \"getLocalOffset()\");\n },\n },\n {\n name: \"getWorldPose returns finite numbers and a unit quaternion\",\n run({ port }) {\n const pose = port.getWorldPose();\n for (const value of [...pose.position, ...pose.quaternion]) {\n assert(Number.isFinite(value), `getWorldPose() must return finite numbers, got ${value}`);\n }\n const length = quatLength(pose.quaternion);\n assert(\n closeTo(length, 1, POSE_EPS),\n `getWorldPose().quaternion must be a unit quaternion, length was ${length}`,\n );\n },\n },\n {\n name: \"setLocalRotation with a unit quaternion does not throw\",\n run({ port }) {\n try {\n port.setLocalRotation(QUARTER_TURN_Y);\n } catch (error) {\n throw new Error(`setLocalRotation(unit quaternion) must not throw, it threw: ${String(error)}`);\n }\n },\n },\n {\n name: \"getRestWorldPose returns the pose captured at registration\",\n run({ port, rest }) {\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose()\");\n },\n },\n {\n name: \"before any write, the live pose is the rest pose\",\n run({ port, rest }) {\n assertPoseClose(port.getWorldPose(), rest, \"getWorldPose()\");\n },\n },\n {\n name: \"getWorldPose follows setLocalOffset while getRestWorldPose stays put\",\n run({ port, rest }) {\n const offset: Vec3Tuple = [0.3, -0.1, 0.05];\n port.setLocalOffset(offset);\n assertVec3Close(\n port.getWorldPose().position,\n vAdd(rest.position, vApplyQuat(offset, rest.quaternion)),\n POSE_EPS,\n \"getWorldPose().position after setLocalOffset\",\n );\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose() after setLocalOffset\");\n },\n },\n {\n name: \"getWorldPose follows setLocalRotation while getRestWorldPose stays put\",\n run({ port, rest }) {\n port.setLocalRotation(QUARTER_TURN_Y);\n assertQuatClose(\n port.getWorldPose().quaternion,\n quatMultiply(rest.quaternion, QUARTER_TURN_Y),\n \"getWorldPose().quaternion after setLocalRotation\",\n );\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose() after setLocalRotation\");\n },\n },\n {\n name: \"setWorldPose, when present, is what getWorldPose reads back\",\n run({ port, rest }) {\n if (!port.setWorldPose) return;\n const target: PoseTuple = { position: [0.5, 1.2, -0.4], quaternion: QUARTER_TURN_Y };\n port.setWorldPose(target);\n assertPoseClose(port.getWorldPose(), target, \"getWorldPose() after setWorldPose\");\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose() after setWorldPose\");\n },\n },\n {\n name: \"every returned tuple is a fresh value the caller owns\",\n run({ port }) {\n const pose = port.getWorldPose();\n const restPose = port.getRestWorldPose();\n const offset = port.getLocalOffset();\n pose.position[0] = 1e6;\n pose.quaternion[3] = 1e6;\n restPose.position[0] = 1e6;\n offset[0] = 1e6;\n assert(port.getWorldPose().position[0] !== 1e6, \"writing to a returned getWorldPose() tuple must not change the port\");\n assert(port.getWorldPose().quaternion[3] !== 1e6, \"writing to a returned getWorldPose() quaternion must not change the port\");\n assert(port.getRestWorldPose().position[0] !== 1e6, \"writing to a returned getRestWorldPose() tuple must not change the port\");\n assert(port.getLocalOffset()[0] !== 1e6, \"writing to a returned getLocalOffset() tuple must not change the port\");\n },\n },\n {\n name: \"a tuple passed in is not kept\",\n run({ port }) {\n const offset: Vec3Tuple = [0.3, -0.1, 0.05];\n port.setLocalOffset(offset);\n offset[0] = 9;\n assertVec3Close(port.getLocalOffset(), [0.3, -0.1, 0.05], POSE_EPS, \"getLocalOffset() after the caller reused its tuple\");\n if (!port.setWorldPose) return;\n const target: PoseTuple = { position: [0.5, 1.2, -0.4], quaternion: [0, 0, 0, 1] };\n port.setWorldPose(target);\n target.position[0] = 9;\n assertVec3Close(port.getWorldPose().position, [0.5, 1.2, -0.4], POSE_EPS, \"getWorldPose() after the caller reused its tuple\");\n },\n },\n {\n name: \"setEffect, when present, accepts scale and emissive without throwing\",\n run({ port }) {\n if (!port.setEffect) return;\n try {\n port.setEffect({ scale: 1.2, emissive: 0.3 });\n } catch (error) {\n throw new Error(`setEffect({ scale, emissive }) must not throw, it threw: ${String(error)}`);\n }\n },\n },\n {\n name: \"Held: beginHold holds a fixed setWorldPose without falling, when the subject has physics\",\n run({ port, rest, physics }) {\n if (!physics || !port.setWorldPose || !port.beginHold) return;\n const held: PoseTuple = {\n position: [rest.position[0], rest.position[1] + 1, rest.position[2]],\n quaternion: rest.quaternion,\n };\n port.beginHold();\n for (let i = 0; i < HELD_STEPS; i++) {\n port.setWorldPose(held);\n physics.step(PHYSICS_DT);\n }\n // A tight tolerance, not PHYSICS_POSE_EPS: a genuinely held body sees\n // no simulation at all, so it matches the written pose exactly bar\n // floating point noise - the same POSE_EPS the non-physics cases\n // above use. One step of unwanted gravity (~2.7 mm at PHYSICS_DT) is\n // what this case exists to catch, and it must not hide inside the\n // tolerance the way it deliberately may in the Reset case below.\n assertPoseClose(port.getWorldPose(), held, `getWorldPose() after ${HELD_STEPS} held steps`);\n },\n },\n {\n name: \"Released: endHold sends the body away with the release velocity, when the subject has physics\",\n run({ port, rest, physics }) {\n if (!physics || !port.beginHold || !port.endHold) return;\n port.beginHold();\n const release: HoldRelease = { linearVelocity: [RELEASE_SPEED, 0, 0], angularVelocity: [0, 0, 0] };\n port.endHold(release);\n physics.step(PHYSICS_DT);\n const moved = port.getWorldPose().position[0] - rest.position[0];\n assert(\n moved > RELEASE_SPEED * PHYSICS_DT * 0.5,\n `endHold({ linearVelocity: [${RELEASE_SPEED}, 0, 0] }) must move the body that way within one step, moved ${moved}`,\n );\n },\n },\n {\n name: \"Reset: setWorldPose while not held teleports to the pose and clears velocity, when the subject has physics\",\n run({ port, rest, physics }) {\n if (!physics || !port.setWorldPose || !port.beginHold || !port.endHold) return;\n // Give the body a large prior velocity and let it run for a step, so\n // carrying that velocity through the reset below is unmistakable -\n // one step of it (~0.83 m) dwarfs PHYSICS_POSE_EPS (2 cm).\n port.beginHold();\n const priorRelease: HoldRelease = { linearVelocity: [LARGE_PRIOR_SPEED, 0, 0], angularVelocity: [0, 0, 0] };\n port.endHold(priorRelease);\n physics.step(PHYSICS_DT);\n const target: PoseTuple = {\n position: [rest.position[0] - 1, rest.position[1] + 2, rest.position[2] + 0.5],\n quaternion: rest.quaternion,\n };\n port.setWorldPose(target);\n // One further step: it must be at `target`, not carrying the prior\n // velocity forward - allowing for this one step's worth of gravity.\n physics.step(PHYSICS_DT);\n assertPhysicsPoseClose(port.getWorldPose(), target, \"getWorldPose() one step after a reset setWorldPose\");\n },\n },\n];\n\n// ---------------------------------------------------------------------------\n// Shared assertion helpers\n// ---------------------------------------------------------------------------\n\nfunction assert(condition: boolean, message: string): asserts condition {\n if (!condition) throw new Error(message);\n}\n\nfunction closeTo(a: number, b: number, eps: number): boolean {\n return Math.abs(a - b) <= eps;\n}\n\n// Indexed one component at a time, rather than in a loop, so each index is a\n// literal: `noUncheckedIndexedAccess` cannot narrow a tuple read through a\n// variable index back to `number`.\nfunction assertVec3Close(value: Vec3Tuple, expected: Vec3Tuple, eps: number, label: string): void {\n assert(closeTo(value[0], expected[0], eps), `${label}[0] must be close to ${expected[0]}, got ${value[0]}`);\n assert(closeTo(value[1], expected[1], eps), `${label}[1] must be close to ${expected[1]}, got ${value[1]}`);\n assert(closeTo(value[2], expected[2], eps), `${label}[2] must be close to ${expected[2]}, got ${value[2]}`);\n}\n\n// q and -q are the same rotation, so compare by the size of the dot product.\nfunction assertQuatClose(value: QuatTuple, expected: QuatTuple, label: string): void {\n const dot = value[0] * expected[0] + value[1] * expected[1] + value[2] * expected[2] + value[3] * expected[3];\n assert(\n closeTo(Math.abs(dot), 1, POSE_EPS),\n `${label} must be close to [${expected.join(\", \")}], got [${value.join(\", \")}]`,\n );\n}\n\nfunction assertPoseClose(value: PoseTuple, expected: PoseTuple, label: string): void {\n assertVec3Close(value.position, expected.position, POSE_EPS, `${label}.position`);\n assertQuatClose(value.quaternion, expected.quaternion, `${label}.quaternion`);\n}\n\nfunction quatLength(q: QuatTuple): number {\n return Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);\n}\n"]}
1
+ {"version":3,"file":"contract-cases.js","sourceRoot":"","sources":["../src/contract-cases.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAkD3D;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,QAAQ,GAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACxE,MAAM,QAAQ,GAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAEvE;;;;;;;;GAQG;AACH,mFAAmF;AACnF,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACjC,CAAC;AAED,SAAS,KAAK,CAAC,MAAc;IAC3B,OAAO,MAAM,GAAG,IAAI,CAAC;AACvB,CA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CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9G,MAAM,CACJ,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,EACnC,GAAG,KAAK,sBAAsB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChF,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAgB,EAAE,QAAmB,EAAE,KAAa;IAC3E,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;IAClF,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,KAAK,aAAa,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,UAAU,CAAC,CAAY;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * Shared `HitTester` and `TransformPort` conformance suites, shipped as data\n * rather than as tests - the same idea as `windowHostContractCases()` in\n * WebXR-UIExtensions and `inputProviderContractCases()` in\n * `@realitycollective/webxr-input`. Five adapters implement these two ports\n * against five different scene graphs; running the same checks against every\n * one is what stops an adapter quietly dropping a documented rule.\n *\n * The suites are runner-free on purpose. Every adapter repository already has\n * its own test runner, and an adapter written outside this repository cannot\n * reach into this one's `test/` folder, so the checks ship as plain objects\n * that throw an `Error` on failure and the adapter iterates them.\n *\n * Both suites assert only what `ports.ts` documents, including two rules\n * every platform now shares:\n * - `getWorldPose()` is the LIVE pose and `getRestWorldPose()` the rest pose\n * offsets are measured from.\n * - Every tuple a port returns is fresh and owned by the caller, and a tuple\n * passed in is not kept.\n */\nimport type { PoseTuple, QuatTuple, RayTuple, Vec3Tuple } from \"@realitycollective/webxr-input\";\nimport { quatMultiply, vAdd, vApplyQuat } from \"./math.js\";\nimport type { HitTester, HoldRelease, TransformPort } from \"./ports.js\";\n\n// ---------------------------------------------------------------------------\n// HitTester\n// ---------------------------------------------------------------------------\n\n/**\n * Places (or replaces) one target for a case to query against. Build a FRESH\n * subject per case: cases place targets of their own and do not clean up.\n */\nexport interface HitTesterContractDriver {\n /**\n * Register a target at `position` with an interaction radius of `radius`,\n * however the platform registers a target - a mesh, a node, an entity.\n */\n place(id: string, position: Vec3Tuple, radius: number): void;\n /**\n * Register a target at `position` with NO declared radius - a bare node\n * with no geometry of its own - on a platform that can register one\n * without a radius (three.js, XR Blocks, Babylon, IWSDK). `hitProximity`\n * must then treat it as a 0.1 m sphere, `ports.ts`'s documented default.\n * Leave this out on a platform whose registration always takes an\n * explicit radius (native); the case that needs it skips without running.\n */\n placeBare?(id: string, position: Vec3Tuple): void;\n /**\n * Hide, or show again, a placed target using the platform's own ordinary\n * visibility flag alone - three.js `Object3D.visible`, Babylon\n * `isVisible`/`setEnabled`, and so on - never by unregistering it. A hit\n * tester must never answer with a target hidden this way, even on an\n * engine whose own raycast ignores that flag by design (three.js's\n * `Raycaster`; see `ThreeHitTester.hitRay`'s own comment). Leave this out\n * on a platform with no such flag to toggle; the case that needs it skips.\n */\n setVisible?(id: string, visible: boolean): void;\n}\n\n/** The tester under test, plus the means of putting targets into its scene. */\nexport interface HitTesterContractSubject {\n hitTester: HitTester;\n driver: HitTesterContractDriver;\n}\n\n/** One check a {@link HitTester} implementation must pass. */\nexport interface HitTesterContractCase {\n name: string;\n run(subject: HitTesterContractSubject): void;\n}\n\n/**\n * The shared `HitTester` conformance suite. An adapter's test file is a loop:\n *\n * ```ts\n * for (const contractCase of hitTesterContractCases()) {\n * it(contractCase.name, () => contractCase.run(makeSubject()));\n * }\n * ```\n */\nexport function hitTesterContractCases(): readonly HitTesterContractCase[] {\n return HIT_TESTER_CASES;\n}\n\nconst DOWN_RAY: RayTuple = { origin: [0, 0, 0], direction: [0, 0, -1] };\nconst AWAY_RAY: RayTuple = { origin: [0, 0, 0], direction: [0, 0, 1] };\n\n/**\n * A ray-based query only has to land WITHIN the target's own radius:\n * `ports.ts` documents `point` as \"world-space hit or closest point\", so a\n * mesh-accurate ray tester (three.js) reporting the surface it actually hit\n * is as conforming as a sphere tester (Babylon, IWSDK) reporting the target's\n * centre. Placing the target exactly on the ray's line makes both answers\n * the same point when a tester has no radius-shaped slack, and this is the\n * tolerance for testers that do.\n */\n/** A surface distance is exact up to 1 mm, the tolerance the master row states. */\nconst SURFACE_EPS = 1e-3;\n\nfunction degrees(value: number): number {\n return (value * Math.PI) / 180;\n}\n\nfunction slack(radius: number): number {\n return radius + 0.05;\n}\n\nconst HIT_TESTER_CASES: readonly HitTesterContractCase[] = [\n {\n name: \"an empty scene answers a ray with null\",\n run({ hitTester }) {\n assert(hitTester.hitRay(DOWN_RAY) === null, \"hitRay over an empty scene must return null\");\n },\n },\n {\n name: \"a ray through a placed target returns its id, a positive distance and a point near the ray\",\n run({ hitTester, driver }) {\n const radius = 0.15;\n driver.place(\"target\", [0, 0, -2], radius);\n const hit = hitTester.hitRay(DOWN_RAY);\n assert(hit !== null, \"a ray through a placed target must not miss\");\n assert(hit.interactableId === \"target\", `expected interactableId \"target\", got \"${hit.interactableId}\"`);\n assert(hit.distance > 0, `distance must be positive, got ${hit.distance}`);\n const eps = slack(radius);\n assert(closeTo(hit.distance, 2, eps), `distance must be close to 2, got ${hit.distance}`);\n assertVec3Close(hit.point, [0, 0, -2], eps, \"point\");\n },\n },\n {\n name: \"a ray pointing away from the target returns null\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.15);\n assert(hitTester.hitRay(AWAY_RAY) === null, \"a ray pointing away from every target must return null\");\n },\n },\n {\n name: \"hitProximity finds a target inside its radius and misses outside it\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.1);\n const inside = hitTester.hitProximity([0, 0, -2], 0.5);\n assert(inside !== null, \"hitProximity at the target's own position must find it\");\n assert(\n inside.interactableId === \"target\",\n `expected interactableId \"target\", got \"${inside.interactableId}\"`,\n );\n const outside = hitTester.hitProximity([5, 5, 5], 0.05);\n assert(outside === null, \"hitProximity far from every target must return null\");\n },\n },\n {\n name: \"hitProximity reports the distance to the target's SURFACE, clamped at zero\",\n run({ hitTester, driver }) {\n // The master row: a point 3 cm outside a 10 cm target reports 0.03, not\n // 0.13. A tester that reports the distance to the centre removes every\n // near interaction, because no fingertip is ever within 5 cm of a\n // target's centre.\n driver.place(\"target\", [0, 0, -2], 0.1);\n const outside = hitTester.hitProximity([0.13, 0, -2], 0.5);\n assert(outside !== null, \"a point 3 cm outside a 10 cm target must be found within 0.5 m\");\n assert(\n closeTo(outside.distance, 0.03, SURFACE_EPS),\n `distance must be to the surface, 0.03 within 1 mm, got ${outside.distance}`,\n );\n const inside = hitTester.hitProximity([0.02, 0, -2], 0.5);\n assert(inside !== null && inside.distance === 0, `a point inside the target is at distance 0, got ${inside?.distance}`);\n },\n },\n {\n name: \"hitProximity misses a target whose surface is farther than the query radius\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.1);\n assert(\n hitTester.hitProximity([0.13, 0, -2], 0.02) === null,\n \"a surface 3 cm away is outside a 2 cm query and must not be found\",\n );\n assert(\n hitTester.hitProximity([0.13, 0, -2], 0.04) !== null,\n \"a surface 3 cm away is inside a 4 cm query and must be found\",\n );\n },\n },\n {\n name: \"a ray that passes a target farther than its radius misses it\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0.5, 0, -2], 0.1);\n assert(hitTester.hitRay(DOWN_RAY) === null, \"a ray 0.5 m from a 0.1 m target must miss it\");\n },\n },\n {\n name: \"with two targets on one ray, the nearer one wins\",\n run({ hitTester, driver }) {\n const radius = 0.1;\n driver.place(\"far\", [0, 0, -3], radius);\n driver.place(\"near\", [0, 0, -1], radius);\n const hit = hitTester.hitRay(DOWN_RAY);\n assert(hit !== null, \"a ray through two targets must not miss\");\n assert(hit.interactableId === \"near\", `the nearer target must win, got \"${hit.interactableId}\"`);\n assert(closeTo(hit.distance, 1, slack(radius)), `distance must be close to 1, got ${hit.distance}`);\n },\n },\n {\n name: \"hitProximity treats a target with no declared radius as a 0.1 m sphere, when the driver can register one\",\n run({ hitTester, driver }) {\n if (!driver.placeBare) return;\n driver.placeBare(\"bare\", [0, 0, -2]);\n // 0.12 m from the centre is 0.02 m outside a 0.1 m default radius -\n // found within a 0.05 m query, and NOT the 0.12 m a zero-radius\n // reading would report.\n const found = hitTester.hitProximity([0.12, 0, -2], 0.05);\n assert(\n found !== null,\n \"a point 0.12 m from a bare target's centre must be found within a 0.05 m query, given the 0.1 m default radius\",\n );\n assert(\n closeTo(found.distance, 0.02, SURFACE_EPS),\n `distance must be to the default 0.1 m surface, 0.02 within 1 mm, got ${found.distance}`,\n );\n },\n },\n {\n name: \"an object hidden by visible alone is never hit, when the driver can toggle it\",\n run({ hitTester, driver }) {\n if (!driver.setVisible) return;\n driver.place(\"target\", [0, 0, -2], 0.15);\n driver.setVisible(\"target\", false);\n assert(\n hitTester.hitRay(DOWN_RAY) === null,\n \"a ray must not hit a target hidden by visible alone\",\n );\n assert(\n hitTester.hitProximity([0, 0, -2], 0.5) === null,\n \"hitProximity must not find a target hidden by visible alone\",\n );\n driver.setVisible(\"target\", true);\n assert(\n hitTester.hitRay(DOWN_RAY) !== null,\n \"showing the target again must restore the hit\",\n );\n },\n },\n {\n name: \"each hit and its point are fresh values the caller owns\",\n run({ hitTester, driver }) {\n driver.place(\"target\", [0, 0, -2], 0.15);\n for (const [label, query] of [\n [\"hitRay\", () => hitTester.hitRay(DOWN_RAY)],\n [\"hitProximity\", () => hitTester.hitProximity([0, 0, -2], 0.5)],\n ] as const) {\n const first = query();\n const second = query();\n assert(first !== null && second !== null, `${label} must find the placed target`);\n assert(second !== first && second.point !== first.point, `${label} must return a new hit and point each call`);\n const expected = first.point[2];\n first.point[2] = 1e6;\n const third = query();\n assert(\n third !== null && closeTo(third.point[2], expected, POSE_EPS),\n `writing to a returned point must not change the next ${label} answer`,\n );\n }\n },\n },\n {\n name: \"hitCone, when present, answers a ray that reaches a target with that target at angular distance zero\",\n run({ hitTester, driver }) {\n if (!hitTester.hitCone) return;\n driver.place(\"cone-direct\", [0, 0, -2], 0.1);\n const hit = hitTester.hitCone(DOWN_RAY, degrees(5), 30);\n assert(hit !== null, \"hitCone answered null for a target on the ray\");\n assert(hit.interactableId === \"cone-direct\", `hitCone named \"${hit.interactableId}\", expected \"cone-direct\"`);\n assert(hit.distance > 0 && hit.distance <= 2 + slack(0.1), `hitCone reported distance ${String(hit.distance)}, expected about 2`);\n assert(dist(hit.point, [0, 0, -2]) <= slack(0.1), \"hitCone's point is not on the target\");\n },\n },\n {\n name: \"hitCone, when present, finds a target inside the cone that the ray itself misses\",\n run({ hitTester, driver }) {\n if (!hitTester.hitCone) return;\n // 2 m ahead and 0.2 m to the side: its silhouette (radius 0.1) is about\n // 2.9 degrees off axis, inside a 5 degree cone, outside the ray.\n driver.place(\"cone-near\", [0.2, 0, -2], 0.1);\n assert(hitTester.hitRay(DOWN_RAY) === null, \"the ray itself must miss the offset target\");\n const hit = hitTester.hitCone(DOWN_RAY, degrees(5), 30);\n assert(hit !== null && hit.interactableId === \"cone-near\", \"hitCone did not find the target inside the cone\");\n assert(dist(hit.point, [0.2, 0, -2]) <= slack(0.1), \"hitCone's point is not on the target\");\n },\n },\n {\n name: \"hitCone, when present, ignores a target outside the cone and one beyond the length\",\n run({ hitTester, driver }) {\n if (!hitTester.hitCone) return;\n driver.place(\"cone-wide\", [0.5, 0, -2], 0.1);\n driver.place(\"cone-far\", [0, 0, -40], 0.1);\n assert(hitTester.hitCone(DOWN_RAY, degrees(5), 30) === null, \"hitCone answered with a target outside the cone or beyond the length\");\n },\n },\n {\n name: \"hitCone, when present, prefers the target nearer the axis, and the nearer of two on the axis\",\n run({ hitTester, driver }) {\n if (!hitTester.hitCone) return;\n driver.place(\"cone-off\", [0.15, 0, -2], 0.05);\n driver.place(\"cone-on\", [0.05, 0, -3], 0.05);\n const byAngle = hitTester.hitCone(DOWN_RAY, degrees(8), 30);\n assert(byAngle !== null && byAngle.interactableId === \"cone-on\", \"hitCone did not prefer the target nearer the axis\");\n driver.place(\"cone-nearer\", [0, 0, -1], 0.05);\n const nearer = hitTester.hitCone(DOWN_RAY, degrees(8), 30);\n assert(nearer !== null && nearer.interactableId === \"cone-nearer\", \"with two targets on the axis, hitCone did not prefer the nearer\");\n },\n },\n {\n name: \"hitCone, when present, never answers with a target hidden by visible alone, when the driver can toggle it\",\n run({ hitTester, driver }) {\n if (!hitTester.hitCone || !driver.setVisible) return;\n driver.place(\"cone-hidden\", [0, 0, -2], 0.1);\n driver.setVisible(\"cone-hidden\", false);\n assert(hitTester.hitCone(DOWN_RAY, degrees(5), 30) === null, \"hitCone answered with a hidden target\");\n driver.setVisible(\"cone-hidden\", true);\n assert(hitTester.hitCone(DOWN_RAY, degrees(5), 30)?.interactableId === \"cone-hidden\", \"hitCone lost the target after it was shown again\");\n },\n },\n];\n\n// ---------------------------------------------------------------------------\n// TransformPort\n// ---------------------------------------------------------------------------\n\n/**\n * Advances a subject's physics simulation - a real engine step where a\n * platform's physics can run in a test, otherwise a fake that faithfully\n * reproduces the one behaviour these cases check: gravity moves the object\n * unless held, and a release velocity carries it.\n */\nexport interface TransformPortPhysicsDriver {\n step(dtSeconds: number): void;\n}\n\n/** The port under test, over one object. Build a FRESH one per case. */\nexport interface TransformPortContractSubject {\n port: TransformPort;\n /**\n * The world pose the object sat at when the port captured its rest. Place\n * it away from the origin and turned, under no parent or an unscaled one,\n * so a port that ignores its rest frame cannot pass by accident.\n */\n rest: PoseTuple;\n /**\n * Present only when the object has a physics body - the same condition\n * that gives the port `beginHold`/`endHold`. The held/released/reset\n * cases below skip without one, since there is nothing for them to check.\n */\n physics?: TransformPortPhysicsDriver;\n}\n\n/** One check a {@link TransformPort} implementation must pass. */\nexport interface TransformPortContractCase {\n name: string;\n run(subject: TransformPortContractSubject): void;\n}\n\n/**\n * The shared `TransformPort` conformance suite. An adapter's test file is a\n * loop, the same shape as {@link hitTesterContractCases}.\n */\nexport function transformPortContractCases(): readonly TransformPortContractCase[] {\n return TRANSFORM_PORT_CASES;\n}\n\nconst POSE_EPS = 1e-3;\n// A quarter turn about Y - a non-identity unit quaternion, so the case\n// cannot pass by accident on a port that ignores its argument.\nconst QUARTER_TURN_Y: QuatTuple = [0, Math.SQRT1_2, 0, Math.SQRT1_2];\n\n// ---------------------------------------------------------------------------\n// Held / released / reset - the \"held pose\" rule, checked only when the\n// subject carries a physics driver. One fixed step size and a looser\n// position tolerance than POSE_EPS: real engines differ slightly in their\n// integrator, and a held/reset case allows for up to one step of gravity\n// (see PHYSICS_POSE_EPS's own comment), where the plain pose cases above\n// never touch physics at all.\n// ---------------------------------------------------------------------------\n\nconst PHYSICS_DT = 1 / 60;\nconst HELD_STEPS = 5;\n/** metres/second - small enough that one step's drift is easy to read, large enough not to vanish into PHYSICS_POSE_EPS. */\nconst RELEASE_SPEED = 2;\n/** metres/second - about 25x RELEASE_SPEED, so \"kept the old velocity\" and \"one step of gravity\" cannot be confused. */\nconst LARGE_PRIOR_SPEED = 50;\n/**\n * 2 cm. One step of gravity at PHYSICS_DT droops roughly\n * `0.5 * 9.8 * PHYSICS_DT^2` ≈ 1.4 mm, well inside this; a full step of\n * LARGE_PRIOR_SPEED (≈ 0.83 m) or RELEASE_SPEED (≈ 33 mm) is well outside it.\n */\nconst PHYSICS_POSE_EPS = 0.02;\n\nfunction assertPhysicsPoseClose(value: PoseTuple, expected: PoseTuple, label: string): void {\n assertVec3Close(value.position, expected.position, PHYSICS_POSE_EPS, `${label}.position`);\n assertQuatClose(value.quaternion, expected.quaternion, `${label}.quaternion`);\n}\n\nconst TRANSFORM_PORT_CASES: readonly TransformPortContractCase[] = [\n {\n name: \"setLocalOffset then getLocalOffset returns the same offset\",\n run({ port }) {\n const offset: Vec3Tuple = [0.3, -0.1, 0.05];\n port.setLocalOffset(offset);\n assertVec3Close(port.getLocalOffset(), offset, POSE_EPS, \"getLocalOffset()\");\n },\n },\n {\n name: \"getWorldPose returns finite numbers and a unit quaternion\",\n run({ port }) {\n const pose = port.getWorldPose();\n for (const value of [...pose.position, ...pose.quaternion]) {\n assert(Number.isFinite(value), `getWorldPose() must return finite numbers, got ${value}`);\n }\n const length = quatLength(pose.quaternion);\n assert(\n closeTo(length, 1, POSE_EPS),\n `getWorldPose().quaternion must be a unit quaternion, length was ${length}`,\n );\n },\n },\n {\n name: \"setLocalRotation with a unit quaternion does not throw\",\n run({ port }) {\n try {\n port.setLocalRotation(QUARTER_TURN_Y);\n } catch (error) {\n throw new Error(`setLocalRotation(unit quaternion) must not throw, it threw: ${String(error)}`);\n }\n },\n },\n {\n name: \"getRestWorldPose returns the pose captured at registration\",\n run({ port, rest }) {\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose()\");\n },\n },\n {\n name: \"before any write, the live pose is the rest pose\",\n run({ port, rest }) {\n assertPoseClose(port.getWorldPose(), rest, \"getWorldPose()\");\n },\n },\n {\n name: \"getWorldPose follows setLocalOffset while getRestWorldPose stays put\",\n run({ port, rest }) {\n const offset: Vec3Tuple = [0.3, -0.1, 0.05];\n port.setLocalOffset(offset);\n assertVec3Close(\n port.getWorldPose().position,\n vAdd(rest.position, vApplyQuat(offset, rest.quaternion)),\n POSE_EPS,\n \"getWorldPose().position after setLocalOffset\",\n );\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose() after setLocalOffset\");\n },\n },\n {\n name: \"getWorldPose follows setLocalRotation while getRestWorldPose stays put\",\n run({ port, rest }) {\n port.setLocalRotation(QUARTER_TURN_Y);\n assertQuatClose(\n port.getWorldPose().quaternion,\n quatMultiply(rest.quaternion, QUARTER_TURN_Y),\n \"getWorldPose().quaternion after setLocalRotation\",\n );\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose() after setLocalRotation\");\n },\n },\n {\n name: \"setWorldPose, when present, is what getWorldPose reads back\",\n run({ port, rest }) {\n if (!port.setWorldPose) return;\n const target: PoseTuple = { position: [0.5, 1.2, -0.4], quaternion: QUARTER_TURN_Y };\n port.setWorldPose(target);\n assertPoseClose(port.getWorldPose(), target, \"getWorldPose() after setWorldPose\");\n assertPoseClose(port.getRestWorldPose(), rest, \"getRestWorldPose() after setWorldPose\");\n },\n },\n {\n name: \"every returned tuple is a fresh value the caller owns\",\n run({ port }) {\n const pose = port.getWorldPose();\n const restPose = port.getRestWorldPose();\n const offset = port.getLocalOffset();\n pose.position[0] = 1e6;\n pose.quaternion[3] = 1e6;\n restPose.position[0] = 1e6;\n offset[0] = 1e6;\n assert(port.getWorldPose().position[0] !== 1e6, \"writing to a returned getWorldPose() tuple must not change the port\");\n assert(port.getWorldPose().quaternion[3] !== 1e6, \"writing to a returned getWorldPose() quaternion must not change the port\");\n assert(port.getRestWorldPose().position[0] !== 1e6, \"writing to a returned getRestWorldPose() tuple must not change the port\");\n assert(port.getLocalOffset()[0] !== 1e6, \"writing to a returned getLocalOffset() tuple must not change the port\");\n },\n },\n {\n name: \"a tuple passed in is not kept\",\n run({ port }) {\n const offset: Vec3Tuple = [0.3, -0.1, 0.05];\n port.setLocalOffset(offset);\n offset[0] = 9;\n assertVec3Close(port.getLocalOffset(), [0.3, -0.1, 0.05], POSE_EPS, \"getLocalOffset() after the caller reused its tuple\");\n if (!port.setWorldPose) return;\n const target: PoseTuple = { position: [0.5, 1.2, -0.4], quaternion: [0, 0, 0, 1] };\n port.setWorldPose(target);\n target.position[0] = 9;\n assertVec3Close(port.getWorldPose().position, [0.5, 1.2, -0.4], POSE_EPS, \"getWorldPose() after the caller reused its tuple\");\n },\n },\n {\n name: \"setEffect, when present, accepts scale and emissive without throwing\",\n run({ port }) {\n if (!port.setEffect) return;\n try {\n port.setEffect({ scale: 1.2, emissive: 0.3 });\n } catch (error) {\n throw new Error(`setEffect({ scale, emissive }) must not throw, it threw: ${String(error)}`);\n }\n },\n },\n {\n name: \"Held: beginHold holds a fixed setWorldPose without falling, when the subject has physics\",\n run({ port, rest, physics }) {\n if (!physics || !port.setWorldPose || !port.beginHold) return;\n const held: PoseTuple = {\n position: [rest.position[0], rest.position[1] + 1, rest.position[2]],\n quaternion: rest.quaternion,\n };\n port.beginHold();\n for (let i = 0; i < HELD_STEPS; i++) {\n port.setWorldPose(held);\n physics.step(PHYSICS_DT);\n }\n // A tight tolerance, not PHYSICS_POSE_EPS: a genuinely held body sees\n // no simulation at all, so it matches the written pose exactly bar\n // floating point noise - the same POSE_EPS the non-physics cases\n // above use. One step of unwanted gravity (~2.7 mm at PHYSICS_DT) is\n // what this case exists to catch, and it must not hide inside the\n // tolerance the way it deliberately may in the Reset case below.\n assertPoseClose(port.getWorldPose(), held, `getWorldPose() after ${HELD_STEPS} held steps`);\n },\n },\n {\n name: \"Released: endHold sends the body away with the release velocity, when the subject has physics\",\n run({ port, rest, physics }) {\n if (!physics || !port.beginHold || !port.endHold) return;\n port.beginHold();\n const release: HoldRelease = { linearVelocity: [RELEASE_SPEED, 0, 0], angularVelocity: [0, 0, 0] };\n port.endHold(release);\n physics.step(PHYSICS_DT);\n const moved = port.getWorldPose().position[0] - rest.position[0];\n assert(\n moved > RELEASE_SPEED * PHYSICS_DT * 0.5,\n `endHold({ linearVelocity: [${RELEASE_SPEED}, 0, 0] }) must move the body that way within one step, moved ${moved}`,\n );\n },\n },\n {\n name: \"Reset: setWorldPose while not held teleports to the pose and clears velocity, when the subject has physics\",\n run({ port, rest, physics }) {\n if (!physics || !port.setWorldPose || !port.beginHold || !port.endHold) return;\n // Give the body a large prior velocity and let it run for a step, so\n // carrying that velocity through the reset below is unmistakable -\n // one step of it (~0.83 m) dwarfs PHYSICS_POSE_EPS (2 cm).\n port.beginHold();\n const priorRelease: HoldRelease = { linearVelocity: [LARGE_PRIOR_SPEED, 0, 0], angularVelocity: [0, 0, 0] };\n port.endHold(priorRelease);\n physics.step(PHYSICS_DT);\n const target: PoseTuple = {\n position: [rest.position[0] - 1, rest.position[1] + 2, rest.position[2] + 0.5],\n quaternion: rest.quaternion,\n };\n port.setWorldPose(target);\n // One further step: it must be at `target`, not carrying the prior\n // velocity forward - allowing for this one step's worth of gravity.\n physics.step(PHYSICS_DT);\n assertPhysicsPoseClose(port.getWorldPose(), target, \"getWorldPose() one step after a reset setWorldPose\");\n },\n },\n];\n\n// ---------------------------------------------------------------------------\n// Shared assertion helpers\n// ---------------------------------------------------------------------------\n\nfunction assert(condition: boolean, message: string): asserts condition {\n if (!condition) throw new Error(message);\n}\n\nfunction dist(a: Vec3Tuple, b: Vec3Tuple): number {\n return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);\n}\n\nfunction closeTo(a: number, b: number, eps: number): boolean {\n return Math.abs(a - b) <= eps;\n}\n\n// Indexed one component at a time, rather than in a loop, so each index is a\n// literal: `noUncheckedIndexedAccess` cannot narrow a tuple read through a\n// variable index back to `number`.\nfunction assertVec3Close(value: Vec3Tuple, expected: Vec3Tuple, eps: number, label: string): void {\n assert(closeTo(value[0], expected[0], eps), `${label}[0] must be close to ${expected[0]}, got ${value[0]}`);\n assert(closeTo(value[1], expected[1], eps), `${label}[1] must be close to ${expected[1]}, got ${value[1]}`);\n assert(closeTo(value[2], expected[2], eps), `${label}[2] must be close to ${expected[2]}, got ${value[2]}`);\n}\n\n// q and -q are the same rotation, so compare by the size of the dot product.\nfunction assertQuatClose(value: QuatTuple, expected: QuatTuple, label: string): void {\n const dot = value[0] * expected[0] + value[1] * expected[1] + value[2] * expected[2] + value[3] * expected[3];\n assert(\n closeTo(Math.abs(dot), 1, POSE_EPS),\n `${label} must be close to [${expected.join(\", \")}], got [${value.join(\", \")}]`,\n );\n}\n\nfunction assertPoseClose(value: PoseTuple, expected: PoseTuple, label: string): void {\n assertVec3Close(value.position, expected.position, POSE_EPS, `${label}.position`);\n assertQuatClose(value.quaternion, expected.quaternion, `${label}.quaternion`);\n}\n\nfunction quatLength(q: QuatTuple): number {\n return Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);\n}\n"]}
@@ -13,7 +13,13 @@ export interface InteractableDescriptor {
13
13
  gaze?: GazeConfig;
14
14
  /** Registered disabled when false (enable later via the runtime). */
15
15
  enabled?: boolean;
16
- /** Poke/proximity trigger radius in meters (default 0.05). */
16
+ /**
17
+ * The touch hover ENTER distance for this target, metres to its surface:
18
+ * a fingertip within it makes touch the active pointer (default 0.15,
19
+ * IWSDK's `enterHoverDistance`; the exit distance is 0.05 beyond it). The
20
+ * press distance (0.02) is the runtime's `nearPointer` option, not per
21
+ * target. See `near-pointer.ts`.
22
+ */
17
23
  pokeRadius?: number;
18
24
  }
19
25
  export interface InteractionDescriptor {
@@ -1 +1 @@
1
- {"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../src/descriptor.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * InteractionDescriptor - the portable scene-interaction format. Plain\n * JSON-able data: which interactables exist, which behaviours they carry\n * (with tuning), and their gaze policy. Every adapter builds the SAME\n * playground from the same descriptor - the portability proof inherited\n * from the UI Extensions' SceneDescriptor.\n */\nimport type { BehaviourConfig } from \"./behaviours/factory.js\";\nimport type { GazeConfig } from \"./gaze.js\";\n\nexport interface InteractableDescriptor {\n id: string;\n behaviours: BehaviourConfig[];\n gaze?: GazeConfig;\n /** Registered disabled when false (enable later via the runtime). */\n enabled?: boolean;\n /** Poke/proximity trigger radius in meters (default 0.05). */\n pokeRadius?: number;\n}\n\nexport interface InteractionDescriptor {\n interactables: InteractableDescriptor[];\n}\n"]}
1
+ {"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../src/descriptor.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * InteractionDescriptor - the portable scene-interaction format. Plain\n * JSON-able data: which interactables exist, which behaviours they carry\n * (with tuning), and their gaze policy. Every adapter builds the SAME\n * playground from the same descriptor - the portability proof inherited\n * from the UI Extensions' SceneDescriptor.\n */\nimport type { BehaviourConfig } from \"./behaviours/factory.js\";\nimport type { GazeConfig } from \"./gaze.js\";\n\nexport interface InteractableDescriptor {\n id: string;\n behaviours: BehaviourConfig[];\n gaze?: GazeConfig;\n /** Registered disabled when false (enable later via the runtime). */\n enabled?: boolean;\n /**\n * The touch hover ENTER distance for this target, metres to its surface:\n * a fingertip within it makes touch the active pointer (default 0.15,\n * IWSDK's `enterHoverDistance`; the exit distance is 0.05 beyond it). The\n * press distance (0.02) is the runtime's `nearPointer` option, not per\n * target. See `near-pointer.ts`.\n */\n pokeRadius?: number;\n}\n\nexport interface InteractionDescriptor {\n interactables: InteractableDescriptor[];\n}\n"]}
package/dist/gaze.d.ts CHANGED
@@ -11,6 +11,8 @@
11
11
  * The dwell state machine is pure and headless-tested. The runtime feeds it
12
12
  * hover booleans; it never sees the engine.
13
13
  */
14
+ import type { RayTuple, Vec3Tuple } from "@realitycollective/webxr-input";
15
+ import type { InteractableHit } from "./ports.js";
14
16
  export interface DwellConfig {
15
17
  /** Seconds of sustained gaze to fire. */
16
18
  holdSeconds?: number;
@@ -42,3 +44,51 @@ export declare class DwellState {
42
44
  update(hovered: boolean, dt: number, config: Required<DwellConfig>): DwellTick;
43
45
  getProgress(): number;
44
46
  }
47
+ /** Comparer tolerance: angular distances within this are "the same", and distance decides. IWSDK `ANGLE_EPSILON`. */
48
+ export declare const GAZE_CONE_ANGLE_EPSILON: number;
49
+ /** A cone hit: {@link InteractableHit} plus how far off the gaze axis the target's silhouette sat, radians (0 when the ray itself hit). */
50
+ export interface GazeConeHit extends InteractableHit {
51
+ angularDistance: number;
52
+ }
53
+ /** A sphere target, as the approximate hit testers and the native host model one. */
54
+ export interface SphereTarget {
55
+ id: string;
56
+ center: Vec3Tuple;
57
+ radius: number;
58
+ }
59
+ /**
60
+ * IWSDK's `GazeConecaster.findFrameBest` over sphere targets: the best
61
+ * target inside a cone of `halfAngle` radians about `ray`, no farther than
62
+ * `maxLength`. A sphere the ray passes through is hit where the ray enters
63
+ * it, with an angular distance of 0. Otherwise the angle from the ray to the
64
+ * sphere's silhouette (the angle to its centre less the angle it subtends)
65
+ * must be within the cone, and the point aimed at is the point of the sphere
66
+ * nearest the ray. Closer by angle wins; within {@link GAZE_CONE_ANGLE_EPSILON}
67
+ * the nearer target wins. A sphere the origin is inside counts as on axis.
68
+ */
69
+ export declare function coneHitForSpheres(ray: RayTuple, targets: Iterable<SphereTarget>, halfAngle: number, maxLength: number): GazeConeHit | null;
70
+ /** IWSDK's default comparer: closer by angle, then closer by distance. Negative when `a` is better. */
71
+ export declare function compareConeHits(a: GazeConeHit, b: GazeConeHit): number;
72
+ /**
73
+ * IWSDK's dwell consensus (`GazeConecaster.recordDwell` / `pruneDwell` /
74
+ * `electDwellWinner` / `resolveDwellWinner`): each frame's best candidate is
75
+ * recorded with its `dt`; samples older than the window are dropped; the
76
+ * candidate with the largest cumulative `dt` inside the window wins. A winner
77
+ * that is no longer available (unregistered, disabled, hidden) is struck
78
+ * from the record and the next is elected. A window of 0 keeps only this
79
+ * frame's sample, so the frame's best wins outright.
80
+ */
81
+ export declare class GazeConsensus {
82
+ windowSeconds: number;
83
+ private readonly samples;
84
+ private time;
85
+ constructor(windowSeconds?: number);
86
+ /** Record this frame's best (or none), advance the window and elect. */
87
+ update(frameBestId: string | null, dt: number, available: (id: string) => boolean): string | null;
88
+ /** Advance the window with nothing recorded (a frame gaze was suppressed or had no pose). */
89
+ skip(dt: number): void;
90
+ reset(): void;
91
+ private prune;
92
+ private elect;
93
+ private remove;
94
+ }
package/dist/gaze.js CHANGED
@@ -58,4 +58,166 @@ export class DwellState {
58
58
  return this.progress;
59
59
  }
60
60
  }
61
+ // ---------------------------------------------------------------------------
62
+ // Eye gaze: the targeting half of the rule `@realitycollective/webxr-input`'s
63
+ // `eye-gaze.ts` states. IWSDK's `GazeConecaster` picks the frame's best
64
+ // in-cone candidate and then holds a time-weighted vote over the dwell
65
+ // window, so a flick across a neighbour does not steal hover.
66
+ // ---------------------------------------------------------------------------
67
+ /** Comparer tolerance: angular distances within this are "the same", and distance decides. IWSDK `ANGLE_EPSILON`. */
68
+ export const GAZE_CONE_ANGLE_EPSILON = 0.5 * (Math.PI / 180);
69
+ /**
70
+ * IWSDK's `GazeConecaster.findFrameBest` over sphere targets: the best
71
+ * target inside a cone of `halfAngle` radians about `ray`, no farther than
72
+ * `maxLength`. A sphere the ray passes through is hit where the ray enters
73
+ * it, with an angular distance of 0. Otherwise the angle from the ray to the
74
+ * sphere's silhouette (the angle to its centre less the angle it subtends)
75
+ * must be within the cone, and the point aimed at is the point of the sphere
76
+ * nearest the ray. Closer by angle wins; within {@link GAZE_CONE_ANGLE_EPSILON}
77
+ * the nearer target wins. A sphere the origin is inside counts as on axis.
78
+ */
79
+ export function coneHitForSpheres(ray, targets, halfAngle, maxLength) {
80
+ const [ox, oy, oz] = ray.origin;
81
+ const [dx, dy, dz] = ray.direction;
82
+ let best = null;
83
+ for (const target of targets) {
84
+ const [cx, cy, cz] = target.center;
85
+ const r = target.radius;
86
+ const vx = cx - ox;
87
+ const vy = cy - oy;
88
+ const vz = cz - oz;
89
+ const dist = Math.hypot(vx, vy, vz);
90
+ if (dist - r > maxLength)
91
+ continue;
92
+ let hit;
93
+ if (dist <= r) {
94
+ // The origin is inside the sphere: fully on axis, aimed at the centre.
95
+ hit = { interactableId: target.id, distance: dist, point: [cx, cy, cz], angularDistance: 0 };
96
+ }
97
+ else {
98
+ const t = vx * dx + vy * dy + vz * dz;
99
+ const missSq = Math.max(0, dist * dist - t * t);
100
+ const miss = Math.sqrt(missSq);
101
+ if (t > 0 && miss <= r) {
102
+ // The ray enters the sphere: the raw ray wins, at the entry point.
103
+ const entry = t - Math.sqrt(r * r - missSq);
104
+ if (entry > maxLength)
105
+ continue;
106
+ hit = {
107
+ interactableId: target.id,
108
+ distance: entry,
109
+ point: [ox + dx * entry, oy + dy * entry, oz + dz * entry],
110
+ angularDistance: 0,
111
+ };
112
+ }
113
+ else {
114
+ const toCentre = Math.atan2(miss, t);
115
+ const angular = Math.max(0, toCentre - Math.asin(Math.min(1, r / dist)));
116
+ if (angular > halfAngle)
117
+ continue;
118
+ // The point of the sphere nearest the ray: from the centre toward the
119
+ // ray's closest point (never behind the origin), out to the surface.
120
+ const tc = Math.max(0, t);
121
+ let nx = ox + dx * tc - cx;
122
+ let ny = oy + dy * tc - cy;
123
+ let nz = oz + dz * tc - cz;
124
+ const nl = Math.hypot(nx, ny, nz);
125
+ if (nl > 1e-9) {
126
+ nx /= nl;
127
+ ny /= nl;
128
+ nz /= nl;
129
+ }
130
+ else {
131
+ nx = -vx / dist;
132
+ ny = -vy / dist;
133
+ nz = -vz / dist;
134
+ }
135
+ const point = [cx + nx * r, cy + ny * r, cz + nz * r];
136
+ const distance = Math.hypot(point[0] - ox, point[1] - oy, point[2] - oz);
137
+ if (distance > maxLength)
138
+ continue;
139
+ hit = { interactableId: target.id, distance, point, angularDistance: angular };
140
+ }
141
+ }
142
+ if (best === null || compareConeHits(hit, best) < 0)
143
+ best = hit;
144
+ }
145
+ return best;
146
+ }
147
+ /** IWSDK's default comparer: closer by angle, then closer by distance. Negative when `a` is better. */
148
+ export function compareConeHits(a, b) {
149
+ const dAngle = a.angularDistance - b.angularDistance;
150
+ if (Math.abs(dAngle) > GAZE_CONE_ANGLE_EPSILON)
151
+ return dAngle;
152
+ return a.distance - b.distance;
153
+ }
154
+ /**
155
+ * IWSDK's dwell consensus (`GazeConecaster.recordDwell` / `pruneDwell` /
156
+ * `electDwellWinner` / `resolveDwellWinner`): each frame's best candidate is
157
+ * recorded with its `dt`; samples older than the window are dropped; the
158
+ * candidate with the largest cumulative `dt` inside the window wins. A winner
159
+ * that is no longer available (unregistered, disabled, hidden) is struck
160
+ * from the record and the next is elected. A window of 0 keeps only this
161
+ * frame's sample, so the frame's best wins outright.
162
+ */
163
+ export class GazeConsensus {
164
+ windowSeconds;
165
+ samples = [];
166
+ time = 0;
167
+ constructor(windowSeconds = 0.15) {
168
+ this.windowSeconds = windowSeconds;
169
+ }
170
+ /** Record this frame's best (or none), advance the window and elect. */
171
+ update(frameBestId, dt, available) {
172
+ this.time += dt;
173
+ if (frameBestId !== null)
174
+ this.samples.push({ id: frameBestId, time: this.time, dt });
175
+ this.prune();
176
+ for (;;) {
177
+ const elected = this.elect();
178
+ if (elected === null)
179
+ return null;
180
+ if (available(elected))
181
+ return elected;
182
+ this.remove(elected);
183
+ }
184
+ }
185
+ /** Advance the window with nothing recorded (a frame gaze was suppressed or had no pose). */
186
+ skip(dt) {
187
+ this.time += dt;
188
+ }
189
+ reset() {
190
+ this.samples.length = 0;
191
+ }
192
+ prune() {
193
+ const cutoff = this.time - this.windowSeconds;
194
+ let drop = 0;
195
+ while (drop < this.samples.length && this.samples[drop].time < cutoff)
196
+ drop += 1;
197
+ if (drop > 0)
198
+ this.samples.splice(0, drop);
199
+ }
200
+ elect() {
201
+ let bestId = null;
202
+ let bestDt = -1;
203
+ const sums = new Map();
204
+ for (const sample of this.samples)
205
+ sums.set(sample.id, (sums.get(sample.id) ?? 0) + sample.dt);
206
+ // First recorded wins a tie, as IWSDK's scan from the ring head does.
207
+ for (const sample of this.samples) {
208
+ const sum = sums.get(sample.id);
209
+ if (sum > bestDt) {
210
+ bestDt = sum;
211
+ bestId = sample.id;
212
+ }
213
+ }
214
+ return bestId;
215
+ }
216
+ remove(id) {
217
+ for (let i = this.samples.length - 1; i >= 0; i--) {
218
+ if (this.samples[i].id === id)
219
+ this.samples.splice(i, 1);
220
+ }
221
+ }
222
+ }
61
223
  //# sourceMappingURL=gaze.js.map