rapid-render 0.1.2 → 0.1.4

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/dist/tilemap.d.ts CHANGED
@@ -1,24 +1,97 @@
1
- import { TilemapOptions } from "./interface";
2
1
  import Rapid from "./render";
2
+ import { IRegisterTileOptions, ILayerRender } from "./interface";
3
3
  import { Texture } from "./texture";
4
- export declare class Tileset {
4
+ import { Vec2 } from "./math";
5
+ /**
6
+ * Represents a tileset that manages tile textures and their properties.
7
+ */
8
+ export declare class TileSet {
9
+ /** Map storing tile textures and their associated options */
5
10
  private textures;
6
- constructor(textures: Texture[]);
7
- getTexture(index: number): Texture | null;
11
+ /** Width of each tile in the tileset */
12
+ width: number;
13
+ /** Height of each tile in the tileset */
14
+ height: number;
15
+ /**
16
+ * Creates a new TileSet instance.
17
+ * @param width - The width of each tile in pixels
18
+ * @param height - The height of each tile in pixels
19
+ */
20
+ constructor(width: number, height: number);
21
+ /**
22
+ * Registers a new tile with the given ID and options.
23
+ * @param id - The unique identifier for the tile
24
+ * @param options - The tile options or texture to register
25
+ */
26
+ setTile(id: string | number, options: IRegisterTileOptions | Texture): void;
27
+ /**
28
+ * Retrieves the registered tile options for the given ID.
29
+ * @param id - The unique identifier of the tile to retrieve
30
+ * @returns The registered tile options, or undefined if not found
31
+ */
32
+ getTile(id: string | number): IRegisterTileOptions | undefined;
8
33
  }
9
- declare class Tilemap {
10
- private tileset;
11
- private tileIndices;
12
- private tileWidth;
13
- private tileHeight;
14
- private columns;
15
- private rows;
16
- private type;
17
- constructor(options: TilemapOptions);
18
- getTileIndex(x: number, y: number): number | null;
19
- render(rapid: Rapid, offsetX?: number, offsetY?: number): void;
20
- private renderOrthogonal;
21
- private renderHex;
22
- private renderIsometric;
34
+ /**
35
+ * Represents a tilemap renderer that handles rendering of tile-based maps.
36
+ */
37
+ export declare class TileMapRender {
38
+ private rapid;
39
+ /**
40
+ * Creates a new TileMapRender instance.
41
+ * @param rapid - The Rapid rendering instance to use.
42
+ */
43
+ constructor(rapid: Rapid);
44
+ /**
45
+ * Gets the y-sorted rows for rendering entities at specific y positions.
46
+ * @param ySortRow - Array of y-sort callbacks to process.
47
+ * @param height - Height of each tile.
48
+ * @param renderRow - Number of rows to render.
49
+ * @returns Array of y-sort callbacks grouped by row.
50
+ * @private
51
+ */
52
+ private getYSortRow;
53
+ /**
54
+ * Calculates the error offset values for tile rendering.
55
+ * @param options - Layer rendering options containing error values.
56
+ * @returns Object containing x and y error offsets.
57
+ * @private
58
+ */
59
+ private getOffset;
60
+ /**
61
+ * Calculates tile rendering data based on the viewport and tileset.
62
+ * @param tileSet - The tileset to use for rendering.
63
+ * @param options - Layer rendering options.
64
+ * @returns Object containing calculated tile rendering data.
65
+ * @private
66
+ */
67
+ private getTileData;
68
+ /**
69
+ * Renders a row of y-sorted entities.
70
+ * @param rapid - The Rapid rendering instance.
71
+ * @param ySortRow - Array of y-sort callbacks to render.
72
+ * @private
73
+ */
74
+ private renderYSortRow;
75
+ /**
76
+ * Renders the tilemap layer based on the provided data and options.
77
+ *
78
+ * @param data - A 2D array representing the tilemap data.
79
+ * @param options - The rendering options for the tilemap layer.
80
+ * @returns
81
+ */
82
+ renderLayer(data: (number | string)[][], options: ILayerRender): void;
83
+ /**
84
+ * Converts local coordinates to map coordinates.
85
+ * @param local - The local coordinates.
86
+ * @param options - The rendering options.
87
+ * @returns The map coordinates.
88
+ */
89
+ localToMap(local: Vec2, options: ILayerRender): Vec2;
90
+ /**
91
+ * Converts map coordinates to local coordinates.
92
+ * @param map - The map coordinates.
93
+ * @param options - The rendering options.
94
+ * @returns The local coordinates.
95
+ */
96
+ mapToLocal(map: Vec2, options: ILayerRender): Vec2;
23
97
  }
24
- export default Tilemap;
@@ -0,0 +1 @@
1
+ export declare const getSize: (obj: any) => number;
@@ -1,17 +1,20 @@
1
- import { IAttribute, UniformType } from "../interface";
1
+ import { IAttribute, ShaderType } from "../interface";
2
2
  import Rapid from "../render";
3
+ import { Uniform } from "./uniform";
3
4
  declare class GLShader {
4
5
  attributeLoc: Record<string, number>;
5
6
  uniformLoc: Record<string, WebGLUniformLocation>;
6
7
  program: WebGLProgram;
8
+ private attributes;
7
9
  private gl;
8
- constructor(rapid: Rapid, vs: string, fs: string);
10
+ usedTexture: number;
11
+ constructor(rapid: Rapid, vs: string, fs: string, attributes?: IAttribute[], usedTexture?: number);
9
12
  /**
10
13
  * Set the uniform of this shader
11
14
  * @param uniforms
12
15
  * @param usedTextureUnit How many texture units have been used
13
16
  */
14
- setUniforms(uniforms: UniformType, usedTextureUnit: number): void;
17
+ setUniforms(uniform: Uniform, usedTextureUnit: number): number;
15
18
  private getUniform;
16
19
  /**
17
20
  * use this shader
@@ -19,9 +22,16 @@ declare class GLShader {
19
22
  use(): void;
20
23
  private parseShader;
21
24
  /**
22
- * Set vertex attributes in glsl shader
25
+ * Set vertex attribute in glsl shader
23
26
  * @param element
24
27
  */
25
28
  setAttribute(element: IAttribute): void;
29
+ /**
30
+ * Set vertex attributes in glsl shader
31
+ * @param elements
32
+ */
33
+ setAttributes(elements: IAttribute[]): void;
34
+ updateAttributes(): void;
35
+ static createCostumShader(rapid: Rapid, vs: string, fs: string, type: ShaderType, usedTexture?: number): GLShader;
26
36
  }
27
37
  export default GLShader;
@@ -0,0 +1,13 @@
1
+ import { UniformType, WebGLContext } from '../interface';
2
+ export declare class Uniform {
3
+ private data;
4
+ isDirty: boolean;
5
+ constructor(data: UniformType);
6
+ setUniform(key: string, data: UniformType[string]): void;
7
+ /**
8
+ * @ignore
9
+ */
10
+ clearDirty(): void;
11
+ getUnifromNames(): string[];
12
+ bind(gl: WebGLContext, uniformName: string, loc: WebGLUniformLocation, usedTextureUnit: number): number;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapid-render",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"