rapid-render 1.0.7 → 1.0.8
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 +2 -2
- package/dist/buffer.d.ts +1 -0
- package/dist/color.d.ts +2 -0
- package/dist/draw.d.ts +12 -11
- package/dist/particle.d.ts +38 -39
- package/dist/rapid-render.js +747 -667
- package/dist/rapid-render.umd.cjs +9 -9
- package/dist/region/particleRegion.d.ts +3 -1
- package/dist/render.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ Rapid is a focused WebGL 2D rendering engine for games and visual tools. lightwe
|
|
|
24
24
|
|
|
25
25
|
## Highlights
|
|
26
26
|
|
|
27
|
-
- **
|
|
28
|
-
|
|
27
|
+
- **Rendering speed**
|
|
28
|
+
An efficient batching system significantly reduces draw calls, allowing Rapid.js to maintain smooth, stable performance even when rendering large numbers of sprites at once.
|
|
29
29
|
|
|
30
30
|
- **Powerful custom shaders**
|
|
31
31
|
Add sprite and geometry effects through shader hooks while still using Rapid's normal renderer, transforms, textures, and draw APIs.
|
package/dist/buffer.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export declare class DynamicArrayBuffer {
|
|
|
49
49
|
* Resets the element usage count to zero. The underlying memory capacity is preserved.
|
|
50
50
|
*/
|
|
51
51
|
clear(): void;
|
|
52
|
+
static removeAtIndices(indices: number[], targets: DynamicArrayBuffer[]): number;
|
|
52
53
|
/**
|
|
53
54
|
* Checks if the buffer has enough space for additional elements and resizes the buffer if necessary.
|
|
54
55
|
* @param size - The number of new elements that need to be accommodated.
|
package/dist/color.d.ts
CHANGED
|
@@ -104,6 +104,8 @@ export declare class Color {
|
|
|
104
104
|
static FromHSL(h: number, s: number, l: number): Color;
|
|
105
105
|
static FromRGB(r: number, g: number, b: number): Color;
|
|
106
106
|
static fromNorm(r: number, g: number, b: number, a?: number): Color;
|
|
107
|
+
static clampColorByte(value: number): number;
|
|
108
|
+
static packColor(r: number, g: number, b: number, a: number, premultipliedAlpha: boolean): number;
|
|
107
109
|
/**
|
|
108
110
|
* Creates a Color instance from a hexadecimal color string.
|
|
109
111
|
* @param hexString - The hexadecimal color string, e.g., '#RRGGBB' or '#RRGGBBAA'.
|
package/dist/draw.d.ts
CHANGED
|
@@ -10,25 +10,26 @@ export type DrawPoint = Vec2 | {
|
|
|
10
10
|
x: number;
|
|
11
11
|
y: number;
|
|
12
12
|
};
|
|
13
|
-
export interface IDrawOptions extends ITransformOptions {
|
|
13
|
+
export interface IDrawOptions extends ITransformOptions, IDisplayOptions {
|
|
14
|
+
}
|
|
15
|
+
export interface IDisplayOptions {
|
|
14
16
|
shader?: DrawShader;
|
|
15
17
|
customMatrix?: number;
|
|
16
18
|
}
|
|
17
|
-
export interface IDrawParticleBatchOptions {
|
|
18
|
-
shader?: DrawShader;
|
|
19
|
+
export interface IDrawParticleBatchOptions extends IDisplayOptions {
|
|
19
20
|
texture: Texture;
|
|
20
|
-
x:
|
|
21
|
-
y:
|
|
22
|
-
rotation
|
|
23
|
-
color
|
|
21
|
+
x: ArrayLike<number>;
|
|
22
|
+
y: ArrayLike<number>;
|
|
23
|
+
rotation?: ArrayLike<number> | number;
|
|
24
|
+
color?: ArrayLike<Color> | ArrayLike<number> | number;
|
|
24
25
|
count?: number;
|
|
25
|
-
scaleX?: number
|
|
26
|
-
scaleY?: number
|
|
26
|
+
scaleX?: ArrayLike<number>;
|
|
27
|
+
scaleY?: ArrayLike<number>;
|
|
27
28
|
originX?: number;
|
|
28
29
|
originY?: number;
|
|
29
30
|
flipX?: boolean;
|
|
30
31
|
flipY?: boolean;
|
|
31
|
-
|
|
32
|
+
reverseOrder?: boolean;
|
|
32
33
|
}
|
|
33
34
|
export interface ISpriteOptions extends IDrawOptions {
|
|
34
35
|
texture: Texture;
|
|
@@ -60,7 +61,7 @@ export interface ICircleOptions extends IDrawOptions {
|
|
|
60
61
|
color?: Color;
|
|
61
62
|
segments?: number;
|
|
62
63
|
}
|
|
63
|
-
export declare const
|
|
64
|
+
export declare const getColorUint32: (premultipliedAlpha: boolean, color?: Color) => number;
|
|
64
65
|
export declare const drawSprite: (rapid: Rapid, options: ISpriteOptions) => void;
|
|
65
66
|
export declare const drawParticles: (rapid: Rapid, options: IDrawParticleBatchOptions) => void;
|
|
66
67
|
export declare const drawGraphic: (rapid: Rapid, options: IGraphicOptions) => void;
|
package/dist/particle.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { Color } from './color';
|
|
|
2
2
|
import { Vec2 } from './math';
|
|
3
3
|
import { Rapid } from './render';
|
|
4
4
|
import { Texture } from './texture';
|
|
5
|
-
|
|
5
|
+
import { DynamicArrayBuffer } from './buffer';
|
|
6
|
+
import { CustomGlShader } from './webgl/glshader';
|
|
6
7
|
/**
|
|
7
8
|
* Describes an animated attribute: it transitions from `start` to `end`
|
|
8
9
|
* over the particle's lifetime, optionally with a per-second damping factor.
|
|
9
10
|
*/
|
|
10
|
-
export interface ParticleAttribute<T
|
|
11
|
+
export interface ParticleAttribute<T = number> {
|
|
11
12
|
/** Starting value (scalar, range tuple, or fixed value). */
|
|
12
13
|
start?: T | [T, T];
|
|
13
14
|
/** Ending value. Defaults to `start` if omitted (no change over time). */
|
|
@@ -24,7 +25,7 @@ export interface ParticleAttribute<T extends ParticleAttributeTypes> {
|
|
|
24
25
|
delta?: T;
|
|
25
26
|
}
|
|
26
27
|
/** Internal resolved state of one animated attribute. */
|
|
27
|
-
export interface ParticleAttributeData<T
|
|
28
|
+
export interface ParticleAttributeData<T = number> {
|
|
28
29
|
value: T;
|
|
29
30
|
delta?: T;
|
|
30
31
|
damping?: number;
|
|
@@ -48,7 +49,8 @@ export interface IParticleAnimation {
|
|
|
48
49
|
}
|
|
49
50
|
export interface IParticleOptions {
|
|
50
51
|
/** Texture(s) to pick from. Pass a weighted tuple `[Texture, weight][]` for weighted random. */
|
|
51
|
-
texture: Texture
|
|
52
|
+
texture: Texture;
|
|
53
|
+
shader: CustomGlShader;
|
|
52
54
|
/** Particle lifetime in seconds, or a [min, max] range. */
|
|
53
55
|
life: number | [number, number];
|
|
54
56
|
/** Animation / per-attribute configuration. */
|
|
@@ -73,37 +75,22 @@ export interface IParticleOptions {
|
|
|
73
75
|
emitTime?: number;
|
|
74
76
|
/** Whether particles are positioned relative to the emitter (default: true). */
|
|
75
77
|
localSpace?: boolean;
|
|
76
|
-
/** World-space position of the emitter (used when localSpace is false). */
|
|
77
|
-
position?: Vec2;
|
|
78
78
|
origin?: Vec2;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
private
|
|
92
|
-
private
|
|
93
|
-
|
|
94
|
-
private getDelta;
|
|
95
|
-
/**
|
|
96
|
-
* Updates particle state.
|
|
97
|
-
* @param deltaTime - Seconds elapsed since last frame
|
|
98
|
-
* @returns `true` while the particle is alive, `false` when it should be removed
|
|
99
|
-
*/
|
|
100
|
-
update(deltaTime: number): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Renders the particle using the Rapid engine's matrixStack + drawSprite.
|
|
103
|
-
* The emitter is responsible for calling save/restore around a batch of particles.
|
|
104
|
-
*/
|
|
105
|
-
render(): void;
|
|
106
|
-
private initializePosition;
|
|
80
|
+
type ParticleAttributeValue = number | Vec2 | Color;
|
|
81
|
+
declare class ParticleAttributeStore {
|
|
82
|
+
readonly components: {
|
|
83
|
+
value: DynamicArrayBuffer;
|
|
84
|
+
delta: DynamicArrayBuffer;
|
|
85
|
+
damping: DynamicArrayBuffer;
|
|
86
|
+
}[];
|
|
87
|
+
constructor(size?: number);
|
|
88
|
+
getArrayBuffer(): DynamicArrayBuffer[];
|
|
89
|
+
update(deltaTime: number): void;
|
|
90
|
+
get(particleIndex: number, componentIndex?: number): number;
|
|
91
|
+
private getComponent;
|
|
92
|
+
private resolveComponent;
|
|
93
|
+
create<T extends ParticleAttributeValue>(attribute: ParticleAttribute<T> | T | undefined, defaultData: T, lifeTime?: number): number;
|
|
107
94
|
}
|
|
108
95
|
/**
|
|
109
96
|
* Creates and manages a pool of Particle instances.
|
|
@@ -119,7 +106,6 @@ export declare class Particle {
|
|
|
119
106
|
* ```
|
|
120
107
|
*/
|
|
121
108
|
export declare class ParticleEmitter {
|
|
122
|
-
private particles;
|
|
123
109
|
private options;
|
|
124
110
|
private emitting;
|
|
125
111
|
private emitTimer;
|
|
@@ -128,16 +114,28 @@ export declare class ParticleEmitter {
|
|
|
128
114
|
private emitTimeCounter;
|
|
129
115
|
/** Whether spawned particles are positioned in local emitter space (default: true). */
|
|
130
116
|
localSpace: boolean;
|
|
131
|
-
/** World position of the emitter. Used for both local-space transform and world-space spawn offset. */
|
|
132
|
-
position: Vec2;
|
|
133
117
|
private rapid;
|
|
134
|
-
|
|
118
|
+
x: DynamicArrayBuffer;
|
|
119
|
+
y: DynamicArrayBuffer;
|
|
120
|
+
scaleX: DynamicArrayBuffer;
|
|
121
|
+
scaleY: DynamicArrayBuffer;
|
|
122
|
+
rotation: DynamicArrayBuffer;
|
|
123
|
+
color: DynamicArrayBuffer;
|
|
124
|
+
animations: {
|
|
125
|
+
speed: ParticleAttributeStore;
|
|
126
|
+
rotation: ParticleAttributeStore;
|
|
127
|
+
scale: ParticleAttributeStore;
|
|
128
|
+
color: ParticleAttributeStore;
|
|
129
|
+
velocity: ParticleAttributeStore;
|
|
130
|
+
};
|
|
131
|
+
count: number;
|
|
135
132
|
/**
|
|
136
133
|
* Creates a new particle emitter.
|
|
137
134
|
* @param rapid - The Rapid renderer instance
|
|
138
135
|
* @param options - Emitter configuration options
|
|
139
136
|
*/
|
|
140
137
|
constructor(rapid: Rapid, options: IParticleOptions);
|
|
138
|
+
getAllArrayBuffer(): DynamicArrayBuffer[];
|
|
141
139
|
/** Replaces the emitter's texture at runtime. */
|
|
142
140
|
setTexture(texture: Texture): void;
|
|
143
141
|
/**
|
|
@@ -160,18 +158,18 @@ export declare class ParticleEmitter {
|
|
|
160
158
|
* Respects `maxParticles` if set.
|
|
161
159
|
*/
|
|
162
160
|
emit(count: number): void;
|
|
161
|
+
createParticle(): void;
|
|
163
162
|
/**
|
|
164
163
|
* Updates the emitter and all live particles.
|
|
165
164
|
* @param deltaTime - Seconds elapsed since last frame
|
|
166
165
|
*/
|
|
167
166
|
update(deltaTime: number): void;
|
|
167
|
+
updateParticle(deltaTime: number): number[];
|
|
168
168
|
/**
|
|
169
169
|
* Renders all live particles.
|
|
170
170
|
* In local-space mode the emitter's own transform is applied around the batch.
|
|
171
171
|
*/
|
|
172
172
|
render(): void;
|
|
173
|
-
/** Returns the current number of live particles. */
|
|
174
|
-
getParticleCount(): number;
|
|
175
173
|
/** Returns `true` if the emitter is running or still has live particles. */
|
|
176
174
|
isActive(): boolean;
|
|
177
175
|
/**
|
|
@@ -179,3 +177,4 @@ export declare class ParticleEmitter {
|
|
|
179
177
|
*/
|
|
180
178
|
oneShot(): void;
|
|
181
179
|
}
|
|
180
|
+
export {};
|