rapid-render 0.1.1 → 0.1.2-1.3

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/texture.d.ts CHANGED
@@ -1,12 +1,15 @@
1
- import Rapid from "./render";
2
- import { Images, ITextOptions } from "./interface";
1
+ import { default as Rapid } from './render';
2
+ import { Images, ITextTextureOptions, TextureWrapMode, WebGLContext } from './interface';
3
+ import { Color } from './math';
3
4
  /**
4
5
  * texture manager
6
+ * @ignore
5
7
  */
6
8
  declare class TextureCache {
7
9
  private render;
8
10
  private cache;
9
- constructor(render: Rapid);
11
+ private antialias;
12
+ constructor(render: Rapid, antialias: boolean);
10
13
  /**
11
14
  * create texture from url
12
15
  * Equivalent to {@link Texture.fromUrl} method
@@ -14,9 +17,46 @@ declare class TextureCache {
14
17
  * @param antialias
15
18
  * @returns
16
19
  */
17
- textureFromUrl(url: string, antialias?: boolean): Promise<Texture>;
20
+ textureFromUrl(url: string, antialias?: boolean, wrapMode?: TextureWrapMode): Promise<Texture>;
21
+ /**
22
+ * Create a new `Texture` instance from a FrameBufferObject.
23
+ * @param fbo - The FrameBufferObject to create the texture from.
24
+ * @returns A new `Texture` instance created from the specified FrameBufferObject.
25
+ */
26
+ textureFromFrameBufferObject(fbo: FrameBufferObject): Texture;
27
+ /**
28
+ * Create a new `Texture` instance from an image source.
29
+ * @param source - The image source to create the texture from.
30
+ * @param antialias - Whether to enable antialiasing.
31
+ * @returns A new `Texture` instance created from the specified image source.
32
+ */
33
+ textureFromSource(source: Images, antialias?: boolean, wrapMode?: TextureWrapMode): Texture;
34
+ /**
35
+ * Load an image from the specified URL.
36
+ * @param url - The URL of the image to load.
37
+ * @returns A promise that resolves to the loaded HTMLImageElement.
38
+ */
18
39
  loadImage(url: string): Promise<HTMLImageElement>;
19
- createText(options: ITextOptions): Text;
40
+ /**
41
+ * Create a new `Text` instance.
42
+ * @param options - The options for rendering the text, such as font, size, color, etc.
43
+ * @returns A new `Text` instance.
44
+ */
45
+ createText(options: ITextTextureOptions): Text;
46
+ /**
47
+ * Destroy the texture
48
+ * @param texture
49
+ */
50
+ destroy(texture: Texture | BaseTexture): void;
51
+ /**
52
+ * Create a new FrameBufferObject instance
53
+ * @param width - Width of the framebuffer
54
+ * @param height - Height of the framebuffer
55
+ * @param antialias - Whether to enable antialiasing
56
+ * @returns A new FrameBufferObject instance
57
+ */
58
+ createFrameBufferObject(width: number, height: number, antialias?: boolean): FrameBufferObject;
59
+ private removeCache;
20
60
  }
21
61
  /**
22
62
  * Each {@link Texture} references a baseTexture, and different textures may have the same baseTexture
@@ -25,8 +65,16 @@ declare class BaseTexture {
25
65
  texture: WebGLTexture;
26
66
  width: number;
27
67
  height: number;
28
- constructor(texture: WebGLTexture, width: number, height: number);
29
- static fromImageSource(r: Rapid, image: Images, antialias?: boolean): BaseTexture;
68
+ wrapMode: TextureWrapMode;
69
+ cacheKey: string | Images | null;
70
+ constructor(texture: WebGLTexture, width: number, height: number, wrapMode?: TextureWrapMode);
71
+ static fromImageSource(r: Rapid, image: Images, antialias?: boolean, wrapMode?: TextureWrapMode): BaseTexture;
72
+ /**
73
+ * Destroy the texture
74
+ * @param gl
75
+ * @ignore
76
+ */
77
+ destroy(gl: WebGLContext): void;
30
78
  }
