@neutrinoparticles/js-v1.1-phaser 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/CHANGELOG.md +6 -0
- package/README.md +212 -0
- package/dist/DataTextureManager.d.ts +32 -0
- package/dist/Effect.d.ts +76 -0
- package/dist/EffectModel.d.ts +27 -0
- package/dist/File.d.ts +18 -0
- package/dist/GamePlugin.d.ts +27 -0
- package/dist/NeutrinoContext.d.ts +88 -0
- package/dist/NeutrinoRenderer.d.ts +54 -0
- package/dist/PerspectiveProjection.d.ts +65 -0
- package/dist/gl1/DataTextureManagerGL1.d.ts +23 -0
- package/dist/gl1/MetaTextureManager.d.ts +9 -0
- package/dist/index.d.ts +43 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.cjs.js +1169 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.cjs.js.map +1 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.d.ts +481 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.es.js +2105 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.es.js.map +1 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.umd.js +1169 -0
- package/dist/neutrinoparticles.js-v1.1-phaser.umd.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/package.json +56 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
// Generated by dts-bundle v0.7.3
|
|
2
|
+
// Dependencies for this module:
|
|
3
|
+
// index.d.ts
|
|
4
|
+
|
|
5
|
+
declare module '@neutrinoparticles/js-v1.1-phaser' {
|
|
6
|
+
import Phaser from 'phaser';
|
|
7
|
+
import { GamePlugin } from '@neutrinoparticles/js-v1.1-phaser/GamePlugin';
|
|
8
|
+
import { NeutrinoFileConfig } from '@neutrinoparticles/js-v1.1-phaser/File';
|
|
9
|
+
import { Effect, EffectOptions } from '@neutrinoparticles/js-v1.1-phaser/Effect';
|
|
10
|
+
import { EffectModel } from '@neutrinoparticles/js-v1.1-phaser/EffectModel';
|
|
11
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/types';
|
|
12
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/GamePlugin';
|
|
13
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/NeutrinoContext';
|
|
14
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/NeutrinoRenderer';
|
|
15
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/DataTextureManager';
|
|
16
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/Effect';
|
|
17
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/EffectModel';
|
|
18
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/File';
|
|
19
|
+
export * from '@neutrinoparticles/js-v1.1-phaser/PerspectiveProjection';
|
|
20
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/index//phaser' {
|
|
21
|
+
namespace Loader {
|
|
22
|
+
interface LoaderPlugin {
|
|
23
|
+
neutrino(key: string | NeutrinoFileConfig | NeutrinoFileConfig[], url?: string, options?: {
|
|
24
|
+
atlases?: string[];
|
|
25
|
+
}, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): this;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
namespace GameObjects {
|
|
29
|
+
interface GameObjectFactory {
|
|
30
|
+
neutrino(effectModel: EffectModel, options?: EffectOptions): Effect;
|
|
31
|
+
}
|
|
32
|
+
interface GameObjectCreator {
|
|
33
|
+
neutrino(config: {
|
|
34
|
+
effectModel: EffectModel;
|
|
35
|
+
} & EffectOptions & {
|
|
36
|
+
add?: boolean;
|
|
37
|
+
}): Effect;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Installs the NeutrinoParticles plugin into Phaser's global registries:
|
|
43
|
+
* - Loader file type: scene.load.neutrino(key, url, options)
|
|
44
|
+
* - GameObjectFactory: scene.add.neutrino(effectModel, options)
|
|
45
|
+
* - GameObjectCreator: scene.make.neutrino(config)
|
|
46
|
+
*/
|
|
47
|
+
export function installPlugin(): void;
|
|
48
|
+
export { GamePlugin };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/GamePlugin' {
|
|
52
|
+
import Phaser from 'phaser';
|
|
53
|
+
import { NeutrinoContext } from '@neutrinoparticles/js-v1.1-phaser/NeutrinoContext';
|
|
54
|
+
export interface GamePluginOptions {
|
|
55
|
+
texturesBasePath?: string;
|
|
56
|
+
generateNoise?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Main NeutrinoParticles plugin for Phaser (JS v1.1 runtime).
|
|
60
|
+
*
|
|
61
|
+
* Owns the shared {@link NeutrinoContext} (shader/index-buffer GL state) and
|
|
62
|
+
* the neutrino simulation context, and manages noise generation. A WebGL
|
|
63
|
+
* renderer is required — the v1.1 data-texture renderer has no Canvas
|
|
64
|
+
* fallback. Both WebGL2 and WebGL1 contexts are supported; the render path is
|
|
65
|
+
* selected automatically by {@link NeutrinoContext}.
|
|
66
|
+
*/
|
|
67
|
+
export class GamePlugin extends Phaser.Plugins.BasePlugin {
|
|
68
|
+
game: Phaser.Game;
|
|
69
|
+
neutrino: any;
|
|
70
|
+
ctx: NeutrinoContext;
|
|
71
|
+
texturesBasePath: string;
|
|
72
|
+
init(options?: GamePluginOptions): void;
|
|
73
|
+
start(): void;
|
|
74
|
+
stop(): void;
|
|
75
|
+
destroy(): void;
|
|
76
|
+
loadNoise(path: string, success?: () => void, fail?: () => void): void;
|
|
77
|
+
generateNoise(): void;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/File' {
|
|
82
|
+
import Phaser from 'phaser';
|
|
83
|
+
export interface NeutrinoFileConfig {
|
|
84
|
+
key: string;
|
|
85
|
+
url: string;
|
|
86
|
+
options?: {
|
|
87
|
+
atlases?: string[];
|
|
88
|
+
};
|
|
89
|
+
xhrSettings?: Phaser.Types.Loader.XHRSettingsObject;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Custom Phaser loader file type for NeutrinoParticles effects (.js export).
|
|
93
|
+
* Parses the exported source into an {@link EffectModel} stored in the binary cache.
|
|
94
|
+
*/
|
|
95
|
+
export class NeutrinoFile extends Phaser.Loader.File {
|
|
96
|
+
constructor(loader: Phaser.Loader.LoaderPlugin, config: NeutrinoFileConfig);
|
|
97
|
+
onProcess(): void;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/Effect' {
|
|
102
|
+
import Phaser from 'phaser';
|
|
103
|
+
import { Pause, Vec2, Vec3 } from '@neutrinoparticles/js-v1.1-phaser/types';
|
|
104
|
+
import { GamePlugin } from '@neutrinoparticles/js-v1.1-phaser/GamePlugin';
|
|
105
|
+
import { EffectModel } from '@neutrinoparticles/js-v1.1-phaser/EffectModel';
|
|
106
|
+
import { NeutrinoSystem } from '@neutrinoparticles/js-v1.1-phaser/types';
|
|
107
|
+
export interface EffectOptions {
|
|
108
|
+
position?: Vec3;
|
|
109
|
+
angle?: number;
|
|
110
|
+
scale?: number;
|
|
111
|
+
pause?: Pause;
|
|
112
|
+
generatorsPaused?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A NeutrinoParticles effect on a Phaser scene (JS v1.1 runtime).
|
|
116
|
+
*
|
|
117
|
+
* Simulation runs in preUpdate(); rendering happens in renderWebGL() via a raw
|
|
118
|
+
* WebGL data-texture draw (WebGL2 or the WebGL1 variant, chosen by the shared
|
|
119
|
+
* NeutrinoContext). Phaser's active pipeline is flushed before and rebound
|
|
120
|
+
* after the draw so its state machine stays consistent.
|
|
121
|
+
*/
|
|
122
|
+
export class Effect extends Phaser.GameObjects.GameObject {
|
|
123
|
+
gamePlugin: GamePlugin;
|
|
124
|
+
effectModel: EffectModel;
|
|
125
|
+
effect: NeutrinoSystem | null;
|
|
126
|
+
x: number;
|
|
127
|
+
y: number;
|
|
128
|
+
z: number;
|
|
129
|
+
angle: number;
|
|
130
|
+
rotation: number;
|
|
131
|
+
scaleX: number;
|
|
132
|
+
scaleY: number;
|
|
133
|
+
scrollFactorX: number;
|
|
134
|
+
scrollFactorY: number;
|
|
135
|
+
alpha: number;
|
|
136
|
+
depth: number;
|
|
137
|
+
blendMode: number;
|
|
138
|
+
constructor(effectModel: EffectModel, scene: Phaser.Scene, options?: EffectOptions);
|
|
139
|
+
get ready(): boolean;
|
|
140
|
+
preUpdate(_time: number, ms: number): void;
|
|
141
|
+
renderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, _src: Effect, camera: Phaser.Cameras.Scene2D.Camera): void;
|
|
142
|
+
restart(options?: {
|
|
143
|
+
position?: Vec3;
|
|
144
|
+
angle?: number;
|
|
145
|
+
rotation?: number;
|
|
146
|
+
}): void;
|
|
147
|
+
resetPosition(options?: {
|
|
148
|
+
position?: Vec3;
|
|
149
|
+
angle?: number;
|
|
150
|
+
rotation?: number;
|
|
151
|
+
}): void;
|
|
152
|
+
pause(): void;
|
|
153
|
+
unpause(): void;
|
|
154
|
+
get paused(): boolean;
|
|
155
|
+
pauseGenerators(): void;
|
|
156
|
+
unpauseGenerators(): void;
|
|
157
|
+
get generatorsPaused(): boolean;
|
|
158
|
+
setPropertyInAllEmitters(name: string, value: Vec3 | Vec2 | number): void;
|
|
159
|
+
getNumParticles(): number;
|
|
160
|
+
setScrollFactor(x: number, y?: number): this;
|
|
161
|
+
setAlpha(topLeft?: number, _topRight?: number, _bottomLeft?: number, _bottomRight?: number): this;
|
|
162
|
+
destroy(fromScene?: boolean): void;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/EffectModel' {
|
|
167
|
+
import Phaser from 'phaser';
|
|
168
|
+
import { GamePlugin } from '@neutrinoparticles/js-v1.1-phaser/GamePlugin';
|
|
169
|
+
import { NeutrinoEffectModel, NeutrinoSubRect } from '@neutrinoparticles/js-v1.1-phaser/types';
|
|
170
|
+
/**
|
|
171
|
+
* Wraps a neutrinoparticles.js v1.1 effect model for Phaser. Loads textures from
|
|
172
|
+
* standalone files or atlases via Phaser's loader, and computes atlas UV remaps
|
|
173
|
+
* as plain {x,y,width,height} objects (the v1.1 renderer reads them directly).
|
|
174
|
+
*/
|
|
175
|
+
export class EffectModel {
|
|
176
|
+
readonly gamePlugin: GamePlugin;
|
|
177
|
+
readonly scene: Phaser.Scene;
|
|
178
|
+
readonly effectModel: NeutrinoEffectModel;
|
|
179
|
+
textureFrames: Array<Phaser.Textures.Frame | null>;
|
|
180
|
+
texturesRemap: Array<NeutrinoSubRect | null>;
|
|
181
|
+
constructor(scene: Phaser.Scene, scriptText: string, options?: {
|
|
182
|
+
atlases?: string[];
|
|
183
|
+
});
|
|
184
|
+
get ready(): boolean;
|
|
185
|
+
/** Raw WebGL texture handle for a given texture index (or null). */
|
|
186
|
+
glTexture(index: number): WebGLTexture | null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/types' {
|
|
191
|
+
export type Vec2 = [number, number];
|
|
192
|
+
export type Vec3 = [number, number, number];
|
|
193
|
+
export type Vec4 = [number, number, number, number];
|
|
194
|
+
export type Quat = [number, number, number, number];
|
|
195
|
+
export type Mat3x2 = [number, number, number, number, number, number];
|
|
196
|
+
export enum Pause {
|
|
197
|
+
NO = 0,
|
|
198
|
+
BEFORE_UPDATE_OR_RENDER = 1,
|
|
199
|
+
YES = 2
|
|
200
|
+
}
|
|
201
|
+
export interface RenderInstruction {
|
|
202
|
+
startParticleIndex: number;
|
|
203
|
+
numParticles: number;
|
|
204
|
+
renderStyleIndex: number;
|
|
205
|
+
blendMode: number;
|
|
206
|
+
}
|
|
207
|
+
export interface RenderStyle {
|
|
208
|
+
materialIndex: number;
|
|
209
|
+
textureIndices: number[];
|
|
210
|
+
}
|
|
211
|
+
export interface NeutrinoEffectModel {
|
|
212
|
+
textures: string[];
|
|
213
|
+
materials: number[];
|
|
214
|
+
renderStyles: RenderStyle[];
|
|
215
|
+
totalParticles: number;
|
|
216
|
+
createInstance(position: Vec3, rotation: Quat, options: object): NeutrinoSystem;
|
|
217
|
+
}
|
|
218
|
+
export interface NeutrinoSystem {
|
|
219
|
+
model: NeutrinoEffectModel;
|
|
220
|
+
particleDataUint32: Uint32Array;
|
|
221
|
+
particleDataBuffer: ArrayBuffer;
|
|
222
|
+
particleDataView: DataView;
|
|
223
|
+
dataTextureWidth: number;
|
|
224
|
+
dataTextureHeight: number;
|
|
225
|
+
renderInstructions: RenderInstruction[] & {
|
|
226
|
+
_totalParticles: number;
|
|
227
|
+
};
|
|
228
|
+
update(dt: number, position?: Vec3 | null, rotation?: Quat | null): void;
|
|
229
|
+
construct(cameraDir?: Vec3): void;
|
|
230
|
+
restart(position?: Vec3, rotation?: Quat, options?: object): void;
|
|
231
|
+
resetPosition(position?: Vec3, rotation?: Quat): void;
|
|
232
|
+
pauseAllEmitters(): void;
|
|
233
|
+
unpauseAllEmitters(): void;
|
|
234
|
+
areAllEmittersPaused(): boolean;
|
|
235
|
+
pauseGeneratorsInAllEmitters(): void;
|
|
236
|
+
unpauseGeneratorsInAllEmitters(): void;
|
|
237
|
+
areGeneratorsInAllEmittersPaused(): boolean;
|
|
238
|
+
getNumParticles(): number;
|
|
239
|
+
setPropertyInAllEmitters(name: string, value: number | Vec2 | Vec3): void;
|
|
240
|
+
}
|
|
241
|
+
export interface NeutrinoRuntimeContext {
|
|
242
|
+
initializeNoise(path: string, success: () => void, fail: () => void): void;
|
|
243
|
+
NoiseGenerator: new () => {
|
|
244
|
+
step(): boolean;
|
|
245
|
+
progress: number;
|
|
246
|
+
};
|
|
247
|
+
axisangle2quat_(axis: Vec3, angleDeg: number): Quat;
|
|
248
|
+
}
|
|
249
|
+
export interface NeutrinoSubRect {
|
|
250
|
+
x: number;
|
|
251
|
+
y: number;
|
|
252
|
+
width: number;
|
|
253
|
+
height: number;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/NeutrinoContext' {
|
|
258
|
+
import { NeutrinoRuntimeContext as INeutrinoContext } from '@neutrinoparticles/js-v1.1-phaser/types';
|
|
259
|
+
/**
|
|
260
|
+
* Engine-agnostic WebGL state for the NeutrinoParticles data-texture renderer:
|
|
261
|
+
* the shader program, a static quad index buffer + VAO (WebGL2) or aId vertex
|
|
262
|
+
* stream (WebGL1), and uniform locations.
|
|
263
|
+
*
|
|
264
|
+
* This is the Phaser counterpart of the pixi adapters' Context, but it holds no
|
|
265
|
+
* reference to a host renderer — it works purely off a WebGL context. Owned by
|
|
266
|
+
* {@link GamePlugin} and shared by every effect in the game.
|
|
267
|
+
*
|
|
268
|
+
* The render path is selected automatically (TDD_js-v1.1-webgl1.md): a WebGL2
|
|
269
|
+
* context uses the texelFetch/gl_VertexID renderer unchanged; a WebGL1 context
|
|
270
|
+
* with the required capabilities (probed here, §4.2) uses the two-texture +
|
|
271
|
+
* static-aId variant; anything else throws a capability-specific Error.
|
|
272
|
+
*/
|
|
273
|
+
export class NeutrinoContext {
|
|
274
|
+
readonly neutrino: INeutrinoContext;
|
|
275
|
+
readonly gl: WebGL2RenderingContext;
|
|
276
|
+
static readonly MAX_BATCH_TEXTURES = 8;
|
|
277
|
+
constructor(gl: WebGL2RenderingContext, neutrino: INeutrinoContext);
|
|
278
|
+
initializeNoise(path: string, success: () => void, fail: () => void): void;
|
|
279
|
+
generateNoise(): void;
|
|
280
|
+
get shaderProgram(): WebGLProgram;
|
|
281
|
+
get isWebGL1(): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Textures usable in one batch. 8 on WebGL2; on WebGL1 reduced when the
|
|
284
|
+
* combined texture-unit budget is tight (the vertex stage takes 2 units).
|
|
285
|
+
* A lower cap only produces more batches, never wrong output.
|
|
286
|
+
*/
|
|
287
|
+
get maxBatchTextures(): number;
|
|
288
|
+
get uDataTexture(): WebGLUniformLocation | null;
|
|
289
|
+
get uDataTextureWidth(): WebGLUniformLocation | null;
|
|
290
|
+
get uMetaTexture(): WebGLUniformLocation | null;
|
|
291
|
+
get uDataTexSize(): WebGLUniformLocation | null;
|
|
292
|
+
get uCameraRight(): WebGLUniformLocation | null;
|
|
293
|
+
get uCameraUp(): WebGLUniformLocation | null;
|
|
294
|
+
get uCameraDir(): WebGLUniformLocation | null;
|
|
295
|
+
get uViewProjMatrix(): WebGLUniformLocation | null;
|
|
296
|
+
get uModelMatrix(): WebGLUniformLocation | null;
|
|
297
|
+
get uViewportAspect(): WebGLUniformLocation | null;
|
|
298
|
+
get uWorldAlpha(): WebGLUniformLocation | null;
|
|
299
|
+
get uTextures(): (WebGLUniformLocation | null)[];
|
|
300
|
+
get uTexRemaps(): (WebGLUniformLocation | null)[];
|
|
301
|
+
ensureIndexBuffer(maxParticles: number): void;
|
|
302
|
+
get vao(): WebGLVertexArrayObject;
|
|
303
|
+
get indexBuffer(): WebGLBuffer;
|
|
304
|
+
get aIdBuffer(): WebGLBuffer;
|
|
305
|
+
get aIdLocation(): number;
|
|
306
|
+
get indexType(): number;
|
|
307
|
+
/** Unbind any VAO (incl. OES on WebGL1) before raw attribute setup. */
|
|
308
|
+
unbindVao(): void;
|
|
309
|
+
destroy(): void;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/NeutrinoRenderer' {
|
|
314
|
+
import { NeutrinoContext } from "@neutrinoparticles/js-v1.1-phaser/NeutrinoContext";
|
|
315
|
+
import { DataTextureManager } from "@neutrinoparticles/js-v1.1-phaser/DataTextureManager";
|
|
316
|
+
import { DataTextureManagerGL1 } from "@neutrinoparticles/js-v1.1-phaser/gl1/DataTextureManagerGL1";
|
|
317
|
+
import { NeutrinoSubRect } from "@neutrinoparticles/js-v1.1-phaser/types";
|
|
318
|
+
export interface RenderParams {
|
|
319
|
+
/** Effect world transform (2x3) already including world scale. */
|
|
320
|
+
model: {
|
|
321
|
+
a: number;
|
|
322
|
+
b: number;
|
|
323
|
+
c: number;
|
|
324
|
+
d: number;
|
|
325
|
+
tx: number;
|
|
326
|
+
ty: number;
|
|
327
|
+
};
|
|
328
|
+
/** Canvas pixel dimensions, for the ortho projection. */
|
|
329
|
+
viewportWidth: number;
|
|
330
|
+
viewportHeight: number;
|
|
331
|
+
/** Camera scroll (subtracted in pixel space) and zoom. */
|
|
332
|
+
scrollX: number;
|
|
333
|
+
scrollY: number;
|
|
334
|
+
zoom: number;
|
|
335
|
+
/** Host scene-graph world alpha, multiplied into each particle's alpha. */
|
|
336
|
+
worldAlpha: number;
|
|
337
|
+
/** Per-particle GL textures (one per render-style texture index). */
|
|
338
|
+
glTextures: (WebGLTexture | null)[];
|
|
339
|
+
remaps: Array<NeutrinoSubRect | null>;
|
|
340
|
+
renderStyles: Array<{
|
|
341
|
+
materialIndex: number;
|
|
342
|
+
textureIndices: number[];
|
|
343
|
+
}>;
|
|
344
|
+
materials: number[];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Raw WebGL data-texture renderer for the Phaser integration.
|
|
348
|
+
*
|
|
349
|
+
* Mirrors the pixi adapters: builds blend-mode batches (≤maxBatchTextures each),
|
|
350
|
+
* patches the per-particle texture-slot byte, uploads the data texture and draws
|
|
351
|
+
* each batch with gl.drawElements. On WebGL1 the u32-packed fields travel via an
|
|
352
|
+
* RGBA8 meta texture and the slot patch goes there instead of the float buffer
|
|
353
|
+
* (TDD_js-v1.1-webgl1.md §4.3/§4.6). Because Phaser owns the GL state machine,
|
|
354
|
+
* the caller is responsible for flushing Phaser's batch and restoring pipeline
|
|
355
|
+
* state around a render() call (see Effect.renderWebGL).
|
|
356
|
+
*/
|
|
357
|
+
export class NeutrinoRenderer {
|
|
358
|
+
constructor();
|
|
359
|
+
render(ctx: NeutrinoContext, dtm: DataTextureManager | DataTextureManagerGL1, dataView: DataView, dataUint32: Uint32Array, instructions: any[], numParticles: number, params: RenderParams): void;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/DataTextureManager' {
|
|
364
|
+
/**
|
|
365
|
+
* Manages a small ring of RGBA32F WebGL textures that hold the runtime's flat
|
|
366
|
+
* particle data buffer. Each frame the current texture is re-uploaded (zero-copy
|
|
367
|
+
* from the runtime-owned Uint32Array via a Float32 view) and the ring advances,
|
|
368
|
+
* which avoids GPU pipeline stalls from re-uploading into a texture still in use.
|
|
369
|
+
*
|
|
370
|
+
* Unlike the pixi7 adapter this owns raw GL textures directly (no PIXI texture
|
|
371
|
+
* system), so the exact same class works for both the PIXI v8 and Phaser
|
|
372
|
+
* integrations, which both do their own raw WebGL2 draw.
|
|
373
|
+
*/
|
|
374
|
+
export class DataTextureManager {
|
|
375
|
+
readonly textureWidth: number;
|
|
376
|
+
readonly textureHeight: number;
|
|
377
|
+
/**
|
|
378
|
+
* @param gl - WebGL2 context (from the host renderer)
|
|
379
|
+
* @param data - Uint32Array from the runtime. A Float32Array view over the
|
|
380
|
+
* same buffer is uploaded as RGBA32F — bit patterns (incl. NaN/Inf) pass
|
|
381
|
+
* through unchanged.
|
|
382
|
+
* @param textureWidth - from runtime (system.dataTextureWidth)
|
|
383
|
+
* @param textureHeight - from runtime (system.dataTextureHeight)
|
|
384
|
+
*/
|
|
385
|
+
constructor(gl: WebGL2RenderingContext, data: Uint32Array, textureWidth: number, textureHeight: number);
|
|
386
|
+
get currentTexture(): WebGLTexture;
|
|
387
|
+
/** Bind the current texture to a unit and upload the latest particle data. */
|
|
388
|
+
uploadAndBind(unit: number): void;
|
|
389
|
+
advance(): void;
|
|
390
|
+
destroy(): void;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/PerspectiveProjection' {
|
|
395
|
+
/**
|
|
396
|
+
* The class implements perspective projection transformation.
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* // Create effect instance using loaded model
|
|
400
|
+
* let effect = new PIXINeutrino.Effect(resources.effectModel, {
|
|
401
|
+
* position: [400, 300, 0],
|
|
402
|
+
* projection: new PIXINeutrino.PerspectiveProjection(60.0)
|
|
403
|
+
* });
|
|
404
|
+
*
|
|
405
|
+
* @param {number} [horizontalAngle] Horizontal angle of the perspective projection in degrees.
|
|
406
|
+
*/
|
|
407
|
+
import { Vec2, Vec3 } from "@neutrinoparticles/js-v1.1-phaser/types";
|
|
408
|
+
export interface ScreenFrame {
|
|
409
|
+
x: number;
|
|
410
|
+
y: number;
|
|
411
|
+
width: number;
|
|
412
|
+
height: number;
|
|
413
|
+
}
|
|
414
|
+
export class PerspectiveProjection {
|
|
415
|
+
set horizontalAngle(value: number);
|
|
416
|
+
constructor(horizontalAngle: number);
|
|
417
|
+
/**
|
|
418
|
+
* Sets rendering frame for the projection.
|
|
419
|
+
*
|
|
420
|
+
* This method shouldn't be called manually when the class is used with effects. It is called
|
|
421
|
+
* on every render call for each effect automatically.
|
|
422
|
+
* @param {ScreenFrame} frame Rendering frame.
|
|
423
|
+
*/
|
|
424
|
+
setScreenFrame(frame: ScreenFrame): void;
|
|
425
|
+
/**
|
|
426
|
+
* Transforms 3D point accordingly to the projection.
|
|
427
|
+
*
|
|
428
|
+
* Basically, point's position X and Y components are simply scaled dependently on Z position. The method
|
|
429
|
+
* is used in WebGL and Canvas rendering.
|
|
430
|
+
*
|
|
431
|
+
* @param {Array} out [x, y] Transformed position.
|
|
432
|
+
* @param {Array} pos [x, y, z] Untransformed input vertex position.
|
|
433
|
+
* @returns false, if a particle is on the back side of the camera and should be discarded. Otherwise - true.
|
|
434
|
+
*/
|
|
435
|
+
transformPosition(out: Vec2, pos: Vec3): boolean;
|
|
436
|
+
/**
|
|
437
|
+
* Transforms 2D size of a particle accordingly to the projection.
|
|
438
|
+
*
|
|
439
|
+
* Basically, size is simply scaled dependently on Z position of a particle. The method is used
|
|
440
|
+
* only in Canvas rendering.
|
|
441
|
+
*
|
|
442
|
+
* @param {Array} outSize [width, height] Transformed size.
|
|
443
|
+
* @param {Array} pos [x, y, z] Untransformed particle position.
|
|
444
|
+
* @param {Array} size [width, height] Untransformed size.
|
|
445
|
+
*/
|
|
446
|
+
transformSize(outSize: Vec2, pos: Vec3, size: Vec2): void;
|
|
447
|
+
_getScale(pos: Vec3): number;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/gl1/DataTextureManagerGL1' {
|
|
452
|
+
import { MetaTextureManager } from "@neutrinoparticles/js-v1.1-phaser/gl1/MetaTextureManager";
|
|
453
|
+
export class DataTextureManagerGL1 {
|
|
454
|
+
readonly textureWidth: number;
|
|
455
|
+
readonly textureHeight: number;
|
|
456
|
+
readonly meta: MetaTextureManager;
|
|
457
|
+
constructor(gl: WebGLRenderingContext, data: Uint32Array, textureWidth: number, textureHeight: number);
|
|
458
|
+
get currentDataTexture(): WebGLTexture;
|
|
459
|
+
get currentMetaTexture(): WebGLTexture;
|
|
460
|
+
/**
|
|
461
|
+
* Upload the rows covering `numParticles` into the current ring textures,
|
|
462
|
+
* leaving them bound to `dataUnit` / `metaUnit`. The caller invalidates
|
|
463
|
+
* PIXI's bound-texture bookkeeping for those units.
|
|
464
|
+
*/
|
|
465
|
+
upload(numParticles: number, dataUnit: number, metaUnit: number): void;
|
|
466
|
+
advance(): void;
|
|
467
|
+
destroy(): void;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
declare module '@neutrinoparticles/js-v1.1-phaser/gl1/MetaTextureManager' {
|
|
472
|
+
export class MetaTextureManager {
|
|
473
|
+
readonly bytes: Uint8Array;
|
|
474
|
+
constructor(textureWidth: number, textureHeight: number);
|
|
475
|
+
/** Repack the packed-u32 record fields for the first `numParticles` records. */
|
|
476
|
+
build(dataUint32: Uint32Array, numParticles: number): void;
|
|
477
|
+
/** Write the batch texture slot into byte0 of M0 (flags) per particle. */
|
|
478
|
+
patchSlot(startParticle: number, count: number, slot: number): void;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|