babylon.quarks 0.17.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 +21 -0
- package/dist/babylon.quarks.cjs +2 -0
- package/dist/babylon.quarks.cjs.map +1 -0
- package/dist/babylon.quarks.esm.js +2 -0
- package/dist/babylon.quarks.esm.js.map +1 -0
- package/dist/types/BatchedParticleRenderer.d.ts +2 -0
- package/dist/types/BatchedRenderer.d.ts +40 -0
- package/dist/types/MeshSurfaceEmitter.d.ts +19 -0
- package/dist/types/ParticleEmitter.d.ts +16 -0
- package/dist/types/ParticleSystem.d.ts +226 -0
- package/dist/types/QuarksLoader.d.ts +28 -0
- package/dist/types/QuarksPrefab.d.ts +48 -0
- package/dist/types/QuarksUtil.d.ts +14 -0
- package/dist/types/SpriteBatch.d.ts +32 -0
- package/dist/types/TrailBatch.d.ts +27 -0
- package/dist/types/VFXBatch.d.ts +51 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/materials/ParticleMaterials.d.ts +12 -0
- package/dist/types/materials/index.d.ts +1 -0
- package/dist/types/shaders/chunks/index.d.ts +1 -0
- package/dist/types/shaders/chunks/register-shader-chunks.d.ts +3 -0
- package/dist/types/shaders/chunks/soft_fragment.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/soft_pars_fragment.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/soft_pars_vertex.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/soft_vertex.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/tile_fragment.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/tile_pars_fragment.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/tile_pars_vertex.glsl.d.ts +2 -0
- package/dist/types/shaders/chunks/tile_vertex.glsl.d.ts +2 -0
- package/dist/types/shaders/index.d.ts +9 -0
- package/dist/types/shaders/local_particle_physics_vert.glsl.d.ts +2 -0
- package/dist/types/shaders/local_particle_vert.glsl.d.ts +2 -0
- package/dist/types/shaders/particle_frag.glsl.d.ts +2 -0
- package/dist/types/shaders/particle_physics_frag.glsl.d.ts +2 -0
- package/dist/types/shaders/particle_vert.glsl.d.ts +2 -0
- package/dist/types/shaders/stretched_bb_particle_vert.glsl.d.ts +2 -0
- package/dist/types/shaders/trail_frag.glsl.d.ts +2 -0
- package/dist/types/shaders/trail_vert.glsl.d.ts +2 -0
- package/package.json +58 -0
- package/src/BatchedParticleRenderer.ts +3 -0
- package/src/BatchedRenderer.ts +135 -0
- package/src/MeshSurfaceEmitter.ts +137 -0
- package/src/ParticleEmitter.ts +86 -0
- package/src/ParticleSystem.ts +1162 -0
- package/src/QuarksLoader.ts +503 -0
- package/src/QuarksPrefab.ts +307 -0
- package/src/QuarksUtil.ts +66 -0
- package/src/SpriteBatch.ts +391 -0
- package/src/TrailBatch.ts +345 -0
- package/src/VFXBatch.ts +102 -0
- package/src/index.ts +54 -0
- package/src/materials/ParticleMaterials.ts +23 -0
- package/src/materials/index.ts +1 -0
- package/src/shaders/chunks/index.ts +1 -0
- package/src/shaders/chunks/register-shader-chunks.ts +32 -0
- package/src/shaders/chunks/soft_fragment.glsl.ts +13 -0
- package/src/shaders/chunks/soft_pars_fragment.glsl.ts +20 -0
- package/src/shaders/chunks/soft_pars_vertex.glsl.ts +6 -0
- package/src/shaders/chunks/soft_vertex.glsl.ts +6 -0
- package/src/shaders/chunks/tile_fragment.glsl.ts +9 -0
- package/src/shaders/chunks/tile_pars_fragment.glsl.ts +9 -0
- package/src/shaders/chunks/tile_pars_vertex.glsl.ts +28 -0
- package/src/shaders/chunks/tile_vertex.glsl.ts +18 -0
- package/src/shaders/index.ts +9 -0
- package/src/shaders/local_particle_physics_vert.glsl.ts +66 -0
- package/src/shaders/local_particle_vert.glsl.ts +50 -0
- package/src/shaders/particle_frag.glsl.ts +61 -0
- package/src/shaders/particle_physics_frag.glsl.ts +67 -0
- package/src/shaders/particle_vert.glsl.ts +85 -0
- package/src/shaders/stretched_bb_particle_vert.glsl.ts +74 -0
- package/src/shaders/trail_frag.glsl.ts +21 -0
- package/src/shaders/trail_vert.glsl.ts +58 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
2
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
3
|
+
import { Texture } from '@babylonjs/core/Materials/Textures/texture';
|
|
4
|
+
import { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';
|
|
5
|
+
import { IParticleSystem } from 'quarks.core';
|
|
6
|
+
import { VFXBatch, RenderMode } from './VFXBatch';
|
|
7
|
+
export interface VFXBatchSettings {
|
|
8
|
+
instancingGeometry: Float32Array;
|
|
9
|
+
instancingIndices: Uint32Array | Uint16Array;
|
|
10
|
+
instancingUVs?: Float32Array;
|
|
11
|
+
instancingNormals?: Float32Array;
|
|
12
|
+
renderMode: RenderMode;
|
|
13
|
+
renderOrder: number;
|
|
14
|
+
uTileCount: number;
|
|
15
|
+
vTileCount: number;
|
|
16
|
+
blendTiles: boolean;
|
|
17
|
+
softParticles: boolean;
|
|
18
|
+
softNearFade: number;
|
|
19
|
+
softFarFade: number;
|
|
20
|
+
materialBlendMode: number;
|
|
21
|
+
materialTransparent: boolean;
|
|
22
|
+
materialDepthTest: boolean;
|
|
23
|
+
materialDepthWrite: boolean;
|
|
24
|
+
materialAlphaTest: number;
|
|
25
|
+
texture: Texture | null;
|
|
26
|
+
layerMask: number;
|
|
27
|
+
}
|
|
28
|
+
export declare class BatchedRenderer extends TransformNode {
|
|
29
|
+
batches: Array<VFXBatch>;
|
|
30
|
+
systemToBatchIndex: Map<IParticleSystem, number>;
|
|
31
|
+
depthTexture: BaseTexture | null;
|
|
32
|
+
constructor(name: string, scene: Scene);
|
|
33
|
+
private static equals;
|
|
34
|
+
addSystem(system: IParticleSystem): void;
|
|
35
|
+
deleteSystem(system: IParticleSystem): void;
|
|
36
|
+
updateSystem(system: IParticleSystem): void;
|
|
37
|
+
setDepthTexture(depthTexture: BaseTexture | null): void;
|
|
38
|
+
update(delta: number): void;
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
2
|
+
import { Particle, EmitterShape, ShapeJSON, IParticleSystem, Plugin } from 'quarks.core';
|
|
3
|
+
export declare class MeshSurfaceEmitter implements EmitterShape {
|
|
4
|
+
type: string;
|
|
5
|
+
private _triangleIndexToArea;
|
|
6
|
+
private _mesh?;
|
|
7
|
+
private _positions?;
|
|
8
|
+
private _indices?;
|
|
9
|
+
private _meshReferenceId?;
|
|
10
|
+
get mesh(): Mesh | undefined;
|
|
11
|
+
set mesh(mesh: Mesh | undefined);
|
|
12
|
+
constructor(mesh?: Mesh, meshReferenceId?: string);
|
|
13
|
+
initialize(p: Particle): void;
|
|
14
|
+
toJSON(): ShapeJSON;
|
|
15
|
+
static fromJSON(json: any): MeshSurfaceEmitter;
|
|
16
|
+
clone(): EmitterShape;
|
|
17
|
+
update(_system: IParticleSystem, _delta: number): void;
|
|
18
|
+
}
|
|
19
|
+
export declare const MeshSurfaceEmitterPlugin: Plugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
2
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
3
|
+
import { Matrix4, IParticleSystem, SerializationOptions } from 'quarks.core';
|
|
4
|
+
export declare class ParticleEmitter extends TransformNode {
|
|
5
|
+
system: IParticleSystem;
|
|
6
|
+
private _matrixWorld;
|
|
7
|
+
get matrixWorld(): Matrix4;
|
|
8
|
+
get visible(): boolean;
|
|
9
|
+
set visible(value: boolean);
|
|
10
|
+
get uuid(): string;
|
|
11
|
+
constructor(system: IParticleSystem, scene?: Scene);
|
|
12
|
+
dispose(): void;
|
|
13
|
+
extractFromCache(cache: any): any[];
|
|
14
|
+
clone(name?: string): ParticleEmitter;
|
|
15
|
+
toJSON(meta?: any, options?: SerializationOptions): any;
|
|
16
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
+
import { Texture } from '@babylonjs/core/Materials/Textures/texture';
|
|
3
|
+
import { ColorGenerator, FunctionColorGenerator, FunctionJSON, FunctionValueGenerator, ValueGenerator, Behavior, Particle, EmitterShape, RendererEmitterSettings, RotationGenerator, IParticleSystem, EmissionState, SerializationOptions, Matrix4, Vector3Generator, ParticleSystemEvent, ParticleSystemEventType } from 'quarks.core';
|
|
4
|
+
import { ParticleEmitter } from './ParticleEmitter';
|
|
5
|
+
import { RenderMode } from './VFXBatch';
|
|
6
|
+
import { BatchedRenderer, VFXBatchSettings } from './BatchedRenderer';
|
|
7
|
+
export interface BurstParameters {
|
|
8
|
+
time: number;
|
|
9
|
+
count: ValueGenerator | FunctionValueGenerator;
|
|
10
|
+
cycle: number;
|
|
11
|
+
interval: number;
|
|
12
|
+
probability: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ParticleSystemParameters {
|
|
15
|
+
autoDestroy?: boolean;
|
|
16
|
+
looping?: boolean;
|
|
17
|
+
prewarm?: boolean;
|
|
18
|
+
duration?: number;
|
|
19
|
+
shape?: EmitterShape;
|
|
20
|
+
startLife?: ValueGenerator | FunctionValueGenerator;
|
|
21
|
+
startSpeed?: ValueGenerator | FunctionValueGenerator;
|
|
22
|
+
startRotation?: ValueGenerator | FunctionValueGenerator | RotationGenerator;
|
|
23
|
+
startSize?: ValueGenerator | FunctionValueGenerator | Vector3Generator;
|
|
24
|
+
startLength?: ValueGenerator | FunctionValueGenerator;
|
|
25
|
+
startColor?: ColorGenerator | FunctionColorGenerator;
|
|
26
|
+
emissionOverTime?: ValueGenerator | FunctionValueGenerator;
|
|
27
|
+
emissionOverDistance?: ValueGenerator | FunctionValueGenerator;
|
|
28
|
+
emissionBursts?: Array<BurstParameters>;
|
|
29
|
+
onlyUsedByOther?: boolean;
|
|
30
|
+
behaviors?: Array<Behavior>;
|
|
31
|
+
instancingGeometry?: Float32Array;
|
|
32
|
+
instancingIndices?: Uint32Array | Uint16Array;
|
|
33
|
+
instancingUVs?: Float32Array;
|
|
34
|
+
instancingNormals?: Float32Array;
|
|
35
|
+
renderMode?: RenderMode;
|
|
36
|
+
rendererEmitterSettings?: RendererEmitterSettings;
|
|
37
|
+
speedFactor?: number;
|
|
38
|
+
material?: any;
|
|
39
|
+
texture?: Texture | null;
|
|
40
|
+
startTileIndex?: ValueGenerator;
|
|
41
|
+
uTileCount?: number;
|
|
42
|
+
vTileCount?: number;
|
|
43
|
+
blendTiles?: boolean;
|
|
44
|
+
softParticles?: boolean;
|
|
45
|
+
softFarFade?: number;
|
|
46
|
+
softNearFade?: number;
|
|
47
|
+
renderOrder?: number;
|
|
48
|
+
worldSpace?: boolean;
|
|
49
|
+
blendMode?: number;
|
|
50
|
+
transparent?: boolean;
|
|
51
|
+
depthTest?: boolean;
|
|
52
|
+
depthWrite?: boolean;
|
|
53
|
+
alphaTest?: number;
|
|
54
|
+
layerMask?: number;
|
|
55
|
+
scene?: Scene;
|
|
56
|
+
}
|
|
57
|
+
export interface BurstParametersJSON {
|
|
58
|
+
time: number;
|
|
59
|
+
count: FunctionJSON | number;
|
|
60
|
+
cycle: number;
|
|
61
|
+
interval: number;
|
|
62
|
+
probability: number;
|
|
63
|
+
}
|
|
64
|
+
export interface ParticleSystemJSONParameters {
|
|
65
|
+
version: string;
|
|
66
|
+
autoDestroy: boolean;
|
|
67
|
+
looping: boolean;
|
|
68
|
+
prewarm: boolean;
|
|
69
|
+
duration: number;
|
|
70
|
+
shape: any;
|
|
71
|
+
startLife: FunctionJSON;
|
|
72
|
+
startSpeed: FunctionJSON;
|
|
73
|
+
startRotation: FunctionJSON;
|
|
74
|
+
startSize: FunctionJSON;
|
|
75
|
+
startColor: FunctionJSON;
|
|
76
|
+
emissionOverTime: FunctionJSON;
|
|
77
|
+
emissionOverDistance: FunctionJSON;
|
|
78
|
+
emissionBursts?: Array<BurstParametersJSON>;
|
|
79
|
+
onlyUsedByOther: boolean;
|
|
80
|
+
rendererEmitterSettings: RendererEmitterSettings;
|
|
81
|
+
instancingGeometry?: any;
|
|
82
|
+
renderMode: number;
|
|
83
|
+
renderOrder?: number;
|
|
84
|
+
speedFactor?: number;
|
|
85
|
+
texture?: string;
|
|
86
|
+
material?: string;
|
|
87
|
+
layers?: number;
|
|
88
|
+
startTileIndex: FunctionJSON | number;
|
|
89
|
+
uTileCount: number;
|
|
90
|
+
vTileCount: number;
|
|
91
|
+
blendTiles?: boolean;
|
|
92
|
+
softParticles?: boolean;
|
|
93
|
+
softFarFade?: number;
|
|
94
|
+
softNearFade?: number;
|
|
95
|
+
blending?: number;
|
|
96
|
+
transparent?: boolean;
|
|
97
|
+
depthTest?: boolean;
|
|
98
|
+
depthWrite?: boolean;
|
|
99
|
+
alphaTest?: number;
|
|
100
|
+
behaviors: Array<any>;
|
|
101
|
+
worldSpace: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface BabylonMetaData {
|
|
104
|
+
textures: {
|
|
105
|
+
[uuid: string]: Texture | null;
|
|
106
|
+
};
|
|
107
|
+
materials: {
|
|
108
|
+
[uuid: string]: any;
|
|
109
|
+
};
|
|
110
|
+
geometries: {
|
|
111
|
+
[uuid: string]: any;
|
|
112
|
+
};
|
|
113
|
+
images?: {
|
|
114
|
+
[uuid: string]: any;
|
|
115
|
+
};
|
|
116
|
+
shapes?: {
|
|
117
|
+
[uuid: string]: any;
|
|
118
|
+
};
|
|
119
|
+
skeletons?: {
|
|
120
|
+
[uuid: string]: any;
|
|
121
|
+
};
|
|
122
|
+
animations?: {
|
|
123
|
+
[uuid: string]: any;
|
|
124
|
+
};
|
|
125
|
+
nodes?: {
|
|
126
|
+
[uuid: string]: any;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export declare class ParticleSystem implements IParticleSystem {
|
|
130
|
+
private static serializationCounter;
|
|
131
|
+
autoDestroy: boolean;
|
|
132
|
+
prewarm: boolean;
|
|
133
|
+
looping: boolean;
|
|
134
|
+
duration: number;
|
|
135
|
+
startLife: ValueGenerator | FunctionValueGenerator;
|
|
136
|
+
startSpeed: ValueGenerator | FunctionValueGenerator;
|
|
137
|
+
startRotation: ValueGenerator | FunctionValueGenerator | RotationGenerator;
|
|
138
|
+
startSize: ValueGenerator | FunctionValueGenerator | Vector3Generator;
|
|
139
|
+
startColor: ColorGenerator | FunctionColorGenerator;
|
|
140
|
+
startTileIndex: ValueGenerator;
|
|
141
|
+
rendererEmitterSettings: RendererEmitterSettings;
|
|
142
|
+
emissionOverTime: ValueGenerator | FunctionValueGenerator;
|
|
143
|
+
emissionOverDistance: ValueGenerator | FunctionValueGenerator;
|
|
144
|
+
emissionBursts: Array<BurstParameters>;
|
|
145
|
+
onlyUsedByOther: boolean;
|
|
146
|
+
worldSpace: boolean;
|
|
147
|
+
particleNum: number;
|
|
148
|
+
paused: boolean;
|
|
149
|
+
particles: Array<Particle>;
|
|
150
|
+
emitterShape: EmitterShape;
|
|
151
|
+
emitter: ParticleEmitter;
|
|
152
|
+
rendererSettings: VFXBatchSettings;
|
|
153
|
+
neededToUpdateRender: boolean;
|
|
154
|
+
behaviors: Array<Behavior>;
|
|
155
|
+
emissionState: EmissionState;
|
|
156
|
+
private prewarmed;
|
|
157
|
+
private emitEnded;
|
|
158
|
+
private markForDestroy;
|
|
159
|
+
private temp;
|
|
160
|
+
private normalMatrix;
|
|
161
|
+
private memory;
|
|
162
|
+
private listeners;
|
|
163
|
+
private readonly layerMaskProxy;
|
|
164
|
+
private materialRef;
|
|
165
|
+
/** @internal **/
|
|
166
|
+
_renderer?: BatchedRenderer;
|
|
167
|
+
set time(time: number);
|
|
168
|
+
get time(): number;
|
|
169
|
+
get layers(): {
|
|
170
|
+
mask: number;
|
|
171
|
+
};
|
|
172
|
+
get texture(): Texture | null;
|
|
173
|
+
set texture(texture: Texture | null);
|
|
174
|
+
get material(): any;
|
|
175
|
+
set material(material: any);
|
|
176
|
+
get uTileCount(): number;
|
|
177
|
+
set uTileCount(u: number);
|
|
178
|
+
get vTileCount(): number;
|
|
179
|
+
set vTileCount(v: number);
|
|
180
|
+
get blendTiles(): boolean;
|
|
181
|
+
set blendTiles(v: boolean);
|
|
182
|
+
get softParticles(): boolean;
|
|
183
|
+
set softParticles(v: boolean);
|
|
184
|
+
get softNearFade(): number;
|
|
185
|
+
set softNearFade(v: number);
|
|
186
|
+
get softFarFade(): number;
|
|
187
|
+
set softFarFade(v: number);
|
|
188
|
+
get instancingGeometry(): Float32Array;
|
|
189
|
+
set instancingGeometry(geometry: Float32Array);
|
|
190
|
+
get blending(): number;
|
|
191
|
+
set blending(blending: number);
|
|
192
|
+
get renderMode(): RenderMode;
|
|
193
|
+
set renderMode(renderMode: RenderMode);
|
|
194
|
+
get renderOrder(): number;
|
|
195
|
+
set renderOrder(renderOrder: number);
|
|
196
|
+
constructor(parameters: ParticleSystemParameters);
|
|
197
|
+
private applyMaterialSettings;
|
|
198
|
+
pause(): void;
|
|
199
|
+
play(): void;
|
|
200
|
+
stop(): void;
|
|
201
|
+
private spawn;
|
|
202
|
+
endEmit(): void;
|
|
203
|
+
dispose(): void;
|
|
204
|
+
restart(): void;
|
|
205
|
+
private firstTimeUpdate;
|
|
206
|
+
/** @internal */
|
|
207
|
+
update(delta: number): void;
|
|
208
|
+
emit(delta: number, emissionState: EmissionState, emitterMatrix: Matrix4): void;
|
|
209
|
+
toJSON(metaData?: BabylonMetaData | string, _options?: SerializationOptions): ParticleSystemJSONParameters;
|
|
210
|
+
static fromJSON(json: ParticleSystemJSONParameters, meta: BabylonMetaData, dependencies?: {
|
|
211
|
+
[uuid: string]: Behavior;
|
|
212
|
+
}, scene?: Scene): ParticleSystem;
|
|
213
|
+
private static nextSerializationId;
|
|
214
|
+
private static createFallbackNormals;
|
|
215
|
+
private toRendererSettingsJSON;
|
|
216
|
+
private ensureGeometryMeta;
|
|
217
|
+
private ensureMaterialMeta;
|
|
218
|
+
private static resolveGeometryData;
|
|
219
|
+
addBehavior(behavior: Behavior): void;
|
|
220
|
+
getRendererSettings(): VFXBatchSettings;
|
|
221
|
+
addEventListener(event: ParticleSystemEventType, callback: (event: ParticleSystemEvent) => void): void;
|
|
222
|
+
removeAllEventListeners(event: ParticleSystemEventType): void;
|
|
223
|
+
removeEventListener(event: ParticleSystemEventType, callback: (event: ParticleSystemEvent) => void): void;
|
|
224
|
+
private fire;
|
|
225
|
+
clone(): ParticleSystem;
|
|
226
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
3
|
+
export interface QuarksLoaderOptions {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class QuarksLoader {
|
|
7
|
+
private scene;
|
|
8
|
+
private options;
|
|
9
|
+
constructor(scene: Scene, options?: QuarksLoaderOptions);
|
|
10
|
+
load(url: string): Promise<TransformNode>;
|
|
11
|
+
parse(json: any, baseUrl?: string): TransformNode;
|
|
12
|
+
private parseGeometries;
|
|
13
|
+
private parseSphereGeometry;
|
|
14
|
+
private parseBufferGeometry;
|
|
15
|
+
private extractInterleavedAttribute;
|
|
16
|
+
private int32ArrayToFloat32;
|
|
17
|
+
private parseImages;
|
|
18
|
+
private parseTextures;
|
|
19
|
+
private mapWrapMode;
|
|
20
|
+
private parseMaterials;
|
|
21
|
+
private getGeometry;
|
|
22
|
+
private getMaterial;
|
|
23
|
+
private createPlaceholderNode;
|
|
24
|
+
private createMeshNode;
|
|
25
|
+
private parseObject;
|
|
26
|
+
private parseParticleSystem;
|
|
27
|
+
private linkReferences;
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IAnimationData, IPrefab } from 'quarks.core';
|
|
2
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
3
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
4
|
+
import { ParticleEmitter } from './ParticleEmitter';
|
|
5
|
+
import { BatchedRenderer } from './BatchedRenderer';
|
|
6
|
+
interface QuarksTimelineClip {
|
|
7
|
+
uuid?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
play?: () => void;
|
|
10
|
+
pause?: () => void;
|
|
11
|
+
stop?: () => void;
|
|
12
|
+
setTime?: (time: number) => void;
|
|
13
|
+
}
|
|
14
|
+
interface AnimationData extends IAnimationData {
|
|
15
|
+
type: 'three' | 'ps';
|
|
16
|
+
target: TransformNode;
|
|
17
|
+
loop: boolean;
|
|
18
|
+
clip?: QuarksTimelineClip;
|
|
19
|
+
clipUUID?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class QuarksPrefab extends TransformNode implements IPrefab {
|
|
22
|
+
type: string;
|
|
23
|
+
animationData: Array<AnimationData>;
|
|
24
|
+
isPlaying: boolean;
|
|
25
|
+
currentTime: number;
|
|
26
|
+
timeScale: number;
|
|
27
|
+
duration: number;
|
|
28
|
+
private _lastUpdateTimeMs;
|
|
29
|
+
private _batchedRenderer?;
|
|
30
|
+
private _tempAnimationJSON;
|
|
31
|
+
constructor(name?: string, scene?: Scene);
|
|
32
|
+
registerBatchedRenderer(renderer: BatchedRenderer): void;
|
|
33
|
+
addParticleSystemAnimation(emitter: ParticleEmitter, startTime?: number, duration?: number, loop?: boolean): AnimationData;
|
|
34
|
+
addThreeAnimation(target: TransformNode, clip?: QuarksTimelineClip, startTime?: number, duration?: number, loop?: boolean, clipUUID?: string): AnimationData;
|
|
35
|
+
removeAnimation(index: number): void;
|
|
36
|
+
play(): void;
|
|
37
|
+
pause(): void;
|
|
38
|
+
stop(): void;
|
|
39
|
+
update(forceDelta?: number): void;
|
|
40
|
+
setTime(time: number): void;
|
|
41
|
+
getDuration(): number;
|
|
42
|
+
resolveReferences(root: TransformNode): void;
|
|
43
|
+
toJSON(): any;
|
|
44
|
+
static fromJSON(json: any, scene?: Scene): QuarksPrefab;
|
|
45
|
+
private resolveTimelineClip;
|
|
46
|
+
private updateDuration;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node } from '@babylonjs/core/node';
|
|
2
|
+
import { ParticleEmitter } from './ParticleEmitter';
|
|
3
|
+
import { BatchedRenderer } from './BatchedRenderer';
|
|
4
|
+
export declare class QuarksUtil {
|
|
5
|
+
static runOnAllParticleEmitters(root: Node, callback: (emitter: ParticleEmitter) => void): void;
|
|
6
|
+
static addToBatchRenderer(root: Node, batchRenderer: BatchedRenderer): void;
|
|
7
|
+
static play(root: Node): void;
|
|
8
|
+
static stop(root: Node): void;
|
|
9
|
+
static pause(root: Node): void;
|
|
10
|
+
static restart(root: Node): void;
|
|
11
|
+
static setAutoDestroy(root: Node, autoDestroy: boolean): void;
|
|
12
|
+
static endEmit(root: Node): void;
|
|
13
|
+
private static traverseNode;
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
+
import { VFXBatch } from './VFXBatch';
|
|
3
|
+
import { VFXBatchSettings } from './BatchedRenderer';
|
|
4
|
+
export declare class SpriteBatch extends VFXBatch {
|
|
5
|
+
private offsetBuffer;
|
|
6
|
+
private rotationBuffer;
|
|
7
|
+
private sizeBuffer;
|
|
8
|
+
private colorBuffer;
|
|
9
|
+
private uvTileBuffer;
|
|
10
|
+
private velocityBuffer?;
|
|
11
|
+
private offsetVB;
|
|
12
|
+
private rotationVB;
|
|
13
|
+
private sizeVB;
|
|
14
|
+
private colorVB;
|
|
15
|
+
private uvTileVB;
|
|
16
|
+
private velocityVB?;
|
|
17
|
+
constructor(settings: VFXBatchSettings, scene: Scene);
|
|
18
|
+
setupBuffers(): void;
|
|
19
|
+
private buildExpandableBuffers;
|
|
20
|
+
expandBuffers(target: number): void;
|
|
21
|
+
rebuildMaterial(): void;
|
|
22
|
+
private vector_;
|
|
23
|
+
private vector2_;
|
|
24
|
+
private vector3_;
|
|
25
|
+
private quaternion_;
|
|
26
|
+
private quaternion2_;
|
|
27
|
+
private quaternion3_;
|
|
28
|
+
private rotationMat_;
|
|
29
|
+
private rotationMat2_;
|
|
30
|
+
update(): void;
|
|
31
|
+
dispose(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
+
import { VFXBatch } from './VFXBatch';
|
|
3
|
+
import { VFXBatchSettings } from './BatchedRenderer';
|
|
4
|
+
export declare class TrailBatch extends VFXBatch {
|
|
5
|
+
private positionBuffer;
|
|
6
|
+
private previousBuffer;
|
|
7
|
+
private nextBuffer;
|
|
8
|
+
private uvBuffer;
|
|
9
|
+
private sideBuffer;
|
|
10
|
+
private widthBuffer;
|
|
11
|
+
private colorBuffer;
|
|
12
|
+
private indexBuffer;
|
|
13
|
+
private previousVB;
|
|
14
|
+
private nextVB;
|
|
15
|
+
private sideVB;
|
|
16
|
+
private widthVB;
|
|
17
|
+
constructor(settings: VFXBatchSettings, scene: Scene);
|
|
18
|
+
setupBuffers(): void;
|
|
19
|
+
expandBuffers(target: number): void;
|
|
20
|
+
rebuildMaterial(): void;
|
|
21
|
+
private vector_;
|
|
22
|
+
private vector2_;
|
|
23
|
+
private vector3_;
|
|
24
|
+
private quaternion_;
|
|
25
|
+
update(): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
2
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
3
|
+
import { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';
|
|
4
|
+
import { IParticleSystem } from 'quarks.core';
|
|
5
|
+
import { VFXBatchSettings } from './BatchedRenderer';
|
|
6
|
+
export declare enum RenderMode {
|
|
7
|
+
BillBoard = 0,
|
|
8
|
+
StretchedBillBoard = 1,
|
|
9
|
+
Mesh = 2,
|
|
10
|
+
Trail = 3,
|
|
11
|
+
HorizontalBillBoard = 4,
|
|
12
|
+
VerticalBillBoard = 5
|
|
13
|
+
}
|
|
14
|
+
export interface StoredBatchSettings {
|
|
15
|
+
instancingGeometry: Float32Array;
|
|
16
|
+
instancingIndices: Uint32Array | Uint16Array;
|
|
17
|
+
instancingUVs?: Float32Array;
|
|
18
|
+
instancingNormals?: Float32Array;
|
|
19
|
+
renderMode: RenderMode;
|
|
20
|
+
renderOrder: number;
|
|
21
|
+
uTileCount: number;
|
|
22
|
+
vTileCount: number;
|
|
23
|
+
blendTiles: boolean;
|
|
24
|
+
softParticles: boolean;
|
|
25
|
+
softNearFade: number;
|
|
26
|
+
softFarFade: number;
|
|
27
|
+
materialBlendMode: number;
|
|
28
|
+
materialTransparent: boolean;
|
|
29
|
+
materialDepthTest: boolean;
|
|
30
|
+
materialDepthWrite: boolean;
|
|
31
|
+
materialAlphaTest: number;
|
|
32
|
+
texture: any;
|
|
33
|
+
layerMask: number;
|
|
34
|
+
}
|
|
35
|
+
export declare abstract class VFXBatch {
|
|
36
|
+
mesh: Mesh;
|
|
37
|
+
systems: Set<IParticleSystem>;
|
|
38
|
+
settings: StoredBatchSettings;
|
|
39
|
+
protected maxParticles: number;
|
|
40
|
+
protected scene: Scene;
|
|
41
|
+
protected constructor(settings: VFXBatchSettings, scene: Scene);
|
|
42
|
+
addSystem(system: IParticleSystem): void;
|
|
43
|
+
removeSystem(system: IParticleSystem): void;
|
|
44
|
+
getVisibleSystems(): IParticleSystem[];
|
|
45
|
+
applyDepthTexture(depthTexture: BaseTexture | null): void;
|
|
46
|
+
abstract setupBuffers(): void;
|
|
47
|
+
abstract expandBuffers(target: number): void;
|
|
48
|
+
abstract rebuildMaterial(): void;
|
|
49
|
+
abstract update(): void;
|
|
50
|
+
dispose(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { BatchedRenderer } from './BatchedRenderer';
|
|
2
|
+
export type { VFXBatchSettings } from './BatchedRenderer';
|
|
3
|
+
export { BatchedParticleRenderer } from './BatchedParticleRenderer';
|
|
4
|
+
export { VFXBatch, RenderMode } from './VFXBatch';
|
|
5
|
+
export type { StoredBatchSettings } from './VFXBatch';
|
|
6
|
+
export { SpriteBatch } from './SpriteBatch';
|
|
7
|
+
export { TrailBatch } from './TrailBatch';
|
|
8
|
+
export { ParticleSystem } from './ParticleSystem';
|
|
9
|
+
export type { ParticleSystemParameters, BurstParameters } from './ParticleSystem';
|
|
10
|
+
export { ParticleEmitter } from './ParticleEmitter';
|
|
11
|
+
export { QuarksUtil } from './QuarksUtil';
|
|
12
|
+
export { QuarksLoader } from './QuarksLoader';
|
|
13
|
+
export type { QuarksLoaderOptions } from './QuarksLoader';
|
|
14
|
+
export { QuarksPrefab } from './QuarksPrefab';
|
|
15
|
+
export { MeshSurfaceEmitter, MeshSurfaceEmitterPlugin } from './MeshSurfaceEmitter';
|
|
16
|
+
export * from './shaders/';
|
|
17
|
+
export * from './materials/';
|
|
18
|
+
export * from 'quarks.core';
|
|
19
|
+
export type { IParticleSystem, IParticle, Particle, EmissionState, RendererEmitterSettings, TrailSettings, StretchedBillBoardSettings, BillBoardSettings, MeshSettings, IEmitter, ParticleSystemEvent, ParticleSystemEventType, SerializationOptions, Behavior, EmitterShape, ValueGenerator, FunctionValueGenerator, ColorGenerator, FunctionColorGenerator, RotationGenerator, Vector3Generator, } from 'quarks.core';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
+
import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
|
|
3
|
+
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
|
|
4
|
+
export type BabylonParticleMaterialParameters = Record<string, any>;
|
|
5
|
+
export declare class ParticleMeshStandardMaterial extends StandardMaterial {
|
|
6
|
+
readonly isParticleMeshStandardMaterial = true;
|
|
7
|
+
constructor(name: string, scene?: Scene, parameters?: BabylonParticleMaterialParameters);
|
|
8
|
+
}
|
|
9
|
+
export declare class ParticleMeshPhysicsMaterial extends PBRMaterial {
|
|
10
|
+
readonly isParticleMeshPhysicsMaterial = true;
|
|
11
|
+
constructor(name: string, scene?: Scene, parameters?: BabylonParticleMaterialParameters);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ParticleMaterials';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './register-shader-chunks';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n#ifdef SOFT_PARTICLES\n\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float viewDepth = linearize_depth(readDepth);\n float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));\n\n gl_FragColor *= softParticlesFade;\n#endif\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n#ifdef SOFT_PARTICLES\n uniform sampler2D depthTexture;\n uniform vec4 projParams;\n uniform vec2 softParams;\n\n varying vec4 projPosition;\n varying float linearDepth;\n\n #define SOFT_NEAR_FADE softParams.x\n #define SOFT_INV_FADE_DISTANCE softParams.y\n\n #define zNear projParams.x\n #define zFar projParams.y\n\n float linearize_depth(float d) {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n#endif\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n#ifdef UV_TILE\n attribute float uvTile;\n uniform vec2 tileCount;\n\n mat3 makeTileTransform(float tileIndex) {\n float col = mod(tileIndex, tileCount.x);\n float row = (tileCount.y - floor(tileIndex / tileCount.x) - 1.0);\n return mat3(\n 1.0 / tileCount.x, 0.0, 0.0,\n 0.0, 1.0 / tileCount.y, 0.0,\n col / tileCount.x, row / tileCount.y, 1.0\n );\n }\n#else\n mat3 makeTileTransform(float tileIndex) {\n return mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);\n }\n#endif\n\n#if defined(USE_UV)\n varying vec2 vUv;\n #ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n #endif\n#endif\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n#ifdef UV_TILE\n mat3 tileTransform = makeTileTransform(floor(uvTile));\n #ifdef TILE_BLEND\n mat3 nextTileTransform = makeTileTransform(ceil(uvTile));\n vUvBlend = fract(uvTile);\n #endif\n#else\n mat3 tileTransform = makeTileTransform(0.0);\n#endif\n\n#if defined(USE_UV)\n vUv = (tileTransform * vec3(uv, 1.0)).xy;\n #if defined(TILE_BLEND) && defined(UV_TILE)\n vUvNext = (nextTileTransform * vec3(uv, 1.0)).xy;\n #endif\n#endif\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './chunks';
|
|
2
|
+
export { default as particleVertShader } from './particle_vert.glsl';
|
|
3
|
+
export { default as particleFragShader } from './particle_frag.glsl';
|
|
4
|
+
export { default as localParticleVertShader } from './local_particle_vert.glsl';
|
|
5
|
+
export { default as localParticlePhysicsVertShader } from './local_particle_physics_vert.glsl';
|
|
6
|
+
export { default as particlePhysicsFragShader } from './particle_physics_frag.glsl';
|
|
7
|
+
export { default as stretchedBillboardVertShader } from './stretched_bb_particle_vert.glsl';
|
|
8
|
+
export { default as trailVertShader } from './trail_vert.glsl';
|
|
9
|
+
export { default as trailFragShader } from './trail_frag.glsl';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\nattribute vec3 position;\nattribute vec2 uv;\nattribute vec3 normal;\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute vec4 rotation;\nattribute float uvTile;\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\nvarying vec3 vWorldPos;\n\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 qVec = q.xyz;\n float qW = q.w;\n vec3 t = 2.0 * cross(qVec, v);\n return v + qW * t + cross(qVec, t);\n}\n\nvoid main() {\n vec3 scaledPosition = position * size;\n vec3 rotatedPosition = applyQuaternion(scaledPosition, rotation);\n vec3 rotatedNormal = normalize(applyQuaternion(normal, rotation));\n vec3 localPos = rotatedPosition + offset;\n\n vec4 worldPos = world * vec4(localPos, 1.0);\n vec4 viewPos = view * worldPos;\n gl_Position = projection * viewPos;\n\n vWorldPos = worldPos.xyz;\n vNormal = normalize((world * vec4(rotatedNormal, 0.0)).xyz);\n\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -viewPos.z;\n#endif\n\n#ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float tileU = mod(uvTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(uvTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n#else\n vUV = uv;\n#endif\n\n vColor = color;\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute vec4 rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 qVec = q.xyz;\n float qW = q.w;\n vec3 t = 2.0 * cross(qVec, v);\n return v + qW * t + cross(qVec, t);\n}\n\nvoid main() {\n vec3 rotatedPosition = applyQuaternion(position * size, rotation);\n vec3 worldPos = rotatedPosition + offset;\n\n gl_Position = worldViewProjection * vec4(worldPos, 1.0);\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_COLOR_AS_ALPHA\n baseColor.a *= (baseColor.r + baseColor.g + baseColor.b) / 3.0;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n gl_FragColor = baseColor;\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\n\nuniform vec3 lightDirection;\nuniform vec3 lightColor;\nuniform vec3 ambientColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n vec3 N = normalize(vNormal);\n vec3 L = normalize(-lightDirection);\n float NdotL = max(dot(N, L), 0.0);\n vec3 litColor = ambientColor + lightColor * NdotL;\n\n gl_FragColor = vec4(baseColor.rgb * litColor, baseColor.a);\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float c = cos(rotation);\n float s = sin(rotation);\n\n vec2 alignedPosition = position.xy * size.xy;\n vec2 rotatedPosition;\n rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;\n rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;\n\n#ifdef HORIZONTAL\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.x += rotatedPosition.x;\n mvPosition.z -= rotatedPosition.y;\n mvPosition = view * mvPosition;\n#elif defined(VERTICAL)\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.y += rotatedPosition.y;\n mvPosition = view * mvPosition;\n mvPosition.x += rotatedPosition.x;\n#else\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n mvPosition.xy += rotatedPosition;\n#endif\n\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\nattribute vec4 velocity;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform float speedFactor;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n vec3 viewVelocity = mat3(view * world) * velocity.xyz;\n float vlength = length(viewVelocity);\n if (vlength < 0.0001) {\n vlength = 0.0001;\n viewVelocity = vec3(0.0, 0.0, 1.0);\n }\n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize;\n mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize;\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n baseColor *= texColor;\n#endif\n\n if (baseColor.a < 0.01) discard;\n\n gl_FragColor = baseColor;\n}\n";
|
|
2
|
+
export default _default;
|