31
79
  declare class Texture {
32
80
  /**
@@ -71,7 +119,7 @@ declare class Texture {
71
119
  * @param base
72
120
  * @param scale
73
121
  */
74
- setBaseTextur(base?: BaseTexture): void;
122
+ setBaseTexture(base?: BaseTexture): void;
75
123
  /**
76
124
  * Sets the region of the texture to be used for rendering.
77
125
  * @param x - The x-coordinate of the top-left corner of the region.
@@ -79,7 +127,7 @@ declare class Texture {
79
127
  * @param w - The width of the region.
80
128
  * @param h - The height of the region.
81
129
  */
82
- setClipRegion(x: number, y: number, w: number, h: number): void;
130
+ setClipRegion(x: number, y: number, w: number, h: number): this | undefined;
83
131
  /**
84
132
  * Creates a new `Texture` instance from the specified image source.
85
133
  * @param rapid - The Rapid instance to use.
@@ -88,31 +136,71 @@ declare class Texture {
88
136
  * @returns A new `Texture` instance created from the image source.
89
137
  */
90
138
  static fromImageSource(rapid: Rapid, image: Images, antialias?: boolean): Texture;
139
+ static fromFrameBufferObject(fbo: FrameBufferObject): Texture;
91
140
  /**
92
- * Creates a new `Texture` instance from the specified URL.
141
+ * Converts the current texture into a spritesheet.
93
142
  * @param rapid - The Rapid instance to use.
94
- * @param url - The URL of the image to create the texture from.
95
- * @returns A new `Texture` instance created from the specified URL.
143
+ * @param spriteWidth - The width of each sprite in the spritesheet.
144
+ * @param spriteHeight - The height of each sprite in the spritesheet.
145
+ * @returns An array of `Texture` instances representing the sprites in the spritesheet.
146
+ */
147
+ createSpritesheet(spriteWidth: number, spriteHeight: number): Texture[];
148
+ /**
149
+ * Clone the current texture
150
+ * @returns A new `Texture` instance with the same base texture reference.
96
151
  */
97
- static fromUrl(rapid: Rapid, url: string): Promise<Texture>;
152
+ clone(): Texture;
98
153
  }
99
- export declare const SCALEFACTOR = 2;
154
+ /**
155
+ * @ignore
156
+ */
157
+ export declare const SCALEFACTOR = 2.5;
100
158
  declare class Text extends Texture {
101
- private options;
102
- private rapid;
159
+ private readonly options;
160
+ private readonly rapid;
103
161
  protected scale: number;
104
162
  text: string;
105
- /**
106
- * Creates a new `Text` instance.
107
- * @param options - The options for rendering the text, such as font, size, color, etc.
108
- */
109
- constructor(rapid: Rapid, options: ITextOptions);
163
+ constructor(rapid: Rapid, options: ITextTextureOptions);
110
164
  private updateTextImage;
111
165
  private createTextCanvas;
112
166
  /**
113
- * Update the displayed text
114
- * @param text
167
+ * Updates the displayed text. Re-renders the texture if the text has changed.
168
+ * @param text - The new text to display.
115
169
  */
116
170
  setText(text: string): void;
117
171
  }
