@opsydyn/effect-three 0.0.0-stage → 0.1.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/CHANGELOG.md +58 -0
- package/LICENSE +21 -0
- package/README.md +191 -2
- package/dist/index-4045wme0.js +129 -0
- package/dist/index-4045wme0.js.map +10 -0
- package/dist/index-ef8pbv9g.js +5118 -0
- package/dist/index-ef8pbv9g.js.map +40 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1361 -0
- package/dist/index.js.map +14 -0
- package/dist/kernel/animation.d.ts +14 -0
- package/dist/kernel/animation.d.ts.map +1 -0
- package/dist/kernel/behaviours.d.ts +16 -0
- package/dist/kernel/behaviours.d.ts.map +1 -0
- package/dist/kernel/bodies.d.ts +60 -0
- package/dist/kernel/bodies.d.ts.map +1 -0
- package/dist/kernel/bodySources.d.ts +47 -0
- package/dist/kernel/bodySources.d.ts.map +1 -0
- package/dist/kernel/build.d.ts +564 -0
- package/dist/kernel/build.d.ts.map +1 -0
- package/dist/kernel/cameraMotion.d.ts +39 -0
- package/dist/kernel/cameraMotion.d.ts.map +1 -0
- package/dist/kernel/clock.d.ts +17 -0
- package/dist/kernel/clock.d.ts.map +1 -0
- package/dist/kernel/contactShadowPasses.d.ts +47 -0
- package/dist/kernel/contactShadowPasses.d.ts.map +1 -0
- package/dist/kernel/description.d.ts +1120 -0
- package/dist/kernel/description.d.ts.map +1 -0
- package/dist/kernel/diff.d.ts +90 -0
- package/dist/kernel/diff.d.ts.map +1 -0
- package/dist/kernel/environmentPresets.d.ts +30 -0
- package/dist/kernel/environmentPresets.d.ts.map +1 -0
- package/dist/kernel/equality.d.ts +64 -0
- package/dist/kernel/equality.d.ts.map +1 -0
- package/dist/kernel/frames.d.ts +55 -0
- package/dist/kernel/frames.d.ts.map +1 -0
- package/dist/kernel/index.d.ts +37 -0
- package/dist/kernel/index.d.ts.map +1 -0
- package/dist/kernel/index.js +335 -0
- package/dist/kernel/index.js.map +9 -0
- package/dist/kernel/instances.d.ts +26 -0
- package/dist/kernel/instances.d.ts.map +1 -0
- package/dist/kernel/labels.d.ts +45 -0
- package/dist/kernel/labels.d.ts.map +1 -0
- package/dist/kernel/loop.d.ts +49 -0
- package/dist/kernel/loop.d.ts.map +1 -0
- package/dist/kernel/materials.d.ts +24 -0
- package/dist/kernel/materials.d.ts.map +1 -0
- package/dist/kernel/motion.d.ts +36 -0
- package/dist/kernel/motion.d.ts.map +1 -0
- package/dist/kernel/orbit.d.ts +127 -0
- package/dist/kernel/orbit.d.ts.map +1 -0
- package/dist/kernel/overlays.d.ts +16 -0
- package/dist/kernel/overlays.d.ts.map +1 -0
- package/dist/kernel/performance.d.ts +41 -0
- package/dist/kernel/performance.d.ts.map +1 -0
- package/dist/kernel/physics.d.ts +166 -0
- package/dist/kernel/physics.d.ts.map +1 -0
- package/dist/kernel/physicsDebug.d.ts +18 -0
- package/dist/kernel/physicsDebug.d.ts.map +1 -0
- package/dist/kernel/pointer.d.ts +357 -0
- package/dist/kernel/pointer.d.ts.map +1 -0
- package/dist/kernel/renderKit.d.ts +48 -0
- package/dist/kernel/renderKit.d.ts.map +1 -0
- package/dist/kernel/renderer.d.ts +83 -0
- package/dist/kernel/renderer.d.ts.map +1 -0
- package/dist/kernel/resources.d.ts +112 -0
- package/dist/kernel/resources.d.ts.map +1 -0
- package/dist/kernel/sceneGraph.d.ts +155 -0
- package/dist/kernel/sceneGraph.d.ts.map +1 -0
- package/dist/kernel/sceneIndex.d.ts +90 -0
- package/dist/kernel/sceneIndex.d.ts.map +1 -0
- package/dist/kernel/stage.d.ts +87 -0
- package/dist/kernel/stage.d.ts.map +1 -0
- package/dist/kernel/textLayout.d.ts +29 -0
- package/dist/kernel/textLayout.d.ts.map +1 -0
- package/dist/kernel/tween.d.ts +35 -0
- package/dist/kernel/tween.d.ts.map +1 -0
- package/dist/kernel/xrInput.d.ts +107 -0
- package/dist/kernel/xrInput.d.ts.map +1 -0
- package/dist/kernel/xrLocomotion.d.ts +38 -0
- package/dist/kernel/xrLocomotion.d.ts.map +1 -0
- package/dist/runtime/FrameSource.d.ts +29 -0
- package/dist/runtime/FrameSource.d.ts.map +1 -0
- package/dist/runtime/ResourceRegistry.d.ts +18 -0
- package/dist/runtime/ResourceRegistry.d.ts.map +1 -0
- package/dist/runtime/SceneRuntime.d.ts +68 -0
- package/dist/runtime/SceneRuntime.d.ts.map +1 -0
- package/dist/runtime/SceneSchema.d.ts +2536 -0
- package/dist/runtime/SceneSchema.d.ts.map +1 -0
- package/dist/runtime/errors.d.ts +19 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/webgl/contactShadows.d.ts +5 -0
- package/dist/webgl/contactShadows.d.ts.map +1 -0
- package/dist/webgl/index.d.ts +11 -0
- package/dist/webgl/index.d.ts.map +1 -0
- package/dist/webgl/index.js +239 -0
- package/dist/webgl/index.js.map +13 -0
- package/dist/webgl/shaderGrid.d.ts +27 -0
- package/dist/webgl/shaderGrid.d.ts.map +1 -0
- package/dist/webgl/sky.d.ts +4 -0
- package/dist/webgl/sky.d.ts.map +1 -0
- package/dist/webgpu/contactShadows.d.ts +5 -0
- package/dist/webgpu/contactShadows.d.ts.map +1 -0
- package/dist/webgpu/index.d.ts +10 -0
- package/dist/webgpu/index.d.ts.map +1 -0
- package/dist/webgpu/index.js +216 -0
- package/dist/webgpu/index.js.map +13 -0
- package/dist/webgpu/shaderGrid.d.ts +5 -0
- package/dist/webgpu/shaderGrid.d.ts.map +1 -0
- package/dist/webgpu/sky.d.ts +4 -0
- package/dist/webgpu/sky.d.ts.map +1 -0
- package/package.json +82 -4
- package/src/index.ts +11 -0
- package/src/kernel/animation.ts +24 -0
- package/src/kernel/behaviours.ts +36 -0
- package/src/kernel/bodies.ts +338 -0
- package/src/kernel/bodySources.ts +203 -0
- package/src/kernel/build.ts +1325 -0
- package/src/kernel/cameraMotion.ts +202 -0
- package/src/kernel/clock.ts +35 -0
- package/src/kernel/contactShadowPasses.ts +207 -0
- package/src/kernel/description.ts +1197 -0
- package/src/kernel/diff.ts +383 -0
- package/src/kernel/environmentPresets.ts +38 -0
- package/src/kernel/equality.ts +604 -0
- package/src/kernel/frames.ts +124 -0
- package/src/kernel/index.ts +274 -0
- package/src/kernel/instances.ts +97 -0
- package/src/kernel/labels.ts +48 -0
- package/src/kernel/loop.ts +248 -0
- package/src/kernel/materials.ts +258 -0
- package/src/kernel/motion.ts +75 -0
- package/src/kernel/orbit.ts +554 -0
- package/src/kernel/overlays.ts +130 -0
- package/src/kernel/performance.ts +101 -0
- package/src/kernel/physics.ts +361 -0
- package/src/kernel/physicsDebug.ts +68 -0
- package/src/kernel/pointer.ts +785 -0
- package/src/kernel/renderKit.ts +53 -0
- package/src/kernel/renderer.ts +136 -0
- package/src/kernel/resources.ts +504 -0
- package/src/kernel/sceneGraph.ts +1440 -0
- package/src/kernel/sceneIndex.ts +219 -0
- package/src/kernel/stage.ts +157 -0
- package/src/kernel/textLayout.ts +102 -0
- package/src/kernel/tween.ts +80 -0
- package/src/kernel/xrInput.ts +230 -0
- package/src/kernel/xrLocomotion.ts +72 -0
- package/src/runtime/FrameSource.ts +41 -0
- package/src/runtime/ResourceRegistry.ts +24 -0
- package/src/runtime/SceneRuntime.ts +229 -0
- package/src/runtime/SceneSchema.ts +983 -0
- package/src/runtime/errors.ts +18 -0
- package/src/runtime/index.ts +10 -0
- package/src/webgl/contactShadows.ts +67 -0
- package/src/webgl/index.ts +19 -0
- package/src/webgl/shaderGrid.ts +196 -0
- package/src/webgl/sky.ts +42 -0
- package/src/webgpu/contactShadows.ts +83 -0
- package/src/webgpu/index.ts +19 -0
- package/src/webgpu/shaderGrid.ts +158 -0
- package/src/webgpu/sky.ts +35 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eased transitions of position and scale. A tween's pose is a pure function of scene
|
|
3
|
+
* time: `from + (to - from) * easing(progress)`, so frames are deterministic.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { Object3D, Vector3Tuple } from 'three';
|
|
8
|
+
import type { Easing, Vec3 } from './description.ts';
|
|
9
|
+
/** Maps linear progress in [0, 1] through an easing curve. */
|
|
10
|
+
export declare const easeProgress: (easing: Easing, progress: number) => number;
|
|
11
|
+
/** A position and scale transition in flight. */
|
|
12
|
+
export type Tween = {
|
|
13
|
+
readonly fromPosition: Vector3Tuple;
|
|
14
|
+
readonly fromScale: Vector3Tuple;
|
|
15
|
+
readonly toPosition: Vec3;
|
|
16
|
+
readonly toScale: Vec3;
|
|
17
|
+
/** Scene time the tween started, in seconds. */
|
|
18
|
+
readonly start: number;
|
|
19
|
+
readonly seconds: number;
|
|
20
|
+
readonly easing: Easing;
|
|
21
|
+
};
|
|
22
|
+
/** Starts a tween from the object's current pose towards the targets. */
|
|
23
|
+
export declare const startTween: (object: Object3D, target: {
|
|
24
|
+
readonly position: Vec3;
|
|
25
|
+
readonly scale: Vec3;
|
|
26
|
+
}, start: number, transition: {
|
|
27
|
+
readonly seconds: number;
|
|
28
|
+
readonly easing: Easing;
|
|
29
|
+
}) => Tween;
|
|
30
|
+
/**
|
|
31
|
+
* Writes the tween's pose at `elapsedSeconds` into the object without allocating.
|
|
32
|
+
* Returns true once the tween has finished, after writing the exact targets.
|
|
33
|
+
*/
|
|
34
|
+
export declare const applyTween: (object: Object3D, tween: Tween, elapsedSeconds: number) => boolean;
|
|
35
|
+
//# sourceMappingURL=tween.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tween.d.ts","sourceRoot":"","sources":["../../src/kernel/tween.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIrD,8DAA8D;AAC9D,eAAO,MAAM,YAAY,WAAY,MAAM,YAAY,MAAM,KAAG,MAW/D,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,UAAU,WACb,QAAQ,UACR;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,SAClD,MAAM,cACD;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAChE,KAQD,CAAC;AAIH;;;GAGG;AACH,eAAO,MAAM,UAAU,WAAY,QAAQ,SAAS,KAAK,kBAAkB,MAAM,KAAG,OAmBnF,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XR input as the scene's events: controllers and hands pointing, selecting, dragging,
|
|
3
|
+
* pushing sticks and pressing buttons, and (in AR) selecting a real surface.
|
|
4
|
+
*
|
|
5
|
+
* Behavioural reference: pmndrs/xr at `0e1acd8`. Its pointers ray-cast along each input
|
|
6
|
+
* source's target ray every frame (`packages/xr/src/pointer`), entering and leaving what
|
|
7
|
+
* they point at, capturing the object a select starts on so moving drags it, and turning
|
|
8
|
+
* select start and end into pointer down, up and click. Its controller locomotion
|
|
9
|
+
* (`controller-locomotion.ts`) reads the thumbstick each frame; here a stick reports when
|
|
10
|
+
* it is pushed past halfway in a direction and when it comes back, so a Model can snap
|
|
11
|
+
* turn and teleport by changing `xr({ origin, heading })`.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { Vec3 } from './description.ts';
|
|
16
|
+
import type { Picker, Ray, SceneEvent } from './pointer.ts';
|
|
17
|
+
/** Which hand an input source is held in or is, as WebXR's `handedness`. */
|
|
18
|
+
export type XrHand = 'left' | 'right' | 'none';
|
|
19
|
+
/** Where a thumbstick is pushed: `forward` is away from the player. */
|
|
20
|
+
export type XrStickDirection = 'center' | 'left' | 'right' | 'forward' | 'back';
|
|
21
|
+
/**
|
|
22
|
+
* A controller's buttons, by the `xr-standard` gamepad mapping: the trigger, the grip
|
|
23
|
+
* (`squeeze`), a touchpad, the thumbstick pressed, and the face buttons (A and B on the
|
|
24
|
+
* right controller, X and Y on the left: `primary` and `secondary`).
|
|
25
|
+
*/
|
|
26
|
+
export type XrButtonName = 'trigger' | 'squeeze' | 'touchpad' | 'thumbstick' | 'primary' | 'secondary';
|
|
27
|
+
/**
|
|
28
|
+
* A plane the session detected (`xr({ planes: true })`): a floor, wall or table, in the
|
|
29
|
+
* scene's space. `polygon` is its outline in its own space (on its x–z plane); `label` is
|
|
30
|
+
* what the device took it for (`floor`, `wall`, `table`…), or `''` when it did not say.
|
|
31
|
+
* Follow one with `group({ follow: planeSpace(id) })`.
|
|
32
|
+
*/
|
|
33
|
+
export type XrPlane = {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly orientation: 'horizontal' | 'vertical';
|
|
36
|
+
readonly label: string;
|
|
37
|
+
readonly position: Vec3;
|
|
38
|
+
readonly rotation: Vec3;
|
|
39
|
+
readonly polygon: ReadonlyArray<Vec3>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A mesh the session detected (`xr({ meshes: true })`): furniture, a wall, the room. Its
|
|
43
|
+
* pose is in the scene's space; its geometry is lent for `xrMesh(id)` rather than sent.
|
|
44
|
+
*/
|
|
45
|
+
export type XrMesh = {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly label: string;
|
|
48
|
+
readonly position: Vec3;
|
|
49
|
+
readonly rotation: Vec3;
|
|
50
|
+
};
|
|
51
|
+
/** Input from an immersive session, each from an input source (`source` tells them apart). */
|
|
52
|
+
export type XrInput =
|
|
53
|
+
/** A select (the trigger, or a pinch) beginning or ending, along the source's ray. */
|
|
54
|
+
{
|
|
55
|
+
readonly _tag: 'SelectStart' | 'SelectEnd';
|
|
56
|
+
readonly source: number;
|
|
57
|
+
readonly ray: Ray;
|
|
58
|
+
}
|
|
59
|
+
/** Where the source points this frame. */
|
|
60
|
+
| {
|
|
61
|
+
readonly _tag: 'Aim';
|
|
62
|
+
readonly source: number;
|
|
63
|
+
readonly ray: Ray;
|
|
64
|
+
}
|
|
65
|
+
/** The source went away (put down, or the session ended). */
|
|
66
|
+
| {
|
|
67
|
+
readonly _tag: 'Lost';
|
|
68
|
+
readonly source: number;
|
|
69
|
+
} | {
|
|
70
|
+
readonly _tag: 'Stick';
|
|
71
|
+
readonly source: number;
|
|
72
|
+
readonly hand: XrHand;
|
|
73
|
+
readonly direction: XrStickDirection;
|
|
74
|
+
} | {
|
|
75
|
+
readonly _tag: 'Button';
|
|
76
|
+
readonly source: number;
|
|
77
|
+
readonly hand: XrHand;
|
|
78
|
+
readonly button: XrButtonName;
|
|
79
|
+
readonly pressed: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Gliding (`xr({ glide })`) stopped: where the player stands now, for the Model. */
|
|
82
|
+
| {
|
|
83
|
+
readonly _tag: 'Moved';
|
|
84
|
+
readonly origin: Vec3;
|
|
85
|
+
readonly heading: number;
|
|
86
|
+
}
|
|
87
|
+
/** The detected planes changed: all of them, as they are now. */
|
|
88
|
+
| {
|
|
89
|
+
readonly _tag: 'Planes';
|
|
90
|
+
readonly planes: ReadonlyArray<XrPlane>;
|
|
91
|
+
}
|
|
92
|
+
/** The detected meshes changed: all of them, as they are now. */
|
|
93
|
+
| {
|
|
94
|
+
readonly _tag: 'Meshes';
|
|
95
|
+
readonly meshes: ReadonlyArray<XrMesh>;
|
|
96
|
+
}
|
|
97
|
+
/** In AR, a select whose ray met a real surface: where, and the surface's normal. */
|
|
98
|
+
| {
|
|
99
|
+
readonly _tag: 'Surface';
|
|
100
|
+
readonly source: number;
|
|
101
|
+
readonly hand: XrHand;
|
|
102
|
+
readonly point: Vec3;
|
|
103
|
+
readonly normal: Vec3;
|
|
104
|
+
};
|
|
105
|
+
/** Creates the tracker turning one session's XR input into scene events. */
|
|
106
|
+
export declare const createXrTracker: (picker: Picker) => (input: XrInput) => ReadonlyArray<SceneEvent>;
|
|
107
|
+
//# sourceMappingURL=xrInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xrInput.d.ts","sourceRoot":"","sources":["../../src/kernel/xrInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAO,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,4EAA4E;AAC5E,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,uEAAuE;AACvE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,SAAS,GACT,UAAU,GACV,YAAY,GACZ,SAAS,GACT,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,YAAY,GAAG,UAAU,CAAC;IAChD,QAAQ,CAAC,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CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AACH,qFAAqF;GACnF;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAC7E,iEAAiE;GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAAE;AACtE,iEAAiE;GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE;AACrE,qFAAqF;GACnF;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB,CAAC;AA8BN,4EAA4E;AAC5E,eAAO,MAAM,eAAe,WAAY,MAAM,aA4E7B,OAAO,KAAG,aAAa,CAAC,UAAU,CA0BlD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moving the player in an immersive session, as functions from the scene's `xr` settings
|
|
3
|
+
* to new ones: the Model keeps where the player stands, and the session follows it.
|
|
4
|
+
*
|
|
5
|
+
* Behavioural reference: pmndrs/xr at `0e1acd8`, `controller-locomotion.ts`: the right
|
|
6
|
+
* thumbstick snap-turns 45° once pushed past halfway (and must come back before turning
|
|
7
|
+
* again), and the left one moves the player along where they face. Here moving is a step
|
|
8
|
+
* per push, not a glide: sticks arrive as `XrStick` events when pushed and let back.
|
|
9
|
+
* `teleport` is `@react-three/xr`'s `TeleportTarget`: the player stands where they point.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { Vec3, Xr } from './description.ts';
|
|
14
|
+
import type { XrHand, XrStickDirection } from './xrInput.ts';
|
|
15
|
+
export type LocomotionOptions = {
|
|
16
|
+
/** Degrees a snap turn turns by. Default 45, as pmndrs/xr's. */
|
|
17
|
+
readonly snapDegrees?: number;
|
|
18
|
+
/** Metres a step moves. Default 1. */
|
|
19
|
+
readonly step?: number;
|
|
20
|
+
/** The hand whose stick turns; the other moves. Default `right`, as pmndrs/xr's. */
|
|
21
|
+
readonly turnHand?: Exclude<XrHand, 'none'>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The settings after a stick is pushed: the turning hand's left and right snap-turn, the
|
|
25
|
+
* other hand's stick steps forward, back, left or right. Centring changes nothing.
|
|
26
|
+
*/
|
|
27
|
+
export declare const locomote: (settings: Xr, stick: {
|
|
28
|
+
readonly hand: XrHand;
|
|
29
|
+
readonly direction: XrStickDirection;
|
|
30
|
+
}, options?: LocomotionOptions) => Xr;
|
|
31
|
+
/** The settings with the player standing at `point` (on the floor there), facing as before. */
|
|
32
|
+
export declare const teleport: (settings: Xr, point: Vec3) => Xr;
|
|
33
|
+
/** The settings where gliding left the player (an `XrMoved` event): its origin and heading. */
|
|
34
|
+
export declare const glided: (settings: Xr, moved: {
|
|
35
|
+
readonly origin: Vec3;
|
|
36
|
+
readonly heading: number;
|
|
37
|
+
}) => Xr;
|
|
38
|
+
//# sourceMappingURL=xrLocomotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xrLocomotion.d.ts","sourceRoot":"","sources":["../../src/kernel/xrLocomotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAWF;;;GAGG;AACH,eAAO,MAAM,QAAQ,aACT,EAAE,SACL;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAA;CAAE,YAC7D,iBAAiB,KACzB,EAkBF,CAAC;AAEF,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,aAAc,EAAE,SAAS,IAAI,KAAG,EAGnD,CAAC;AAEH,+FAA+F;AAC/F,eAAO,MAAM,MAAM,aACP,EAAE,SACL;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KACzD,EAAqE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where frames come from. Wraps a kernel `FrameScheduler` so a scene's per-frame callback
|
|
3
|
+
* is registered for exactly the lifetime of its scope.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { Context, Effect, Layer } from 'effect';
|
|
8
|
+
import { type FrameControl, type FrameScheduler } from '../kernel/index.ts';
|
|
9
|
+
/** The frame source service for `scheduler`, for providing directly with `provideService`. */
|
|
10
|
+
export declare const fromScheduler: (scheduler: FrameScheduler) => {
|
|
11
|
+
/**
|
|
12
|
+
* Calls `onFrame` once per frame until the current scope closes, while awake. Returns
|
|
13
|
+
* the control that puts the subscription to sleep and wakes it.
|
|
14
|
+
*/
|
|
15
|
+
subscribe: (onFrame: () => void) => Effect.Effect<FrameControl, never, import("effect/Scope").Scope>;
|
|
16
|
+
};
|
|
17
|
+
declare const FrameSource_base: Context.ServiceClass<FrameSource, "effect-three/FrameSource", {
|
|
18
|
+
/**
|
|
19
|
+
* Calls `onFrame` once per frame until the current scope closes, while awake. Returns
|
|
20
|
+
* the control that puts the subscription to sleep and wakes it.
|
|
21
|
+
*/
|
|
22
|
+
subscribe: (onFrame: () => void) => Effect.Effect<FrameControl, never, import("effect/Scope").Scope>;
|
|
23
|
+
}>;
|
|
24
|
+
export declare class FrameSource extends FrameSource_base {
|
|
25
|
+
}
|
|
26
|
+
/** Provides a frame source backed by `scheduler`. */
|
|
27
|
+
export declare const layer: (scheduler: FrameScheduler) => Layer.Layer<FrameSource, never, never>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=FrameSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameSource.d.ts","sourceRoot":"","sources":["../../src/runtime/FrameSource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAqB,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAY/F,8FAA8F;AAC9F,eAAO,MAAM,aAAa,cAAe,cAAc;IACrD;;;OAGG;IACH,SAAS,YAAY,MAAM,IAAI;CAM/B,CAAC;;IAVD;;;OAGG;yBACkB,MAAM,IAAI;;AAQjC,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,qDAAqD;AACrD,eAAO,MAAM,KAAK,cAAe,cAAc,2CACO,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-level owner of shared GPU resources (ADR-005). Every scene runtime built with the
|
|
3
|
+
* same Layer shares one kernel resource store; the store is disposed when the Layer's
|
|
4
|
+
* scope closes.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { Context, Layer } from 'effect';
|
|
9
|
+
import { type ResourceStore } from '../kernel/index.ts';
|
|
10
|
+
declare const ResourceRegistry_base: Context.ServiceClass<ResourceRegistry, "effect-three/ResourceRegistry", {
|
|
11
|
+
readonly store: ResourceStore;
|
|
12
|
+
}>;
|
|
13
|
+
export declare class ResourceRegistry extends ResourceRegistry_base {
|
|
14
|
+
}
|
|
15
|
+
/** Provides one shared resource store for the lifetime of the Layer. */
|
|
16
|
+
export declare const layer: Layer.Layer<ResourceRegistry, never, never>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=ResourceRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceRegistry.d.ts","sourceRoot":"","sources":["../../src/runtime/ResourceRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;;oBAIzD,aAAa;;AAFjC,qBAAa,gBAAiB,SAAQ,qBAGF;CAAG;AAQvC,wEAAwE;AACxE,eAAO,MAAM,KAAK,6CAA0E,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A running scene: a kernel scene graph, a renderer and a frame subscription, all owned
|
|
3
|
+
* by the caller's `Scope`. Closing the scope stops the frame loop, then releases the
|
|
4
|
+
* event queue, the renderer and every resource the scene acquired, in that order.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { Effect, Scope, Stream } from 'effect';
|
|
9
|
+
import { type Behaviour, type Op, type OverlayPlacement, type LabelEngine, type PhysicsEngine, type RendererFactory, type SceneDescription, type SceneEvent, type SceneGraph, type Viewport } from '../kernel/index.ts';
|
|
10
|
+
import { InvalidScene, RendererUnavailable } from './errors.ts';
|
|
11
|
+
import { FrameSource } from './FrameSource.ts';
|
|
12
|
+
import { ResourceRegistry } from './ResourceRegistry.ts';
|
|
13
|
+
export type SceneRuntimeOptions = {
|
|
14
|
+
readonly scene: SceneDescription;
|
|
15
|
+
readonly renderer: RendererFactory;
|
|
16
|
+
readonly viewport: Viewport;
|
|
17
|
+
/** Events kept when the consumer falls behind; older events are dropped. Default 64. */
|
|
18
|
+
readonly eventCapacity?: number;
|
|
19
|
+
/** Behaviours nodes may name, beside the built-in ones. */
|
|
20
|
+
readonly behaviours?: Readonly<Record<string, Behaviour>>;
|
|
21
|
+
/** The physics engine for meshes with a `body`; without one, bodies stay put. */
|
|
22
|
+
readonly physics?: PhysicsEngine | undefined;
|
|
23
|
+
/** Draws `label` nodes (distance-field text); without one, labels are empty. */
|
|
24
|
+
readonly labels?: LabelEngine | undefined;
|
|
25
|
+
/** Receives where the overlays are after each drawn frame, to move their HTML there. */
|
|
26
|
+
readonly placeOverlays?: (placements: ReadonlyArray<OverlayPlacement>) => void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Starts a scene in the current scope. Fails with `InvalidScene` if the initial
|
|
30
|
+
* description is rejected and `RendererUnavailable` if the renderer can't be created.
|
|
31
|
+
* A failed or interrupted start releases everything it acquired before returning.
|
|
32
|
+
*/
|
|
33
|
+
export declare const make: (options: SceneRuntimeOptions) => Effect.Effect<{
|
|
34
|
+
/** The hosted scene graph, for inspection. */
|
|
35
|
+
graph: SceneGraph;
|
|
36
|
+
/** The operations that built the initial scene. */
|
|
37
|
+
startupOps: readonly Op[];
|
|
38
|
+
/**
|
|
39
|
+
* Applies a new description and returns the operations it took. Structurally equal
|
|
40
|
+
* descriptions return no operations and cost no host changes.
|
|
41
|
+
*/
|
|
42
|
+
update: (scene: SceneDescription) => Effect.Effect<readonly Op[], InvalidScene, never>;
|
|
43
|
+
/** Resizes the camera aspect and the renderer's drawing surface. */
|
|
44
|
+
resize: (viewport: Viewport) => Effect.Effect<void, never, never>;
|
|
45
|
+
/** Freezes (`false`) or resumes (`true`) behaviours; frozen, transitions land at once. */
|
|
46
|
+
setAnimating: (animating: boolean) => Effect.Effect<void, never, never>;
|
|
47
|
+
/**
|
|
48
|
+
* Draws one frame now, whatever the frame mode: React Three Fiber's `advance`, for
|
|
49
|
+
* `frames: 'never'` scenes and frame-exact capture.
|
|
50
|
+
*/
|
|
51
|
+
advance: Effect.Effect<void, never, never>;
|
|
52
|
+
/**
|
|
53
|
+
* Draws one frame now, synchronously, for a host's own frame source to call directly:
|
|
54
|
+
* an immersive (WebXR) session's animation loop.
|
|
55
|
+
*/
|
|
56
|
+
drawNow: () => void;
|
|
57
|
+
/** Routes pointer input. Synchronous, so DOM listeners can call it directly. */
|
|
58
|
+
pointer: (input: import("../index.ts").PointerInput) => ReadonlyArray<SceneEvent>;
|
|
59
|
+
/** Routes XR input: aims, selects, sticks, buttons and surfaces. Synchronous, as `pointer`. */
|
|
60
|
+
xrInput: (input: import("../index.ts").XrInput) => ReadonlyArray<SceneEvent>;
|
|
61
|
+
/** Scene events, newest kept when the consumer falls behind. */
|
|
62
|
+
events: Stream.Stream<SceneEvent, never, never>;
|
|
63
|
+
/** Removes and returns every pending event without waiting. */
|
|
64
|
+
drainEvents: Effect.Effect<SceneEvent[], never, never>;
|
|
65
|
+
}, InvalidScene | RendererUnavailable, FrameSource | ResourceRegistry | Scope.Scope>;
|
|
66
|
+
/** The handle `make` returns. */
|
|
67
|
+
export type SceneHandle = Effect.Success<ReturnType<typeof make>>;
|
|
68
|
+
//# sourceMappingURL=SceneRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneRuntime.d.ts","sourceRoot":"","sources":["../../src/runtime/SceneRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAS,MAAM,EAAsC,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAGL,KAAK,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