@skewedaspect/sage 0.9.6 → 0.10.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behaviors/sound.d.ts +12 -127
- package/dist/classes/debugConsole.d.ts +1 -0
- package/dist/classes/gameEngine.d.ts +31 -46
- package/dist/classes/gameLevel.d.ts +21 -12
- package/dist/classes/level.d.ts +24 -29
- package/dist/entities/constants.d.ts +1 -0
- package/dist/entities/defineEntity.d.ts +17 -0
- package/dist/entities/entityPicking.d.ts +15 -0
- package/dist/entities/meshConfig.d.ts +14 -0
- package/dist/entities/nodeEntity.d.ts +43 -0
- package/dist/entities/nodePool.d.ts +8 -0
- package/dist/entities/nodeSimulation.d.ts +30 -0
- package/dist/entities/nodeSimulationContext.d.ts +17 -0
- package/dist/entities/standardMeshSource.d.ts +8 -0
- package/dist/events/payloads.d.ts +0 -42
- package/dist/events/types.d.ts +2 -23
- package/dist/input/actionContext.d.ts +13 -0
- package/dist/input/actionRegistry.d.ts +7 -0
- package/dist/input/binding.d.ts +33 -0
- package/dist/input/bindings/delta.d.ts +23 -0
- package/dist/input/bindings/toggle.d.ts +25 -0
- package/dist/input/bindings/trigger.d.ts +23 -0
- package/dist/input/bindings/value.d.ts +26 -0
- package/dist/input/configuration.d.ts +15 -0
- package/dist/input/deliverAction.d.ts +4 -0
- package/dist/input/deviceReader.d.ts +5 -0
- package/dist/input/deviceReaders/gamepad.d.ts +9 -0
- package/dist/input/deviceReaders/keyboard.d.ts +8 -0
- package/dist/input/deviceReaders/mouse.d.ts +9 -0
- package/dist/input/deviceState.d.ts +24 -0
- package/dist/input/inputCapture.d.ts +21 -0
- package/dist/input/resolveBinding.d.ts +4 -0
- package/dist/interfaces/game.d.ts +21 -5
- package/dist/interfaces/level.d.ts +21 -3
- package/dist/managers/asset.d.ts +17 -3
- package/dist/managers/game.d.ts +15 -5
- package/dist/managers/input.d.ts +31 -51
- package/dist/managers/level.d.ts +20 -4
- package/dist/managers/outline.d.ts +4 -4
- package/dist/managers/simulationSave.d.ts +38 -0
- package/dist/{postProcessingFrameGraph-CaMgQzR-.js → postProcessingFrameGraph-C3Og4kaS.js} +34 -26
- package/dist/postProcessingFrameGraph-C3Og4kaS.js.map +1 -0
- package/dist/sage.d.ts +54 -16
- package/dist/sage.es.js +1868 -2424
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/dist/utils/bounds.d.ts +11 -0
- package/dist/utils/physics.d.ts +4 -1
- package/package.json +29 -66
- package/LICENSE +0 -21
- package/Readme.md +0 -73
- package/dist/behaviors/index.d.ts +0 -2
- package/dist/behaviors/stateMachine.d.ts +0 -76
- package/dist/classes/bindings/toggle.d.ts +0 -116
- package/dist/classes/bindings/trigger.d.ts +0 -81
- package/dist/classes/bindings/value.d.ts +0 -104
- package/dist/classes/entity.d.ts +0 -332
- package/dist/classes/input/gamepad.d.ts +0 -94
- package/dist/classes/input/keyboard.d.ts +0 -66
- package/dist/classes/input/mouse.d.ts +0 -91
- package/dist/classes/input/readers/gamepad.d.ts +0 -73
- package/dist/classes/input/readers/keyboard.d.ts +0 -56
- package/dist/classes/input/readers/mouse.d.ts +0 -41
- package/dist/interfaces/action.d.ts +0 -22
- package/dist/interfaces/binding.d.ts +0 -123
- package/dist/interfaces/entity.d.ts +0 -97
- package/dist/interfaces/input.d.ts +0 -180
- package/dist/managers/binding.d.ts +0 -233
- package/dist/managers/entity.d.ts +0 -264
- package/dist/managers/save.d.ts +0 -75
- package/dist/postProcessingFrameGraph-CaMgQzR-.js.map +0 -1
- package/dist/utils/entityProxy.d.ts +0 -2
- package/dist/utils/raycast.d.ts +0 -26
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TransformNode, Vector3 } from '@babylonjs/core';
|
|
2
|
+
export interface HierarchyBounds {
|
|
3
|
+
/** Full box size across the node's descendants. */
|
|
4
|
+
extents: Vector3;
|
|
5
|
+
/** Offset from the node's origin, in the node's local frame. */
|
|
6
|
+
center: Vector3;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Measures a node's descendant geometry as a box, in the format `PhysicsAggregate` takes in its options.
|
|
10
|
+
*/
|
|
11
|
+
export declare function computeHierarchyBounds(node: TransformNode): HierarchyBounds;
|
package/dist/utils/physics.d.ts
CHANGED
|
@@ -5,8 +5,11 @@ import { HavokPlugin } from '@babylonjs/core';
|
|
|
5
5
|
*
|
|
6
6
|
* Each BabylonJS scene needs its own HavokPlugin instance (because scene.dispose() disposes the
|
|
7
7
|
* plugin attached to it). The raw WASM module can be shared across plugins safely.
|
|
8
|
+
*
|
|
9
|
+
* @param wasmBinary - Pre-loaded Havok WASM. Left unset, Havok fetches its own over HTTP, which
|
|
10
|
+
* only works in a browser.
|
|
8
11
|
*/
|
|
9
|
-
export declare function initHavok(): Promise<HavokPhysicsWithBindings>;
|
|
12
|
+
export declare function initHavok(wasmBinary?: BufferSource): Promise<HavokPhysicsWithBindings>;
|
|
10
13
|
/**
|
|
11
14
|
* Creates a new HavokPlugin from an existing WASM instance.
|
|
12
15
|
*/
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skewedaspect/sage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-beta.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": true,
|
|
4
6
|
"main": "dist/sage.umd.js",
|
|
5
7
|
"module": "dist/sage.es.js",
|
|
6
8
|
"types": "dist/sage.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"sideEffects": true,
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/sage.d.ts",
|
|
@@ -14,87 +14,50 @@
|
|
|
14
14
|
"default": "./dist/sage.es.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://gitlab.com/skewed-aspect/sage/sage",
|
|
20
|
+
"directory": "packages/sage"
|
|
21
|
+
},
|
|
22
|
+
"author": "Christopher S. Case<chris.case@g33xnexus.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"description": "A modern JavaScript/TypeScript game engine built on top of BabylonJS that provides simplified abstractions for 3D game development.",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"engine",
|
|
27
|
+
"babylonjs",
|
|
28
|
+
"babylon.js",
|
|
29
|
+
"game"
|
|
21
30
|
],
|
|
22
31
|
"scripts": {
|
|
23
32
|
"build": "vite build",
|
|
24
33
|
"dev": "vite",
|
|
25
|
-
"
|
|
26
|
-
"examples:build": "vite build --config examples/vite.config.ts",
|
|
27
|
-
"docs": "npm run examples:build -- --base /examples/ && rm -rf site/docs/public/examples && cp -r examples/dist site/docs/public/examples && cd site && npx vitepress dev docs",
|
|
28
|
-
"docs:build": "npm run examples:build -- --base /examples/ && node scripts/examples-spa-fallback.mjs && rm -rf site/docs/public/examples && cp -r examples/dist site/docs/public/examples && cd site && npx vitepress build docs",
|
|
29
|
-
"test": "vitest run",
|
|
30
|
-
"test:watch": "vitest",
|
|
34
|
+
"test": "vitest run --config vitest.config.ts",
|
|
31
35
|
"test:e2e": "playwright test",
|
|
32
36
|
"test:e2e:ui": "playwright test --ui",
|
|
33
|
-
"
|
|
34
|
-
"test:bench:id": "node ./benchmark/id-generation.bench.ts",
|
|
35
|
-
"lint": "eslint \"{src,tests,benchmark}/**/*.{ts,js,vue}\" --max-warnings=0 --no-warn-ignored",
|
|
36
|
-
"lint:staged": "lint-staged",
|
|
37
|
-
"prepare": "if-env NODE_ENV=production && exit 0 || husky",
|
|
38
|
-
"release": "bash scripts/release.sh"
|
|
37
|
+
"lint:types": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tests/tsconfig.json"
|
|
39
38
|
},
|
|
40
39
|
"files": [
|
|
41
40
|
"dist"
|
|
42
41
|
],
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@skewedaspect/sage-core": "*",
|
|
44
|
+
"hexoid": "^2.0.0",
|
|
45
|
+
"js-yaml": "^4.1.1"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@babylonjs/core": "^9.0.0",
|
|
49
|
+
"@babylonjs/havok": "^1.3.10",
|
|
50
|
+
"@babylonjs/loaders": "^9.0.0"
|
|
52
51
|
},
|
|
53
|
-
"author": "Christopher S. Case<chris.case@g33xnexus.com>",
|
|
54
|
-
"license": "MIT",
|
|
55
|
-
"description": "A modern JavaScript/TypeScript game engine built on top of BabylonJS that provides simplified abstractions for 3D game development.",
|
|
56
52
|
"devDependencies": {
|
|
57
53
|
"@babylonjs/core": "^9.0.0",
|
|
58
54
|
"@babylonjs/havok": "^1.3.12",
|
|
59
55
|
"@babylonjs/loaders": "^9.0.0",
|
|
60
|
-
"@eslint/js": "^10.0.1",
|
|
61
56
|
"@playwright/test": "^1.58.0",
|
|
62
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
63
|
-
"@types/eslint__js": "^8.42.3",
|
|
64
57
|
"@types/js-yaml": "^4.0.9",
|
|
65
|
-
"@types/node": "^25.5.0",
|
|
66
|
-
"@types/sinon": "^21.0.0",
|
|
67
|
-
"eslint": "^10.1.0",
|
|
68
|
-
"eslint-formatter-junit": "^9.0.1",
|
|
69
|
-
"husky": "^9.1.7",
|
|
70
|
-
"if-env": "^1.0.4",
|
|
71
|
-
"jsdom": "^29.0.1",
|
|
72
|
-
"lint-staged": "^16.4.0",
|
|
73
|
-
"sinon": "^21.0.3",
|
|
74
|
-
"tinybench": "^6.0.0",
|
|
75
|
-
"tslib": "^2.8.1",
|
|
76
58
|
"typescript": "^6.0.2",
|
|
77
|
-
"typescript-eslint": "^8.29.0",
|
|
78
|
-
"uid": "^2.0.2",
|
|
79
59
|
"vite": "^8.0.3",
|
|
80
|
-
"vite-plugin-
|
|
81
|
-
"
|
|
82
|
-
},
|
|
83
|
-
"lint-staged": {
|
|
84
|
-
"*.{ts,js}": "npm run lint"
|
|
85
|
-
},
|
|
86
|
-
"peerDependencies": {
|
|
87
|
-
"@babylonjs/core": "^9.0.0",
|
|
88
|
-
"@babylonjs/havok": "^1.3.10",
|
|
89
|
-
"@babylonjs/loaders": "^9.0.0"
|
|
90
|
-
},
|
|
91
|
-
"overrides": {
|
|
92
|
-
"typescript-eslint": {
|
|
93
|
-
"typescript": "$typescript"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"dependencies": {
|
|
97
|
-
"hexoid": "^2.0.0",
|
|
98
|
-
"js-yaml": "^4.1.1"
|
|
60
|
+
"vite-plugin-checker": "^0.12.0",
|
|
61
|
+
"vite-plugin-dts": "^4.5.4"
|
|
99
62
|
}
|
|
100
63
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Christopher Case
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/Readme.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# SkewedAspect Game Engine (SAGE)
|
|
3
|
-
|
|
4
|
-
<div align="center">
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
The SkewedAspect Game Engine (SAGE) is a powerful and flexible game engine designed for creating 2D and 3D games. It leverages BabylonJS for rendering and Havok for physics simulation.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
To install the SAGE library, use npm:
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
npm install @skewedaspect/sage
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
### Creating a Game Engine Instance
|
|
22
|
-
|
|
23
|
-
To create an instance of the SkewedAspect Game Engine, you need to provide a game canvas and rendering options.
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { createGameEngine, GameCanvas, RenderEngineOptions } from '@skewedaspect/sage';
|
|
27
|
-
|
|
28
|
-
const canvas: GameCanvas = document.getElementById('gameCanvas') as HTMLCanvasElement;
|
|
29
|
-
const renderOptions: RenderEngineOptions = {
|
|
30
|
-
// ...your rendering options...
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const gameEngine = await createGameEngine(canvas, renderOptions);
|
|
34
|
-
|
|
35
|
-
// Start the game engine
|
|
36
|
-
gameEngine.start();
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Stopping the Game Engine
|
|
40
|
-
|
|
41
|
-
To stop the game engine, simply call the `stop` method on the game engine instance.
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
gameEngine.stop();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Releasing
|
|
48
|
-
|
|
49
|
-
Releases are done locally via the release script, which bumps the version, stamps the changelog, commits, tags,
|
|
50
|
-
and pushes. CI then auto-publishes to npm when it sees the version tag.
|
|
51
|
-
|
|
52
|
-
```sh
|
|
53
|
-
npm run release -- patch # 0.8.0 -> 0.8.1
|
|
54
|
-
npm run release -- minor # 0.8.0 -> 0.9.0
|
|
55
|
-
npm run release -- major # 0.8.0 -> 1.0.0
|
|
56
|
-
npm run release -- prerelease --preid=beta # 0.9.0 -> 0.9.1-beta.0
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Requirements:
|
|
60
|
-
- Clean working tree (commit or stash first)
|
|
61
|
-
- On the `main` branch
|
|
62
|
-
- GitLab CI needs `NPM_ID_TOKEN` OIDC configured for npm provenance publishing
|
|
63
|
-
|
|
64
|
-
The script publishes both `@skewedaspect/sage` and `@skewedaspect/sage-vue` at the same version. Prereleases are
|
|
65
|
-
tagged as `next` on npm.
|
|
66
|
-
|
|
67
|
-
## Contributing
|
|
68
|
-
|
|
69
|
-
Contributions are welcome! Please open an issue or submit a merge request on GitLab.
|
|
70
|
-
|
|
71
|
-
## License
|
|
72
|
-
|
|
73
|
-
This project is licensed under the MIT License.
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { GameEntityBehavior } from "../classes/entity.d.ts";
|
|
2
|
-
import { GameEvent } from "../classes/eventBus.d.ts";
|
|
3
|
-
import { StateMachine } from "../utils/stateMachine.d.ts";
|
|
4
|
-
/**
|
|
5
|
-
* A single transition definition for the state machine behavior configuration.
|
|
6
|
-
*/
|
|
7
|
-
export interface TransitionConfig<States extends string> {
|
|
8
|
-
from: States;
|
|
9
|
-
to: States;
|
|
10
|
-
guard?: () => boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A wildcard transition definition (from any state).
|
|
14
|
-
*/
|
|
15
|
-
export interface WildcardTransitionConfig<States extends string> {
|
|
16
|
-
to: States;
|
|
17
|
-
guard?: () => boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Configuration for creating a StateMachineBehavior subclass.
|
|
21
|
-
*/
|
|
22
|
-
export interface StateMachineBehaviorConfig<States extends string, EntityState extends object> {
|
|
23
|
-
/** The initial state of the state machine. */
|
|
24
|
-
initialState: States;
|
|
25
|
-
/** The key in the entity's state object to update when state changes. */
|
|
26
|
-
stateKey: keyof EntityState & string;
|
|
27
|
-
/** Valid transitions between states. */
|
|
28
|
-
transitions: TransitionConfig<States>[];
|
|
29
|
-
/** Wildcard transitions (from any state). */
|
|
30
|
-
wildcardTransitions?: WildcardTransitionConfig<States>[];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A behavior that wraps a {@link StateMachine} and ties it to entity state.
|
|
34
|
-
*
|
|
35
|
-
* Since behaviors are instantiated with `new BehaviorClass()` (no constructor args),
|
|
36
|
-
* use the static factory `StateMachineBehavior.create(config)` to produce a configured subclass.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const EnemyAI = StateMachineBehavior.create<EnemyStates, EnemyState>({
|
|
41
|
-
* initialState: 'idle',
|
|
42
|
-
* stateKey: 'aiState',
|
|
43
|
-
* transitions: [
|
|
44
|
-
* { from: 'idle', to: 'patrol' },
|
|
45
|
-
* { from: 'patrol', to: 'chase' },
|
|
46
|
-
* { from: 'chase', to: 'attack' },
|
|
47
|
-
* ],
|
|
48
|
-
* wildcardTransitions: [
|
|
49
|
-
* { to: 'dead' },
|
|
50
|
-
* ],
|
|
51
|
-
* });
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare class StateMachineBehavior<States extends string = string, EntityState extends object = object> extends GameEntityBehavior<EntityState> {
|
|
55
|
-
name: string;
|
|
56
|
-
eventSubscriptions: string[];
|
|
57
|
-
protected stateMachine: StateMachine<States>;
|
|
58
|
-
protected stateKey: keyof EntityState & string;
|
|
59
|
-
protected constructor();
|
|
60
|
-
/**
|
|
61
|
-
* The current state of the state machine.
|
|
62
|
-
*/
|
|
63
|
-
get currentState(): States;
|
|
64
|
-
/**
|
|
65
|
-
* Transition to a new state. Updates the entity's state and emits a state changed event.
|
|
66
|
-
*
|
|
67
|
-
* @throws If the transition is not defined or a guard rejects it.
|
|
68
|
-
*/
|
|
69
|
-
transition(to: States): void;
|
|
70
|
-
processEvent(_event: GameEvent, _state: EntityState): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a configured StateMachineBehavior subclass with the given state machine configuration baked in.
|
|
73
|
-
* The returned class can be used directly as a behavior constructor.
|
|
74
|
-
*/
|
|
75
|
-
static create<States extends string, EntityState extends object>(config: StateMachineBehaviorConfig<States, EntityState>): new () => StateMachineBehavior<States, EntityState>;
|
|
76
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { GameEventBus } from "../eventBus.d.ts";
|
|
2
|
-
import { Action } from "../../interfaces/action.d.ts";
|
|
3
|
-
import { Binding, ToggleBindingDefinition } from "../../interfaces/binding.d.ts";
|
|
4
|
-
import { DeviceType, DeviceValueReader, InputState } from "../../interfaces/input.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Options for configuring a toggle binding
|
|
7
|
-
*/
|
|
8
|
-
export interface ToggleBindingOptions {
|
|
9
|
-
/**
|
|
10
|
-
* If true, toggle on falling edge (true -> false) instead of rising edge (false -> true)
|
|
11
|
-
*/
|
|
12
|
-
invert?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Initial toggle state (defaults to false - off)
|
|
15
|
-
*/
|
|
16
|
-
initialState?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Threshold for analog inputs (0.0 to 1.0)
|
|
19
|
-
* When input value is >= threshold, it's considered "active" (true)
|
|
20
|
-
* When input value is < threshold, it's considered "inactive" (false)
|
|
21
|
-
* Defaults to 0.5 for analog inputs
|
|
22
|
-
*/
|
|
23
|
-
threshold?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Value to emit when the toggle is in the "on" state for digital actions
|
|
26
|
-
* If undefined, will emit boolean true
|
|
27
|
-
* Ignored for analog actions
|
|
28
|
-
*/
|
|
29
|
-
onValue?: boolean | number;
|
|
30
|
-
/**
|
|
31
|
-
* Value to emit when the toggle is in the "off" state for digital actions
|
|
32
|
-
* If undefined, will emit boolean false
|
|
33
|
-
* Ignored for analog actions
|
|
34
|
-
*/
|
|
35
|
-
offValue?: boolean | number;
|
|
36
|
-
/**
|
|
37
|
-
* Optional context name this binding belongs to
|
|
38
|
-
*/
|
|
39
|
-
context?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Implementation of a toggle binding, which maintains and toggles state between true/false
|
|
43
|
-
* when a button/key is pressed or released, remaining in that state until toggled again.
|
|
44
|
-
* Can handle both digital and analog inputs with configurable threshold.
|
|
45
|
-
* Can output either digital or analog values based on the action type.
|
|
46
|
-
*/
|
|
47
|
-
export declare class ToggleBinding implements Binding {
|
|
48
|
-
readonly type: "toggle";
|
|
49
|
-
readonly action: Action;
|
|
50
|
-
readonly context?: string;
|
|
51
|
-
readonly deviceID: string;
|
|
52
|
-
readonly deviceType: DeviceType;
|
|
53
|
-
readonly reader: DeviceValueReader;
|
|
54
|
-
private readonly _invert;
|
|
55
|
-
private readonly _threshold;
|
|
56
|
-
private readonly _initialState;
|
|
57
|
-
private readonly _onValue;
|
|
58
|
-
private readonly _offValue;
|
|
59
|
-
private _lastDigitalState;
|
|
60
|
-
private _toggleState;
|
|
61
|
-
/**
|
|
62
|
-
* Get the current toggle state (true = on, false = off)
|
|
63
|
-
*/
|
|
64
|
-
get state(): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Set the toggle state directly (useful for programmatic control)
|
|
67
|
-
*/
|
|
68
|
-
set state(value: boolean);
|
|
69
|
-
/**
|
|
70
|
-
* Get the value emitted when toggle is in the "on" state
|
|
71
|
-
*/
|
|
72
|
-
get onValue(): boolean | number;
|
|
73
|
-
/**
|
|
74
|
-
* Get the value emitted when toggle is in the "off" state
|
|
75
|
-
*/
|
|
76
|
-
get offValue(): boolean | number;
|
|
77
|
-
/**
|
|
78
|
-
* Get the current value based on toggle state.
|
|
79
|
-
* For analog actions, returns min/max value. For digital, returns on/off value.
|
|
80
|
-
*/
|
|
81
|
-
get value(): boolean | number;
|
|
82
|
-
/**
|
|
83
|
-
* Get the current options for this toggle binding.
|
|
84
|
-
*/
|
|
85
|
-
get options(): ToggleBindingOptions;
|
|
86
|
-
/**
|
|
87
|
-
* Create a new toggle binding
|
|
88
|
-
*
|
|
89
|
-
* @param action
|
|
90
|
-
* @param deviceID
|
|
91
|
-
* @param deviceType
|
|
92
|
-
* @param reader
|
|
93
|
-
* @param options
|
|
94
|
-
*/
|
|
95
|
-
constructor(action: Action, deviceID: string, deviceType: DeviceType, reader: DeviceValueReader, options?: ToggleBindingOptions);
|
|
96
|
-
/**
|
|
97
|
-
* Process input state and emit an action event if the toggle flipped.
|
|
98
|
-
*
|
|
99
|
-
* @param state
|
|
100
|
-
* @param eventBus
|
|
101
|
-
*/
|
|
102
|
-
process(state: InputState, eventBus: GameEventBus): void;
|
|
103
|
-
/**
|
|
104
|
-
* Reset edge-detection state for a context activation. When a state is provided, primes from the current physical
|
|
105
|
-
* input so that already-held inputs don't produce phantom edges in the newly activated context.
|
|
106
|
-
*/
|
|
107
|
-
resetEdgeState(state?: InputState): void;
|
|
108
|
-
/**
|
|
109
|
-
* Reset toggle to its initial state
|
|
110
|
-
*/
|
|
111
|
-
reset(): void;
|
|
112
|
-
/**
|
|
113
|
-
* Returns a JSON-serializable representation of this toggle binding.
|
|
114
|
-
*/
|
|
115
|
-
toJSON(): ToggleBindingDefinition;
|
|
116
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { GameEventBus } from "../eventBus.d.ts";
|
|
2
|
-
import { Action } from "../../interfaces/action.d.ts";
|
|
3
|
-
import { Binding, TriggerBindingDefinition } from "../../interfaces/binding.d.ts";
|
|
4
|
-
import { DeviceType, DeviceValueReader, InputState } from "../../interfaces/input.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* All supported edge modes for validation
|
|
7
|
-
*/
|
|
8
|
-
export declare const edgeModes: readonly ["rising", "falling", "both"];
|
|
9
|
-
/**
|
|
10
|
-
* Defines when a trigger binding will fire based on input state changes
|
|
11
|
-
*/
|
|
12
|
-
export type EdgeMode = typeof edgeModes[number];
|
|
13
|
-
/**
|
|
14
|
-
* Options for configuring a trigger binding
|
|
15
|
-
*/
|
|
16
|
-
export interface TriggerBindingOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Which edge(s) should cause the trigger to fire
|
|
19
|
-
* - 'rising': Only trigger on false -> true transitions
|
|
20
|
-
* - 'falling': Only trigger on true -> false transitions
|
|
21
|
-
* - 'both': Trigger on any state change
|
|
22
|
-
*/
|
|
23
|
-
edgeMode?: EdgeMode;
|
|
24
|
-
/**
|
|
25
|
-
* Threshold for analog inputs (0.0 to 1.0)
|
|
26
|
-
* When input value is >= threshold, it's considered "active" (true)
|
|
27
|
-
* When input value is < threshold, it's considered "inactive" (false)
|
|
28
|
-
* Defaults to 0.5 for analog inputs
|
|
29
|
-
*/
|
|
30
|
-
threshold?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Optional context name this binding belongs to
|
|
33
|
-
*/
|
|
34
|
-
context?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Implementation of a trigger binding, which emits an action when a button/key is pressed or released.
|
|
38
|
-
* Can handle both digital and analog inputs with configurable threshold.
|
|
39
|
-
* Can output either digital or analog values based on the action type.
|
|
40
|
-
*/
|
|
41
|
-
export declare class TriggerBinding implements Binding {
|
|
42
|
-
readonly type: "trigger";
|
|
43
|
-
readonly action: Action;
|
|
44
|
-
readonly context?: string;
|
|
45
|
-
readonly deviceID: string;
|
|
46
|
-
readonly deviceType: DeviceType;
|
|
47
|
-
readonly reader: DeviceValueReader;
|
|
48
|
-
private readonly _edgeMode;
|
|
49
|
-
private readonly _threshold;
|
|
50
|
-
private _lastDigitalState;
|
|
51
|
-
/**
|
|
52
|
-
* Get the current options for this trigger binding.
|
|
53
|
-
*/
|
|
54
|
-
get options(): TriggerBindingOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Create a new trigger binding
|
|
57
|
-
*
|
|
58
|
-
* @param action
|
|
59
|
-
* @param deviceID
|
|
60
|
-
* @param deviceType
|
|
61
|
-
* @param reader
|
|
62
|
-
* @param options
|
|
63
|
-
*/
|
|
64
|
-
constructor(action: Action, deviceID: string, deviceType: DeviceType, reader: DeviceValueReader, options?: TriggerBindingOptions);
|
|
65
|
-
/**
|
|
66
|
-
* Process input state and emit an action event on the configured edge transition(s).
|
|
67
|
-
*
|
|
68
|
-
* @param state
|
|
69
|
-
* @param eventBus
|
|
70
|
-
*/
|
|
71
|
-
process(state: InputState, eventBus: GameEventBus): void;
|
|
72
|
-
/**
|
|
73
|
-
* Reset edge-detection state for a context activation. When a state is provided, primes from the current physical
|
|
74
|
-
* input so that already-held inputs don't produce phantom rising edges in the newly activated context.
|
|
75
|
-
*/
|
|
76
|
-
resetEdgeState(state?: InputState): void;
|
|
77
|
-
/**
|
|
78
|
-
* Returns a JSON-serializable representation of this trigger binding.
|
|
79
|
-
*/
|
|
80
|
-
toJSON(): TriggerBindingDefinition;
|
|
81
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { GameEventBus } from "../eventBus.d.ts";
|
|
2
|
-
import { Action } from "../../interfaces/action.d.ts";
|
|
3
|
-
import { Binding, ValueBindingDefinition } from "../../interfaces/binding.d.ts";
|
|
4
|
-
import { DeviceType, DeviceValueReader, InputState } from "../../interfaces/input.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Options for configuring a value binding
|
|
7
|
-
*/
|
|
8
|
-
export interface ValueBindingOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Factor to scale the input value by (1.0 = no scaling)
|
|
11
|
-
*/
|
|
12
|
-
scale?: number;
|
|
13
|
-
/**
|
|
14
|
-
* Value to add to the input value after scaling
|
|
15
|
-
*/
|
|
16
|
-
offset?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to invert the input value (multiply by -1)
|
|
19
|
-
*/
|
|
20
|
-
invert?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Optional context name this binding belongs to
|
|
23
|
-
*/
|
|
24
|
-
context?: string;
|
|
25
|
-
/**
|
|
26
|
-
* If true, only emit values when they change
|
|
27
|
-
* If false, always emit values on each process call
|
|
28
|
-
*/
|
|
29
|
-
emitOnChange?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Deadzone threshold (0.0 to 1.0)
|
|
32
|
-
* Input values below this threshold will be treated as 0
|
|
33
|
-
*/
|
|
34
|
-
deadzone?: number;
|
|
35
|
-
/**
|
|
36
|
-
* Value to emit when the input is digital and true
|
|
37
|
-
* Only used when action is digital
|
|
38
|
-
*/
|
|
39
|
-
onValue?: boolean | number;
|
|
40
|
-
/**
|
|
41
|
-
* Value to emit when the input is digital and false
|
|
42
|
-
* Only used when action is digital
|
|
43
|
-
*/
|
|
44
|
-
offValue?: boolean | number;
|
|
45
|
-
/**
|
|
46
|
-
* Minimum value to clamp output to
|
|
47
|
-
*/
|
|
48
|
-
min?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Maximum value to clamp output to
|
|
51
|
-
*/
|
|
52
|
-
max?: number;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Implementation of a value binding, which directly converts an analog input
|
|
56
|
-
* to an analog output with optional scaling, offset, and clamping.
|
|
57
|
-
* Can handle both digital and analog inputs/outputs based on action type.
|
|
58
|
-
*/
|
|
59
|
-
export declare class ValueBinding implements Binding {
|
|
60
|
-
readonly type: "value";
|
|
61
|
-
readonly action: Action;
|
|
62
|
-
readonly context?: string;
|
|
63
|
-
readonly deviceID: string;
|
|
64
|
-
readonly deviceType: DeviceType;
|
|
65
|
-
readonly reader: DeviceValueReader;
|
|
66
|
-
private readonly _scale;
|
|
67
|
-
private readonly _offset;
|
|
68
|
-
private readonly _invert;
|
|
69
|
-
private readonly _emitOnChange;
|
|
70
|
-
private readonly _deadzone;
|
|
71
|
-
private readonly _onValue;
|
|
72
|
-
private readonly _offValue;
|
|
73
|
-
private readonly _min;
|
|
74
|
-
private readonly _max;
|
|
75
|
-
private _lastValue;
|
|
76
|
-
/**
|
|
77
|
-
* Get the current options for this value binding.
|
|
78
|
-
*/
|
|
79
|
-
get options(): ValueBindingOptions;
|
|
80
|
-
/**
|
|
81
|
-
* Create a new value binding
|
|
82
|
-
*
|
|
83
|
-
* @param action
|
|
84
|
-
* @param deviceID
|
|
85
|
-
* @param reader
|
|
86
|
-
* @param options
|
|
87
|
-
*/
|
|
88
|
-
constructor(action: Action, deviceID: string, deviceType: DeviceType, reader: DeviceValueReader, options?: ValueBindingOptions);
|
|
89
|
-
/**
|
|
90
|
-
* Process input state, apply scaling/deadzone/clamping, and emit an action event if the value changed.
|
|
91
|
-
*
|
|
92
|
-
* @param state
|
|
93
|
-
* @param eventBus
|
|
94
|
-
*/
|
|
95
|
-
process(state: InputState, eventBus: GameEventBus): void;
|
|
96
|
-
/**
|
|
97
|
-
* No-op for value bindings — they have no edge-detection state to reset.
|
|
98
|
-
*/
|
|
99
|
-
resetEdgeState(_state?: InputState): void;
|
|
100
|
-
/**
|
|
101
|
-
* Returns a JSON-serializable representation of this value binding.
|
|
102
|
-
*/
|
|
103
|
-
toJSON(): ValueBindingDefinition;
|
|
104
|
-
}
|