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/README.md +36 -100
- package/dist/depth.d.ts +8 -0
- package/dist/index.d.ts +4 -3
- package/dist/interface.d.ts +83 -34
- package/dist/line.d.ts +8 -1
- package/dist/log.d.ts +2 -0
- package/dist/math.d.ts +218 -44
- package/dist/rapid.global.js +1 -1
- package/dist/rapid.js +2453 -1
- package/dist/rapid.umd.cjs +1 -1
- package/dist/regions/attributes.d.ts +44 -0
- package/dist/regions/graphic_region.d.ts +5 -25
- package/dist/regions/region.d.ts +12 -5
- package/dist/regions/sprite_region.d.ts +2 -26
- package/dist/render.d.ts +91 -49
- package/dist/texture.d.ts +30 -2
- package/dist/tilemap.d.ts +92 -19
- package/dist/utils.d.ts +1 -0
- package/dist/webgl/glshader.d.ts +14 -4
- package/dist/webgl/uniform.d.ts +13 -0
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSize: (obj: any) => number;
|
package/dist/webgl/glshader.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { IAttribute,
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
+
}
|