118
- export { Text, Texture, BaseTexture, TextureCache };
172
+ declare class FrameBufferObject extends BaseTexture {
173
+ private framebuffer;
174
+ private gl;
175
+ private readonly stencilBuffer;
176
+ /**
177
+ * Creates a new FrameBufferObject instance
178
+ * @param render - The Rapid instance to use
179
+ * @param width - Width of the framebuffer
180
+ * @param height - Height of the framebuffer
181
+ * @param antialias - Whether to enable antialiasing
182
+ */
183
+ constructor(render: Rapid, width: number, height: number, antialias?: boolean);
184
+ /**
185
+ * Bind the framebuffer for rendering
186
+ * @ignore
187
+ */
188
+ bind(bgColor: Color): void;
189
+ /**
190
+ * Unbind the framebuffer and restore default framebuffer
191
+ * @ignore
192
+ */
193
+ unbind(): void;
194
+ /**
195
+ * Resize the framebuffer
196
+ * @param width - New width
197
+ * @param height - New height
198
+ */
199
+ resize(width: number, height: number): void;
200
+ /**
201
+ * Override destroy method to clean up framebuffer resources
202
+ * @param gl - WebGL context
203
+ */
204
+ destroy(gl: WebGLContext): void;
205
+ }
206
+ export { Text, Texture, BaseTexture, TextureCache, FrameBufferObject };
@@ -0,0 +1,159 @@
1
+ import { default as Rapid } from './render';
2
+ import { IRegisterTileOptions, ILayerRenderOptions, YSortCallback, TilemapShape, ISpriteRenderOptions, IEntityTilemapLayerOptions } from './interface';
3
+ import { Texture } from './texture';
4
+ import { Vec2 } from './math';
5
+ import { Entity, Game } from './game';
6
+ /**
7
+ * Represents a tileset that manages tile textures and their properties.
8
+ */
9
+ export declare class TileSet {
10
+ /** Map storing tile textures and their associated options */
11
+ private textures;
12
+ /** Width of each tile in the tileset */
13
+ width: number;
14
+ /** Height of each tile in the tileset */
15
+ height: number;
16
+ /**
17
+ * Creates a new TileSet instance.
18
+ * @param width - The width of each tile in pixels
19
+ * @param height - The height of each tile in pixels
20
+ */
21
+ constructor(width: number, height: number);
22
+ /**
23
+ * Registers a new tile with the given ID and options.
24
+ * @param id - The unique identifier for the tile
25
+ * @param options - The tile options or texture to register
26
+ */
27
+ setTile(id: string | number, options: IRegisterTileOptions | Texture): void;
28
+ /**
29
+ * Retrieves the registered tile options for the given ID.
30
+ * @param id - The unique identifier of the tile to retrieve
31
+ * @returns The registered tile options, or undefined if not found
32
+ */
33
+ getTile(id: string | number): IRegisterTileOptions | undefined;
34
+ }
35
+ /**
36
+ * Represents a tilemap renderer that handles rendering of tile-based maps.
37
+ */
38
+ export declare class TileMapRender {
39
+ private rapid;
40
+ /**
41
+ * Creates a new TileMapRender instance.
42
+ * @param rapid - The Rapid rendering instance to use.
43
+ */
44
+ constructor(rapid: Rapid);
45
+ /**
46
+ * Calculates the error offset values for tile rendering.
47
+ * @param options - Layer rendering options containing error values.
48
+ * @returns Object containing x and y error offsets.
49
+ * @private
50
+ */
51
+ private getOffset;
52
+ /**
53
+ * Calculates tile rendering data based on the viewport and tileset.
54
+ * @param tileSet - The tileset to use for rendering.
55
+ * @param options - Layer rendering options.
56
+ * @returns Object containing calculated tile rendering data.
57
+ * @private
58
+ */
59
+ private getTileData;
60
+ /**
61
+ * Renders the tilemap layer based on the provided data and options.
62
+ * This method collects all visible tiles and y-sortable objects into a single queue,
63
+ * sorts them once by their y-coordinate, and then renders them in the correct order.
64
+ *
65
+ * @param data - A 2D array representing the tilemap data.
66
+ * @param options - The rendering options for the tilemap layer.
67
+ */
68
+ renderLayer(data: (number | string)[][], options: ILayerRenderOptions): void;
69
+ /**
70
+ * Converts local coordinates to map coordinates.
71
+ * @param local - The local coordinates.
72
+ * @param options - The rendering options.
73
+ * @returns The map coordinates.
74
+ */
75
+ localToMap(local: Vec2, options: ILayerRenderOptions): Vec2;
76
+ /**
77
+ * Converts map coordinates to local coordinates.
78
+ * @param map - The map coordinates.
79
+ * @param options - The rendering options.
80
+ * @returns The local coordinates.
81
+ */
82
+ mapToLocal(map: Vec2, options: ILayerRenderOptions): Vec2;
83
+ }
84
+ /**
85
+ * Tilemap entity for rendering tiled maps.
86
+ */
87
+ export declare class Tilemap extends Entity {
88
+ static readonly DEFAULT_ERROR = 0;
89
+ static readonly EMPTY_TILE = -1;
90
+ error: Vec2;
91
+ shape: TilemapShape;
92
+ tileSet: TileSet;
93
+ data: (number | string)[][];
94
+ eachTile?: (tileId: string | number, mapX: number, mapY: number) => ISpriteRenderOptions | undefined | void;
95
+ ySortCallback: YSortCallback[];
96
+ enableYsort: boolean;
97
+ /**
98
+ * Creates a tilemap entity.
99
+ * @param game - The game instance this tilemap belongs to.
100
+ * @param options - Configuration options for the tilemap.
101
+ */
102
+ constructor(game: Game, options: IEntityTilemapLayerOptions);
103
+ /**
104
+ * Collects renderable entities, excluding children unless they override onRender.
105
+ * @param queue - The array to collect renderable entities.
106
+ */
107
+ collectRenderables(queue: Entity[]): void;
108
+ /**
109
+ * Sets a tile at the specified map coordinates.
110
+ * @param x - The X coordinate (column) on the map.
111
+ * @param y - The Y coordinate (row) on the map.
112
+ * @param tileId - The tile ID to set (number or string).
113
+ * @returns True if the tile was set successfully, false if coordinates are out of bounds.
114
+ */
115
+ setTile(x: number, y: number, tileId: number | string): boolean;
116
+ /**
117
+ * Gets the tile ID at the specified map coordinates.
118
+ * @param x - The X coordinate (column) on the map.
119
+ * @param y - The Y coordinate (row) on the map.
120
+ * @returns The tile ID (number or string) or undefined if coordinates are out of bounds.
121
+ */
122
+ getTile(x: number, y: number): number | string | undefined;
123
+ /**
124
+ * Removes a tile at the specified map coordinates (sets it to EMPTY_TILE).
125
+ * @param x - The X coordinate (column) on the map.
126
+ * @param y - The Y coordinate (row) on the map.
127
+ * @returns True if the tile was removed successfully, false if coordinates are out of bounds.
128
+ */
129
+ removeTile(x: number, y: number): boolean;
130
+ /**
131
+ * Fills a rectangular area with a specified tile ID.
132
+ * @param tileId - The tile ID to use for filling.
133
+ * @param startX - The starting X coordinate.
134
+ * @param startY - The starting Y coordinate.
135
+ * @param width - The width of the fill area.
136
+ * @param height - The height of the fill area.
137
+ */
138
+ fill(tileId: number | string, startX: number, startY: number, width: number, height: number): void;
139
+ /**
140
+ * Replaces the entire tilemap data and updates dimensions.
141
+ * @param newData - The new 2D array of tile data.
142
+ */
143
+ setData(newData: (number | string)[][]): void;
144
+ /**
145
+ * Converts local coordinates to map coordinates.
146
+ * @param local - The local coordinates to convert.
147
+ */
148
+ localToMap(local: Vec2): void;
149
+ /**
150
+ * Converts map coordinates to local coordinates.
151
+ * @param local - The map coordinates to convert.
152
+ */
153
+ mapToLocal(local: Vec2): void;
154
+ /**
155
+ * Renders the tilemap layer.
156
+ * @param render - The rendering engine instance.
157
+ */
158
+ onRender(render: Rapid): void;
159
+ }
@@ -0,0 +1,106 @@
1
+ import { default as EventEmitter } from 'eventemitter3';
2
+ import { IMathObject } from './interface';
3
+ interface TweenrEvents {
4
+ complete: () => void;
5
+ }
6
+ /**
7
+ * Manages the interpolation of a property on a target object over a specific duration.
8
+ * @template T - The type of the value being tweened (e.g., number, Vec2, Color).
9
+ */
10
+ export declare class Tween<T extends IMathObject<T> | number> extends EventEmitter<TweenrEvents> {
11
+ private target;
12
+ private property;
13
+ private to;
14
+ private from;
15
+ private duration;
16
+ private easing;
17
+ private elapsed;
18
+ isRunning: boolean;
19
+ isFinished: boolean;
20
+ /**
21
+ * Creates an instance of Tween.
22
+ * @param target - The object whose property will be animated.
23
+ * @param property - The name of the property to animate.
24
+ * @param to - The target value of the property.
25
+ * @param duration - The duration of the animation in seconds.
26
+ * @param easing - The easing function to use for the animation.
27
+ */
28
+ constructor(target: any, property: string, to: T, duration: number, easing: EasingFunction);
29
+ /**
30
+ * Starts the tween animation.
31
+ * It captures the initial state of the property.
32
+ */
33
+ start(): void;
34
+ /**
35
+ * Updates the tween's state. This should be called every frame.
36
+ * @param deltaTime - The time elapsed since the last frame, in seconds.
37
+ */
38
+ update(deltaTime: number): void;
39
+ }
40
+ export declare const isPlainObject: (obj: any) => boolean;
41
+ /**
42
+ * A type definition for an easing function.
43
+ * It takes a progress ratio (0 to 1) and returns a modified ratio.
44
+ * @param t - The linear progress of the animation, from 0 to 1.
45
+ * @returns The eased progress, typically also from 0 to 1.
46
+ */
47
+ export type EasingFunction = (t: number) => number;
48
+ /**
49
+ * A collection of common easing functions for tweening.
50
+ * Reference: https://easings.net/
51
+ */
52
+ export declare class Easing {
53
+ static Linear: EasingFunction;
54
+ static EaseInQuad: EasingFunction;
55
+ static EaseOutQuad: EasingFunction;
56
+ static EaseInOutQuad: EasingFunction;
57
+ static EaseInCubic: EasingFunction;
58
+ static EaseOutCubic: EasingFunction;
59
+ static EaseInOutCubic: EasingFunction;
60
+ static EaseInQuart: EasingFunction;
61
+ static EaseOutQuart: EasingFunction;
62
+ static EaseInOutQuart: EasingFunction;
63
+ }
64
+ interface TimerEvents {
65
+ timeout: () => void;
66
+ }
67
+ /**
68
+ * Represents a timer that executes a callback after a specified duration.
69
+ * The timer can be set to repeat. It is managed and updated by the Game's main loop.
70
+ */
71
+ export declare class Timer extends EventEmitter<TimerEvents> {
72
+ private duration;
73
+ private repeat;
74
+ private elapsedTime;
75
+ /** Indicates whether the timer is currently active and counting down. */
76
+ isRunning: boolean;
77
+ /** Indicates whether the timer has finished its lifecycle (for non-repeating timers). */
78
+ isFinished: boolean;
79
+ /**
80
+ * Creates an instance of a Timer.
81
+ * @param duration - The duration of the timer in seconds.
82
+ * @param onComplete - The callback function to execute when the timer completes a cycle.
83
+ * @param repeat - Whether the timer should restart automatically after completion. Defaults to false.
84
+ */
85
+ constructor(duration: number, repeat?: boolean);
86
+ /**
87
+ * Starts or resumes the timer.
88
+ */
89
+ start(): void;
90
+ /**
91
+ * Stops (pauses) the timer. It can be resumed with start().
92
+ */
93
+ stop(): void;
94
+ /**
95
+ * Updates the timer's state. This is called by the Game loop every frame.
96
+ * @param deltaTime - The time elapsed since the last frame, in seconds.
97
+ * @internal
98
+ */
99
+ update(deltaTime: number): void;
100
+ /**
101
+ * Immediately stops the timer and marks it as finished, preventing any further execution.
102
+ * This is used for cleanup to avoid memory leaks from stale callbacks.
103
+ */
104
+ destroy(): void;
105
+ }
106
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapid-render",
3
- "version": "0.1.1",
3
+ "version": "0.1.21.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -14,22 +14,30 @@
14
14
  "require": "./dist/rapid.umd.cjs"
