@i7r.tech/moveby 0.0.21-ywc → 0.21.2-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.
@@ -1,9 +1,14 @@
1
1
  export type Rgb = readonly [number, number, number];
2
+ export declare function skyImageRect(horizonRow: number, canvasWidth: number, canvasHeight: number, imageWidth: number, imageHeight: number, share: number, parallax: number): Float32Array;
2
3
  export declare class BackdropPass {
3
4
  private gl;
4
5
  private ground;
5
6
  private sky;
6
- constructor(gl: WebGLRenderingContext, ground: Rgb, sky: Rgb);
7
+ private share;
8
+ private image;
9
+ constructor(gl: WebGLRenderingContext, ground: Rgb, sky: Rgb, share: number);
10
+ setSkyImage(source: TexImageSource, code: string, message: string): void;
7
11
  clearToGround(): void;
8
12
  fillSky(horizonRow: number, width: number, height: number): void;
13
+ drawSkyImage(horizonRow: number, width: number, height: number, parallax: number): void;
9
14
  }
@@ -1,4 +1,5 @@
1
1
  import type { Engine } from "../engine/wasm_engine.js";
2
+ import { type CameraViews } from "../utils.js";
2
3
  export declare const FIELD_ERRORS: {
3
4
  readonly FIELD_RANGE: "A field span has a bad range: 0 ≤ start < end.";
4
5
  readonly FIELD_END: "A field span ends past the end of the track.";
@@ -16,15 +17,17 @@ export declare class FieldPass {
16
17
  private fieldBuffer;
17
18
  private fieldIndexBuffer;
18
19
  private fieldLoc;
20
+ private fieldLocList;
19
21
  private fieldUni;
20
22
  private fieldTextures;
21
23
  private fieldAtlasProgram;
22
24
  private fieldAtlasLoc;
25
+ private fieldAtlasLocList;
23
26
  private fieldAtlasUni;
24
27
  private fieldAtlasCellRectLoc;
25
28
  private fieldAtlas;
26
29
  constructor(gl: WebGLRenderingContext, engine: Engine);
27
30
  setFieldTexture(id: number, bitmap: TexImageSource): void;
28
31
  setFieldAtlas(bitmap: TexImageSource): void;
29
- draw(): void;
32
+ draw(camera: CameraViews): void;
30
33
  }
@@ -1,4 +1,6 @@
1
1
  import type { Engine } from "../engine/wasm_engine.js";
2
+ import { type CameraViews } from "../utils.js";
3
+ import type { Rgb } from "./backdrop.js";
2
4
  export declare const ROAD_ERRORS: {
3
5
  readonly LANE_COUNT: "A lane span's lane count must be from 1 to 8.";
4
6
  readonly LANE_BOUNDS: "A lane span has a bad range: 0 ≤ start < end ≤ track length.";
@@ -7,6 +9,7 @@ export declare const ROAD_ERRORS: {
7
9
  readonly LANE_DASH: "A dashed divider needs dashOn and dashGap above 0.";
8
10
  readonly LANE_COLOR: "A divider colour needs each part from 0 to 1.";
9
11
  readonly ROAD_CAPACITY: "The track has more road quads in one frame than one draw can index.";
12
+ readonly ROAD_ASPHALT: "The asphalt colour needs three parts, each from 0 to 1.";
10
13
  };
11
14
  export declare class RoadPass {
12
15
  private gl;
@@ -15,7 +18,8 @@ export declare class RoadPass {
15
18
  private vertexBuffer;
16
19
  private indexBuffer;
17
20
  private loc;
21
+ private locList;
18
22
  private uni;
19
- constructor(gl: WebGLRenderingContext, engine: Engine);
20
- draw(): void;
23
+ constructor(gl: WebGLRenderingContext, engine: Engine, asphalt: Rgb);
24
+ draw(camera: CameraViews): void;
21
25
  }
@@ -1,4 +1,5 @@
1
1
  import type { Engine } from "../engine/wasm_engine.js";
2
+ import { type CameraViews } from "../utils.js";
2
3
  export declare const SCENERY_ERRORS: {
3
4
  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
5
  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.";
@@ -20,9 +21,10 @@ export declare class SceneryPass {
20
21
  private sceneryBuffer;
21
22
  private sceneryIndexBuffer;
22
23
  private sceneryLoc;
24
+ private sceneryLocList;
23
25
  private sceneryUni;
24
26
  private sceneryTexture;
25
27
  constructor(gl: WebGLRenderingContext, engine: Engine);
26
28
  setSceneryAtlas(bitmap: TexImageSource): void;
27
- draw(): void;
29
+ draw(camera: CameraViews): void;
28
30
  }
@@ -5,6 +5,7 @@ export declare class SkyPass {
5
5
  private vertexBuffer;
6
6
  private indexBuffer;
7
7
  private loc;
8
+ private locList;
8
9
  private uni;
9
10
  constructor(gl: WebGLRenderingContext);
10
11
  draw(engine: Engine, groundRows: number, canvasWidth: number, canvasHeight: number): void;
@@ -18,6 +18,7 @@ export declare class TextPass {
18
18
  private textBuffer;
19
19
  private textIndexBuffer;
20
20
  private textLoc;
21
+ private textLocList;
21
22
  private uColor;
22
23
  private textTexture;
23
24
  constructor(gl: WebGLRenderingContext, engine: Engine);
package/dist/scene.d.ts CHANGED
@@ -8,9 +8,10 @@ export { SCENE_MODULE_ERRORS, asset, loadTrack, trackTypes, type Asset, type Loa
8
8
  export type Layer = {
9
9
  kind: "backdrop";
10
10
  ground: Rgb;
11
- sky: Rgb;
11
+ sky: SkyInput;
12
12
  } | {
13
13
  kind: "road";
14
+ asphalt: Rgb;
14
15
  } | {
15
16
  kind: "field";
16
17
  atlas?: TexImageSource | string;
@@ -24,11 +25,18 @@ export type Layer = {
24
25
  kind: "text";
25
26
  atlas: TexImageSource | string;
26
27
  };
27
- export declare function backdrop({ ground, sky: skyColor, }?: {
28
+ type SkyInput = Rgb | TexImageSource | string | {
29
+ image: TexImageSource | string;
30
+ color?: Rgb;
31
+ share?: number;
32
+ };
33
+ export declare function backdrop({ ground, sky: above, }?: {
28
34
  ground?: Rgb;
29
- sky?: Rgb;
35
+ sky?: SkyInput;
36
+ }): Layer;
37
+ export declare function road({ asphalt }?: {
38
+ asphalt?: Rgb;
30
39
  }): Layer;
31
- export declare function road(): Layer;
32
40
  export declare function field(inputs: {
33
41
  atlas?: TexImageSource | string;
34
42
  textures?: Readonly<Record<number, TexImageSource>>;
@@ -46,7 +54,10 @@ export declare const SCENE_ERRORS: {
46
54
  readonly LAYER_MISSING: "The scene lists a layer that the track does not declare.";
47
55
  readonly WEBGL_UNSUPPORTED: "This browser gave no WebGL context for the canvas.";
48
56
  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.";
57
+ readonly SCENE_ATLAS: "An image the scene names as a URL could not be fetched or decoded.";
58
+ readonly SCENE_IMAGE_SIZE: "An image the scene names is larger than the largest texture of this device.";
59
+ readonly SCENE_IMAGE_MISSING: "The sky of backdrop() is not a colour and holds no image.";
60
+ readonly SCENE_IMAGE_SHARE: "The share of a sky image is a number above 0 and at most 1.";
50
61
  };
51
62
  export declare const ERROR_MESSAGES: Readonly<Record<string, string>>;
52
63
  export interface Scene<Dynamic = never> {
package/dist/utils.d.ts CHANGED
@@ -1,15 +1,26 @@
1
+ import type { Engine } from "./engine/wasm_engine.js";
1
2
  export declare const VERTS_PER_QUAD_INDEXED = 4;
2
3
  export declare const UINT16_INDEX_QUAD_CAP: number;
3
4
  export declare function buildQuadIndices(maxQuads: number): Uint16Array;
4
5
  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;
6
+ export declare function pixelSize(bitmap: TexImageSource): {
7
+ width: number;
8
+ height: number;
9
9
  };
10
- export declare function disableAttributes(gl: WebGLRenderingContext, locations: Record<string, number>): void;
10
+ export declare function assertMipmapable(code: string, message: string, what: string, bitmap: TexImageSource): void;
11
+ export declare function drawQuadRange(gl: WebGLRenderingContext, startVertex: number, countVertex: number): void;
12
+ export declare class CameraViews {
13
+ position: Float32Array;
14
+ forward: Float32Array;
15
+ private readonly memory;
16
+ private readonly address;
17
+ private buffer;
18
+ constructor(engine: Engine);
19
+ current(): CameraViews;
20
+ }
21
+ export declare function disableAttributes(gl: WebGLRenderingContext, locations: readonly number[]): void;
11
22
  export declare function compileShader(gl: WebGLRenderingContext, type: number, // gl.VERTEX_SHADER or gl.FRAGMENT_SHADER
12
23
  source: string): WebGLShader;
13
24
  export declare function uploadGridAtlas(gl: WebGLRenderingContext, bitmap: TexImageSource): WebGLTexture;
14
- export declare function decodeAtlas(url: string): Promise<ImageBitmap>;
25
+ export declare function decodeImage(url: string, premultiplyAlpha: PremultiplyAlpha): Promise<ImageBitmap>;
15
26
  export declare function createProgram(gl: WebGLRenderingContext, vsSource: string, fsSource: string): WebGLProgram;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i7r.tech/moveby",
3
- "version": "0.0.21-ywc",
3
+ "version": "0.21.2-ywc",
4
4
  "description": "A 3D road renderer: a Rust engine compiled to WebAssembly, raw WebGL passes, and a small scene language",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",