@woosh/meep-engine 3.36.0 → 3.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/engine/input/devices/XRInputDevice.d.ts +51 -23
- package/src/engine/input/devices/XRInputDevice.d.ts.map +1 -1
- package/src/engine/input/devices/XRInputDevice.js +145 -52
- package/src/engine/input/devices/xr/XRGamepadMapping.d.ts +14 -0
- package/src/engine/input/devices/xr/XRGamepadMapping.d.ts.map +1 -0
- package/src/engine/input/devices/xr/XRGamepadMapping.js +9 -0
- package/src/engine/input/devices/xr/XRHandedness.d.ts +15 -0
- package/src/engine/input/devices/xr/XRHandedness.d.ts.map +1 -0
- package/src/engine/input/devices/xr/XRHandedness.js +10 -0
- package/src/engine/input/devices/xr/XRInputAction.d.ts +24 -11
- package/src/engine/input/devices/xr/XRInputAction.d.ts.map +1 -1
- package/src/engine/input/devices/xr/XRInputAction.js +55 -24
- package/src/engine/input/devices/xr/XRInputButton.d.ts +7 -9
- package/src/engine/input/devices/xr/XRInputButton.d.ts.map +1 -1
- package/src/engine/input/devices/xr/XRInputButton.js +18 -8
- package/src/engine/input/devices/xr/XRInputCoordinates.d.ts +11 -3
- package/src/engine/input/devices/xr/XRInputCoordinates.d.ts.map +1 -1
- package/src/engine/input/devices/xr/XRInputCoordinates.js +17 -3
- package/src/engine/input/devices/xr/XRInputHandle.d.ts +41 -11
- package/src/engine/input/devices/xr/XRInputHandle.d.ts.map +1 -1
- package/src/engine/input/devices/xr/XRInputHandle.js +129 -32
- package/src/engine/input/devices/xr/XRInputPose.d.ts +41 -5
- package/src/engine/input/devices/xr/XRInputPose.d.ts.map +1 -1
- package/src/engine/input/devices/xr/XRInputPose.js +57 -16
- package/src/engine/input/devices/xr/XRInputTypes.d.ts +18 -18
- package/src/engine/input/devices/xr/XRInputTypes.js +3 -3
- package/src/engine/input/devices/xr/XRTargetRayMode.d.ts +17 -0
- package/src/engine/input/devices/xr/XRTargetRayMode.d.ts.map +1 -0
- package/src/engine/input/devices/xr/XRTargetRayMode.js +12 -0
- package/src/engine/input/devices/xr/XRVisibilityState.d.ts +15 -0
- package/src/engine/input/devices/xr/XRVisibilityState.d.ts.map +1 -0
- package/src/engine/input/devices/xr/XRVisibilityState.js +10 -0
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.d.ts +3 -1
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.d.ts.map +1 -1
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js +5 -1
- package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.d.ts +19 -5
- package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.d.ts.map +1 -1
- package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.js +42 -9
- package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.d.ts +8 -2
- package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.d.ts.map +1 -1
- package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.js +19 -9
- package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.d.ts +10 -2
- package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.d.ts.map +1 -1
- package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.js +12 -2
- package/src/shade/renderer/animation/chunk_pose_accumulator.js +14 -24
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.js +16 -15
- package/src/shade/renderer/deferred/indirect/chunk_lpv_sample_light.js +1 -1
- package/src/shade/renderer/gpu_primitive/bvh/GPU_BVH_BUILD_PLAN.md +1123 -1122
- package/src/shade/renderer/gpu_primitive/bvh/PHASE1_HANDOVER.md +202 -201
- package/src/shade/renderer/light/environment/chunk_roughness_to_mip_ratio.js +24 -0
- package/src/shade/renderer/light/environment/chunk_sphere_probe_roughness_to_lod.js +2 -25
- package/src/shade/renderer/light/environment/shader_project_environment_sh.d.ts +2 -2
- package/src/shade/renderer/light/environment/shader_project_environment_sh.d.ts.map +1 -1
- package/src/shade/renderer/light/environment/shader_project_environment_sh.js +50 -19
- package/src/shade/renderer/particles/DESIGN.md +1 -1
- package/src/shade/renderer/particles/bounds/chunk_particle_bounds.js +10 -9
- package/src/shade/renderer/scene/shader_bvh_extract_instance_leaves.js +10 -8
- package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_add_f32_storage.js +25 -0
- package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_max_f32_storage.js +28 -0
- package/src/shade/renderer/shader/chunk/atomic/chunk_atomic_min_f32_storage.js +28 -0
- package/src/shade/renderer/shader/chunk/geometry/plane/{plane_ray_raycast.js → chunk_plane_ray_raycast.js} +1 -1
- package/src/shade/renderer/shadow/map/csm/shader/shader_csm_caster_range.js +3 -3
- package/src/shade/renderer/animation/skinning/bounds_refresh/chunk_aabb_atomic_f32.js +0 -59
|
@@ -1,6 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a pose relative to the reference space. Returns {@link DEFAULT_POSE} when either space or
|
|
3
|
+
* the native pose is unavailable.
|
|
4
|
+
* @param {import('./XRInputTypes.js').XRFrame} frame
|
|
5
|
+
* @param {EventTarget|null} space
|
|
6
|
+
* @param {EventTarget|null} referenceSpace
|
|
7
|
+
* @returns {import('./XRInputTypes.js').XRPose}
|
|
8
|
+
*/
|
|
9
|
+
export function xr_input_read_pose(frame: import('./XRInputTypes.js').XRFrame, space: EventTarget | null, referenceSpace: EventTarget | null): import('./XRInputTypes.js').XRPose;
|
|
10
|
+
/**
|
|
11
|
+
* Neutral, unavailable pose. Shared immutable data, copied into each handle's own meep vectors.
|
|
12
|
+
* Identity is significant: a real tracked pose at the origin is still valid.
|
|
13
|
+
* @readonly
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_POSE: Readonly<{
|
|
16
|
+
transform: Readonly<{
|
|
17
|
+
position: Readonly<{
|
|
18
|
+
x: 0;
|
|
19
|
+
y: 0;
|
|
20
|
+
z: 0;
|
|
21
|
+
}>;
|
|
22
|
+
orientation: Readonly<{
|
|
23
|
+
x: 0;
|
|
24
|
+
y: 0;
|
|
25
|
+
z: 0;
|
|
26
|
+
w: 1;
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
29
|
+
emulatedPosition: false;
|
|
30
|
+
}>;
|
|
1
31
|
/**
|
|
2
32
|
* A copied pose in the device's configured reference space. The device owns mutation.
|
|
3
|
-
*
|
|
33
|
+
* Check {@link valid} before use. An unavailable pose has zero position and identity rotation.
|
|
4
34
|
* Target-ray forward is local -Z, regardless of a game's own forward convention.
|
|
5
35
|
*/
|
|
6
36
|
export class XRInputPose {
|
|
@@ -8,15 +38,21 @@ export class XRInputPose {
|
|
|
8
38
|
readonly position: Vector3;
|
|
9
39
|
/** @readonly */
|
|
10
40
|
readonly rotation: Quaternion;
|
|
11
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Whether a pose is available in the current reference space. Do not modify directly.
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
*/
|
|
12
45
|
valid: boolean;
|
|
13
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Whether the browser estimates the position instead of tracking it. Do not modify directly.
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
*/
|
|
14
50
|
emulatedPosition: boolean;
|
|
15
51
|
/**
|
|
16
52
|
* @internal
|
|
17
|
-
* @param {import("./XRInputTypes.js").XRPose
|
|
53
|
+
* @param {import("./XRInputTypes.js").XRPose} [pose=DEFAULT_POSE]
|
|
18
54
|
*/
|
|
19
|
-
update(pose
|
|
55
|
+
update(pose?: import("./XRInputTypes.js").XRPose): void;
|
|
20
56
|
}
|
|
21
57
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
22
58
|
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XRInputPose.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputPose.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XRInputPose.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputPose.js"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,0CALW,OAAO,mBAAmB,EAAE,OAAO,SACnC,WAAW,GAAC,IAAI,kBAChB,WAAW,GAAC,IAAI,GACd,OAAO,mBAAmB,EAAE,MAAM,CAW9C;AA9BD;;;;GAIG;AACH;;;;;;;;;;;;;;;GAMG;AAqBH;;;;GAIG;AACH;IACI,gBAAgB;IAChB,2BAAyB;IAEzB,gBAAgB;IAChB,8BAA4B;IAE5B;;;OAGG;IACH,OAFU,OAAO,CAEH;IAEd;;;OAGG;IACH,kBAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,cAFW,OAAO,mBAAmB,EAAE,MAAM,QAa5C;CACJ;oBA1EmB,kCAAkC;uBAD/B,qCAAqC"}
|
|
@@ -1,36 +1,77 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
1
2
|
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
2
3
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Neutral, unavailable pose. Shared immutable data, copied into each handle's own meep vectors.
|
|
7
|
+
* Identity is significant: a real tracked pose at the origin is still valid.
|
|
8
|
+
* @readonly
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_POSE = Object.freeze({
|
|
11
|
+
transform: Object.freeze({
|
|
12
|
+
position: Object.freeze({ x: 0, y: 0, z: 0 }),
|
|
13
|
+
orientation: Object.freeze({ x: 0, y: 0, z: 0, w: 1 })
|
|
14
|
+
}),
|
|
15
|
+
emulatedPosition: false
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Read a pose relative to the reference space. Returns {@link DEFAULT_POSE} when either space or
|
|
20
|
+
* the native pose is unavailable.
|
|
21
|
+
* @param {import('./XRInputTypes.js').XRFrame} frame
|
|
22
|
+
* @param {EventTarget|null} space
|
|
23
|
+
* @param {EventTarget|null} referenceSpace
|
|
24
|
+
* @returns {import('./XRInputTypes.js').XRPose}
|
|
25
|
+
*/
|
|
26
|
+
export function xr_input_read_pose(frame, space, referenceSpace) {
|
|
27
|
+
assert.defined(space, 'space');
|
|
28
|
+
assert.defined(referenceSpace, 'referenceSpace');
|
|
29
|
+
|
|
30
|
+
if (space === null || referenceSpace === null) {
|
|
31
|
+
return DEFAULT_POSE;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return frame.getPose(space, referenceSpace) ?? DEFAULT_POSE;
|
|
35
|
+
}
|
|
36
|
+
|
|
4
37
|
/**
|
|
5
38
|
* A copied pose in the device's configured reference space. The device owns mutation.
|
|
6
|
-
*
|
|
39
|
+
* Check {@link valid} before use. An unavailable pose has zero position and identity rotation.
|
|
7
40
|
* Target-ray forward is local -Z, regardless of a game's own forward convention.
|
|
8
41
|
*/
|
|
9
42
|
export class XRInputPose {
|
|
10
43
|
/** @readonly */
|
|
11
44
|
position = new Vector3();
|
|
45
|
+
|
|
12
46
|
/** @readonly */
|
|
13
47
|
rotation = new Quaternion();
|
|
14
|
-
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Whether a pose is available in the current reference space. Do not modify directly.
|
|
51
|
+
* @type {boolean}
|
|
52
|
+
*/
|
|
15
53
|
valid = false;
|
|
16
|
-
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether the browser estimates the position instead of tracking it. Do not modify directly.
|
|
57
|
+
* @type {boolean}
|
|
58
|
+
*/
|
|
17
59
|
emulatedPosition = false;
|
|
18
60
|
|
|
19
61
|
/**
|
|
20
62
|
* @internal
|
|
21
|
-
* @param {import("./XRInputTypes.js").XRPose
|
|
63
|
+
* @param {import("./XRInputTypes.js").XRPose} [pose=DEFAULT_POSE]
|
|
22
64
|
*/
|
|
23
|
-
update(pose) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
65
|
+
update(pose = DEFAULT_POSE) {
|
|
66
|
+
assert.notNull(pose, 'pose');
|
|
67
|
+
assert.isBoolean(pose.emulatedPosition, 'pose.emulatedPosition');
|
|
68
|
+
|
|
69
|
+
const p = pose.transform.position;
|
|
70
|
+
const q = pose.transform.orientation;
|
|
71
|
+
|
|
72
|
+
this.valid = pose !== DEFAULT_POSE;
|
|
73
|
+
this.emulatedPosition = pose.emulatedPosition;
|
|
74
|
+
this.position.set(p.x, p.y, p.z);
|
|
75
|
+
this.rotation.set(q.x, q.y, q.z, q.w);
|
|
35
76
|
}
|
|
36
77
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
3
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
4
|
+
* Only the members consumed by the input device are required.
|
|
5
5
|
*/
|
|
6
6
|
export type XRGamepad = {
|
|
7
7
|
mapping: string;
|
|
@@ -13,9 +13,9 @@ export type XRGamepad = {
|
|
|
13
13
|
axes: ReadonlyArray<number>;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
17
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
18
|
+
* Only the members consumed by the input device are required.
|
|
19
19
|
*/
|
|
20
20
|
export type XRInputSource = {
|
|
21
21
|
handedness: string;
|
|
@@ -26,18 +26,18 @@ export type XRInputSource = {
|
|
|
26
26
|
gamepad?: XRGamepad | null;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
30
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
31
|
+
* Only the members consumed by the input device are required.
|
|
32
32
|
*/
|
|
33
33
|
export type XRSession = EventTarget & {
|
|
34
34
|
readonly inputSources: ArrayLike<XRInputSource>;
|
|
35
35
|
readonly visibilityState: string;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
39
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
40
|
+
* Only the members consumed by the input device are required.
|
|
41
41
|
*/
|
|
42
42
|
export type XRPose = {
|
|
43
43
|
transform: {
|
|
@@ -56,18 +56,18 @@ export type XRPose = {
|
|
|
56
56
|
emulatedPosition: boolean;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
60
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
61
|
+
* Only the members consumed by the input device are required.
|
|
62
62
|
*/
|
|
63
63
|
export type XRFrame = {
|
|
64
64
|
session: XRSession;
|
|
65
65
|
getPose: (space: EventTarget, baseSpace: EventTarget) => XRPose | null | undefined;
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
68
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
69
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
70
|
+
* Only the members consumed by the input device are required.
|
|
71
71
|
*/
|
|
72
72
|
export type XRSessionInputEvent = Event & {
|
|
73
73
|
inputSource?: XRInputSource;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* WebXR interfaces accepted by meep's input API. Native WebXR objects satisfy these structural types;
|
|
3
|
+
* applications can use meep's declarations without installing ambient WebXR types.
|
|
4
|
+
* Only the members consumed by the input device are required.
|
|
5
5
|
*
|
|
6
6
|
* @typedef {object} XRGamepad
|
|
7
7
|
* @property {string} mapping
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native target-ray modes, plus Unavailable for a disconnected handle.
|
|
3
|
+
*/
|
|
4
|
+
export type XRTargetRayMode = string;
|
|
5
|
+
/**
|
|
6
|
+
* Native target-ray modes, plus Unavailable for a disconnected handle.
|
|
7
|
+
* @readonly
|
|
8
|
+
* @enum {string}
|
|
9
|
+
*/
|
|
10
|
+
export const XRTargetRayMode: Readonly<{
|
|
11
|
+
Unavailable: "";
|
|
12
|
+
Gaze: "gaze";
|
|
13
|
+
TrackedPointer: "tracked-pointer";
|
|
14
|
+
Screen: "screen";
|
|
15
|
+
TransientPointer: "transient-pointer";
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=XRTargetRayMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XRTargetRayMode.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRTargetRayMode.js"],"names":[],"mappings":";;;8BAGU,MAAM;AAHhB;;;;GAIG;AACH;;;;;;GAMG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native target-ray modes, plus Unavailable for a disconnected handle.
|
|
3
|
+
* @readonly
|
|
4
|
+
* @enum {string}
|
|
5
|
+
*/
|
|
6
|
+
export const XRTargetRayMode = Object.freeze({
|
|
7
|
+
Unavailable: '',
|
|
8
|
+
Gaze: 'gaze',
|
|
9
|
+
TrackedPointer: 'tracked-pointer',
|
|
10
|
+
Screen: 'screen',
|
|
11
|
+
TransientPointer: 'transient-pointer'
|
|
12
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native XRSession visibility states.
|
|
3
|
+
*/
|
|
4
|
+
export type XRVisibilityState = string;
|
|
5
|
+
/**
|
|
6
|
+
* Native XRSession visibility states.
|
|
7
|
+
* @readonly
|
|
8
|
+
* @enum {string}
|
|
9
|
+
*/
|
|
10
|
+
export const XRVisibilityState: Readonly<{
|
|
11
|
+
Visible: "visible";
|
|
12
|
+
VisibleBlurred: "visible-blurred";
|
|
13
|
+
Hidden: "hidden";
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=XRVisibilityState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XRVisibilityState.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRVisibilityState.js"],"names":[],"mappings":";;;gCAGU,MAAM;AAHhB;;;;GAIG;AACH;;;;GAIG"}
|
|
@@ -30,8 +30,10 @@ export class InputCoordinateDevice extends InputCoordinateChannel {
|
|
|
30
30
|
static fromGamepad(code: number): InputCoordinateDevice;
|
|
31
31
|
/**
|
|
32
32
|
* Select/squeeze and raw buttons/axes are scalar; thumbstick/touchpad have two components.
|
|
33
|
+
* Missing hardware reads zero. Named sticks require xr-standard; raw axes retain native ordering.
|
|
34
|
+
*
|
|
33
35
|
* @param {'left'|'right'|'none'} handedness
|
|
34
|
-
* @param {number} code XRInputCoordinates or
|
|
36
|
+
* @param {number} code A value from XRInputCoordinates, xr_input_button_coordinate or xr_input_axis_coordinate.
|
|
35
37
|
* @returns {InputCoordinateDevice}
|
|
36
38
|
*/
|
|
37
39
|
static fromXR(handedness: 'left' | 'right' | 'none', code: number): InputCoordinateDevice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputCoordinateDevice.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js"],"names":[],"mappings":"AAaA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH;IA2BI;;;OAGG;IACH,0BAHW,qBAAqB,GACnB,qBAAqB,CAUjC;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAQjC;IAED
|
|
1
|
+
{"version":3,"file":"InputCoordinateDevice.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js"],"names":[],"mappings":"AAaA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH;IA2BI;;;OAGG;IACH,0BAHW,qBAAqB,GACnB,qBAAqB,CAUjC;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAQjC;IAED;;;;;;;OAOG;IACH,0BAJW,MAAM,GAAC,OAAO,GAAC,MAAM,QACrB,MAAM,GACJ,qBAAqB,CAUjC;IAED;;;;;;;OAOG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAajC;IA1FD;;OAEG;IACH,QAFU,qBAAqB,CAEM;IAwHrC;;OAEG;IACH,SAFa,qBAAqB,CAIjC;;CAiBJ;+BApKY,OAAO,wBAAwB,EAAE,gBAAgB;iCACjD,OAAO,iCAAiC,EAAE,kBAAkB;qBAC5D,OAAO,sCAAsC,EAAE,MAAM;uCAP3B,6BAA6B;sCAD9B,6BAA6B"}
|
|
@@ -86,13 +86,17 @@ export class InputCoordinateDevice extends InputCoordinateChannel {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Select/squeeze and raw buttons/axes are scalar; thumbstick/touchpad have two components.
|
|
89
|
+
* Missing hardware reads zero. Named sticks require xr-standard; raw axes retain native ordering.
|
|
90
|
+
*
|
|
89
91
|
* @param {'left'|'right'|'none'} handedness
|
|
90
|
-
* @param {number} code XRInputCoordinates or
|
|
92
|
+
* @param {number} code A value from XRInputCoordinates, xr_input_button_coordinate or xr_input_axis_coordinate.
|
|
91
93
|
* @returns {InputCoordinateDevice}
|
|
92
94
|
*/
|
|
93
95
|
static fromXR(handedness, code) {
|
|
94
96
|
assert.isNonNegativeInteger(code, 'code');
|
|
97
|
+
|
|
95
98
|
const dimensions = code === XRInputCoordinates.thumbstick || code === XRInputCoordinates.touchpad ? 2 : 1;
|
|
99
|
+
|
|
96
100
|
return InputCoordinateDevice.fromSource(InputCoordinateSource.from(
|
|
97
101
|
xr_input_device_id(handedness), code, dimensions, InputCoordinateKind.Normalized
|
|
98
102
|
));
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Exposes one persistent XR handedness slot to {@link InputMapSystem}, including before hardware exists.
|
|
3
|
+
* Use {@link InputTriggerXRButton} for native pressed/touched switches and
|
|
4
|
+
* {@link InputCoordinateDevice.fromXR} for amounts, sticks and axes.
|
|
5
|
+
*
|
|
6
|
+
* Subscribe to select/squeeze completion directly through XRInputAction.completed or an InputController
|
|
7
|
+
* path such as 'xr/right/select/completed'. Button press triggers and action completion are independent.
|
|
5
8
|
*
|
|
6
9
|
* @example
|
|
7
|
-
*
|
|
10
|
+
* // With a running engine and an active scene:
|
|
11
|
+
* const system = new InputMapSystem([new XRInputDeviceAdapter(engine.devices.xr, 'right')]);
|
|
12
|
+
* await engine.entityManager.addSystem(system);
|
|
13
|
+
* const map = new InputMap();
|
|
8
14
|
* map.bindCoordinate('pressure', InputCoordinateDevice.fromXR('right', XRInputCoordinates.select));
|
|
15
|
+
* const entity = engine.entityManager.dataset.createEntity();
|
|
16
|
+
* engine.entityManager.dataset.addComponentToEntity(entity, map);
|
|
17
|
+
* // Read after XRInputDevice.poll in the application's frame callback.
|
|
18
|
+
* const pressure = new Vector1();
|
|
19
|
+
* map.axis1(pressure, 'pressure');
|
|
9
20
|
*/
|
|
10
21
|
export class XRInputDeviceAdapter extends InputDeviceAdapter {
|
|
11
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @param {import('../../../devices/XRInputDevice.js').XRInputDevice} device
|
|
24
|
+
* @param {'left'|'right'|'none'} handedness
|
|
25
|
+
*/
|
|
12
26
|
constructor(device: import('../../../devices/XRInputDevice.js').XRInputDevice, handedness: 'left' | 'right' | 'none');
|
|
13
27
|
#private;
|
|
14
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XRInputDeviceAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/device/XRInputDeviceAdapter.js"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"XRInputDeviceAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/device/XRInputDeviceAdapter.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAII;;;OAGG;IACH,oBAHW,OAAO,mCAAmC,EAAE,aAAa,cACzD,MAAM,GAAC,OAAO,GAAC,MAAM,EAU/B;;CA6CJ;mCApFkC,yBAAyB"}
|
|
@@ -4,39 +4,72 @@ import { InputDeviceAdapter } from "./InputDeviceAdapter.js";
|
|
|
4
4
|
import { xr_input_device_id } from "./XR_INPUT_DEVICE_IDS.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Exposes one persistent XR handedness slot to {@link InputMapSystem}, including before hardware exists.
|
|
8
|
+
* Use {@link InputTriggerXRButton} for native pressed/touched switches and
|
|
9
|
+
* {@link InputCoordinateDevice.fromXR} for amounts, sticks and axes.
|
|
10
|
+
*
|
|
11
|
+
* Subscribe to select/squeeze completion directly through XRInputAction.completed or an InputController
|
|
12
|
+
* path such as 'xr/right/select/completed'. Button press triggers and action completion are independent.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
|
-
*
|
|
15
|
+
* // With a running engine and an active scene:
|
|
16
|
+
* const system = new InputMapSystem([new XRInputDeviceAdapter(engine.devices.xr, 'right')]);
|
|
17
|
+
* await engine.entityManager.addSystem(system);
|
|
18
|
+
* const map = new InputMap();
|
|
13
19
|
* map.bindCoordinate('pressure', InputCoordinateDevice.fromXR('right', XRInputCoordinates.select));
|
|
20
|
+
* const entity = engine.entityManager.dataset.createEntity();
|
|
21
|
+
* engine.entityManager.dataset.addComponentToEntity(entity, map);
|
|
22
|
+
* // Read after XRInputDevice.poll in the application's frame callback.
|
|
23
|
+
* const pressure = new Vector1();
|
|
24
|
+
* map.axis1(pressure, 'pressure');
|
|
14
25
|
*/
|
|
15
26
|
export class XRInputDeviceAdapter extends InputDeviceAdapter {
|
|
16
27
|
/** @type {import('../../../devices/xr/XRInputHandle.js').XRInputHandle} */
|
|
17
28
|
#handle;
|
|
18
29
|
|
|
19
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* @param {import('../../../devices/XRInputDevice.js').XRInputDevice} device
|
|
32
|
+
* @param {'left'|'right'|'none'} handedness
|
|
33
|
+
*/
|
|
20
34
|
constructor(device, handedness) {
|
|
21
35
|
super();
|
|
36
|
+
|
|
37
|
+
assert.defined(device, 'device');
|
|
38
|
+
assert.notNull(device, 'device');
|
|
39
|
+
|
|
22
40
|
this.id = xr_input_device_id(handedness);
|
|
23
41
|
this.#handle = device[handedness];
|
|
24
42
|
}
|
|
25
43
|
|
|
26
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* @param {number} code Even codes are pressed, odd codes touched; button index is floor(code/2).
|
|
46
|
+
* @returns {import('../../../devices/InputDeviceSwitch.js').InputDeviceSwitch}
|
|
47
|
+
*/
|
|
27
48
|
getSwitch(code) {
|
|
28
49
|
assert.isNonNegativeInteger(code, 'code');
|
|
50
|
+
|
|
29
51
|
const button = this.#handle.getButton(Math.floor(code / 2));
|
|
30
52
|
return code % 2 === 0 ? button.pressed : button.touched;
|
|
31
53
|
}
|
|
32
54
|
|
|
33
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* @param {number[]|Float64Array} result
|
|
57
|
+
* @param {number} offset
|
|
58
|
+
* @param {number} code
|
|
59
|
+
*/
|
|
34
60
|
readCoordinate(result, offset, code) {
|
|
61
|
+
assert.isArrayLike(result, 'result');
|
|
62
|
+
assert.isNonNegativeInteger(offset, 'offset');
|
|
35
63
|
assert.isNonNegativeInteger(code, 'code');
|
|
64
|
+
|
|
36
65
|
const handle = this.#handle;
|
|
37
66
|
switch (code) {
|
|
38
|
-
case XRInputCoordinates.select:
|
|
39
|
-
|
|
67
|
+
case XRInputCoordinates.select:
|
|
68
|
+
result[offset] = handle.select.x;
|
|
69
|
+
return;
|
|
70
|
+
case XRInputCoordinates.squeeze:
|
|
71
|
+
result[offset] = handle.squeeze.x;
|
|
72
|
+
return;
|
|
40
73
|
case XRInputCoordinates.thumbstick:
|
|
41
74
|
result[offset] = handle.thumbstick.value.x;
|
|
42
75
|
result[offset + 1] = handle.thumbstick.value.y;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @param {'left'|'right'|'none'} handedness
|
|
3
|
+
* @returns {string}
|
|
4
|
+
*/
|
|
2
5
|
export function xr_input_device_id(handedness: 'left' | 'right' | 'none'): string;
|
|
3
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Stable IDs used in serialized input maps.
|
|
8
|
+
* @readonly
|
|
9
|
+
*/
|
|
4
10
|
export const XR_INPUT_DEVICE_IDS: Readonly<{
|
|
5
11
|
left: "xr-left";
|
|
6
12
|
right: "xr-right";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XR_INPUT_DEVICE_IDS.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XR_INPUT_DEVICE_IDS.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,+CAHW,MAAM,GAAC,OAAO,GAAC,MAAM,GACnB,MAAM,CAMlB;AAlBD;;;GAGG;AACH;;;;GAIG"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { assert } from "../../../../../core/assert.js";
|
|
2
|
+
import { XRHandedness } from "../../../devices/xr/XRHandedness.js";
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Stable IDs used in serialized input maps.
|
|
6
|
+
* @readonly
|
|
7
|
+
*/
|
|
8
|
+
export const XR_INPUT_DEVICE_IDS = Object.freeze({
|
|
9
|
+
left: 'xr-left',
|
|
10
|
+
right: 'xr-right',
|
|
11
|
+
none: 'xr-none'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {'left'|'right'|'none'} handedness
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
5
18
|
export function xr_input_device_id(handedness) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
case 'none': return XR_INPUT_DEVICE_IDS.none;
|
|
10
|
-
default: throw new Error(`Invalid XR handedness: ${handedness}`);
|
|
11
|
-
}
|
|
19
|
+
assert.enum(handedness, XRHandedness, 'handedness');
|
|
20
|
+
|
|
21
|
+
return XR_INPUT_DEVICE_IDS[handedness];
|
|
12
22
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Trigger on a native XR button's pressed or touched switch.
|
|
3
|
+
* Subscribe to XRInputAction.completed for semantic select/squeeze completion.
|
|
4
|
+
*/
|
|
2
5
|
export class InputTriggerXRButton extends InputTriggerSwitch {
|
|
3
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @param {'left'|'right'|'none'} handedness
|
|
8
|
+
* @param {number} index Native button index.
|
|
9
|
+
* @param {boolean} [touched=false] True selects touched; false selects pressed.
|
|
10
|
+
* @returns {InputTriggerXRButton}
|
|
11
|
+
*/
|
|
4
12
|
static from(handedness: 'left' | 'right' | 'none', index: number, touched?: boolean): InputTriggerXRButton;
|
|
5
13
|
}
|
|
6
14
|
import { InputTriggerSwitch } from "./InputTriggerSwitch.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputTriggerXRButton.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/trigger/InputTriggerXRButton.js"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"InputTriggerXRButton.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/trigger/InputTriggerXRButton.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACI;;;;;OAKG;IACH,wBALW,MAAM,GAAC,OAAO,GAAC,MAAM,SACrB,MAAM,YACN,OAAO,GACL,oBAAoB,CAShC;CACJ;mCArBkC,yBAAyB"}
|
|
@@ -3,11 +3,21 @@ import { xr_input_device_id } from "../device/XR_INPUT_DEVICE_IDS.js";
|
|
|
3
3
|
import { InputSource } from "../InputSource.js";
|
|
4
4
|
import { InputTriggerSwitch } from "./InputTriggerSwitch.js";
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Trigger on a native XR button's pressed or touched switch.
|
|
8
|
+
* Subscribe to XRInputAction.completed for semantic select/squeeze completion.
|
|
9
|
+
*/
|
|
7
10
|
export class InputTriggerXRButton extends InputTriggerSwitch {
|
|
8
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* @param {'left'|'right'|'none'} handedness
|
|
13
|
+
* @param {number} index Native button index.
|
|
14
|
+
* @param {boolean} [touched=false] True selects touched; false selects pressed.
|
|
15
|
+
* @returns {InputTriggerXRButton}
|
|
16
|
+
*/
|
|
9
17
|
static from(handedness, index, touched = false) {
|
|
10
18
|
assert.isNonNegativeInteger(index, 'index');
|
|
19
|
+
assert.isBoolean(touched, 'touched');
|
|
20
|
+
|
|
11
21
|
const result = new InputTriggerXRButton();
|
|
12
22
|
result.source = InputSource.from(xr_input_device_id(handedness), index * 2 + (touched ? 1 : 0));
|
|
13
23
|
return result;
|