rapid-render 0.1.21 → 1.0.0
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 +2 -2
- package/README.md +70 -82
- package/dist/buffer.d.ts +153 -0
- package/dist/color.d.ts +144 -0
- package/dist/draw.d.ts +53 -0
- package/dist/index.d.ts +12 -15
- package/dist/line.d.ts +17 -3
- package/dist/math.d.ts +17 -492
- package/dist/matrix-engine.d.ts +360 -0
- package/dist/particle.d.ts +146 -36
- package/dist/rapid-render.js +3258 -0
- package/dist/rapid-render.umd.cjs +268 -0
- package/dist/region/atlasSpriteRegion.d.ts +9 -0
- package/dist/region/graphicRegion.d.ts +40 -0
- package/dist/region/region.d.ts +42 -0
- package/dist/region/spriteRegion.d.ts +33 -0
- package/dist/render.d.ts +342 -205
- package/dist/texture.d.ts +219 -152
- package/dist/utils.d.ts +28 -25
- package/dist/vite.svg +1 -0
- package/dist/webgl/glshader.d.ts +107 -25
- package/dist/webgl/utils.d.ts +18 -8
- package/package.json +36 -38
- package/dist/depth.d.ts +0 -8
- package/dist/input.d.ts +0 -60
- package/dist/interface.d.ts +0 -334
- package/dist/light.d.ts +0 -7
- package/dist/log.d.ts +0 -2
- package/dist/rapid.global.js +0 -1
- package/dist/rapid.js +0 -1
- package/dist/rapid.umd.cjs +0 -1
- package/dist/regions/attributes.d.ts +0 -44
- package/dist/regions/graphic_region.d.ts +0 -15
- package/dist/regions/region.d.ts +0 -41
- package/dist/regions/sprite_region.d.ts +0 -18
- package/dist/tilemap.d.ts +0 -98
- package/dist/webgl/uniform.d.ts +0 -14
package/dist/webgl/glshader.d.ts
CHANGED
|
@@ -1,38 +1,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Rapid from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Region } from '../region/region';
|
|
2
|
+
import { Rapid } from '../render';
|
|
3
|
+
export type WebGLContext = WebGL2RenderingContext;
|
|
4
|
+
export interface IAttribute {
|
|
5
|
+
name: string;
|
|
6
|
+
size: number;
|
|
7
|
+
type?: number;
|
|
8
|
+
normalized?: boolean;
|
|
9
|
+
stride: number;
|
|
10
|
+
offset?: number;
|
|
11
|
+
/** 0 = per-vertex (default), 1 = per-instance */
|
|
12
|
+
divisor?: number;
|
|
13
|
+
}
|
|
14
|
+
/** All value types accepted by setUniform / setUniforms */
|
|
15
|
+
export type UniformValue = number | [number, number] | [number, number, number] | [number, number, number, number] | Float32Array | number[] | Int32Array;
|
|
16
|
+
/**
|
|
17
|
+
* Wraps a WebGL shader program.
|
|
18
|
+
* Parses attribute/uniform locations and types from GLSL source automatically.
|
|
19
|
+
*/
|
|
20
|
+
export declare class GLShader {
|
|
21
|
+
program: WebGLProgram;
|
|
6
22
|
attributeLoc: Record<string, number>;
|
|
7
23
|
uniformLoc: Record<string, WebGLUniformLocation>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
isCustom: boolean;
|
|
25
|
+
/** Padding in pixels this shader needs beyond the sprite bounds (for outline/glow effects) */
|
|
26
|
+
padding: number;
|
|
27
|
+
/** GLSL type for each uniform, parsed from source */
|
|
28
|
+
private uniformType;
|
|
29
|
+
/** Whether the uniform is an array (e.g. sampler2D uTextures[8]) */
|
|
30
|
+
private uniformIsArray;
|
|
11
31
|
private gl;
|
|
12
|
-
|
|
32
|
+
shaderId: number;
|
|
33
|
+
readonly vao: WebGLVertexArrayObject;
|
|
34
|
+
constructor(gl: WebGLContext, vs: string, fs: string, attributes?: IAttribute[]);
|
|
35
|
+
/** Switch GPU to use this shader program */
|
|
36
|
+
use(): void;
|
|
37
|
+
/** Bind this shader's VAO (start recording or replaying attribute state) */
|
|
38
|
+
bindVAO(): void;
|
|
39
|
+
/** Unbind VAO (finish recording) */
|
|
40
|
+
unbindVAO(): void;
|
|
13
41
|
/**
|
|
14
|
-
* Set
|
|
15
|
-
* @
|
|
16
|
-
*
|
|
42
|
+
* Set a single uniform by name. Type is inferred from the parsed GLSL source.
|
|
43
|
+
* @example
|
|
44
|
+
* shader.setUniform("uTime", 1.5);
|
|
45
|
+
* shader.setUniform("uColor", [1, 0, 0, 1]);
|
|
46
|
+
* shader.setUniform("uMVP", mat4array);
|
|
17
47
|
*/
|
|
18
|
-
|
|
19
|
-
private getUniform;
|
|
48
|
+
setUniform(name: string, value: UniformValue): void;
|
|
20
49
|
/**
|
|
21
|
-
*
|
|
50
|
+
* Batch-set uniforms via a plain value map.
|
|
51
|
+
* @example
|
|
52
|
+
* shader.setUniforms({
|
|
53
|
+
* uTime: 1.5,
|
|
54
|
+
* uResolution: [800, 600],
|
|
55
|
+
* uMVP: mat4,
|
|
56
|
+
* });
|
|
22
57
|
*/
|
|
23
|
-
|
|
58
|
+
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
59
|
+
/**
|
|
60
|
+
* Bind a single vertex attribute pointer.
|
|
61
|
+
* The VBO must already be bound before calling this.
|
|
62
|
+
*/
|
|
63
|
+
setAttribute(attr: IAttribute): void;
|
|
64
|
+
/** Bind all vertex attribute pointers at once */
|
|
65
|
+
setAttributes(attrs: IAttribute[]): void;
|
|
66
|
+
/** Free GPU resources */
|
|
67
|
+
destroy(): void;
|
|
68
|
+
/** Parse attribute/uniform names and GLSL types from raw shader source */
|
|
24
69
|
private parseShader;
|
|
70
|
+
}
|
|
71
|
+
export default GLShader;
|
|
72
|
+
/**
|
|
73
|
+
* A wrapper for creating and managing custom shaders across multiple rendering regions.
|
|
74
|
+
*/
|
|
75
|
+
export declare class CustomGlShader {
|
|
76
|
+
/** Custom vertex shader code */
|
|
77
|
+
vs: string;
|
|
78
|
+
/** Custom fragment shader code */
|
|
79
|
+
fs: string;
|
|
80
|
+
/** Map of compiled GLShader instances per region key */
|
|
81
|
+
glshader: Map<string, GLShader>;
|
|
82
|
+
/** Currently stored uniform values */
|
|
83
|
+
uniforms: Record<string, UniformValue>;
|
|
84
|
+
/** Set of region keys that need uniform updates */
|
|
85
|
+
uniformDirty: Set<string>;
|
|
86
|
+
/** Map of textures to be bound to this shader */
|
|
87
|
+
uniformTextures: Record<string, WebGLTexture>;
|
|
88
|
+
/** Number of texture units reserved by this custom shader */
|
|
89
|
+
usedTextureUnitNum: number;
|
|
90
|
+
/** Padding in pixels this shader needs beyond the sprite bounds (for outline/glow effects) */
|
|
91
|
+
padding: number;
|
|
92
|
+
rapid: Rapid;
|
|
93
|
+
constructor(rapid: Rapid, vs: string, fs: string, usedTextureUnitNum?: number, uniforms?: Record<string, UniformValue>);
|
|
94
|
+
/**
|
|
95
|
+
* Updates uniform values or textures for the custom shader.
|
|
96
|
+
* @param uniforms Map of uniform values or WebGL textures to apply.
|
|
97
|
+
*/
|
|
98
|
+
setUniforms(uniforms: Record<string, UniformValue | WebGLTexture>): void;
|
|
25
99
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
100
|
+
* Sets the padding (in pixels) for this shader and propagates to all compiled GLShaders.
|
|
101
|
+
* Must be called before the first draw call if set after construction.
|
|
102
|
+
* @param pixels - Number of pixels to expand the quad on each side.
|
|
28
103
|
*/
|
|
29
|
-
|
|
104
|
+
setPadding(pixels: number): this;
|
|
30
105
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @param
|
|
106
|
+
* Applies current uniforms and texture unit mappings to the region-specific shader.
|
|
107
|
+
* @param key The region key.
|
|
108
|
+
* @param textureUniforms Map of texture uniform names to assigned texture unit indices.
|
|
33
109
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
110
|
+
applyUniform(key: string, textureUniforms: Record<string, number>): void;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves or compiles a customized GLShader for a specific region.
|
|
113
|
+
* @param region The Region requesting the shader.
|
|
114
|
+
* @param key The region key.
|
|
115
|
+
* @param baseVS The base vertex shader template.
|
|
116
|
+
* @param baseFS The base fragment shader template.
|
|
117
|
+
* @returns The combined and compiled GLShader.
|
|
118
|
+
*/
|
|
119
|
+
getGLShader(region: Region, key: string, baseVS?: string, baseFS?: string): GLShader | null;
|
|
37
120
|
}
|
|
38
|
-
export default GLShader;
|
package/dist/webgl/utils.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Rapid, TextureFilterMode } from '../render';
|
|
2
|
+
import { ITextOptions, TextureWrapMode } from '../texture';
|
|
3
|
+
export type WebGLContext = WebGL2RenderingContext;
|
|
4
|
+
export declare const supportsWebGL: (canvas: HTMLCanvasElement) => boolean;
|
|
2
5
|
/**
|
|
3
|
-
* get
|
|
6
|
+
* get webgl2 rendering context
|
|
4
7
|
* @param canvas
|
|
5
|
-
* @returns
|
|
8
|
+
* @returns webgl2
|
|
6
9
|
*/
|
|
7
|
-
export declare const getContext: (canvas: HTMLCanvasElement) => WebGLContext;
|
|
10
|
+
export declare const getContext: (canvas: HTMLCanvasElement, antialias?: boolean, premultipliedAlpha?: boolean) => WebGLContext;
|
|
8
11
|
/**
|
|
9
12
|
* compile string to webgl shader
|
|
10
13
|
* @param gl
|
|
@@ -21,17 +24,24 @@ export declare const compileShader: (gl: WebGLContext, source: string, type: num
|
|
|
21
24
|
* @returns
|
|
22
25
|
*/
|
|
23
26
|
export declare const createShaderProgram: (gl: WebGLContext, vsSource: string, fsSource: string) => WebGLProgram;
|
|
27
|
+
export declare function setTextureWrapMode(gl: WebGLRenderingContext | WebGL2RenderingContext, wrapMode: TextureWrapMode): void;
|
|
28
|
+
export declare function setTextureFilterMode(gl: WebGLRenderingContext | WebGL2RenderingContext, filterMode: TextureFilterMode): void;
|
|
29
|
+
export interface ICreateTextureOptions extends ITextOptions {
|
|
30
|
+
onlySize?: boolean;
|
|
31
|
+
}
|
|
24
32
|
/**
|
|
25
33
|
* Creates a WebGL texture either from an image source or as a blank texture
|
|
26
34
|
* @param gl - The WebGL rendering context
|
|
27
35
|
* @param source - The image source or dimensions for a blank texture
|
|
28
|
-
* @param
|
|
36
|
+
* @param filterMode - texture filter mode
|
|
29
37
|
* @returns A WebGL texture
|
|
30
38
|
*/
|
|
31
|
-
export declare function createTexture(
|
|
39
|
+
export declare function createTexture(render: Rapid, source: TexImageSource | {
|
|
32
40
|
width: number;
|
|
33
41
|
height: number;
|
|
34
|
-
},
|
|
35
|
-
export declare function
|
|
42
|
+
}, options: ICreateTextureOptions): WebGLTexture;
|
|
43
|
+
export declare function generateShader(fs: string, max: number): string;
|
|
36
44
|
export declare const FLOAT = 5126;
|
|
37
45
|
export declare const UNSIGNED_BYTE = 5121;
|
|
46
|
+
export declare function vertexAttribDivisor(gl: WebGLContext, index: number, divisor: number): void;
|
|
47
|
+
export declare function drawArraysInstanced(gl: WebGLContext, mode: number, first: number, count: number, instanceCount: number): void;
|
package/package.json
CHANGED
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rapid-render",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"dev": "
|
|
20
|
-
"build": "
|
|
21
|
-
"docs": "typedoc"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "rapid-render",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"index.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/rapid.umd.cjs",
|
|
11
|
+
"module": "./dist/rapid.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/rapid.js",
|
|
16
|
+
"require": "./dist/rapid.umd.cjs"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "tsc && vite build",
|
|
21
|
+
"docs": "typedoc",
|
|
22
|
+
"example:dev": "vite --config example/vite.config.ts",
|
|
23
|
+
"example:build": "vite build --config example/vite.config.ts"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"typedoc": "^0.28.17",
|
|
27
|
+
"typescript": "~5.9.3",
|
|
28
|
+
"vite": "^7.3.1"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@types/stats.js": "^0.17.4",
|
|
32
|
+
"highlight.js": "^11.11.1",
|
|
33
|
+
"stats.js": "^0.17.0",
|
|
34
|
+
"vite-plugin-dts": "^4.5.4"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/depth.d.ts
DELETED
package/dist/input.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Vec2 } from "./math";
|
|
2
|
-
import Rapid from "./render";
|
|
3
|
-
import { Entity } from "./utils";
|
|
4
|
-
export declare class InputManager {
|
|
5
|
-
rapid: Rapid;
|
|
6
|
-
canvas: HTMLCanvasElement;
|
|
7
|
-
mousePosition: Vec2;
|
|
8
|
-
private keysDown;
|
|
9
|
-
private keysDownLastFrame;
|
|
10
|
-
private buttonsDown;
|
|
11
|
-
private buttonsDownLastFrame;
|
|
12
|
-
constructor(rapid: Rapid);
|
|
13
|
-
/**
|
|
14
|
-
* 附加所有必要的事件监听器
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
private attachEventListeners;
|
|
18
|
-
updateNextFrame(): void;
|
|
19
|
-
/**
|
|
20
|
-
* 检查某个按键当前是否被按下 (持续检测)
|
|
21
|
-
* @param key `event.code` 的值, e.g., "KeyW", "Space"
|
|
22
|
-
*/
|
|
23
|
-
isKeyDown(key: string): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* 检查某个按键当前是否是松开状态
|
|
26
|
-
* @param key `event.code` 的值
|
|
27
|
-
*/
|
|
28
|
-
isKeyUp(key: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 检查某个按键是否在当前帧“刚刚被按下” (单次触发)
|
|
31
|
-
* @param key `event.code` 的值
|
|
32
|
-
*/
|
|
33
|
-
wasKeyPressed(key: string): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* 检查某个按键是否在当前帧“刚刚被松开” (单次触发)
|
|
36
|
-
* @param key `event.code` 的值
|
|
37
|
-
*/
|
|
38
|
-
wasKeyReleased(key: string): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* 检查某个鼠标按钮当前是否被按下 (持续检测)
|
|
41
|
-
* @param button 鼠标按钮编号
|
|
42
|
-
*/
|
|
43
|
-
isButtonDown(button: number): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* 检查某个鼠标按钮当前是否是松开状态
|
|
46
|
-
* @param button 鼠标按钮编号
|
|
47
|
-
*/
|
|
48
|
-
isButtonUp(button: number): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* 检查某个鼠标按钮是否在当前帧“刚刚被按下” (单次触发)
|
|
51
|
-
* @param button 鼠标按钮编号
|
|
52
|
-
*/
|
|
53
|
-
wasButtonPressed(button: number): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* 检查某个鼠标按钮是否在当前帧“刚刚被松开” (单次触发)
|
|
56
|
-
* @param button 鼠标按钮编号
|
|
57
|
-
*/
|
|
58
|
-
wasButtonReleased(button: number): boolean;
|
|
59
|
-
getMouseLocal(entity: Entity): Vec2;
|
|
60
|
-
}
|
package/dist/interface.d.ts
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import { Color, Vec2 } from "./math";
|
|
2
|
-
import { Texture } from "./texture";
|
|
3
|
-
import { TileSet } from "./tilemap";
|
|
4
|
-
import GLShader from "./webgl/glshader";
|
|
5
|
-
import { Uniform } from "./webgl/uniform";
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
export type WebGLContext = WebGL2RenderingContext | WebGLRenderingContext;
|
|
10
|
-
/**
|
|
11
|
-
* @ignore
|
|
12
|
-
*/
|
|
13
|
-
export interface IMathStruct<T> {
|
|
14
|
-
clone(obj: T): T;
|
|
15
|
-
copy(obj: T): void;
|
|
16
|
-
equal(obj: T): boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare enum ScaleRadio {
|
|
19
|
-
KEEP = "keep",
|
|
20
|
-
KEEP_H = "keep_h",
|
|
21
|
-
KEEP_W = "keep_w",
|
|
22
|
-
IGNORE = "ignore",
|
|
23
|
-
EXPAND = "expand"
|
|
24
|
-
}
|
|
25
|
-
export interface IRapidOptions {
|
|
26
|
-
canvas: HTMLCanvasElement;
|
|
27
|
-
width?: number;
|
|
28
|
-
height?: number;
|
|
29
|
-
backgroundColor?: Color;
|
|
30
|
-
antialias?: boolean;
|
|
31
|
-
devicePixelRatio?: number;
|
|
32
|
-
scaleEnable?: boolean;
|
|
33
|
-
scaleRadio?: ScaleRadio;
|
|
34
|
-
}
|
|
35
|
-
export interface IAttribute {
|
|
36
|
-
name: string;
|
|
37
|
-
size: number;
|
|
38
|
-
type: number;
|
|
39
|
-
normalized?: boolean;
|
|
40
|
-
stride: number;
|
|
41
|
-
offset?: number;
|
|
42
|
-
}
|
|
43
|
-
export interface IEntityTransformOptions {
|
|
44
|
-
position?: Vec2;
|
|
45
|
-
scale?: Vec2 | number;
|
|
46
|
-
rotation?: number;
|
|
47
|
-
x?: number;
|
|
48
|
-
y?: number;
|
|
49
|
-
tags: string[];
|
|
50
|
-
}
|
|
51
|
-
export interface ITransformOptions {
|
|
52
|
-
restoreTransform?: boolean;
|
|
53
|
-
saveTransform?: boolean;
|
|
54
|
-
position?: Vec2;
|
|
55
|
-
scale?: Vec2 | number;
|
|
56
|
-
rotation?: number;
|
|
57
|
-
x?: number;
|
|
58
|
-
y?: number;
|
|
59
|
-
offset?: Vec2;
|
|
60
|
-
offsetX?: number;
|
|
61
|
-
offsetY?: number;
|
|
62
|
-
origin?: Vec2 | number;
|
|
63
|
-
afterSave?(): unknown;
|
|
64
|
-
beforRestore?(): unknown;
|
|
65
|
-
}
|
|
66
|
-
export interface ISpriteRenderOptions extends ITransformOptions, IShaderRenderOptions {
|
|
67
|
-
color?: Color;
|
|
68
|
-
texture?: Texture;
|
|
69
|
-
offset?: Vec2;
|
|
70
|
-
flipX?: boolean;
|
|
71
|
-
flipY?: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface ITextTextureOptions {
|
|
74
|
-
/**
|
|
75
|
-
* The text string to be rendered.
|
|
76
|
-
*/
|
|
77
|
-
text?: string;
|
|
78
|
-
/**
|
|
79
|
-
* The font size for the text.
|
|
80
|
-
* Default is 16.
|
|
81
|
-
*/
|
|
82
|
-
fontSize?: number;
|
|
83
|
-
/**
|
|
84
|
-
* The font family for the text.
|
|
85
|
-
* Default is 'Arial'.
|
|
86
|
-
*/
|
|
87
|
-
fontFamily?: string;
|
|
88
|
-
/**
|
|
89
|
-
* The color of the text.
|
|
90
|
-
* Default is '#000000' (black).
|
|
91
|
-
*/
|
|
92
|
-
color?: string;
|
|
93
|
-
/**
|
|
94
|
-
* The alignment of the text.
|
|
95
|
-
* Possible values: 'left', 'right', 'center', 'start', 'end'.
|
|
96
|
-
* Default is 'left'.
|
|
97
|
-
*/
|
|
98
|
-
textAlign?: CanvasTextAlign;
|
|
99
|
-
/**
|
|
100
|
-
* The baseline of the text.
|
|
101
|
-
* Possible values: 'top', 'hanging', 'middle', 'alphabetic', 'ideographic', 'bottom'.
|
|
102
|
-
* Default is 'top'.
|
|
103
|
-
*/
|
|
104
|
-
textBaseline?: CanvasTextBaseline;
|
|
105
|
-
}
|
|
106
|
-
export interface ILineStyleOptions extends IGraphicRenderOptions {
|
|
107
|
-
width?: number;
|
|
108
|
-
closed?: boolean;
|
|
109
|
-
roundCap?: boolean;
|
|
110
|
-
textureMode?: LineTextureMode;
|
|
111
|
-
points: Vec2[];
|
|
112
|
-
}
|
|
113
|
-
export declare enum LineTextureMode {
|
|
114
|
-
STRETCH = "stretch",
|
|
115
|
-
REPEAT = "repeat"
|
|
116
|
-
}
|
|
117
|
-
export declare enum TextureWrapMode {
|
|
118
|
-
REPEAT = "repeat",
|
|
119
|
-
CLAMP = "clamp",
|
|
120
|
-
MIRROR = "mirror"
|
|
121
|
-
}
|
|
122
|
-
export interface IRenderLineOptions extends ILineStyleOptions, ITransformOptions {
|
|
123
|
-
}
|
|
124
|
-
export interface IGraphicRenderOptions extends ITransformOptions, IShaderRenderOptions {
|
|
125
|
-
color?: Color | Color[];
|
|
126
|
-
drawType?: number;
|
|
127
|
-
uv?: Vec2[];
|
|
128
|
-
texture?: Texture;
|
|
129
|
-
}
|
|
130
|
-
export interface IPolygonGraphicRenderOptions extends IGraphicRenderOptions {
|
|
131
|
-
points: Vec2[];
|
|
132
|
-
}
|
|
133
|
-
export interface ICircleRenderOptions extends IGraphicRenderOptions {
|
|
134
|
-
radius: number;
|
|
135
|
-
segments?: number;
|
|
136
|
-
}
|
|
137
|
-
export interface IRectRenderOptions extends IGraphicRenderOptions {
|
|
138
|
-
width: number;
|
|
139
|
-
height: number;
|
|
140
|
-
}
|
|
141
|
-
export declare enum MaskType {
|
|
142
|
-
Include = "normal",
|
|
143
|
-
Exclude = "inverse"
|
|
144
|
-
}
|
|
145
|
-
export type UniformType = Record<string, number | Array<any> | boolean | Texture>;
|
|
146
|
-
export type Images = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas;
|
|
147
|
-
export interface IRegisterTileOptions extends ISpriteRenderOptions {
|
|
148
|
-
texture: Texture;
|
|
149
|
-
offsetX?: number;
|
|
150
|
-
offsetY?: number;
|
|
151
|
-
ySortOffset?: number;
|
|
152
|
-
}
|
|
153
|
-
export interface YSortCallback {
|
|
154
|
-
ySort: number;
|
|
155
|
-
render?: () => void;
|
|
156
|
-
renderSprite?: ISpriteRenderOptions;
|
|
157
|
-
}
|
|
158
|
-
export interface ILayerRenderOptions extends ITransformOptions {
|
|
159
|
-
error?: number | Vec2;
|
|
160
|
-
errorX?: number;
|
|
161
|
-
errorY?: number;
|
|
162
|
-
ySortCallback?: Array<YSortCallback>;
|
|
163
|
-
shape?: TilemapShape;
|
|
164
|
-
tileSet: TileSet;
|
|
165
|
-
eachTile?: (tileId: string | number, mapX: number, mapY: number) => ISpriteRenderOptions | undefined | void;
|
|
166
|
-
}
|
|
167
|
-
export interface IShaderRenderOptions {
|
|
168
|
-
shader?: GLShader;
|
|
169
|
-
uniforms?: Uniform;
|
|
170
|
-
}
|
|
171
|
-
export declare enum TilemapShape {
|
|
172
|
-
SQUARE = "square",
|
|
173
|
-
ISOMETRIC = "isometric"
|
|
174
|
-
}
|
|
175
|
-
export declare enum ShaderType {
|
|
176
|
-
SPRITE = "sprite",
|
|
177
|
-
GRAPHIC = "graphic"
|
|
178
|
-
}
|
|
179
|
-
export declare enum BlendMode {
|
|
180
|
-
Additive = "additive",
|
|
181
|
-
Subtractive = "subtractive",
|
|
182
|
-
Mix = "mix"
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Interface for light rendering options
|
|
186
|
-
*/
|
|
187
|
-
export interface ILightRenderOptions {
|
|
188
|
-
/** Position of the light source */
|
|
189
|
-
lightSource: Vec2;
|
|
190
|
-
/** Array of vertex arrays for occlusion objects, each occlusion object is defined by a set of vertices */
|
|
191
|
-
occlusion: Vec2[][];
|
|
192
|
-
/** Base projection length that controls shadow length */
|
|
193
|
-
baseProjectionLength?: number;
|
|
194
|
-
/** Type of mask to apply */
|
|
195
|
-
type?: MaskType;
|
|
196
|
-
}
|
|
197
|
-
export interface ICameraOptions extends ITransformOptions {
|
|
198
|
-
center?: boolean;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Defines particle emitter shape types
|
|
202
|
-
*/
|
|
203
|
-
export declare enum ParticleShape {
|
|
204
|
-
/**
|
|
205
|
-
* Point emitter, emits particles from a single point
|
|
206
|
-
*/
|
|
207
|
-
POINT = "point",
|
|
208
|
-
/**
|
|
209
|
-
* Circle emitter, emits particles randomly from a circular area
|
|
210
|
-
*/
|
|
211
|
-
CIRCLE = "circle",
|
|
212
|
-
/**
|
|
213
|
-
* Rectangle emitter, emits particles randomly from a rectangular area
|
|
214
|
-
*/
|
|
215
|
-
RECT = "rect"
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Defines particle attribute animation
|
|
219
|
-
* @template T Attribute type, can be number, vector or color
|
|
220
|
-
*/
|
|
221
|
-
export interface ParticleAttribute<T extends number | Vec2 | Color> {
|
|
222
|
-
/**
|
|
223
|
-
* Damping coefficient, controls attribute decay rate over time
|
|
224
|
-
*/
|
|
225
|
-
damping?: number;
|
|
226
|
-
/**
|
|
227
|
-
* Initial attribute value
|
|
228
|
-
*/
|
|
229
|
-
start: T;
|
|
230
|
-
/**
|
|
231
|
-
* Final attribute value, uses initial value if not specified
|
|
232
|
-
*/
|
|
233
|
-
end?: T;
|
|
234
|
-
/**
|
|
235
|
-
* Attribute change rate, automatically calculated from start and end if not specified
|
|
236
|
-
*/
|
|
237
|
-
delta?: T;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Particle system configuration options
|
|
241
|
-
*/
|
|
242
|
-
export interface IParticleOptions extends ITransformOptions, IShaderRenderOptions {
|
|
243
|
-
/**
|
|
244
|
-
* Particle texture, can be a single texture, array of textures, or weighted texture array
|
|
245
|
-
*/
|
|
246
|
-
texture: Texture | Texture[] | [Texture, number][];
|
|
247
|
-
/**
|
|
248
|
-
* Particle emission rate (particles per second)
|
|
249
|
-
*/
|
|
250
|
-
emitRate?: number;
|
|
251
|
-
/**
|
|
252
|
-
* Emission time interval in seconds
|
|
253
|
-
*/
|
|
254
|
-
emitTime?: number;
|
|
255
|
-
/**
|
|
256
|
-
* Maximum number of particles limit
|
|
257
|
-
*/
|
|
258
|
-
maxParticles?: number;
|
|
259
|
-
/**
|
|
260
|
-
* Particle lifetime in seconds, can be fixed value or range
|
|
261
|
-
*/
|
|
262
|
-
life?: number | [number, number];
|
|
263
|
-
/**
|
|
264
|
-
* Particle animation properties collection
|
|
265
|
-
*/
|
|
266
|
-
animation: {
|
|
267
|
-
/**
|
|
268
|
-
* Velocity vector, controls particle movement direction and speed
|
|
269
|
-
*/
|
|
270
|
-
velocity?: ParticleAttribute<Vec2>;
|
|
271
|
-
/**
|
|
272
|
-
* Acceleration vector, controls particle velocity changes
|
|
273
|
-
*/
|
|
274
|
-
acceleration?: ParticleAttribute<Vec2>;
|
|
275
|
-
/**
|
|
276
|
-
* Speed scalar, used in combination with rotation direction
|
|
277
|
-
*/
|
|
278
|
-
speed?: ParticleAttribute<number>;
|
|
279
|
-
/**
|
|
280
|
-
* Scale factor, controls particle size
|
|
281
|
-
*/
|
|
282
|
-
scale?: ParticleAttribute<number>;
|
|
283
|
-
/**
|
|
284
|
-
* Rotation angle (in radians)
|
|
285
|
-
*/
|
|
286
|
-
rotation?: ParticleAttribute<number>;
|
|
287
|
-
/**
|
|
288
|
-
* Color and transparency
|
|
289
|
-
*/
|
|
290
|
-
color?: ParticleAttribute<Color>;
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* Emitter shape
|
|
294
|
-
*/
|
|
295
|
-
emitShape?: ParticleShape;
|
|
296
|
-
/**
|
|
297
|
-
* Circular emitter radius
|
|
298
|
-
*/
|
|
299
|
-
emitRadius?: number;
|
|
300
|
-
/**
|
|
301
|
-
* Rectangular emitter dimensions
|
|
302
|
-
*/
|
|
303
|
-
emitRect?: {
|
|
304
|
-
width: number;
|
|
305
|
-
height: number;
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* Whether to use local coordinate system, true means particles are relative to emitter position,
|
|
309
|
-
* false means using global coordinates
|
|
310
|
-
*/
|
|
311
|
-
localSpace?: boolean;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Particle attribute data types
|
|
315
|
-
*/
|
|
316
|
-
export type ParticleAttributeTypes = number | Vec2 | Color;
|
|
317
|
-
/**
|
|
318
|
-
* Particle attribute runtime data
|
|
319
|
-
* @template T Attribute type
|
|
320
|
-
*/
|
|
321
|
-
export type ParticleAttributeData<T extends ParticleAttributeTypes> = {
|
|
322
|
-
/**
|
|
323
|
-
* Attribute change rate per second
|
|
324
|
-
*/
|
|
325
|
-
delta?: T;
|
|
326
|
-
/**
|
|
327
|
-
* Current attribute value
|
|
328
|
-
*/
|
|
329
|
-
value: T;
|
|
330
|
-
/**
|
|
331
|
-
* Damping coefficient
|
|
332
|
-
*/
|
|
333
|
-
damping?: number;
|
|
334
|
-
};
|
package/dist/light.d.ts
DELETED
package/dist/log.d.ts
DELETED