@typeonce/ritmo-math 0.9.0 → 0.11.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 +193 -0
- package/README.md +2 -4
- package/dist/Aabb.d.ts +2 -1
- package/dist/Aabb.d.ts.map +1 -1
- package/dist/Aabb.js.map +1 -1
- package/dist/InputAxis.d.ts +5 -2
- package/dist/InputAxis.d.ts.map +1 -1
- package/dist/InputAxis.js +9 -3
- package/dist/InputAxis.js.map +1 -1
- package/dist/Random.d.ts +1 -1
- package/dist/Scalar.d.ts +10 -6
- package/dist/Scalar.d.ts.map +1 -1
- package/dist/Scalar.js +6 -3
- package/dist/Scalar.js.map +1 -1
- package/dist/Vector2.d.ts +2 -1
- package/dist/Vector2.d.ts.map +1 -1
- package/dist/Vector2.js.map +1 -1
- package/package.json +3 -2
- package/src/Aabb.ts +2 -1
- package/src/InputAxis.ts +9 -3
- package/src/Random.ts +1 -1
- package/src/Scalar.ts +10 -6
- package/src/Vector2.ts +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @typeonce/ritmo-math
|
|
2
|
+
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e46f284: **Documentation pass over every public module.** Every export has JSDoc saying what it is for and which neighbouring API to use instead; examples that no longer compiled (`Session.make` without `hostClock`, `Replay.session`, the `Pointer` rebind) are fixed; `Debug.Lint` lists every lint code the runtime emits. The `stale-target` lint's fix now names `queries.x.getHandle(handle)`.
|
|
8
|
+
- Updated dependencies [778301a]
|
|
9
|
+
- Updated dependencies [866bcff]
|
|
10
|
+
- Updated dependencies [e46f284]
|
|
11
|
+
- @typeonce/ritmo@0.11.0
|
|
12
|
+
|
|
13
|
+
## 0.10.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 7002f4d: **Everything a game's agent needs now ships with the packages, and `ritmo-devtools lint` reports simulation modules the lint rules miss.**
|
|
18
|
+
|
|
19
|
+
- **Breaking: `ritmo-devtools lint` fails on an uncovered simulation module.** Every module the entry loads that the `ritmo/keep-simulation-headless` override in `.oxlintrc.json` does not cover is reported as `uncovered-simulation-module`, and the command exits 1. Add the module (or its folder) to the simulation override's `"files"`, or stop importing values from it. Modules loaded only inside `lintTarget` are not checked. Requires Node 22.15 or newer (`engines.node` is now `>=22.15`).
|
|
20
|
+
- **An agent skill ships with `@typeonce/ritmo`** in `skills/ritmo/SKILL.md`, for every change: where the docs are, and principles for where a game's code and state belong. Link it into the folder the game's agent reads skills from, for example `ln -s ../../node_modules/@typeonce/ritmo/skills/ritmo .agents/skills/ritmo`. `SETUP.md` in `@typeonce/ritmo` is the one-time setup: the base packages and checks every game uses, the add-ons, and linking the skill.
|
|
21
|
+
- **Every package ships its `CHANGELOG.md`.** The upgrade notes for 0.8.0 and 0.9.0 are in the `@typeonce/ritmo` changelog.
|
|
22
|
+
- **JSDoc corrections.** Examples no longer provide randomness or time as services (use the `Random` resource and `Clock`), the `Command` module example declares its commands, inspector docs state that `added`/`changed` reads report records since the inspector's previous evaluation, and every example uses prefixed names (`"Game/Position"`). Guidance that lived only in the repository's guides (spawn order, `ReadonlyValue` helpers, re-entering a state, `thisTick` and plugin systems, service effects and rollback) is now in the JSDoc.
|
|
23
|
+
- Package READMEs link other packages' READMEs by GitHub URL, so the links work on npm.
|
|
24
|
+
|
|
25
|
+
- 388a696: **The Ritmo skill routes each change to a playbook, and simulation code names no renderer type.**
|
|
26
|
+
|
|
27
|
+
- **Breaking: `ritmo/keep-simulation-headless` reports type-only renderer imports** (`import type { Container } from "pixi.js"`, `export type ... from "three"`) and subpath imports of `@typeonce/ritmo-render` and `@typeonce/ritmo-pixi`. A schema that names a renderer type ties the simulation to that renderer. Move the renderer service (a `Descriptor.Service<NodeRegistry.NodeRegistry<Sprite>>()(...)`) and the systems that use it into render code; services are not registered in the schema, so nothing else changes:
|
|
28
|
+
|
|
29
|
+
```diff
|
|
30
|
+
-// src/game/schema.ts
|
|
31
|
+
-import type { Sprite } from "pixi.js"
|
|
32
|
+
-export const Sprites = Descriptor.Service<NodeRegistry.NodeRegistry<Sprite>>()("Game/Sprites")
|
|
33
|
+
+// src/render/sprites.ts
|
|
34
|
+
+import type { Sprite } from "pixi.js"
|
|
35
|
+
+export const Sprites = Descriptor.Service<NodeRegistry.NodeRegistry<Sprite>>()("Game/Sprites")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **The skill in `skills/ritmo` now has playbooks**: one per kind of change (a mechanic, content, UI and rendering, a bug fix, a refactor, state and upgrades), each a short list of steps that ends with the check that proves it. `SKILL.md` routes to them and keeps the principles. A game that already links the skill folder gets them on upgrade.
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [7002f4d]
|
|
41
|
+
- Updated dependencies [388a696]
|
|
42
|
+
- @typeonce/ritmo@0.10.0
|
|
43
|
+
|
|
44
|
+
## 0.9.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- 003b902: **`Ops` covers every `Math` function engines approximate.** New: `Ops.expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `sinh`, `cosh`, `asinh`, `acosh`, and `atanh`, each a pure-JavaScript fdlibm port that returns the same bits on every engine and CPU (checked on V8 for macOS arm64, Linux x64, and Linux arm64, and on JavaScriptCore), within 1 ulp of the exact value. Simulation code no longer needs any `Math` function except the exact ones (`sqrt`, `abs`, `min`, `max`, `floor`, `ceil`, `round`, `trunc`, `sign`).
|
|
49
|
+
- 6cd9771: **`Ops`: math that returns the same bits on every engine.**
|
|
50
|
+
|
|
51
|
+
JavaScript engines may approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `tanh`, `pow`, `hypot`, and `a ** b`, and they do: V8 on macOS arm64 and on Linux x64, and JavaScriptCore (Safari, every iOS browser), return different last bits, and a simulation grows that bit into a different run. `Ops` from `@typeonce/ritmo-math` has the same functions as pure-JavaScript ports of fdlibm (musl libm), built only from operations every engine rounds exactly, so a run replays bit for bit on any device. Each is within 1 ulp of the exact value (`tanh` within 2, like the native one); `Ops.hypot` takes exactly two numbers and never overflows.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Ops } from "@typeonce/ritmo-math";
|
|
55
|
+
|
|
56
|
+
const heading = Ops.atan2(dy, dx);
|
|
57
|
+
const step = { x: Ops.cos(heading) * speed, y: Ops.sin(heading) * speed };
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use `Ops` in simulation code instead of those `Math` functions; `Math.abs`, `min`, `max`, `floor`, `ceil`, `round`, `trunc`, `sign`, `sqrt`, `+ - * /`, and `x ** 2` are already exact everywhere.
|
|
61
|
+
|
|
62
|
+
`Vec2.rotate`, `length`, `distance`, `normalizeOr`, `moveToward`, `clampLength`, `Collide2` corner normals, and `FlowField.way` now use `Ops`. Their results can differ from the previous version in the last bit, so a replay recorded on an earlier version may diverge. `Touch` (browser) measures stick and aim offsets with `Math.sqrt(x * x + y * y)` instead of `Math.hypot`, for the same reason.
|
|
63
|
+
|
|
64
|
+
- 886ba39: **Support package fixes from a second review.**
|
|
65
|
+
|
|
66
|
+
- **Random state in a resource.** `Random` is now a validator for its own state (`Descriptor.ConstructedResource(Random)("Game/Rng")`, saved and checked like any constructed resource), `Random.seed(n)` is its starting value, and `Random.draw(resources.rng)` gives a generator over the system's write cell that writes every draw back, so a system no longer stores the state by hand and a failed run rolls its draws back. `Random.make(state)` stays for state kept outside the world.
|
|
67
|
+
- **Preconditions are checked.** `Random.integer` throws unless both bounds are whole with `min < maxExclusive` (it drew outside both bounds), and `Random.range` throws when `min > max` or a bound is not finite (equal bounds still return `min`). `SpatialGrid.insert` / `forEachIn` throw on non-finite numbers (an infinite box never returned), and a box covering more cells than are occupied scans the occupied cells. `Random.weighted` calls `weight` once per item.
|
|
68
|
+
- **Input edges.** `Touch`: a `pointerdown` for a pointer id still held (its up was lost) cancels what that id held first, instead of leaving a button held until blur. `Keyboard.scripted`: pressing an action that is already held is not a new press, as with a live keyboard.
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- 9cca78b: **One shape for `Runtime.make`, and runtime guards from a review of 0.8.0.** See Upgrading under 0.9.0 in the `@typeonce/ritmo` CHANGELOG.md.
|
|
73
|
+
|
|
74
|
+
- **Breaking: `Runtime.make` always returns a `Result`.** It returned the bare runtime or a `Result` depending on the resource values present at runtime, while its type decided from the keys of the provided type, so resources typed `{ Score?: ... }` produced a bare runtime the type called a `Result`. The type is now `Success<Runtime>` when nothing provided can fail (read `.value`), and a `Result` to check when a constructed resource may be provided.
|
|
75
|
+
- **`thisTick` checks a writer that shares its reader's display name.** Systems may share a display name; the static check skipped any writer named like the reader. It now tells the reader apart by its system type.
|
|
76
|
+
- **New lint `next-state-replaced`** (warning, debug runtimes): a next state one system queued and another replaced with a different value before the same `applyStateTransitions(...)`, naming both. Observed lints (this one and `requirement-violated`) no longer need `nameSchedules` to appear. `Debug.NextStateReplacement` describes an entry.
|
|
77
|
+
- **A query match used after its run throws a named error.** Reading through a match kept past its run (in `local`) returned the internal absent marker once the entity was despawned, and writing put a removed component back without the insert path.
|
|
78
|
+
- **A query descriptor that behaves unlike the registered one throws**: a look-alike (same kind and name) that adds or drops entity-state transitions, a constructor, immutability, or transience. Look-alikes that behave the same keep working.
|
|
79
|
+
- `Scalar.Finite` and the `Vector2` / `Scalar` arithmetic helpers document that results keep the brand without re-validating, finite while they stay within `±Number.MAX_VALUE`.
|
|
80
|
+
|
|
81
|
+
- d47a4f9: **Runtime fixes from a review of 0.8.0.** No API changes; each fix restores what the docs already promised.
|
|
82
|
+
|
|
83
|
+
- **Sub-states enter with their parent.** A sub-state now gets its entry value at the parent's commit, before any `onEnter` schedule runs. A failing `onEnter` of the parent no longer leaves it without a value (`inState` false and `set` failing with `SubStateInactive` until the parent came back), and its `despawnOnEnter` scopes no longer despawn what the parent's `onEnter` just spawned. The `onEnter` schedules still run parents first.
|
|
84
|
+
- **A queued transition survives a transition schedule setting the same machine.** A value queued before `applyStateTransitions(...)` is committed there even when an `onEnter` / `onExit` of an earlier machine also calls `set` on it; that newer value waits for the next marker.
|
|
85
|
+
- **`snapshot` and `restore` throw while a schedule is running**, like `send`. A restore from a system let its queued spawns overwrite restored entities, and a snapshot captured writes a failing system then rolled back. `tryTick` now sets the same guard, so `send` inside `tryTick` throws too.
|
|
86
|
+
- **`restore` rejects an unknown scope name** with the new `UnknownScope` error, instead of putting entities in a scope nothing can name.
|
|
87
|
+
- **`describe()` counts reads inside `Query.anyOf`**, so `component-never-read` no longer fires for a component read only through `anyOf`, and `read-before-write` sees it. A system placed directly and under `Schedule.when` / `pauseWhen` is one entry with both placements and the conditions of each.
|
|
88
|
+
- **`Collide2` stops a circle that starts exactly touching a wall** and moves into it, instead of moving it through the wall: `sweepCircleBox` / `sweepCircleBoxes` now report a hit at time 0, and `moveCircle` blocks. This happens whenever a game places a body exactly at a wall without a skin (a snapped spawn point, or a projectile set to a sweep's contact point). Moving away from the wall or sliding along it is unchanged. A game that fingerprints its simulation will see fights that touched a wall this way play differently: re-record the fingerprints with the upgrade.
|
|
89
|
+
- **Replays carry input into their window.** A replay saved after unchanged input (holding a direction longer than `keep`) had no input on its first ticks and handed systems `undefined` when played.
|
|
90
|
+
- **`Session.run` stops with `invariant-threw`** when an invariant throws, naming the invariant and the error, instead of throwing out of `run` and losing the run's text.
|
|
91
|
+
- The `Snapshot` docs now say that unread `runtime.send` events survive a restore, as they always did.
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [c2c32e0]
|
|
94
|
+
- Updated dependencies [9cca78b]
|
|
95
|
+
- Updated dependencies [6c09482]
|
|
96
|
+
- Updated dependencies [ecfd0f1]
|
|
97
|
+
- Updated dependencies [d47a4f9]
|
|
98
|
+
- Updated dependencies [330246e]
|
|
99
|
+
- Updated dependencies [7f2b2dd]
|
|
100
|
+
- @typeonce/ritmo@0.9.0
|
|
101
|
+
|
|
102
|
+
## 0.8.0
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- Updated dependencies [0b22113]
|
|
107
|
+
- Updated dependencies [a0fac0a]
|
|
108
|
+
- Updated dependencies [0b22113]
|
|
109
|
+
- Updated dependencies [a0fac0a]
|
|
110
|
+
- Updated dependencies [a580c9c]
|
|
111
|
+
- Updated dependencies [a580c9c]
|
|
112
|
+
- @typeonce/ritmo@0.8.0
|
|
113
|
+
|
|
114
|
+
## 0.7.0
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- 358401a: Link the bevy-ts migration guide from each published package README.
|
|
119
|
+
- Updated dependencies [84eac37]
|
|
120
|
+
- Updated dependencies [7ebd9af]
|
|
121
|
+
- Updated dependencies [358401a]
|
|
122
|
+
- @typeonce/ritmo@0.7.0
|
|
123
|
+
|
|
124
|
+
## 0.6.0
|
|
125
|
+
|
|
126
|
+
### Minor Changes
|
|
127
|
+
|
|
128
|
+
- 130cb6e: Rename the package family from `@typeonce/bevy-ts*` to `@typeonce/ritmo*`.
|
|
129
|
+
Update imports, workspace dependencies, type identity markers, examples, and
|
|
130
|
+
documentation together. There are no compatibility aliases; use the matching
|
|
131
|
+
Ritmo package for each previous Bevy TS package. The separate release preparation
|
|
132
|
+
change coordinates the repository rename and retirement of the generated
|
|
133
|
+
documentation site.
|
|
134
|
+
Use "The agent-first type safe ECS runtime" in package metadata,
|
|
135
|
+
documentation, and brand assets.
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- c20bbc0: Document line of sight with `Collide2.sweepCircleBoxes` and a radius of 0.
|
|
140
|
+
- a8e0473: Retire the generated documentation site and point package homepages, source links,
|
|
141
|
+
and issue links to the Ritmo repository in the Typeonce GitHub organization.
|
|
142
|
+
Keep source JSDoc and repository guides, including the Pixi walkthrough in its
|
|
143
|
+
example README.
|
|
144
|
+
- Updated dependencies [a8e0473]
|
|
145
|
+
- Updated dependencies [130cb6e]
|
|
146
|
+
- Updated dependencies [a1f18a8]
|
|
147
|
+
- @typeonce/ritmo@0.6.0
|
|
148
|
+
|
|
149
|
+
## 0.5.0
|
|
150
|
+
|
|
151
|
+
### Minor Changes
|
|
152
|
+
|
|
153
|
+
- c5bd6d3: Add hot-path game helpers, lifted from a shipped top-down game: `Vec2` plain vector arithmetic (accepts validated `Vector2` values), `Box2` edge boxes, `Collide2` swept circle collision with sliding (no tunneling through thin walls, rounded corners), a `SpatialGrid` broad phase that allocates nothing per step, a `FlowField` that leads bodies around walls with clearance, and a deterministic `Random` whose whole state is one integer.
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- @typeonce/bevy-ts@0.5.0
|
|
158
|
+
|
|
159
|
+
## 0.4.0
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- Updated dependencies [e2b2275]
|
|
164
|
+
- @typeonce/bevy-ts@0.4.0
|
|
165
|
+
|
|
166
|
+
## 0.3.0
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- Updated dependencies [2b0fb7e]
|
|
171
|
+
- Updated dependencies [c4d1add]
|
|
172
|
+
- Updated dependencies [bd9bdd5]
|
|
173
|
+
- Updated dependencies [bd9bdd5]
|
|
174
|
+
- Updated dependencies [94bdc32]
|
|
175
|
+
- Updated dependencies [bd9bdd5]
|
|
176
|
+
- @typeonce/bevy-ts@0.3.0
|
|
177
|
+
|
|
178
|
+
## 0.2.0
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Updated dependencies [4b3a312]
|
|
183
|
+
- Updated dependencies [4b3a312]
|
|
184
|
+
- Updated dependencies [4b3a312]
|
|
185
|
+
- @typeonce/bevy-ts@0.2.0
|
|
186
|
+
|
|
187
|
+
## 0.1.1
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- c95a102: First release published from CI through npm trusted publishing, with provenance attestations. Declarations are now verified against consumers on both TypeScript 7 and TypeScript 6. No API or output changes.
|
|
192
|
+
- Updated dependencies [c95a102]
|
|
193
|
+
- @typeonce/bevy-ts@0.1.1
|
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# `@typeonce/ritmo-math`
|
|
2
2
|
|
|
3
|
-
Migrating from bevy-ts? See the [package migration guide](https://github.com/typeonce-dev/ritmo/blob/main/MIGRATION.md).
|
|
4
|
-
|
|
5
3
|
Math for ritmo games, in two kinds:
|
|
6
4
|
|
|
7
5
|
- **Validated values**: `Scalar`, `Vector2`, `Size2`, `Aabb`, and `InputAxis`. Every one exports constructors that validate untrusted input, so they work as `Descriptor.ConstructedComponent(...)` constructors and survive snapshot restore.
|
|
@@ -23,7 +21,7 @@ pnpm add @typeonce/ritmo-math @typeonce/ritmo
|
|
|
23
21
|
|
|
24
22
|
## Determinism across devices
|
|
25
23
|
|
|
26
|
-
JavaScript engines may approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `pow`, `hypot`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `a ** b`, and they do: Chrome, Safari, macOS, and Linux disagree in the last bit, and a simulation grows that bit into a different run, so a session recorded on a phone stops replaying on a server. `Ops` has the same functions as pure-JavaScript ports of fdlibm, built only from operations every engine rounds exactly, so they return the same bits everywhere (within an ulp of the exact value). Use them in simulation code; `Math.abs`, `min`, `max`, `floor`, `ceil`, `round`, `trunc`, `sign`, `sqrt`, `+ - * /`, and `x ** 2` are already exact. `Vec2`, `Collide2`, and `FlowField` use `Ops` themselves, and the `ritmo/use-ops-for-math` rule of [`@typeonce/oxlint-plugin-ritmo`](
|
|
24
|
+
JavaScript engines may approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `pow`, `hypot`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `a ** b`, and they do: Chrome, Safari, macOS, and Linux disagree in the last bit, and a simulation grows that bit into a different run, so a session recorded on a phone stops replaying on a server. `Ops` has the same functions as pure-JavaScript ports of fdlibm, built only from operations every engine rounds exactly, so they return the same bits everywhere (within an ulp of the exact value). Use them in simulation code; `Math.abs`, `min`, `max`, `floor`, `ceil`, `round`, `trunc`, `sign`, `sqrt`, `+ - * /`, and `x ** 2` are already exact. `Vec2`, `Collide2`, and `FlowField` use `Ops` themselves, and the `ritmo/use-ops-for-math` rule of [`@typeonce/oxlint-plugin-ritmo`](https://github.com/typeonce-dev/ritmo/blob/main/packages/oxlint-plugin/README.md) reports the `Math` calls left in simulation code.
|
|
27
25
|
|
|
28
26
|
```ts
|
|
29
27
|
import { Ops } from "@typeonce/ritmo-math"
|
|
@@ -33,6 +31,6 @@ const velocity = { x: Ops.cos(heading) * speed, y: Ops.sin(heading) * speed }
|
|
|
33
31
|
const damping = Ops.exp(-friction * dt)
|
|
34
32
|
```
|
|
35
33
|
|
|
36
|
-
Released together with [`@typeonce/ritmo`](https://
|
|
34
|
+
Released together with [`@typeonce/ritmo`](https://github.com/typeonce-dev/ritmo/blob/main/packages/core/README.md), always with the same version.
|
|
37
35
|
|
|
38
36
|
Source: https://github.com/typeonce-dev/ritmo
|
package/dist/Aabb.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* In game code this is the natural helper for collision volumes, trigger
|
|
9
9
|
* regions, camera bounds, and spatial authored data that should stay validated
|
|
10
|
-
* and immutable after construction.
|
|
10
|
+
* and immutable after construction. For the per-frame collision tests of
|
|
11
|
+
* `Collide2` and `FlowField`, build a plain `Box2` (edge form) from it once.
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```ts
|
package/dist/Aabb.d.ts.map
CHANGED
|
@@ -1 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AACpE;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,OAA6B,CAAA;AACrF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,OAAuC,CAAA;AACzG;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,OAAqC,CAAA;AACrG;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,KAAK,IAAyB,CAAA"}
|
package/dist/Aabb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Aabb.js","sourceRoot":"","sources":["../src/Aabb.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Aabb.js","sourceRoot":"","sources":["../src/Aabb.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AA6C9C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAA6C,QAAQ,CAAC,MAAM,CAAA;AAC/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAA+D,QAAQ,CAAC,MAAM,CAAA;AACjG;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAA8B,QAAQ,CAAC,MAAM,CAAA;AAChE;;;;GAIG;AACH,MAAM,CAAC,MAAM,EAAE,GAAoC,QAAQ,CAAC,EAAE,CAAA;AAC9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoC,QAAQ,CAAC,QAAQ,CAAA;AAC1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAgC,QAAQ,CAAC,IAAI,CAAA;AAC9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAkC,QAAQ,CAAC,IAAI,CAAA;AAChE;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAkC,QAAQ,CAAC,KAAK,CAAA;AAClE;;;;GAIG;AACH,MAAM,CAAC,MAAM,GAAG,GAAkC,QAAQ,CAAC,GAAG,CAAA;AAC9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAkC,QAAQ,CAAC,MAAM,CAAA;AACpE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAA2C,QAAQ,CAAC,UAAU,CAAA;AACrF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA2C,QAAQ,CAAC,oBAAoB,CAAA;AACzG;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA2C,QAAQ,CAAC,kBAAkB,CAAA;AACrG;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAiD,QAAQ,CAAC,SAAS,CAAA"}
|
package/dist/InputAxis.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export type Axis = -1 | 0 | 1;
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const axis: (negativePressed: boolean, positivePressed: boolean) => Axis;
|
|
14
14
|
/**
|
|
15
|
-
* Builds a normalized movement vector from four directional booleans
|
|
15
|
+
* Builds a normalized movement vector from four directional booleans, in
|
|
16
|
+
* screen coordinates: `up` is negative `y`, `right` positive `x`. Opposite
|
|
17
|
+
* presses cancel, and diagonals have length 1.
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
@@ -33,7 +35,8 @@ export declare const vectorFromAxes: (input: {
|
|
|
33
35
|
readonly down: boolean;
|
|
34
36
|
}) => Vector2.Vector2;
|
|
35
37
|
/**
|
|
36
|
-
* Builds a normalized movement vector from two explicit axis values
|
|
38
|
+
* Builds a normalized movement vector from two explicit axis values
|
|
39
|
+
* (diagonals have length 1).
|
|
37
40
|
*
|
|
38
41
|
* @category Vector Helpers
|
|
39
42
|
*/
|
package/dist/InputAxis.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputAxis.d.ts","sourceRoot":"","sources":["../src/InputAxis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InputAxis.d.ts","sourceRoot":"","sources":["../src/InputAxis.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAA;AAE5C;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAE7B;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,KAAK,IAAoB,CAAA;AAC/F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,EAAE,CAC3B,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,KACrG,OAAO,CAAC,OAAiC,CAAA;AAC9C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,OAAO,CAAC,OAAuC,CAAA"}
|
package/dist/InputAxis.js
CHANGED
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This module is runtime-agnostic: it does not know about keyboard events,
|
|
6
6
|
* gamepads, or host APIs. It only translates already-sampled booleans into the
|
|
7
|
-
* compact movement values
|
|
7
|
+
* compact movement values that systems consume.
|
|
8
8
|
*
|
|
9
9
|
* Reach for it in the gap between host input sampling and ECS simulation:
|
|
10
10
|
* capture raw button state in the host, normalize it here, then write the
|
|
11
11
|
* resulting axes or vectors into resources/components for systems to consume.
|
|
12
|
+
* With `@typeonce/ritmo-browser`, bind movement as a vector action instead
|
|
13
|
+
* (`Keyboard.vector`, `Gamepad.vector`), which already reports the merged
|
|
14
|
+
* vector; use this module for booleans from another source.
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```ts
|
|
@@ -41,7 +44,9 @@ import * as internal from "./internal/inputAxis.js";
|
|
|
41
44
|
*/
|
|
42
45
|
export const axis = internal.axis;
|
|
43
46
|
/**
|
|
44
|
-
* Builds a normalized movement vector from four directional booleans
|
|
47
|
+
* Builds a normalized movement vector from four directional booleans, in
|
|
48
|
+
* screen coordinates: `up` is negative `y`, `right` positive `x`. Opposite
|
|
49
|
+
* presses cancel, and diagonals have length 1.
|
|
45
50
|
*
|
|
46
51
|
* @example
|
|
47
52
|
* ```ts
|
|
@@ -57,7 +62,8 @@ export const axis = internal.axis;
|
|
|
57
62
|
*/
|
|
58
63
|
export const vectorFromAxes = internal.vectorFromAxes;
|
|
59
64
|
/**
|
|
60
|
-
* Builds a normalized movement vector from two explicit axis values
|
|
65
|
+
* Builds a normalized movement vector from two explicit axis values
|
|
66
|
+
* (diagonals have length 1).
|
|
61
67
|
*
|
|
62
68
|
* @category Vector Helpers
|
|
63
69
|
*/
|
package/dist/InputAxis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputAxis.js","sourceRoot":"","sources":["../src/InputAxis.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"InputAxis.js","sourceRoot":"","sources":["../src/InputAxis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AAUnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAiE,QAAQ,CAAC,IAAI,CAAA;AAC/F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,cAAc,GAEJ,QAAQ,CAAC,cAAc,CAAA;AAC9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0D,QAAQ,CAAC,oBAAoB,CAAA"}
|
package/dist/Random.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* const Rng = Descriptor.ConstructedResource(Random)("Game/Rng")
|
|
15
15
|
* const runtime = Game.Runtime.make({ services, resources: { Rng: Random.seed(0x5eed) } })
|
|
16
16
|
*
|
|
17
|
-
* Game.System("Spawn", { resources: { rng: Game.System.writeResource(Rng) } }, ({ resources }) => {
|
|
17
|
+
* Game.System("Game/Spawn", { resources: { rng: Game.System.writeResource(Rng) } }, ({ resources }) => {
|
|
18
18
|
* const random = Random.draw(resources.rng)
|
|
19
19
|
* const angle = random.range(0, Math.PI * 2)
|
|
20
20
|
* const kind = random.pick(kinds) ?? "grunt"
|
package/dist/Scalar.d.ts
CHANGED
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* ```ts
|
|
15
15
|
* // Validate raw numbers before geometry or gameplay code relies on them.
|
|
16
16
|
* const speed = Scalar.Finite.result(12)
|
|
17
|
-
* const
|
|
18
|
-
*
|
|
17
|
+
* const min = Scalar.Finite.result(0)
|
|
18
|
+
* const max = Scalar.Finite.result(8)
|
|
19
|
+
* if (!speed.ok || !min.ok || !max.ok) return
|
|
19
20
|
*
|
|
20
21
|
* // Operate on the branded values after the boundary has been crossed.
|
|
21
|
-
* const clamped = Scalar.clamp(speed.value,
|
|
22
|
+
* const clamped = Scalar.clamp(speed.value, min.value, max.value)
|
|
22
23
|
* ```
|
|
23
24
|
*
|
|
24
25
|
* @module Scalar
|
|
@@ -86,19 +87,22 @@ export type InterpolationError = {
|
|
|
86
87
|
readonly end: number;
|
|
87
88
|
};
|
|
88
89
|
/**
|
|
89
|
-
* Constructor for {@link Finite}
|
|
90
|
+
* Constructor for {@link Finite}: `result` (explicit failure), `option`
|
|
91
|
+
* (`null` on failure), and `is` (a type guard).
|
|
90
92
|
*
|
|
91
93
|
* @category Constructors
|
|
92
94
|
*/
|
|
93
95
|
export declare const Finite: Brand.Constructor<Finite, number, Error>;
|
|
94
96
|
/**
|
|
95
|
-
* Constructor for {@link NonNegative}
|
|
97
|
+
* Constructor for {@link NonNegative}: `result` (explicit failure), `option`
|
|
98
|
+
* (`null` on failure), and `is` (a type guard).
|
|
96
99
|
*
|
|
97
100
|
* @category Constructors
|
|
98
101
|
*/
|
|
99
102
|
export declare const NonNegative: Brand.Constructor<NonNegative, number, Error>;
|
|
100
103
|
/**
|
|
101
|
-
* Constructor for {@link Positive}
|
|
104
|
+
* Constructor for {@link Positive}: `result` (explicit failure), `option`
|
|
105
|
+
* (`null` on failure), and `is` (a type guard).
|
|
102
106
|
*
|
|
103
107
|
* @category Constructors
|
|
104
108
|
*/
|
package/dist/Scalar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scalar.d.ts","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Scalar.d.ts","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,uBAAuB,CAAA;AAEnD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAC3D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;AACrE;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;AAE/D;;;;GAIG;AACH,MAAM,MAAM,KAAK,GACb;IAAE,QAAQ,CAAC,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,CAAwB,CAAA;AACrE;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAkB,CAAA;AAE/D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA"}
|
package/dist/Scalar.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import * as internal from "./internal/scalar.js";
|
|
2
2
|
/**
|
|
3
|
-
* Constructor for {@link Finite}
|
|
3
|
+
* Constructor for {@link Finite}: `result` (explicit failure), `option`
|
|
4
|
+
* (`null` on failure), and `is` (a type guard).
|
|
4
5
|
*
|
|
5
6
|
* @category Constructors
|
|
6
7
|
*/
|
|
7
8
|
export const Finite = internal.Finite;
|
|
8
9
|
/**
|
|
9
|
-
* Constructor for {@link NonNegative}
|
|
10
|
+
* Constructor for {@link NonNegative}: `result` (explicit failure), `option`
|
|
11
|
+
* (`null` on failure), and `is` (a type guard).
|
|
10
12
|
*
|
|
11
13
|
* @category Constructors
|
|
12
14
|
*/
|
|
13
15
|
export const NonNegative = internal.NonNegative;
|
|
14
16
|
/**
|
|
15
|
-
* Constructor for {@link Positive}
|
|
17
|
+
* Constructor for {@link Positive}: `result` (explicit failure), `option`
|
|
18
|
+
* (`null` on failure), and `is` (a type guard).
|
|
16
19
|
*
|
|
17
20
|
* @category Constructors
|
|
18
21
|
*/
|
package/dist/Scalar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scalar.js","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Scalar.js","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAA;AAkDhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;AACrC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAA;AAC/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;AAEzC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAwD,QAAQ,CAAC,KAAK,CAAA;AACxF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAA2D,QAAQ,CAAC,IAAI,CAAA;AACzF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAuE,QAAQ,CAAC,QAAQ,CAAA;AAC7G;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAIyB,QAAQ,CAAC,WAAW,CAAA;AACrE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAM+B,QAAQ,CAAC,KAAK,CAAA"}
|
package/dist/Vector2.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* This is the common math value that game code threads through position,
|
|
8
8
|
* velocity, input direction, camera motion, and collision helpers. Use it when
|
|
9
9
|
* vectors should stay explicitly validated and reusable across ECS and helper
|
|
10
|
-
* modules.
|
|
10
|
+
* modules. For per-frame arithmetic on numbers already known to be sane, use
|
|
11
|
+
* `Vec2` (a `Vector2` is a `Vec2`, so it passes without conversion).
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```ts
|
package/dist/Vector2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../src/Vector2.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../src/Vector2.ts"],"names":[],"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AAM,CAAC,MAAM,KAAK,OAAwB,CAAA;AACxF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,WAAoC,CAAA;AAC5F;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,WAA6B,CAAA;AAC9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAsB,CAAA;AACxG;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAkC,CAAA"}
|
package/dist/Vector2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector2.js","sourceRoot":"","sources":["../src/Vector2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Vector2.js","sourceRoot":"","sources":["../src/Vector2.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AAuDjD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAAgD,QAAQ,CAAC,MAAM,CAAA;AAClF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAkE,QAAQ,CAAC,MAAM,CAAA;AACpG;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAiC,QAAQ,CAAC,MAAM,CAAA;AACnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,EAAE,GAAuC,QAAQ,CAAC,EAAE,CAAA;AACjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAA6B,QAAQ,CAAC,KAAK,CAAA;AAC7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAkF,QAAQ,CAAC,UAAU,CAAA;AAC5H;;;;GAIG;AACH,MAAM,CAAC,MAAM,CAAC,GAAuC,QAAQ,CAAC,CAAC,CAAA;AAC/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,CAAC,GAAuC,QAAQ,CAAC,CAAC,CAAA;AAC/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAkB,QAAQ,CAAC,IAAI,CAAA;AAChD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAA+C,QAAQ,CAAC,GAAG,CAAA;AAC3E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA+C,QAAQ,CAAC,QAAQ,CAAA;AACrF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAwD,QAAQ,CAAC,KAAK,CAAA;AACxF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAA4C,QAAQ,CAAC,aAAa,CAAA;AAC5F;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAA4C,QAAQ,CAAC,MAAM,CAAA;AAC9E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgE,QAAQ,CAAC,SAAS,CAAA;AACxG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiC,QAAQ,CAAC,eAAe,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typeonce/ritmo-math",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Validated math values and hot-path game helpers (collision, spatial grid, flow field, random) for Ritmo games",
|
|
5
5
|
"author": "Sandro Maglione",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"src/**/*.ts",
|
|
27
27
|
"dist",
|
|
28
28
|
"README.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
29
30
|
"LICENSE"
|
|
30
31
|
],
|
|
31
32
|
"exports": {
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"provenance": true
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@typeonce/ritmo": "^0.
|
|
50
|
+
"@typeonce/ritmo": "^0.11.0"
|
|
50
51
|
},
|
|
51
52
|
"engines": {
|
|
52
53
|
"node": ">=20"
|
package/src/Aabb.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* In game code this is the natural helper for collision volumes, trigger
|
|
9
9
|
* regions, camera bounds, and spatial authored data that should stay validated
|
|
10
|
-
* and immutable after construction.
|
|
10
|
+
* and immutable after construction. For the per-frame collision tests of
|
|
11
|
+
* `Collide2` and `FlowField`, build a plain `Box2` (edge form) from it once.
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```ts
|
package/src/InputAxis.ts
CHANGED
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This module is runtime-agnostic: it does not know about keyboard events,
|
|
6
6
|
* gamepads, or host APIs. It only translates already-sampled booleans into the
|
|
7
|
-
* compact movement values
|
|
7
|
+
* compact movement values that systems consume.
|
|
8
8
|
*
|
|
9
9
|
* Reach for it in the gap between host input sampling and ECS simulation:
|
|
10
10
|
* capture raw button state in the host, normalize it here, then write the
|
|
11
11
|
* resulting axes or vectors into resources/components for systems to consume.
|
|
12
|
+
* With `@typeonce/ritmo-browser`, bind movement as a vector action instead
|
|
13
|
+
* (`Keyboard.vector`, `Gamepad.vector`), which already reports the merged
|
|
14
|
+
* vector; use this module for booleans from another source.
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```ts
|
|
@@ -50,7 +53,9 @@ export type Axis = -1 | 0 | 1
|
|
|
50
53
|
*/
|
|
51
54
|
export const axis: (negativePressed: boolean, positivePressed: boolean) => Axis = internal.axis
|
|
52
55
|
/**
|
|
53
|
-
* Builds a normalized movement vector from four directional booleans
|
|
56
|
+
* Builds a normalized movement vector from four directional booleans, in
|
|
57
|
+
* screen coordinates: `up` is negative `y`, `right` positive `x`. Opposite
|
|
58
|
+
* presses cancel, and diagonals have length 1.
|
|
54
59
|
*
|
|
55
60
|
* @example
|
|
56
61
|
* ```ts
|
|
@@ -68,7 +73,8 @@ export const vectorFromAxes: (
|
|
|
68
73
|
input: { readonly left: boolean; readonly right: boolean; readonly up: boolean; readonly down: boolean }
|
|
69
74
|
) => Vector2.Vector2 = internal.vectorFromAxes
|
|
70
75
|
/**
|
|
71
|
-
* Builds a normalized movement vector from two explicit axis values
|
|
76
|
+
* Builds a normalized movement vector from two explicit axis values
|
|
77
|
+
* (diagonals have length 1).
|
|
72
78
|
*
|
|
73
79
|
* @category Vector Helpers
|
|
74
80
|
*/
|
package/src/Random.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* const Rng = Descriptor.ConstructedResource(Random)("Game/Rng")
|
|
15
15
|
* const runtime = Game.Runtime.make({ services, resources: { Rng: Random.seed(0x5eed) } })
|
|
16
16
|
*
|
|
17
|
-
* Game.System("Spawn", { resources: { rng: Game.System.writeResource(Rng) } }, ({ resources }) => {
|
|
17
|
+
* Game.System("Game/Spawn", { resources: { rng: Game.System.writeResource(Rng) } }, ({ resources }) => {
|
|
18
18
|
* const random = Random.draw(resources.rng)
|
|
19
19
|
* const angle = random.range(0, Math.PI * 2)
|
|
20
20
|
* const kind = random.pick(kinds) ?? "grunt"
|
package/src/Scalar.ts
CHANGED
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* ```ts
|
|
15
15
|
* // Validate raw numbers before geometry or gameplay code relies on them.
|
|
16
16
|
* const speed = Scalar.Finite.result(12)
|
|
17
|
-
* const
|
|
18
|
-
*
|
|
17
|
+
* const min = Scalar.Finite.result(0)
|
|
18
|
+
* const max = Scalar.Finite.result(8)
|
|
19
|
+
* if (!speed.ok || !min.ok || !max.ok) return
|
|
19
20
|
*
|
|
20
21
|
* // Operate on the branded values after the boundary has been crossed.
|
|
21
|
-
* const clamped = Scalar.clamp(speed.value,
|
|
22
|
+
* const clamped = Scalar.clamp(speed.value, min.value, max.value)
|
|
22
23
|
* ```
|
|
23
24
|
*
|
|
24
25
|
* @module Scalar
|
|
@@ -85,19 +86,22 @@ export type InterpolationError = {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
|
-
* Constructor for {@link Finite}
|
|
89
|
+
* Constructor for {@link Finite}: `result` (explicit failure), `option`
|
|
90
|
+
* (`null` on failure), and `is` (a type guard).
|
|
89
91
|
*
|
|
90
92
|
* @category Constructors
|
|
91
93
|
*/
|
|
92
94
|
export const Finite = internal.Finite
|
|
93
95
|
/**
|
|
94
|
-
* Constructor for {@link NonNegative}
|
|
96
|
+
* Constructor for {@link NonNegative}: `result` (explicit failure), `option`
|
|
97
|
+
* (`null` on failure), and `is` (a type guard).
|
|
95
98
|
*
|
|
96
99
|
* @category Constructors
|
|
97
100
|
*/
|
|
98
101
|
export const NonNegative = internal.NonNegative
|
|
99
102
|
/**
|
|
100
|
-
* Constructor for {@link Positive}
|
|
103
|
+
* Constructor for {@link Positive}: `result` (explicit failure), `option`
|
|
104
|
+
* (`null` on failure), and `is` (a type guard).
|
|
101
105
|
*
|
|
102
106
|
* @category Constructors
|
|
103
107
|
*/
|
package/src/Vector2.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* This is the common math value that game code threads through position,
|
|
8
8
|
* velocity, input direction, camera motion, and collision helpers. Use it when
|
|
9
9
|
* vectors should stay explicitly validated and reusable across ECS and helper
|
|
10
|
-
* modules.
|
|
10
|
+
* modules. For per-frame arithmetic on numbers already known to be sane, use
|
|
11
|
+
* `Vec2` (a `Vector2` is a `Vec2`, so it passes without conversion).
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```ts
|