@n3rdw1z4rd/core 0.14.1 → 0.15.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/README.md +10 -8
- package/dist/index.css +0 -9
- package/dist/index.d.mts +288 -287
- package/dist/index.d.ts +288 -287
- package/dist/index.js +979 -1098
- package/dist/index.mjs +970 -1091
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,31 +23,32 @@ This package ships both CJS and ESM builds plus `.d.ts` types (built with `tsup`
|
|
|
23
23
|
## Quick start
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import { rng, clamp, log, Clock } from
|
|
26
|
+
import { rng, clamp, log, Clock } from "@n3rdw1z4rd/core";
|
|
27
27
|
|
|
28
28
|
log(rng.range(0, 10)); // random int in [0, 10)
|
|
29
29
|
log(clamp(15, 0, 10)); // 10
|
|
30
30
|
|
|
31
31
|
const clock = new Clock();
|
|
32
|
-
clock.
|
|
32
|
+
clock.on('frame', (dt) => {
|
|
33
33
|
// dt is seconds since last frame
|
|
34
34
|
});
|
|
35
|
+
clock.start();
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
Everything (including the `three/*` modules) is re-exported from the package root, so `import { ThreeJsBoilerPlate } from
|
|
38
|
+
Everything (including the `three/*` modules) is re-exported from the package root, so `import { ThreeJsBoilerPlate } from "@n3rdw1z4rd/core"` works. Import from the `three` subpath if you want to make the Three.js dependency explicit in your own code:
|
|
38
39
|
|
|
39
40
|
```ts
|
|
40
|
-
import { ThreeJsBoilerPlate } from
|
|
41
|
+
import { ThreeJsBoilerPlate } from "@n3rdw1z4rd/core/three";
|
|
41
42
|
```
|
|
42
43
|
|
|
43
44
|
## What's in here
|
|
44
45
|
|
|
45
46
|
| Area | Docs | Summary |
|
|
46
47
|
|---|---|---|
|
|
47
|
-
| Math & RNG | [docs/math-and-rng.md](docs/math-and-rng.md) | Pure-math `sin`/`cos`/`floor`/etc. (no native `Math` calls), a seeded `
|
|
48
|
+
| Math & RNG | [docs/math-and-rng.md](docs/math-and-rng.md) | Pure-math `sin`/`cos`/`floor`/etc. (no native `Math` calls), a seeded `RandomNumberGenerator` class with an exclusive `range()`, gaussian sampling, shuffling. |
|
|
48
49
|
| Events | [docs/events.md](docs/events.md) | `Emitter` (typed on/emit/clear), `EventBus` (DOM `CustomEvent`-based, for cross-module pub/sub without a shared instance). |
|
|
49
50
|
| ECS | [docs/ecs.md](docs/ecs.md) | Two independent designs: a component-template-registry singleton (`ECS.instance`), and an Object3D-based variant under `three/ecs.ts` where components live in `userData`. |
|
|
50
|
-
| Clock, logging, input | [docs/clock-logging-input.md](docs/clock-logging-input.md) | `Clock` (rAF loop + FPS/dt tracking
|
|
51
|
+
| Clock, logging, input | [docs/clock-logging-input.md](docs/clock-logging-input.md) | `Clock` (rAF loop + FPS/dt tracking, emits a `'frame'` event), leveled console loggers, `Input` (keyboard/mouse event normalization). |
|
|
51
52
|
| Noise | [docs/noise.md](docs/noise.md) | `Noise` (2D/3D/4D + fractal/fBm, wraps the `simplex-noise` package), plus a self-contained `SimplexNoise` class. |
|
|
52
53
|
| 2D primitives | [docs/2d-primitives.md](docs/2d-primitives.md) | `Vector`, `Rectangle`, `Map2D`/`Map3D` (sparse coordinate maps), `Tilemap<T>`. |
|
|
53
54
|
| Procedural generation | [docs/procedural-generation.md](docs/procedural-generation.md) | `AStar` pathfinding, `PoissonDiskSampler`, and a full room-based dungeon generator (`GenerateRooms`/`GenerateDoors`/`GenerateWalls`). |
|
|
@@ -57,7 +58,7 @@ import { ThreeJsBoilerPlate } from '@n3rdw1z4rd/core/three';
|
|
|
57
58
|
| Three.js meshes & textures | [docs/threejs-meshes-and-textures.md](docs/threejs-meshes-and-textures.md) | `VoxelMesh` (per-face-culled voxel geometry + palettes), `TextureAtlas`/`AtlasTextureMaterial`, `CubeSphereGeometry`, `AsteroidMesh`, starfield generators. |
|
|
58
59
|
| Three.js widgets | [docs/threejs-widgets.md](docs/threejs-widgets.md) | `CreatePaletteController`, a lil-gui color-swatch widget for picking a palette index. |
|
|
59
60
|
| Networking | [docs/networking.md](docs/networking.md) | `WorkerInterface`, a thin `Emitter`-based wrapper around `Worker`. |
|
|
60
|
-
| Misc | [docs/misc.md](docs/misc.md) | A
|
|
61
|
+
| Misc | [docs/misc.md](docs/misc.md) | A handful of small standalone helpers: `isNullOrUndefined`, `isPositiveString`, `getRedYellowGreenGradientHex`, `GetUrlParams`. |
|
|
61
62
|
|
|
62
63
|
## Design notes worth knowing before you dig in
|
|
63
64
|
|
|
@@ -65,4 +66,5 @@ import { ThreeJsBoilerPlate } from '@n3rdw1z4rd/core/three';
|
|
|
65
66
|
- **Two camera-control approaches, both supported.** `ThreeJsBoilerPlate.enableCameraRigControls()` uses the hand-rolled `ThreeJsCameraRig` (orbit/dolly driven by `Input` events). `enableOrbitControls()` uses Three's own `OrbitControls` instead. They're mutually exclusive - call one or the other, not both.
|
|
66
67
|
- **`rng.range(min, max)` is exclusive of `max`.** If you're carrying over code from an older version of this package (pre-0.12), note this changed from inclusive to exclusive.
|
|
67
68
|
- **No native `Math` calls in `math.ts`.** `sin`/`cos`/`floor`/`ceil`/`round`/`sqrt` etc. are all reimplemented from scratch (Taylor series + quadrant reduction for trig, accurate to ~4.65e-7). Everything else in the package builds on these rather than calling `Math.*` directly, with a few explicitly-commented pragmatic exceptions (e.g. `rng.parkMillerNormal()` uses native `Math.log`).
|
|
68
|
-
- **No `gl-matrix` dependency, and no `VEC2`/`VEC3`/`VEC4` types (as of 0.14).** `Input.mousePosition`/`mousePosition2`, `CanvasRenderer`'s draw methods, `TextureAtlas.getUv`, and `
|
|
69
|
+
- **No `gl-matrix` dependency, and no `VEC2`/`VEC3`/`VEC4` types (as of 0.14).** `Input.mousePosition`/`mousePosition2`, `CanvasRenderer`'s draw methods, `TextureAtlas.getUv`, and `RandomNumberGenerator.randomUnitVector` used to return `gl-matrix`'s `vec2`/`vec4` (`Float32Array`-backed at runtime, 32-bit float precision). They now return plain `[number, number]`/`[number, number, number, number]` tuples inline - full double precision, no longer `instanceof Float32Array`, and no named vector type at all. If you're upgrading from an older version and relied on any of that, this is a breaking change.
|
|
70
|
+
- **`Rng` was renamed to `RandomNumberGenerator`.** The shared instance is still exported as `rng`, but the class type itself is `RandomNumberGenerator` now, not `Rng`. Update any type annotations that referenced `Rng` directly.
|
package/dist/index.css
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/* src/css/clock-stats.css */
|
|
2
|
-
#clock-stats {
|
|
3
|
-
padding: var(--padding-medium);
|
|
4
|
-
border-radius: var(--border-radius);
|
|
5
|
-
border: var(--border-style);
|
|
6
|
-
background: var(--background-opacity-medium);
|
|
7
|
-
z-index: 1000;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
1
|
/* src/css/reset.css */
|
|
11
2
|
*,
|
|
12
3
|
*::before,
|