15
15
  },
16
16
  "scripts": {
17
- "dev": "rollup -c rollup.config.dev.js -w",
18
- "build": "rollup -c rollup.config.prod.js && tsc",
17
+ "dev": "vite",
18
+ "build": "vite build",
19
19
  "docs": "typedoc"
20
20
  },
21
21
  "devDependencies": {
22
+ "express": "^4.18.2",
22
23
  "rollup": "^4.12.0",
23
24
  "rollup-plugin-dts": "^6.1.0",
24
- "rollup-plugin-server": "^0.7.0",
25
25
  "rollup-plugin-string": "^3.0.0",
26
26
  "rollup-plugin-terser": "^7.0.2",
27
27
  "rollup-plugin-typescript2": "^0.36.0",
28
28
  "tslib": "^2.6.2",
29
- "typedoc": "^0.26.6",
30
- "typescript": "^5.3.3"
29
+ "typedoc-theme-category-nav": "^0.0.3",
30
+ "typescript": "^5.3.3",
31
+ "unplugin-dts": "^1.0.0-beta.0",
32
+ "vite-plugin-dts": "^4.5.4"
31
33
  },
32
34
  "dependencies": {
33
- "typedoc-theme-category-nav": "^0.0.3"
35
+ "@rollup/plugin-commonjs": "^28.0.6",
36
+ "@rollup/plugin-node-resolve": "^16.0.1",
37
+ "concurrently": "^9.1.2",
38
+ "eventemitter3": "^5.0.1",
39
+ "typedoc": "^0.28.3",
40
+ "vite": "^7.1.2",
41
+ "vite-plugin-string": "^1.2.3"
34
42
  }
