@i7r.tech/moveby 0.0.0-stage → 0.0.21-ywc
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/LICENSE +202 -0
- package/README.md +67 -2
- package/bin/index.js +34557 -0
- package/bin/moveby.js +8573 -0
- package/bin/parse-worker.mjs +39 -0
- package/bin/tooling/wasm_engine.cjs +131 -0
- package/bin/tooling/wasm_engine_bg.wasm +0 -0
- package/dist/engine/wasm_engine.d.ts +330 -0
- package/dist/engine/wasm_engine.js +733 -0
- package/dist/engine/wasm_engine_bg.wasm +0 -0
- package/dist/errors.d.ts +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1907 -0
- package/dist/passes/backdrop.d.ts +9 -0
- package/dist/passes/field.d.ts +30 -0
- package/dist/passes/index.d.ts +5 -0
- package/dist/passes/road.d.ts +21 -0
- package/dist/passes/scenery.d.ts +28 -0
- package/dist/passes/sky.d.ts +11 -0
- package/dist/passes/text.d.ts +26 -0
- package/dist/scene-module.d.ts +165 -0
- package/dist/scene.d.ts +59 -0
- package/dist/utils.d.ts +15 -0
- package/docs/attribution.md +31 -0
- package/docs/decisions.md +26 -0
- package/package.json +33 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Rgb = readonly [number, number, number];
|
|
2
|
+
export declare class BackdropPass {
|
|
3
|
+
private gl;
|
|
4
|
+
private ground;
|
|
5
|
+
private sky;
|
|
6
|
+
constructor(gl: WebGLRenderingContext, ground: Rgb, sky: Rgb);
|
|
7
|
+
clearToGround(): void;
|
|
8
|
+
fillSky(horizonRow: number, width: number, height: number): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Engine } from "../engine/wasm_engine.js";
|
|
2
|
+
export declare const FIELD_ERRORS: {
|
|
3
|
+
readonly FIELD_RANGE: "A field span has a bad range: 0 ≤ start < end.";
|
|
4
|
+
readonly FIELD_END: "A field span ends past the end of the track.";
|
|
5
|
+
readonly FIELD_OVERLAP: "Two field spans overlap on the same side.";
|
|
6
|
+
readonly FIELD_ATLAS_CELL: "A field span uses an atlas cell, but the track has no field atlas, or the cell block does not fit its grid.";
|
|
7
|
+
readonly FIELD_ATLAS_DIMS: "The field atlas grid is bad: cols and rows are at least 1, each pixel size is a whole number of cells, and the grid has at most 65,536 cells.";
|
|
8
|
+
readonly FIELD_IMAGE_MISSING: "The field layer has no image to draw from.";
|
|
9
|
+
readonly FIELD_IMAGE_SIZE: "A field tile image must be loaded, with power-of-two sides such as 256 × 256.";
|
|
10
|
+
readonly FIELD_CAPACITY: "The track has more field quads in one frame than one draw can index.";
|
|
11
|
+
};
|
|
12
|
+
export declare class FieldPass {
|
|
13
|
+
private gl;
|
|
14
|
+
private engine;
|
|
15
|
+
private fieldProgram;
|
|
16
|
+
private fieldBuffer;
|
|
17
|
+
private fieldIndexBuffer;
|
|
18
|
+
private fieldLoc;
|
|
19
|
+
private fieldUni;
|
|
20
|
+
private fieldTextures;
|
|
21
|
+
private fieldAtlasProgram;
|
|
22
|
+
private fieldAtlasLoc;
|
|
23
|
+
private fieldAtlasUni;
|
|
24
|
+
private fieldAtlasCellRectLoc;
|
|
25
|
+
private fieldAtlas;
|
|
26
|
+
constructor(gl: WebGLRenderingContext, engine: Engine);
|
|
27
|
+
setFieldTexture(id: number, bitmap: TexImageSource): void;
|
|
28
|
+
setFieldAtlas(bitmap: TexImageSource): void;
|
|
29
|
+
draw(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Engine } from "../engine/wasm_engine.js";
|
|
2
|
+
export declare const ROAD_ERRORS: {
|
|
3
|
+
readonly LANE_COUNT: "A lane span's lane count must be from 1 to 8.";
|
|
4
|
+
readonly LANE_BOUNDS: "A lane span has a bad range: 0 ≤ start < end ≤ track length.";
|
|
5
|
+
readonly LANE_OVERLAP: "Two lane spans overlap.";
|
|
6
|
+
readonly LANE_TAPER: "Two changes of road width are closer than the 30 m taper.";
|
|
7
|
+
readonly LANE_DASH: "A dashed divider needs dashOn and dashGap above 0.";
|
|
8
|
+
readonly LANE_COLOR: "A divider colour needs each part from 0 to 1.";
|
|
9
|
+
readonly ROAD_CAPACITY: "The track has more road quads in one frame than one draw can index.";
|
|
10
|
+
};
|
|
11
|
+
export declare class RoadPass {
|
|
12
|
+
private gl;
|
|
13
|
+
private engine;
|
|
14
|
+
private program;
|
|
15
|
+
private vertexBuffer;
|
|
16
|
+
private indexBuffer;
|
|
17
|
+
private loc;
|
|
18
|
+
private uni;
|
|
19
|
+
constructor(gl: WebGLRenderingContext, engine: Engine);
|
|
20
|
+
draw(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Engine } from "../engine/wasm_engine.js";
|
|
2
|
+
export declare const SCENERY_ERRORS: {
|
|
3
|
+
readonly SCENERY_ATLAS: "The scenery atlas grid is bad: cols and rows are at least 1, each pixel size is a whole number of cells, and the grid has at most 65,536 cells.";
|
|
4
|
+
readonly SCENERY_SPRITE: "A sprite is bad: its cell is outside the grid or declared twice, its cell block does not fit, or its size is not a positive finite number.";
|
|
5
|
+
readonly SCENERY_ASSET: "A scenery asset is bad: its cell is outside the grid, or its cell block does not fit the grid.";
|
|
6
|
+
readonly SCENERY_PLACED: "A placed object names an asset the track does not declare.";
|
|
7
|
+
readonly SCENERY_OBJECT_SPRITE: "An object uses a sprite that the track does not declare.";
|
|
8
|
+
readonly SCENERY_OBJECT_S: "An object is outside the track, or one of its positions is not a finite number.";
|
|
9
|
+
readonly SCENERY_SCALE: "An object's scale must be a finite number, 0 or more. 0 hides the object.";
|
|
10
|
+
readonly SCENERY_ROTATION: "An object's rotation must be a finite number.";
|
|
11
|
+
readonly SCENERY_ORIGIN: "An object's rotation origin must be on the card: each part from 0 to 1.";
|
|
12
|
+
readonly SCENERY_ANIM: "An object has an animate, oscillate or shape key. Animation moved to the scene module.";
|
|
13
|
+
readonly SCENERY_CAPACITY: "The track has more scenery quads than one draw can index.";
|
|
14
|
+
readonly SCENERY_IMAGE_MISSING: "The scenery layer has no image to draw from.";
|
|
15
|
+
};
|
|
16
|
+
export declare class SceneryPass {
|
|
17
|
+
private gl;
|
|
18
|
+
private engine;
|
|
19
|
+
private sceneryProgram;
|
|
20
|
+
private sceneryBuffer;
|
|
21
|
+
private sceneryIndexBuffer;
|
|
22
|
+
private sceneryLoc;
|
|
23
|
+
private sceneryUni;
|
|
24
|
+
private sceneryTexture;
|
|
25
|
+
constructor(gl: WebGLRenderingContext, engine: Engine);
|
|
26
|
+
setSceneryAtlas(bitmap: TexImageSource): void;
|
|
27
|
+
draw(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Engine } from "../engine/wasm_engine.js";
|
|
2
|
+
export declare class SkyPass {
|
|
3
|
+
private gl;
|
|
4
|
+
private program;
|
|
5
|
+
private vertexBuffer;
|
|
6
|
+
private indexBuffer;
|
|
7
|
+
private loc;
|
|
8
|
+
private uni;
|
|
9
|
+
constructor(gl: WebGLRenderingContext);
|
|
10
|
+
draw(engine: Engine, groundRows: number, canvasWidth: number, canvasHeight: number): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Engine } from "../engine/wasm_engine.js";
|
|
2
|
+
export declare const TEXT_ERRORS: {
|
|
3
|
+
readonly TEXT_FONT: "The font is bad: scaleW, scaleH and lineHeight are finite and above 0, and base is finite and 0 or more.";
|
|
4
|
+
readonly TEXT_GLYPH: "A glyph has a bad rectangle, a negative size, or an offset or advance that is not a finite number.";
|
|
5
|
+
readonly TEXT_GLYPH_DUP: "The font declares one glyph twice.";
|
|
6
|
+
readonly TEXT_LABEL: "A label is bad: its height is a finite number, 0 or more (0 hides it), and each part of its colour is from 0 to 1.";
|
|
7
|
+
readonly TEXT_ROAD_S: "A label is outside the track, or one of its positions is not a finite number.";
|
|
8
|
+
readonly TEXT_CODEPOINT: "A label has a character with no glyph in the font.";
|
|
9
|
+
readonly TEXT_ANIM: "A label has an animate or shape key. Animation moved to the scene module.";
|
|
10
|
+
readonly TEXT_CAPACITY: "The track has more glyph quads than one draw can index.";
|
|
11
|
+
readonly TEXT_IMAGE_MISSING: "The text layer has no image to draw from.";
|
|
12
|
+
readonly TEXT_IMAGE_SIZE: "The text atlas image must be loaded, with power-of-two sides such as 256 × 256.";
|
|
13
|
+
};
|
|
14
|
+
export declare class TextPass {
|
|
15
|
+
private gl;
|
|
16
|
+
private engine;
|
|
17
|
+
private textProgram;
|
|
18
|
+
private textBuffer;
|
|
19
|
+
private textIndexBuffer;
|
|
20
|
+
private textLoc;
|
|
21
|
+
private uColor;
|
|
22
|
+
private textTexture;
|
|
23
|
+
constructor(gl: WebGLRenderingContext, engine: Engine);
|
|
24
|
+
setTextAtlas(bitmap: TexImageSource): void;
|
|
25
|
+
draw(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { Engine } from "./engine/wasm_engine.js";
|
|
2
|
+
export declare const SCENE_MODULE_ERRORS: {
|
|
3
|
+
readonly SCENE_HOST: "The scene module is not one this library reads: it has no moveby.host section of version 2, or that section is malformed. Build it again.";
|
|
4
|
+
readonly SCENE_POSITION: "The scene declares no dynamic input named position.";
|
|
5
|
+
readonly SCENE_KIND: "An object's kind is not image(<asset>) or text(\"<string>\"), or its arguments are not one asset or one string.";
|
|
6
|
+
readonly SCENE_PROPERTY: "An object does not declare exactly the properties its kind takes.";
|
|
7
|
+
readonly SCENE_NAME: "An out field of the scene is not camera_x or camera_y.";
|
|
8
|
+
readonly SCENE_ASSET: "An image does not bind an asset of the scene's moveby.asset group, or the page's asset records do not fit the scene.";
|
|
9
|
+
readonly SCENE_TRACK: "The track file and the scene do not fit: the track holds placed rows of its own, or it lacks the atlas grid or the font that the scene needs. Build the track again beside the scene.";
|
|
10
|
+
readonly SCENE_USING: "A using input of the scene gets no value at load, or one that is not a finite number.";
|
|
11
|
+
readonly SCENE_DYNAMIC: "A dynamic input is missing from the draw call, or is not a finite number.";
|
|
12
|
+
readonly SCENE_VALUE: "A value from the scene is out of range: not finite, a size below 0, or an alpha, a pivot part or a colour part outside 0 to 1. It is never clamped: the frame is rejected as a whole.";
|
|
13
|
+
};
|
|
14
|
+
/** The custom section's name. */
|
|
15
|
+
export declare const HOST_SECTION = "moveby.host";
|
|
16
|
+
export type HostArgument = {
|
|
17
|
+
readonly kind: "literal";
|
|
18
|
+
readonly value: number | string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: "using";
|
|
21
|
+
readonly slot: number;
|
|
22
|
+
};
|
|
23
|
+
export interface HostObject {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly firstLeaf: number;
|
|
26
|
+
readonly leafCount: number;
|
|
27
|
+
readonly kind: {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly id: number;
|
|
30
|
+
readonly args: readonly HostArgument[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface HostTable {
|
|
34
|
+
readonly version: number;
|
|
35
|
+
readonly dynamic: readonly string[];
|
|
36
|
+
readonly using: readonly string[];
|
|
37
|
+
readonly outOffset: number;
|
|
38
|
+
readonly leaves: readonly string[];
|
|
39
|
+
readonly objects: readonly HostObject[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read the host table from the bytes of its custom section: what
|
|
43
|
+
* `WebAssembly.Module.customSections(module, HOST_SECTION)` hands back, wrapped in a `Uint8Array`.
|
|
44
|
+
* A malformed stream or another version is `SCENE_HOST`: a module is loaded from bytes the page
|
|
45
|
+
* fetched, so every read is bounded.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readHostTable(section: Uint8Array): HostTable;
|
|
48
|
+
export interface SceneObject {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly assetSlot: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SceneLabel {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly text: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A host table that passed `checkScene`: what the load and the frame read. The objects and the
|
|
58
|
+
* labels are in `out[]` order, which is the engine's record order (decision 76).
|
|
59
|
+
*/
|
|
60
|
+
export interface GatherPlan {
|
|
61
|
+
readonly dynamic: readonly string[];
|
|
62
|
+
readonly using: readonly string[];
|
|
63
|
+
readonly assets: readonly string[];
|
|
64
|
+
readonly objects: readonly SceneObject[];
|
|
65
|
+
readonly labels: readonly SceneLabel[];
|
|
66
|
+
readonly map: Int32Array;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check that a host table is a scene this library can draw, and make its gather plan. One pure
|
|
70
|
+
* function of the table (decision 9): `loadTrack` runs it on a module, and `moveby build` runs it on
|
|
71
|
+
* the manifest to name each fault `file:line`. The first fault in reading order wins: the version,
|
|
72
|
+
* then `position`, then `out[]` in order (each object's kind, its arguments, its properties; each
|
|
73
|
+
* other field's name).
|
|
74
|
+
*/
|
|
75
|
+
export declare function checkScene(table: HostTable): GatherPlan;
|
|
76
|
+
/** One asset record, as `asset()` makes it: the page's data for a look the scene binds by name. */
|
|
77
|
+
export interface Asset {
|
|
78
|
+
/** The name the scene binds: the leaf `moveby.asset.<name>`. */
|
|
79
|
+
readonly name: string;
|
|
80
|
+
/** The atlas cell at the block's top-left. */
|
|
81
|
+
readonly cell: number;
|
|
82
|
+
/** The block's span in cells. Each is 1 by default (decision 41's defaults). */
|
|
83
|
+
readonly cols: number;
|
|
84
|
+
readonly rows: number;
|
|
85
|
+
/** Metres, before the object's `scale`. */
|
|
86
|
+
readonly width: number;
|
|
87
|
+
readonly height: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* One asset record for `loadTrack`. The library reads a record once, at load (decision 77): its cell
|
|
91
|
+
* and its span go to the engine's asset table, its size to the value block. To swap a cell, declare
|
|
92
|
+
* two assets and two objects, and hide one object with `scale = 0`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function asset(name: string, look: {
|
|
95
|
+
cell: number;
|
|
96
|
+
cols?: number;
|
|
97
|
+
rows?: number;
|
|
98
|
+
width: number;
|
|
99
|
+
height: number;
|
|
100
|
+
}): Asset;
|
|
101
|
+
interface SceneModule {
|
|
102
|
+
readonly $memory: WebAssembly.Memory;
|
|
103
|
+
readonly $init: (...using: number[]) => void;
|
|
104
|
+
readonly $fill: (...dynamic: number[]) => void;
|
|
105
|
+
readonly $reset: () => void;
|
|
106
|
+
}
|
|
107
|
+
/** What `loadTrack` takes beside the two files. */
|
|
108
|
+
export interface LoadInputs<Using extends object = object> {
|
|
109
|
+
/** The asset records: one for each name the scene binds. A record of a name it does not bind is ignored. */
|
|
110
|
+
readonly assets?: readonly Asset[];
|
|
111
|
+
/** Every using input outside `moveby.asset`, by path: `{ lamp: { start: 3 } }` for `lamp.start`. */
|
|
112
|
+
readonly using?: Using;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A track with its scene module: what `loadTrack` gives a page. The engine draws the track; the
|
|
116
|
+
* module computes each frame's values. `createScene(canvas, track, layers)` builds a scene over it
|
|
117
|
+
* whose `draw(dynamic)` runs this class's `draw`, then the passes. The engine is public for a page
|
|
118
|
+
* that draws with its own passes.
|
|
119
|
+
*/
|
|
120
|
+
export declare class Track {
|
|
121
|
+
readonly engine: Engine;
|
|
122
|
+
private readonly scene;
|
|
123
|
+
private readonly plan;
|
|
124
|
+
private readonly leaves;
|
|
125
|
+
/** The module's `out[]`, one f32 per leaf. Read only: it is the module's memo too. */
|
|
126
|
+
private readonly out;
|
|
127
|
+
/** Each asset's width and height, read from its record once (decision 77). */
|
|
128
|
+
private readonly sizes;
|
|
129
|
+
/** The frame's dynamic inputs, in `$fill` argument order. */
|
|
130
|
+
private readonly inputs;
|
|
131
|
+
private readonly dynamicKeys;
|
|
132
|
+
private readonly fillWith;
|
|
133
|
+
/** Where `position` sits among the dynamic inputs. */
|
|
134
|
+
private readonly positionAt;
|
|
135
|
+
constructor(engine: Engine, scene: SceneModule, table: HostTable, plan: GatherPlan, records: readonly Asset[], out: Float32Array);
|
|
136
|
+
/**
|
|
137
|
+
* One frame of the scene module (decision 11): read each dynamic input once by its path, call
|
|
138
|
+
* `$fill`, gather `out[]` into the engine's staging block, commit, then seek. A missing input, or
|
|
139
|
+
* one that is not a finite number, is `SCENE_DYNAMIC`. A value the engine refuses — a NaN, a size
|
|
140
|
+
* below 0, an alpha, a pivot part or a colour part outside 0 to 1, the camera's too — is
|
|
141
|
+
* `SCENE_VALUE` with its leaf path, and the frame changes nothing. Nothing here allocates except
|
|
142
|
+
* the staging view, which each engine call of its kind makes. No reference to the page's records.
|
|
143
|
+
*/
|
|
144
|
+
draw(dynamic: object): void;
|
|
145
|
+
/** `$reset` (decision 12): drop every `delta` snapshot, so a replay from the start begins at a rising edge. */
|
|
146
|
+
reset(): void;
|
|
147
|
+
private pathOf;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Load a track with its scene module (decisions 5, 6 and 10). The module is compiled
|
|
151
|
+
* asynchronously, and its host table is read and checked (`checkScene`). The page's inputs fill the
|
|
152
|
+
* module's using inputs and its asset records. The load calls `$init`, and no `$fill`: the first
|
|
153
|
+
* `scene.draw` is the module's first frame. Each kind argument is read from the module's memory
|
|
154
|
+
* after `$init`, and becomes a row of the engine, with the page's assets. Then the engine is built
|
|
155
|
+
* from the track bytes and the rows together.
|
|
156
|
+
*/
|
|
157
|
+
export declare function loadTrack<Using extends object = object>(trackBytes: Uint8Array, sceneBytes: Uint8Array<ArrayBuffer>, inputs?: LoadInputs<Using>): Promise<Track>;
|
|
158
|
+
/**
|
|
159
|
+
* The text of `track.d.ts` for a scene (decision 13): `SceneDynamic`, the argument of
|
|
160
|
+
* `scene.draw`, and `SceneUsing`, the `using` of `loadTrack`. A dotted path becomes a nested type.
|
|
161
|
+
* The assets are not typed here: `asset()` declares them. A pure function of the host table;
|
|
162
|
+
* `moveby build` writes its output.
|
|
163
|
+
*/
|
|
164
|
+
export declare function trackTypes(table: HostTable): string;
|
|
165
|
+
export {};
|
package/dist/scene.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Engine } from "./engine/wasm_engine.js";
|
|
2
|
+
import { type Rgb } from "./passes/backdrop.js";
|
|
3
|
+
import { Track } from "./scene-module.js";
|
|
4
|
+
export { CORE_ERRORS, MovebyError } from "./errors.js";
|
|
5
|
+
export type { Rgb } from "./passes/backdrop.js";
|
|
6
|
+
export { FIELD_ERRORS, ROAD_ERRORS, SCENERY_ERRORS, TEXT_ERRORS } from "./passes/index.js";
|
|
7
|
+
export { SCENE_MODULE_ERRORS, asset, loadTrack, trackTypes, type Asset, type LoadInputs, type Track } from "./scene-module.js";
|
|
8
|
+
export type Layer = {
|
|
9
|
+
kind: "backdrop";
|
|
10
|
+
ground: Rgb;
|
|
11
|
+
sky: Rgb;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "road";
|
|
14
|
+
} | {
|
|
15
|
+
kind: "field";
|
|
16
|
+
atlas?: TexImageSource | string;
|
|
17
|
+
textures?: Readonly<Record<number, TexImageSource>>;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "sky";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "scenery";
|
|
22
|
+
atlas: TexImageSource | string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "text";
|
|
25
|
+
atlas: TexImageSource | string;
|
|
26
|
+
};
|
|
27
|
+
export declare function backdrop({ ground, sky: skyColor, }?: {
|
|
28
|
+
ground?: Rgb;
|
|
29
|
+
sky?: Rgb;
|
|
30
|
+
}): Layer;
|
|
31
|
+
export declare function road(): Layer;
|
|
32
|
+
export declare function field(inputs: {
|
|
33
|
+
atlas?: TexImageSource | string;
|
|
34
|
+
textures?: Readonly<Record<number, TexImageSource>>;
|
|
35
|
+
}): Layer;
|
|
36
|
+
export declare function sky(): Layer;
|
|
37
|
+
export declare function scenery({ atlas }: {
|
|
38
|
+
atlas: TexImageSource | string;
|
|
39
|
+
}): Layer;
|
|
40
|
+
export declare function text({ atlas }: {
|
|
41
|
+
atlas: TexImageSource | string;
|
|
42
|
+
}): Layer;
|
|
43
|
+
export declare const SCENE_ERRORS: {
|
|
44
|
+
readonly LAYER_DUPLICATE: "The scene lists the same layer twice.";
|
|
45
|
+
readonly LAYER_UNLISTED: "The track declares a layer that the scene does not list.";
|
|
46
|
+
readonly LAYER_MISSING: "The scene lists a layer that the track does not declare.";
|
|
47
|
+
readonly WEBGL_UNSUPPORTED: "This browser gave no WebGL context for the canvas.";
|
|
48
|
+
readonly SCENE_NO_TRACK: "This scene draws an engine the page moves itself, so it takes no dynamic inputs: scene.draw({ … }) needs a track from loadTrack.";
|
|
49
|
+
readonly SCENE_ATLAS: "An atlas the scene names as a URL could not be fetched or decoded.";
|
|
50
|
+
};
|
|
51
|
+
export declare const ERROR_MESSAGES: Readonly<Record<string, string>>;
|
|
52
|
+
export interface Scene<Dynamic = never> {
|
|
53
|
+
draw(): void;
|
|
54
|
+
draw(dynamic: Dynamic): void;
|
|
55
|
+
reset(): void;
|
|
56
|
+
readonly ready: Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export declare function createScene<Dynamic extends object>(canvas: HTMLCanvasElement, track: Track, layers: readonly Layer[]): Scene<Dynamic>;
|
|
59
|
+
export declare function createScene(canvas: HTMLCanvasElement, engine: Engine, layers: readonly Layer[]): Scene;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const VERTS_PER_QUAD_INDEXED = 4;
|
|
2
|
+
export declare const UINT16_INDEX_QUAD_CAP: number;
|
|
3
|
+
export declare function buildQuadIndices(maxQuads: number): Uint16Array;
|
|
4
|
+
export declare function assertQuadCapacity(pass: string, maxQuads: number, code: string, message: string): void;
|
|
5
|
+
export declare function assertMipmapable(code: string, message: string, what: string, bitmap: TexImageSource): void;
|
|
6
|
+
export declare function quadRangeToIndexRange(startVertex: number, countVertex: number): {
|
|
7
|
+
count: number;
|
|
8
|
+
offset: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function disableAttributes(gl: WebGLRenderingContext, locations: Record<string, number>): void;
|
|
11
|
+
export declare function compileShader(gl: WebGLRenderingContext, type: number, // gl.VERTEX_SHADER or gl.FRAGMENT_SHADER
|
|
12
|
+
source: string): WebGLShader;
|
|
13
|
+
export declare function uploadGridAtlas(gl: WebGLRenderingContext, bitmap: TexImageSource): WebGLTexture;
|
|
14
|
+
export declare function decodeAtlas(url: string): Promise<ImageBitmap>;
|
|
15
|
+
export declare function createProgram(gl: WebGLRenderingContext, vsSource: string, fsSource: string): WebGLProgram;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Attribution
|
|
2
|
+
|
|
3
|
+
This package bundles parts of two projects at build time. Nothing of either runs in a page: the
|
|
4
|
+
bundles below are build-time files of the `moveby` command.
|
|
5
|
+
|
|
6
|
+
## moveby-lang — Apache-2.0
|
|
7
|
+
|
|
8
|
+
The `moveby` command bundles the compiler of moveby-lang, the scene language's compiler, together
|
|
9
|
+
with its `parse-worker.mjs` deep-parse thread. moveby-lang is Apache-2.0; the license text is this
|
|
10
|
+
package's `LICENSE`.
|
|
11
|
+
|
|
12
|
+
## langium — MIT
|
|
13
|
+
|
|
14
|
+
That compiler is built on langium, and the bundle includes it.
|
|
15
|
+
|
|
16
|
+
Copyright 2021 TypeFox GmbH
|
|
17
|
+
|
|
18
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
19
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
20
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
21
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
furnished to do so, subject to the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
25
|
+
substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
28
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
29
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
30
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Design notes
|
|
2
|
+
|
|
3
|
+
Facts the engine's source comments carried, moved out of the shipped code (decision 7: no spec
|
|
4
|
+
references there). The RFCs, contracts, reviews and measurements that decided them live in the
|
|
5
|
+
engine's source tree, not in this package.
|
|
6
|
+
|
|
7
|
+
## A scale of 0 is a legal, deliberate author
|
|
8
|
+
|
|
9
|
+
An object's `scale` of 0 hides the object. The validation rejects a negative or non-finite scale
|
|
10
|
+
only; the emit path skips a 0-scale card instead of drawing a degenerate one, so an author who wants
|
|
11
|
+
an object hidden by default writes `scale = 0` directly rather than a workaround value (settled
|
|
12
|
+
2026-08-05). A label's `height` follows the same rule.
|
|
13
|
+
|
|
14
|
+
## The engine's `.wasm` is measured by brotli
|
|
15
|
+
|
|
16
|
+
The size that matters is the compression a page ships (brotli), never a convenient one: raw and gzip
|
|
17
|
+
disagree with it, and the build-flag verdicts flip with the metric. The sweep that fixed the recipe
|
|
18
|
+
ran on 2026-06-21 with the binaryen v117 that wasm-pack bundles: `wasm-opt -O2` ships a larger raw
|
|
19
|
+
module that brotli compresses better than the default, `opt-level = "z"` made the binary bigger,
|
|
20
|
+
`strip` broke the build, and `codegen-units = 1` was the one safe rustc lever. The measurement table
|
|
21
|
+
is recorded in the engine's source tree.
|
|
22
|
+
|
|
23
|
+
## Section citations
|
|
24
|
+
|
|
25
|
+
The engine's source comments cite its validation rules as `E1–E6` and `O1–O13`, and cite documents
|
|
26
|
+
as `§N`. The documents those sections belong to live in the engine's source tree.
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i7r.tech/moveby",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.21-ywc",
|
|
4
|
+
"description": "A 3D road renderer: a Rust engine compiled to WebAssembly, raw WebGL passes, and a small scene language",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"moveby": "bin/moveby.js"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"bin",
|
|
25
|
+
"docs"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "bun run scripts/build.ts"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@repo/engine-binding": "workspace:*",
|
|
32
|
+
"@repo/moveby-build": "workspace:*",
|
|
33
|
+
"@repo/wasm-engine": "workspace:*"
|
|
34
|
+
}
|
|
35
|
+
}
|