@n3rdw1z4rd/core 0.17.0 → 0.17.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/README.md +3 -29
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +21 -2
- package/dist/index.mjs +21 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,9 +29,11 @@ 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
|
-
|
|
32
|
+
|
|
33
|
+
clock.onFrame.subscribe((dt) => {
|
|
33
34
|
// dt is seconds since last frame
|
|
34
35
|
});
|
|
36
|
+
|
|
35
37
|
clock.start();
|
|
36
38
|
```
|
|
37
39
|
|
|
@@ -40,31 +42,3 @@ Everything (including the `three/*` modules) is re-exported from the package roo
|
|
|
40
42
|
```ts
|
|
41
43
|
import { ThreeJsBoilerPlate } from "@n3rdw1z4rd/core/three";
|
|
42
44
|
```
|
|
43
|
-
|
|
44
|
-
## What's in here
|
|
45
|
-
|
|
46
|
-
| Area | Docs | Summary |
|
|
47
|
-
|---|---|---|
|
|
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. |
|
|
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). |
|
|
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`. |
|
|
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). |
|
|
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. |
|
|
53
|
-
| 2D primitives | [docs/2d-primitives.md](docs/2d-primitives.md) | `Vector`, `Rectangle`, `Map2D`/`Map3D` (sparse coordinate maps), `Tilemap<T>`. |
|
|
54
|
-
| Procedural generation | [docs/procedural-generation.md](docs/procedural-generation.md) | `AStar` pathfinding, `PoissonDiskSampler`, and a full room-based dungeon generator (`GenerateRooms`/`GenerateDoors`/`GenerateWalls`). |
|
|
55
|
-
| Particle life | [docs/particles.md](docs/particles.md) | 2D (canvas) and 3D (Three.js `Points`) "particle life" attraction-matrix simulations, `Color`, `SpatialPartition2d`/`3d`. |
|
|
56
|
-
| 2D/WebGL rendering | [docs/rendering-2d-webgl.md](docs/rendering-2d-webgl.md) | `CanvasRenderer` (shape/text drawing), and a thin raw-WebGL2 helper layer (`CreateWebGlContext`, shader/program helpers, `WebGlRenderer`). |
|
|
57
|
-
| Three.js bootstrap | [docs/threejs-bootstrap.md](docs/threejs-bootstrap.md) | `ThreeJsBoilerPlate` (scene/camera/renderer/input wiring), `ThreeJsCameraRig` (hand-rolled orbit rig) vs. opt-in `OrbitControls`, `ThreeJsPlayerController`. |
|
|
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. |
|
|
59
|
-
| Three.js widgets | [docs/threejs-widgets.md](docs/threejs-widgets.md) | `CreatePaletteController`, a lil-gui color-swatch widget for picking a palette index. |
|
|
60
|
-
| Networking | [docs/networking.md](docs/networking.md) | `WorkerInterface`, a thin `Emitter`-based wrapper around `Worker`. |
|
|
61
|
-
| Misc | [docs/misc.md](docs/misc.md) | A handful of small standalone helpers: `isNullOrUndefined`, `isPositiveString`, `getRedYellowGreenGradientHex`, `GetUrlParams`. |
|
|
62
|
-
|
|
63
|
-
## Design notes worth knowing before you dig in
|
|
64
|
-
|
|
65
|
-
- **Two ECS designs, on purpose.** The top-level `ECS` (in `ecs.ts`) is a component-template-registry singleton (`ECS.instance.createComponent(...)`). The Three.js-flavored one (`three/ecs.ts`) stores components directly on an `Object3D`'s `userData`, so the scene graph doubles as the entity list. Pick whichever fits a given project - they don't interoperate and aren't meant to.
|
|
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.
|
|
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.
|
|
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`).
|
|
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.d.mts
CHANGED
|
@@ -359,7 +359,9 @@ declare class Noise {
|
|
|
359
359
|
type CanvasColor = string | CanvasGradient | CanvasPattern;
|
|
360
360
|
declare const DEFAULT_COLOR: CanvasColor;
|
|
361
361
|
declare const DEFAULT_PIXEL_SIZE: number;
|
|
362
|
-
declare const
|
|
362
|
+
declare const DEFAULT_FONT_SIZE = 14;
|
|
363
|
+
declare const DEFAULT_FONT_NAME = "monospace";
|
|
364
|
+
declare const DEFAULT_FONT = "14px monospace";
|
|
363
365
|
declare const DEFAULT_TEXTALIGN = "left";
|
|
364
366
|
declare const DEFAULT_TEXTBASELINE = "alphabetic";
|
|
365
367
|
interface DrawParams {
|
|
@@ -367,6 +369,10 @@ interface DrawParams {
|
|
|
367
369
|
filled?: boolean;
|
|
368
370
|
size?: number;
|
|
369
371
|
lineDash?: number[];
|
|
372
|
+
textAlign?: CanvasTextAlign;
|
|
373
|
+
textBaseline?: CanvasTextBaseline;
|
|
374
|
+
font?: string;
|
|
375
|
+
fontName?: string;
|
|
370
376
|
}
|
|
371
377
|
interface SpriteParams extends DrawParams {
|
|
372
378
|
sourceX?: number;
|
|
@@ -382,6 +388,7 @@ declare class CanvasRenderer {
|
|
|
382
388
|
constructor(canvas?: HTMLCanvasElement);
|
|
383
389
|
resize(width?: number, height?: number): boolean;
|
|
384
390
|
clear(): void;
|
|
391
|
+
render(callback: () => void, camera?: XYZ): void;
|
|
385
392
|
private drawPath;
|
|
386
393
|
drawRect(x: number, y: number, width: number, height: number, params?: DrawParams): void;
|
|
387
394
|
drawPixel(x: number, y: number, params?: DrawParams): void;
|
|
@@ -854,4 +861,4 @@ declare class WorkerInterface {
|
|
|
854
861
|
terminate(): void;
|
|
855
862
|
}
|
|
856
863
|
|
|
857
|
-
export { AStar, type AStarFindPathParams, type AStarPoint, AddThreeComponent, AsteroidMesh, type AsteroidOptions, type AtlasParams, AtlasTextureMaterial, type AtlasTextureMaterialParams, BuildDefaultPalette, type CanvasColor, CanvasRenderer, Clock, Color, type ColorSelectionOptions, type ColorSelectionResult, Colors, CompileShader, CreatePaletteController, CreateProgram, CreateProgramInfo, CreateStarfield, CreateSubTexture, CreateSystemStar, CreateThreeEntity, CreateWebGlContext, CubeSphereGeometry, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DOWN, Disposable, type DoorsParams, type DrawParams, E, ECS, EPSILON, type Entity, EventQueue, type EyeDropper, type FractalParams, GenerateDoors, GenerateEntityId, GenerateRooms, type GenerateRoomsParams, GenerateWalls, GetProgramLocations, GetThreeComponent, GetUrlParams, HALF_PI, Input, type InputEventState, IsThreeEntity, type KeyValue, LN10, LN2, LOG10E, LOG2E, LoadTexture, Map2D, type Map2DData, Map3D, type Map3DData, Noise, Observable, PI, type PaletteController, type PaletteControllerOnChange, ParticleRenderer, ParticleSystem2d, ParticleSystem3d, type PathsParams, type PointPair, PoissonDiskSampler, type ProgramInfo, type ProgramLocations, QUARTER_PI, RAD2DEG, type RGB, type RGBA, Random, RandomTools, type RectPair, Rectangle, RemoveThreeComponent, type RendererParams, ResizeWebGlContext, type RoomsParams, SQRT1_2, SQRT2, type SetupBasicSceneParams, ShaderType, Signal, SimplexNoise, SpatialPartition2d, SpatialPartition3d, type SpatialPartitionEntity2d, type SpatialPartitionEntity3d, type SpriteParams, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureAtlas, type TextureData, type ThreeComponent, type ThreeEntity, ThreeJsBoilerPlate, type ThreeJsBoilerPlateParams, ThreeJsCameraRig, type ThreeJsCameraRigParams, ThreeJsPlayerController, type ThreeSystem, Tilemap, UP, Vector, type Voxel, type VoxelData, VoxelFaces, type VoxelMap, type VoxelMaterial, VoxelMesh, WebGlRenderer, WorkerInterface, type XY, type XYZ, type XYZW, abs, acos, asin, atan, atan2, cbrt, ceil, clamp, cos, cosh, degrees, distance2d, distance3d, exp, expm1, floor, fract, getRedYellowGreenGradientHex, hypot, hypot2, hypot3, imul, inverseLerp, isFinite, isInteger, isNaN, isNullOrUndefined, isPositiveString, k2xy, k2xyz, lerp, log, log10, log1p, log2, manhattanDistance, map, max, min, mod, nearlyEqual, normalizeRadians, pow, radians, randomMatrix, rng, round, roundTo, saturate, sign, sin, sinh, smoothstep, sqrt, squaredDistance, tan, tanh, trunc, wrap, xy2k, xyz2k };
|
|
864
|
+
export { AStar, type AStarFindPathParams, type AStarPoint, AddThreeComponent, AsteroidMesh, type AsteroidOptions, type AtlasParams, AtlasTextureMaterial, type AtlasTextureMaterialParams, BuildDefaultPalette, type CanvasColor, CanvasRenderer, Clock, Color, type ColorSelectionOptions, type ColorSelectionResult, Colors, CompileShader, CreatePaletteController, CreateProgram, CreateProgramInfo, CreateStarfield, CreateSubTexture, CreateSystemStar, CreateThreeEntity, CreateWebGlContext, CubeSphereGeometry, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DOWN, Disposable, type DoorsParams, type DrawParams, E, ECS, EPSILON, type Entity, EventQueue, type EyeDropper, type FractalParams, GenerateDoors, GenerateEntityId, GenerateRooms, type GenerateRoomsParams, GenerateWalls, GetProgramLocations, GetThreeComponent, GetUrlParams, HALF_PI, Input, type InputEventState, IsThreeEntity, type KeyValue, LN10, LN2, LOG10E, LOG2E, LoadTexture, Map2D, type Map2DData, Map3D, type Map3DData, Noise, Observable, PI, type PaletteController, type PaletteControllerOnChange, ParticleRenderer, ParticleSystem2d, ParticleSystem3d, type PathsParams, type PointPair, PoissonDiskSampler, type ProgramInfo, type ProgramLocations, QUARTER_PI, RAD2DEG, type RGB, type RGBA, Random, RandomTools, type RectPair, Rectangle, RemoveThreeComponent, type RendererParams, ResizeWebGlContext, type RoomsParams, SQRT1_2, SQRT2, type SetupBasicSceneParams, ShaderType, Signal, SimplexNoise, SpatialPartition2d, SpatialPartition3d, type SpatialPartitionEntity2d, type SpatialPartitionEntity3d, type SpriteParams, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureAtlas, type TextureData, type ThreeComponent, type ThreeEntity, ThreeJsBoilerPlate, type ThreeJsBoilerPlateParams, ThreeJsCameraRig, type ThreeJsCameraRigParams, ThreeJsPlayerController, type ThreeSystem, Tilemap, UP, Vector, type Voxel, type VoxelData, VoxelFaces, type VoxelMap, type VoxelMaterial, VoxelMesh, WebGlRenderer, WorkerInterface, type XY, type XYZ, type XYZW, abs, acos, asin, atan, atan2, cbrt, ceil, clamp, cos, cosh, degrees, distance2d, distance3d, exp, expm1, floor, fract, getRedYellowGreenGradientHex, hypot, hypot2, hypot3, imul, inverseLerp, isFinite, isInteger, isNaN, isNullOrUndefined, isPositiveString, k2xy, k2xyz, lerp, log, log10, log1p, log2, manhattanDistance, map, max, min, mod, nearlyEqual, normalizeRadians, pow, radians, randomMatrix, rng, round, roundTo, saturate, sign, sin, sinh, smoothstep, sqrt, squaredDistance, tan, tanh, trunc, wrap, xy2k, xyz2k };
|
package/dist/index.d.ts
CHANGED
|
@@ -359,7 +359,9 @@ declare class Noise {
|
|
|
359
359
|
type CanvasColor = string | CanvasGradient | CanvasPattern;
|
|
360
360
|
declare const DEFAULT_COLOR: CanvasColor;
|
|
361
361
|
declare const DEFAULT_PIXEL_SIZE: number;
|
|
362
|
-
declare const
|
|
362
|
+
declare const DEFAULT_FONT_SIZE = 14;
|
|
363
|
+
declare const DEFAULT_FONT_NAME = "monospace";
|
|
364
|
+
declare const DEFAULT_FONT = "14px monospace";
|
|
363
365
|
declare const DEFAULT_TEXTALIGN = "left";
|
|
364
366
|
declare const DEFAULT_TEXTBASELINE = "alphabetic";
|
|
365
367
|
interface DrawParams {
|
|
@@ -367,6 +369,10 @@ interface DrawParams {
|
|
|
367
369
|
filled?: boolean;
|
|
368
370
|
size?: number;
|
|
369
371
|
lineDash?: number[];
|
|
372
|
+
textAlign?: CanvasTextAlign;
|
|
373
|
+
textBaseline?: CanvasTextBaseline;
|
|
374
|
+
font?: string;
|
|
375
|
+
fontName?: string;
|
|
370
376
|
}
|
|
371
377
|
interface SpriteParams extends DrawParams {
|
|
372
378
|
sourceX?: number;
|
|
@@ -382,6 +388,7 @@ declare class CanvasRenderer {
|
|
|
382
388
|
constructor(canvas?: HTMLCanvasElement);
|
|
383
389
|
resize(width?: number, height?: number): boolean;
|
|
384
390
|
clear(): void;
|
|
391
|
+
render(callback: () => void, camera?: XYZ): void;
|
|
385
392
|
private drawPath;
|
|
386
393
|
drawRect(x: number, y: number, width: number, height: number, params?: DrawParams): void;
|
|
387
394
|
drawPixel(x: number, y: number, params?: DrawParams): void;
|
|
@@ -854,4 +861,4 @@ declare class WorkerInterface {
|
|
|
854
861
|
terminate(): void;
|
|
855
862
|
}
|
|
856
863
|
|
|
857
|
-
export { AStar, type AStarFindPathParams, type AStarPoint, AddThreeComponent, AsteroidMesh, type AsteroidOptions, type AtlasParams, AtlasTextureMaterial, type AtlasTextureMaterialParams, BuildDefaultPalette, type CanvasColor, CanvasRenderer, Clock, Color, type ColorSelectionOptions, type ColorSelectionResult, Colors, CompileShader, CreatePaletteController, CreateProgram, CreateProgramInfo, CreateStarfield, CreateSubTexture, CreateSystemStar, CreateThreeEntity, CreateWebGlContext, CubeSphereGeometry, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DOWN, Disposable, type DoorsParams, type DrawParams, E, ECS, EPSILON, type Entity, EventQueue, type EyeDropper, type FractalParams, GenerateDoors, GenerateEntityId, GenerateRooms, type GenerateRoomsParams, GenerateWalls, GetProgramLocations, GetThreeComponent, GetUrlParams, HALF_PI, Input, type InputEventState, IsThreeEntity, type KeyValue, LN10, LN2, LOG10E, LOG2E, LoadTexture, Map2D, type Map2DData, Map3D, type Map3DData, Noise, Observable, PI, type PaletteController, type PaletteControllerOnChange, ParticleRenderer, ParticleSystem2d, ParticleSystem3d, type PathsParams, type PointPair, PoissonDiskSampler, type ProgramInfo, type ProgramLocations, QUARTER_PI, RAD2DEG, type RGB, type RGBA, Random, RandomTools, type RectPair, Rectangle, RemoveThreeComponent, type RendererParams, ResizeWebGlContext, type RoomsParams, SQRT1_2, SQRT2, type SetupBasicSceneParams, ShaderType, Signal, SimplexNoise, SpatialPartition2d, SpatialPartition3d, type SpatialPartitionEntity2d, type SpatialPartitionEntity3d, type SpriteParams, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureAtlas, type TextureData, type ThreeComponent, type ThreeEntity, ThreeJsBoilerPlate, type ThreeJsBoilerPlateParams, ThreeJsCameraRig, type ThreeJsCameraRigParams, ThreeJsPlayerController, type ThreeSystem, Tilemap, UP, Vector, type Voxel, type VoxelData, VoxelFaces, type VoxelMap, type VoxelMaterial, VoxelMesh, WebGlRenderer, WorkerInterface, type XY, type XYZ, type XYZW, abs, acos, asin, atan, atan2, cbrt, ceil, clamp, cos, cosh, degrees, distance2d, distance3d, exp, expm1, floor, fract, getRedYellowGreenGradientHex, hypot, hypot2, hypot3, imul, inverseLerp, isFinite, isInteger, isNaN, isNullOrUndefined, isPositiveString, k2xy, k2xyz, lerp, log, log10, log1p, log2, manhattanDistance, map, max, min, mod, nearlyEqual, normalizeRadians, pow, radians, randomMatrix, rng, round, roundTo, saturate, sign, sin, sinh, smoothstep, sqrt, squaredDistance, tan, tanh, trunc, wrap, xy2k, xyz2k };
|
|
864
|
+
export { AStar, type AStarFindPathParams, type AStarPoint, AddThreeComponent, AsteroidMesh, type AsteroidOptions, type AtlasParams, AtlasTextureMaterial, type AtlasTextureMaterialParams, BuildDefaultPalette, type CanvasColor, CanvasRenderer, Clock, Color, type ColorSelectionOptions, type ColorSelectionResult, Colors, CompileShader, CreatePaletteController, CreateProgram, CreateProgramInfo, CreateStarfield, CreateSubTexture, CreateSystemStar, CreateThreeEntity, CreateWebGlContext, CubeSphereGeometry, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DOWN, Disposable, type DoorsParams, type DrawParams, E, ECS, EPSILON, type Entity, EventQueue, type EyeDropper, type FractalParams, GenerateDoors, GenerateEntityId, GenerateRooms, type GenerateRoomsParams, GenerateWalls, GetProgramLocations, GetThreeComponent, GetUrlParams, HALF_PI, Input, type InputEventState, IsThreeEntity, type KeyValue, LN10, LN2, LOG10E, LOG2E, LoadTexture, Map2D, type Map2DData, Map3D, type Map3DData, Noise, Observable, PI, type PaletteController, type PaletteControllerOnChange, ParticleRenderer, ParticleSystem2d, ParticleSystem3d, type PathsParams, type PointPair, PoissonDiskSampler, type ProgramInfo, type ProgramLocations, QUARTER_PI, RAD2DEG, type RGB, type RGBA, Random, RandomTools, type RectPair, Rectangle, RemoveThreeComponent, type RendererParams, ResizeWebGlContext, type RoomsParams, SQRT1_2, SQRT2, type SetupBasicSceneParams, ShaderType, Signal, SimplexNoise, SpatialPartition2d, SpatialPartition3d, type SpatialPartitionEntity2d, type SpatialPartitionEntity3d, type SpriteParams, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureAtlas, type TextureData, type ThreeComponent, type ThreeEntity, ThreeJsBoilerPlate, type ThreeJsBoilerPlateParams, ThreeJsCameraRig, type ThreeJsCameraRigParams, ThreeJsPlayerController, type ThreeSystem, Tilemap, UP, Vector, type Voxel, type VoxelData, VoxelFaces, type VoxelMap, type VoxelMaterial, VoxelMesh, WebGlRenderer, WorkerInterface, type XY, type XYZ, type XYZW, abs, acos, asin, atan, atan2, cbrt, ceil, clamp, cos, cosh, degrees, distance2d, distance3d, exp, expm1, floor, fract, getRedYellowGreenGradientHex, hypot, hypot2, hypot3, imul, inverseLerp, isFinite, isInteger, isNaN, isNullOrUndefined, isPositiveString, k2xy, k2xyz, lerp, log, log10, log1p, log2, manhattanDistance, map, max, min, mod, nearlyEqual, normalizeRadians, pow, radians, randomMatrix, rng, round, roundTo, saturate, sign, sin, sinh, smoothstep, sqrt, squaredDistance, tan, tanh, trunc, wrap, xy2k, xyz2k };
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,8 @@ __export(index_exports, {
|
|
|
72
72
|
CubeSphereGeometry: () => CubeSphereGeometry,
|
|
73
73
|
DEFAULT_COLOR: () => DEFAULT_COLOR,
|
|
74
74
|
DEFAULT_FONT: () => DEFAULT_FONT,
|
|
75
|
+
DEFAULT_FONT_NAME: () => DEFAULT_FONT_NAME,
|
|
76
|
+
DEFAULT_FONT_SIZE: () => DEFAULT_FONT_SIZE,
|
|
75
77
|
DEFAULT_PIXEL_SIZE: () => DEFAULT_PIXEL_SIZE,
|
|
76
78
|
DEFAULT_TEXTALIGN: () => DEFAULT_TEXTALIGN,
|
|
77
79
|
DEFAULT_TEXTBASELINE: () => DEFAULT_TEXTBASELINE,
|
|
@@ -635,7 +637,7 @@ var RandomTools = class {
|
|
|
635
637
|
max2 = min2;
|
|
636
638
|
min2 = 0;
|
|
637
639
|
}
|
|
638
|
-
return floor(this.floatRange(min2, max2
|
|
640
|
+
return floor(this.floatRange(min2, max2));
|
|
639
641
|
}
|
|
640
642
|
//----------------------------------------------------------------------
|
|
641
643
|
// Collections
|
|
@@ -1844,7 +1846,9 @@ function PoissonDiskSampler(width, height, minDist, maxPoints = 30) {
|
|
|
1844
1846
|
// src/rendering/canvas-renderer.ts
|
|
1845
1847
|
var DEFAULT_COLOR = "white";
|
|
1846
1848
|
var DEFAULT_PIXEL_SIZE = 1;
|
|
1847
|
-
var
|
|
1849
|
+
var DEFAULT_FONT_SIZE = 14;
|
|
1850
|
+
var DEFAULT_FONT_NAME = "monospace";
|
|
1851
|
+
var DEFAULT_FONT = `${DEFAULT_FONT_SIZE}px ${DEFAULT_FONT_NAME}`;
|
|
1848
1852
|
var DEFAULT_TEXTALIGN = "left";
|
|
1849
1853
|
var DEFAULT_TEXTBASELINE = "alphabetic";
|
|
1850
1854
|
var CanvasRenderer = class {
|
|
@@ -1878,6 +1882,16 @@ var CanvasRenderer = class {
|
|
|
1878
1882
|
clear() {
|
|
1879
1883
|
this.context.clearRect(0, 0, this.width, this.height);
|
|
1880
1884
|
}
|
|
1885
|
+
render(callback, camera) {
|
|
1886
|
+
camera = camera ?? { x: 0, y: 0, z: 1 };
|
|
1887
|
+
this.clear();
|
|
1888
|
+
this.context.save();
|
|
1889
|
+
this.context.translate(this.width / 2, this.height / 2);
|
|
1890
|
+
this.context.scale(camera.z, camera.z);
|
|
1891
|
+
this.context.translate(-camera.x, -camera.y);
|
|
1892
|
+
callback();
|
|
1893
|
+
this.context.restore();
|
|
1894
|
+
}
|
|
1881
1895
|
drawPath(buildPath, params = {}) {
|
|
1882
1896
|
this.context.fillStyle = params.color ?? DEFAULT_COLOR;
|
|
1883
1897
|
this.context.strokeStyle = params.color ?? DEFAULT_COLOR;
|
|
@@ -1956,6 +1970,9 @@ var CanvasRenderer = class {
|
|
|
1956
1970
|
}, params);
|
|
1957
1971
|
}
|
|
1958
1972
|
drawText(x, y, text, params = {}) {
|
|
1973
|
+
this.context.font = params.font ?? `${params.size ?? DEFAULT_FONT_SIZE}px ${params.fontName ?? DEFAULT_FONT_NAME}`;
|
|
1974
|
+
this.context.textAlign = params.textAlign ?? DEFAULT_TEXTALIGN;
|
|
1975
|
+
this.context.textBaseline = params.textBaseline ?? DEFAULT_TEXTBASELINE;
|
|
1959
1976
|
this.context.fillStyle = params.color ?? DEFAULT_COLOR;
|
|
1960
1977
|
this.context.fillText(text, x, y);
|
|
1961
1978
|
}
|
|
@@ -3557,6 +3574,8 @@ var WorkerInterface = class {
|
|
|
3557
3574
|
CubeSphereGeometry,
|
|
3558
3575
|
DEFAULT_COLOR,
|
|
3559
3576
|
DEFAULT_FONT,
|
|
3577
|
+
DEFAULT_FONT_NAME,
|
|
3578
|
+
DEFAULT_FONT_SIZE,
|
|
3560
3579
|
DEFAULT_PIXEL_SIZE,
|
|
3561
3580
|
DEFAULT_TEXTALIGN,
|
|
3562
3581
|
DEFAULT_TEXTBASELINE,
|
package/dist/index.mjs
CHANGED
|
@@ -70,6 +70,8 @@ __export(index_exports, {
|
|
|
70
70
|
CubeSphereGeometry: () => CubeSphereGeometry,
|
|
71
71
|
DEFAULT_COLOR: () => DEFAULT_COLOR,
|
|
72
72
|
DEFAULT_FONT: () => DEFAULT_FONT,
|
|
73
|
+
DEFAULT_FONT_NAME: () => DEFAULT_FONT_NAME,
|
|
74
|
+
DEFAULT_FONT_SIZE: () => DEFAULT_FONT_SIZE,
|
|
73
75
|
DEFAULT_PIXEL_SIZE: () => DEFAULT_PIXEL_SIZE,
|
|
74
76
|
DEFAULT_TEXTALIGN: () => DEFAULT_TEXTALIGN,
|
|
75
77
|
DEFAULT_TEXTBASELINE: () => DEFAULT_TEXTBASELINE,
|
|
@@ -632,7 +634,7 @@ var RandomTools = class {
|
|
|
632
634
|
max2 = min2;
|
|
633
635
|
min2 = 0;
|
|
634
636
|
}
|
|
635
|
-
return floor(this.floatRange(min2, max2
|
|
637
|
+
return floor(this.floatRange(min2, max2));
|
|
636
638
|
}
|
|
637
639
|
//----------------------------------------------------------------------
|
|
638
640
|
// Collections
|
|
@@ -1841,7 +1843,9 @@ function PoissonDiskSampler(width, height, minDist, maxPoints = 30) {
|
|
|
1841
1843
|
// src/rendering/canvas-renderer.ts
|
|
1842
1844
|
var DEFAULT_COLOR = "white";
|
|
1843
1845
|
var DEFAULT_PIXEL_SIZE = 1;
|
|
1844
|
-
var
|
|
1846
|
+
var DEFAULT_FONT_SIZE = 14;
|
|
1847
|
+
var DEFAULT_FONT_NAME = "monospace";
|
|
1848
|
+
var DEFAULT_FONT = `${DEFAULT_FONT_SIZE}px ${DEFAULT_FONT_NAME}`;
|
|
1845
1849
|
var DEFAULT_TEXTALIGN = "left";
|
|
1846
1850
|
var DEFAULT_TEXTBASELINE = "alphabetic";
|
|
1847
1851
|
var CanvasRenderer = class {
|
|
@@ -1875,6 +1879,16 @@ var CanvasRenderer = class {
|
|
|
1875
1879
|
clear() {
|
|
1876
1880
|
this.context.clearRect(0, 0, this.width, this.height);
|
|
1877
1881
|
}
|
|
1882
|
+
render(callback, camera) {
|
|
1883
|
+
camera = camera ?? { x: 0, y: 0, z: 1 };
|
|
1884
|
+
this.clear();
|
|
1885
|
+
this.context.save();
|
|
1886
|
+
this.context.translate(this.width / 2, this.height / 2);
|
|
1887
|
+
this.context.scale(camera.z, camera.z);
|
|
1888
|
+
this.context.translate(-camera.x, -camera.y);
|
|
1889
|
+
callback();
|
|
1890
|
+
this.context.restore();
|
|
1891
|
+
}
|
|
1878
1892
|
drawPath(buildPath, params = {}) {
|
|
1879
1893
|
this.context.fillStyle = params.color ?? DEFAULT_COLOR;
|
|
1880
1894
|
this.context.strokeStyle = params.color ?? DEFAULT_COLOR;
|
|
@@ -1953,6 +1967,9 @@ var CanvasRenderer = class {
|
|
|
1953
1967
|
}, params);
|
|
1954
1968
|
}
|
|
1955
1969
|
drawText(x, y, text, params = {}) {
|
|
1970
|
+
this.context.font = params.font ?? `${params.size ?? DEFAULT_FONT_SIZE}px ${params.fontName ?? DEFAULT_FONT_NAME}`;
|
|
1971
|
+
this.context.textAlign = params.textAlign ?? DEFAULT_TEXTALIGN;
|
|
1972
|
+
this.context.textBaseline = params.textBaseline ?? DEFAULT_TEXTBASELINE;
|
|
1956
1973
|
this.context.fillStyle = params.color ?? DEFAULT_COLOR;
|
|
1957
1974
|
this.context.fillText(text, x, y);
|
|
1958
1975
|
}
|
|
@@ -3553,6 +3570,8 @@ export {
|
|
|
3553
3570
|
CubeSphereGeometry,
|
|
3554
3571
|
DEFAULT_COLOR,
|
|
3555
3572
|
DEFAULT_FONT,
|
|
3573
|
+
DEFAULT_FONT_NAME,
|
|
3574
|
+
DEFAULT_FONT_SIZE,
|
|
3556
3575
|
DEFAULT_PIXEL_SIZE,
|
|
3557
3576
|
DEFAULT_TEXTALIGN,
|
|
3558
3577
|
DEFAULT_TEXTBASELINE,
|