35
43
  }
@@ -1,28 +0,0 @@
1
- import { Rapid } from "..";
2
- import RenderRegion from "./region";
3
- declare class GraphicRegion extends RenderRegion {
4
- private vertex;
5
- drawType: number;
6
- constructor(rapid: Rapid);
7
- startRender(): void;
8
- addVertex(x: number, y: number, color: number): void;
9
- drawCircle(x: number, y: number, radius: number, color: number): void;
10
- protected executeRender(): void;
11
- }
12
- declare const graphicAttributes: ({
13
- name: string;
14
- size: number;
15
- type: number;
16
- stride: number;
17
- offset?: undefined;
18
- normalized?: undefined;
19
- } | {
20
- name: string;
21
- size: number;
22
- type: number;
23
- stride: number;
24
- offset: number;
25
- normalized: boolean;
26
- })[];
27
- export { graphicAttributes };
28
- export default GraphicRegion;
@@ -1,25 +0,0 @@
1
- import { IAttribute, WebGLContext } from "../interface";
2
- import { WebglBufferArray } from "../math";
3
- import Rapid from "../render";
4
- import GLShader from "../webgl/glshader";
5
- declare class RenderRegion {
6
- currentShader?: GLShader;
7
- protected defaultShader: GLShader;
8
- protected attribute: IAttribute[];
9
- protected webglArrayBuffer: WebglBufferArray;
10
- protected rapid: Rapid;
11
- protected gl: WebGLContext;
12
- protected usedTextures: WebGLTexture[];
13
- protected readonly TEXTURE_UNITS_ARRAY: number[];
14
- protected needBind: Set<number>;
15
- constructor(rapid: Rapid, attributes?: IAttribute[]);
16
- protected addVertex(x: number, y: number, ..._: unknown[]): void;
17
- protected useTexture(texture: WebGLTexture): number;
18
- enterRegion(customShader?: GLShader): void;
19
- exitRegion(): void;
20
- protected initDefaultShader(vs: string, fs: string): void;
21
- render(): void;
22
- protected executeRender(): void;
23
- protected initializeForNextRender(): void;
24
- }
25
- export default RenderRegion;
@@ -1,39 +0,0 @@
1
- import RenderRegion from "./region";
2
- import Rapid from "../render";
3
- import { UniformType } from "../interface";
4
- import GLShader from "../webgl/glshader";
5
- declare class SpriteRegion extends RenderRegion {
6
- private batchSprite;
7
- private indexBuffer;
8
- protected readonly MAX_BATCH: number;
9
- constructor(rapid: Rapid);
10
- protected addVertex(x: number, y: number, u: number, v: number, textureUnit: number, color: number): void;
11
- renderSprite(texture: WebGLTexture, width: number, height: number, u0: number, v0: number, u1: number, v1: number, offsetX: number, offsetY: number, color: number, uniforms?: UniformType): void;
12
- protected executeRender(): void;
13
- enterRegion(customShader?: GLShader | undefined): void;
14
- protected initializeForNextRender(): void;
15
- }
16
- declare const spriteAttributes: ({
17
- name: string;
18
- size: number;
19
- type: number;
20
- stride: number;
21
- offset?: undefined;
22
- normalized?: undefined;
23
- } | {
24
- name: string;
25
- size: number;
26
- type: number;
27
- stride: number;
28
- offset: number;
29
- normalized?: undefined;
30
- } | {
31
- name: string;
32
- size: number;
33
- type: number;
34
- stride: number;
35
- offset: number;
36
- normalized: boolean;
37
- })[];
38
- export { spriteAttributes };
39
- export default SpriteRegion;
@@ -1,27 +0,0 @@
1
- import { IAttribute, UniformType } from "../interface";
2
- import Rapid from "../render";
3
- declare class GLShader {
4
- attributeLoc: Record<string, number>;
5
- uniformLoc: Record<string, WebGLUniformLocation>;
6
- program: WebGLProgram;
7
- private gl;
8
- constructor(rapid: Rapid, vs: string, fs: string);
9
- /**
10
- * Set the uniform of this shader
11
- * @param uniforms
12
- * @param usedTextureUnit How many texture units have been used
13
- */
14
- setUniforms(uniforms: UniformType, usedTextureUnit: number): void;
15
- private getUniform;
16
- /**
17
- * use this shader
18
- */
19
- use(): void;
20
- private parseShader;
21
- /**
22
- * Set vertex attributes in glsl shader
23
- * @param element
24
- */
25
- setAttribute(element: IAttribute): void;
26
- }
27
- export default GLShader;
@@ -1,27 +0,0 @@
1
- import { WebGLContext } from "../interface";
2
- /**
3
- * get webgl rendering context
4
- * @param canvas
5
- * @returns webgl1 or webgl2
6
- */
7
- export declare const getContext: (canvas: HTMLCanvasElement) => WebGLContext;
8
- /**
9
- * compile string to webgl shader
10
- * @param gl
11
- * @param source
12
- * @param type
13
- * @returns
14
- */
15
- export declare const compileShader: (gl: WebGLContext, source: string, type: number) => WebGLShader;
16
- /**
17
- * create webgl program by shader string
18
- * @param gl
19
- * @param vsSource
20
- * @param fsSource
21
- * @returns
22
- */
23
- export declare const createShaderProgram: (gl: WebGLContext, vsSource: string, fsSource: string) => WebGLProgram;
24
- export declare function createTexture(gl: WebGLRenderingContext, image: TexImageSource, antialias: boolean): WebGLTexture;
25
- export declare function generateFragShader(fs: string, max: number): string;
26
- export declare const FLOAT = 5126;
27
- export declare const UNSIGNED_BYTE = 5121;