babylon.quarks 0.17.4 → 0.17.7
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 +103 -0
- package/LICENSE +21 -21
- package/README.md +169 -33
- package/dist/babylon.quarks.cjs +1 -1
- package/dist/babylon.quarks.cjs.map +1 -1
- package/dist/babylon.quarks.esm.js +1 -1
- package/dist/babylon.quarks.esm.js.map +1 -1
- package/dist/babylon.quarks.umd.min.js +2 -0
- package/dist/babylon.quarks.umd.min.js.map +1 -0
- package/dist/types/index.d.ts +2829 -19
- package/package.json +62 -60
- package/src/BatchedParticleRenderer.ts +3 -3
- package/src/BatchedRenderer.ts +228 -227
- package/src/MeshSurfaceEmitter.ts +137 -137
- package/src/ParticleEmitter.ts +86 -86
- package/src/ParticleSystem.ts +1322 -1285
- package/src/QuarksLoader.ts +529 -510
- package/src/QuarksPrefab.ts +307 -307
- package/src/QuarksUtil.ts +66 -66
- package/src/SpriteBatch.ts +403 -404
- package/src/TrailBatch.ts +420 -419
- package/src/VFXBatch.ts +108 -108
- package/src/geometryUtil.ts +15 -15
- package/src/index.ts +59 -52
- package/src/materials/ParticleMaterials.ts +23 -23
- package/src/materials/index.ts +1 -1
- package/src/shaders/chunks/index.ts +1 -1
- package/src/shaders/chunks/register-shader-chunks.ts +32 -32
- package/src/shaders/chunks/soft_fragment.glsl.ts +13 -13
- package/src/shaders/chunks/soft_pars_fragment.glsl.ts +20 -20
- package/src/shaders/chunks/soft_pars_vertex.glsl.ts +6 -6
- package/src/shaders/chunks/soft_vertex.glsl.ts +6 -6
- package/src/shaders/chunks/tile_fragment.glsl.ts +9 -9
- package/src/shaders/chunks/tile_pars_fragment.glsl.ts +9 -9
- package/src/shaders/chunks/tile_pars_vertex.glsl.ts +28 -28
- package/src/shaders/chunks/tile_vertex.glsl.ts +18 -18
- package/src/shaders/index.ts +9 -9
- package/src/shaders/local_particle_physics_vert.glsl.ts +79 -79
- package/src/shaders/local_particle_vert.glsl.ts +50 -50
- package/src/shaders/particle_frag.glsl.ts +61 -61
- package/src/shaders/particle_physics_frag.glsl.ts +67 -67
- package/src/shaders/particle_vert.glsl.ts +85 -85
- package/src/shaders/stretched_bb_particle_vert.glsl.ts +76 -74
- package/src/shaders/trail_frag.glsl.ts +21 -21
- package/src/shaders/trail_vert.glsl.ts +58 -58
- package/dist/types/BatchedParticleRenderer.d.ts +0 -2
- package/dist/types/BatchedRenderer.d.ts +0 -59
- package/dist/types/MeshSurfaceEmitter.d.ts +0 -19
- package/dist/types/ParticleEmitter.d.ts +0 -16
- package/dist/types/ParticleSystem.d.ts +0 -234
- package/dist/types/QuarksLoader.d.ts +0 -28
- package/dist/types/QuarksPrefab.d.ts +0 -48
- package/dist/types/QuarksUtil.d.ts +0 -14
- package/dist/types/SpriteBatch.d.ts +0 -33
- package/dist/types/TrailBatch.d.ts +0 -28
- package/dist/types/VFXBatch.d.ts +0 -51
- package/dist/types/geometryUtil.d.ts +0 -2
- package/dist/types/materials/ParticleMaterials.d.ts +0 -12
- package/dist/types/materials/index.d.ts +0 -1
- package/dist/types/shaders/chunks/index.d.ts +0 -1
- package/dist/types/shaders/chunks/register-shader-chunks.d.ts +0 -3
- package/dist/types/shaders/chunks/soft_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/soft_pars_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/soft_pars_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/soft_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_pars_fragment.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_pars_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/chunks/tile_vertex.glsl.d.ts +0 -2
- package/dist/types/shaders/index.d.ts +0 -9
- package/dist/types/shaders/local_particle_physics_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/local_particle_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/particle_frag.glsl.d.ts +0 -2
- package/dist/types/shaders/particle_physics_frag.glsl.d.ts +0 -2
- package/dist/types/shaders/particle_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/stretched_bb_particle_vert.glsl.d.ts +0 -2
- package/dist/types/shaders/trail_frag.glsl.d.ts +0 -2
- package/dist/types/shaders/trail_vert.glsl.d.ts +0 -2
package/src/VFXBatch.ts
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
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 {ShaderMaterial} from '@babylonjs/core/Materials/shaderMaterial';
|
|
5
|
-
import {IParticleSystem} from 'quarks.core';
|
|
6
|
-
import {VFXBatchSettings} from './BatchedRenderer';
|
|
7
|
-
|
|
8
|
-
export enum RenderMode {
|
|
9
|
-
BillBoard = 0,
|
|
10
|
-
StretchedBillBoard = 1,
|
|
11
|
-
Mesh = 2,
|
|
12
|
-
Trail = 3,
|
|
13
|
-
HorizontalBillBoard = 4,
|
|
14
|
-
VerticalBillBoard = 5,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface StoredBatchSettings {
|
|
18
|
-
instancingGeometry: Float32Array;
|
|
19
|
-
instancingIndices: Uint32Array | Uint16Array;
|
|
20
|
-
instancingUVs?: Float32Array;
|
|
21
|
-
instancingNormals?: Float32Array;
|
|
22
|
-
renderMode: RenderMode;
|
|
23
|
-
renderOrder: number;
|
|
24
|
-
uTileCount: number;
|
|
25
|
-
vTileCount: number;
|
|
26
|
-
blendTiles: boolean;
|
|
27
|
-
softParticles: boolean;
|
|
28
|
-
softNearFade: number;
|
|
29
|
-
softFarFade: number;
|
|
30
|
-
materialBlendMode: number;
|
|
31
|
-
materialTransparent: boolean;
|
|
32
|
-
materialDepthTest: boolean;
|
|
33
|
-
materialDepthWrite: boolean;
|
|
34
|
-
materialAlphaTest: number;
|
|
35
|
-
texture: any;
|
|
36
|
-
layerMask: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export abstract class VFXBatch {
|
|
40
|
-
mesh: Mesh;
|
|
41
|
-
systems: Set<IParticleSystem>;
|
|
42
|
-
settings: StoredBatchSettings;
|
|
43
|
-
protected maxParticles: number;
|
|
44
|
-
protected scene: Scene;
|
|
45
|
-
|
|
46
|
-
protected constructor(settings: VFXBatchSettings, scene: Scene) {
|
|
47
|
-
this.scene = scene;
|
|
48
|
-
this.maxParticles = 1000;
|
|
49
|
-
this.systems = new Set<IParticleSystem>();
|
|
50
|
-
this.settings = {
|
|
51
|
-
instancingGeometry: settings.instancingGeometry,
|
|
52
|
-
instancingIndices: settings.instancingIndices,
|
|
53
|
-
instancingUVs: settings.instancingUVs,
|
|
54
|
-
instancingNormals: settings.instancingNormals,
|
|
55
|
-
renderMode: settings.renderMode,
|
|
56
|
-
renderOrder: settings.renderOrder,
|
|
57
|
-
uTileCount: settings.uTileCount,
|
|
58
|
-
vTileCount: settings.vTileCount,
|
|
59
|
-
blendTiles: settings.blendTiles,
|
|
60
|
-
softParticles: settings.softParticles,
|
|
61
|
-
softNearFade: settings.softNearFade,
|
|
62
|
-
softFarFade: settings.softFarFade,
|
|
63
|
-
materialBlendMode: settings.materialBlendMode,
|
|
64
|
-
materialTransparent: settings.materialTransparent,
|
|
65
|
-
materialDepthTest: settings.materialDepthTest,
|
|
66
|
-
materialDepthWrite: settings.materialDepthWrite,
|
|
67
|
-
materialAlphaTest: settings.materialAlphaTest,
|
|
68
|
-
texture: settings.texture,
|
|
69
|
-
layerMask: settings.layerMask,
|
|
70
|
-
};
|
|
71
|
-
this.mesh = new Mesh('vfxBatch', scene);
|
|
72
|
-
this.mesh.alwaysSelectAsActiveMesh = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
addSystem(system: IParticleSystem) {
|
|
76
|
-
this.systems.add(system);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
removeSystem(system: IParticleSystem) {
|
|
80
|
-
this.systems.delete(system);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
getVisibleSystems(): IParticleSystem[] {
|
|
84
|
-
const visibleSystems: IParticleSystem[] = [];
|
|
85
|
-
for (const system of this.systems) {
|
|
86
|
-
if (system.emitter.visible) {
|
|
87
|
-
visibleSystems.push(system);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return visibleSystems;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
applyDepthTexture(depthTexture: BaseTexture | null): void {
|
|
94
|
-
const material = this.mesh.material;
|
|
95
|
-
if (material && material instanceof ShaderMaterial) {
|
|
96
|
-
material.setTexture('depthTexture', depthTexture);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
abstract setupBuffers(): void;
|
|
101
|
-
abstract expandBuffers(target: number): void;
|
|
102
|
-
abstract rebuildMaterial(): void;
|
|
103
|
-
abstract update(): void;
|
|
104
|
-
|
|
105
|
-
dispose(): void {
|
|
106
|
-
this.mesh.dispose();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
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 {ShaderMaterial} from '@babylonjs/core/Materials/shaderMaterial';
|
|
5
|
+
import {IParticleSystem} from 'quarks.core';
|
|
6
|
+
import {VFXBatchSettings} from './BatchedRenderer';
|
|
7
|
+
|
|
8
|
+
export enum RenderMode {
|
|
9
|
+
BillBoard = 0,
|
|
10
|
+
StretchedBillBoard = 1,
|
|
11
|
+
Mesh = 2,
|
|
12
|
+
Trail = 3,
|
|
13
|
+
HorizontalBillBoard = 4,
|
|
14
|
+
VerticalBillBoard = 5,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface StoredBatchSettings {
|
|
18
|
+
instancingGeometry: Float32Array;
|
|
19
|
+
instancingIndices: Uint32Array | Uint16Array;
|
|
20
|
+
instancingUVs?: Float32Array;
|
|
21
|
+
instancingNormals?: Float32Array;
|
|
22
|
+
renderMode: RenderMode;
|
|
23
|
+
renderOrder: number;
|
|
24
|
+
uTileCount: number;
|
|
25
|
+
vTileCount: number;
|
|
26
|
+
blendTiles: boolean;
|
|
27
|
+
softParticles: boolean;
|
|
28
|
+
softNearFade: number;
|
|
29
|
+
softFarFade: number;
|
|
30
|
+
materialBlendMode: number;
|
|
31
|
+
materialTransparent: boolean;
|
|
32
|
+
materialDepthTest: boolean;
|
|
33
|
+
materialDepthWrite: boolean;
|
|
34
|
+
materialAlphaTest: number;
|
|
35
|
+
texture: any;
|
|
36
|
+
layerMask: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export abstract class VFXBatch {
|
|
40
|
+
mesh: Mesh;
|
|
41
|
+
systems: Set<IParticleSystem>;
|
|
42
|
+
settings: StoredBatchSettings;
|
|
43
|
+
protected maxParticles: number;
|
|
44
|
+
protected scene: Scene;
|
|
45
|
+
|
|
46
|
+
protected constructor(settings: VFXBatchSettings, scene: Scene) {
|
|
47
|
+
this.scene = scene;
|
|
48
|
+
this.maxParticles = 1000;
|
|
49
|
+
this.systems = new Set<IParticleSystem>();
|
|
50
|
+
this.settings = {
|
|
51
|
+
instancingGeometry: settings.instancingGeometry,
|
|
52
|
+
instancingIndices: settings.instancingIndices,
|
|
53
|
+
instancingUVs: settings.instancingUVs,
|
|
54
|
+
instancingNormals: settings.instancingNormals,
|
|
55
|
+
renderMode: settings.renderMode,
|
|
56
|
+
renderOrder: settings.renderOrder,
|
|
57
|
+
uTileCount: settings.uTileCount,
|
|
58
|
+
vTileCount: settings.vTileCount,
|
|
59
|
+
blendTiles: settings.blendTiles,
|
|
60
|
+
softParticles: settings.softParticles,
|
|
61
|
+
softNearFade: settings.softNearFade,
|
|
62
|
+
softFarFade: settings.softFarFade,
|
|
63
|
+
materialBlendMode: settings.materialBlendMode,
|
|
64
|
+
materialTransparent: settings.materialTransparent,
|
|
65
|
+
materialDepthTest: settings.materialDepthTest,
|
|
66
|
+
materialDepthWrite: settings.materialDepthWrite,
|
|
67
|
+
materialAlphaTest: settings.materialAlphaTest,
|
|
68
|
+
texture: settings.texture,
|
|
69
|
+
layerMask: settings.layerMask,
|
|
70
|
+
};
|
|
71
|
+
this.mesh = new Mesh('vfxBatch', scene);
|
|
72
|
+
this.mesh.alwaysSelectAsActiveMesh = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
addSystem(system: IParticleSystem) {
|
|
76
|
+
this.systems.add(system);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
removeSystem(system: IParticleSystem) {
|
|
80
|
+
this.systems.delete(system);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getVisibleSystems(): IParticleSystem[] {
|
|
84
|
+
const visibleSystems: IParticleSystem[] = [];
|
|
85
|
+
for (const system of this.systems) {
|
|
86
|
+
if (system.emitter.visible) {
|
|
87
|
+
visibleSystems.push(system);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return visibleSystems;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
applyDepthTexture(depthTexture: BaseTexture | null): void {
|
|
94
|
+
const material = this.mesh.material;
|
|
95
|
+
if (material && material instanceof ShaderMaterial) {
|
|
96
|
+
material.setTexture('depthTexture', depthTexture);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
abstract setupBuffers(): void;
|
|
101
|
+
abstract expandBuffers(target: number): void;
|
|
102
|
+
abstract rebuildMaterial(): void;
|
|
103
|
+
abstract update(): void;
|
|
104
|
+
|
|
105
|
+
dispose(): void {
|
|
106
|
+
this.mesh.dispose();
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/geometryUtil.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/** Sequential 0..N-1 indices for non-indexed triangle-list BufferGeometry (Three.js drawArrays). */
|
|
2
|
-
export function ensureTriangleIndices(
|
|
3
|
-
positions: Float32Array,
|
|
4
|
-
indices?: Uint32Array | Uint16Array
|
|
5
|
-
): Uint32Array | Uint16Array {
|
|
6
|
-
if (indices && indices.length > 0) {
|
|
7
|
-
return indices;
|
|
8
|
-
}
|
|
9
|
-
const vertexCount = positions.length / 3;
|
|
10
|
-
const out = new Uint32Array(vertexCount);
|
|
11
|
-
for (let i = 0; i < vertexCount; i++) {
|
|
12
|
-
out[i] = i;
|
|
13
|
-
}
|
|
14
|
-
return out;
|
|
15
|
-
}
|
|
1
|
+
/** Sequential 0..N-1 indices for non-indexed triangle-list BufferGeometry (Three.js drawArrays). */
|
|
2
|
+
export function ensureTriangleIndices(
|
|
3
|
+
positions: Float32Array,
|
|
4
|
+
indices?: Uint32Array | Uint16Array
|
|
5
|
+
): Uint32Array | Uint16Array {
|
|
6
|
+
if (indices && indices.length > 0) {
|
|
7
|
+
return indices;
|
|
8
|
+
}
|
|
9
|
+
const vertexCount = positions.length / 3;
|
|
10
|
+
const out = new Uint32Array(vertexCount);
|
|
11
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
12
|
+
out[i] = i;
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,52 +1,59 @@
|
|
|
1
|
-
import {loadPlugin} from 'quarks.core';
|
|
2
|
-
import {MeshSurfaceEmitterPlugin} from './MeshSurfaceEmitter';
|
|
3
|
-
import {registerShaderChunks} from './shaders';
|
|
4
|
-
|
|
5
|
-
export {BatchedRenderer} from './BatchedRenderer';
|
|
6
|
-
export type {VFXBatchSettings} from './BatchedRenderer';
|
|
7
|
-
export {BatchedParticleRenderer} from './BatchedParticleRenderer';
|
|
8
|
-
export {VFXBatch, RenderMode} from './VFXBatch';
|
|
9
|
-
export type {StoredBatchSettings} from './VFXBatch';
|
|
10
|
-
export {SpriteBatch} from './SpriteBatch';
|
|
11
|
-
export {TrailBatch} from './TrailBatch';
|
|
12
|
-
export {ParticleSystem} from './ParticleSystem';
|
|
13
|
-
export type {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import {loadPlugin} from 'quarks.core';
|
|
2
|
+
import {MeshSurfaceEmitterPlugin} from './MeshSurfaceEmitter';
|
|
3
|
+
import {registerShaderChunks} from './shaders';
|
|
4
|
+
|
|
5
|
+
export {BatchedRenderer} from './BatchedRenderer';
|
|
6
|
+
export type {VFXBatchSettings, AdaptivePerformanceOptions, AdaptivePerformanceState} from './BatchedRenderer';
|
|
7
|
+
export {BatchedParticleRenderer} from './BatchedParticleRenderer';
|
|
8
|
+
export {VFXBatch, RenderMode} from './VFXBatch';
|
|
9
|
+
export type {StoredBatchSettings} from './VFXBatch';
|
|
10
|
+
export {SpriteBatch} from './SpriteBatch';
|
|
11
|
+
export {TrailBatch} from './TrailBatch';
|
|
12
|
+
export {ParticleSystem} from './ParticleSystem';
|
|
13
|
+
export type {
|
|
14
|
+
ParticleSystemParameters,
|
|
15
|
+
BurstParameters,
|
|
16
|
+
BurstParametersJSON,
|
|
17
|
+
ParticleSystemJSONParameters,
|
|
18
|
+
BabylonMetaData,
|
|
19
|
+
} from './ParticleSystem';
|
|
20
|
+
export {ParticleEmitter} from './ParticleEmitter';
|
|
21
|
+
export {QuarksUtil} from './QuarksUtil';
|
|
22
|
+
export {QuarksLoader} from './QuarksLoader';
|
|
23
|
+
export type {QuarksLoaderOptions} from './QuarksLoader';
|
|
24
|
+
export {QuarksPrefab} from './QuarksPrefab';
|
|
25
|
+
export type {AnimationData, QuarksTimelineClip} from './QuarksPrefab';
|
|
26
|
+
export {MeshSurfaceEmitter, MeshSurfaceEmitterPlugin} from './MeshSurfaceEmitter';
|
|
27
|
+
export * from './shaders/';
|
|
28
|
+
export * from './materials/';
|
|
29
|
+
export * from 'quarks.core';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// Re-export quarks.core types (interfaces - type-only)
|
|
33
|
+
export type {
|
|
34
|
+
IParticleSystem,
|
|
35
|
+
IParticle,
|
|
36
|
+
Particle,
|
|
37
|
+
EmissionState,
|
|
38
|
+
RendererEmitterSettings,
|
|
39
|
+
TrailSettings,
|
|
40
|
+
StretchedBillBoardSettings,
|
|
41
|
+
BillBoardSettings,
|
|
42
|
+
MeshSettings,
|
|
43
|
+
IEmitter,
|
|
44
|
+
ParticleSystemEvent,
|
|
45
|
+
ParticleSystemEventType,
|
|
46
|
+
SerializationOptions,
|
|
47
|
+
Behavior,
|
|
48
|
+
EmitterShape,
|
|
49
|
+
ValueGenerator,
|
|
50
|
+
FunctionValueGenerator,
|
|
51
|
+
ColorGenerator,
|
|
52
|
+
FunctionColorGenerator,
|
|
53
|
+
RotationGenerator,
|
|
54
|
+
Vector3Generator,
|
|
55
|
+
} from 'quarks.core';
|
|
56
|
+
|
|
57
|
+
registerShaderChunks();
|
|
58
|
+
loadPlugin(MeshSurfaceEmitterPlugin);
|
|
59
|
+
|
|
@@ -1,23 +1,23 @@
|
|
|
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
|
-
|
|
5
|
-
export type BabylonParticleMaterialParameters = Record<string, any>;
|
|
6
|
-
|
|
7
|
-
export class ParticleMeshStandardMaterial extends StandardMaterial {
|
|
8
|
-
readonly isParticleMeshStandardMaterial = true;
|
|
9
|
-
|
|
10
|
-
constructor(name: string, scene?: Scene, parameters: BabylonParticleMaterialParameters = {}) {
|
|
11
|
-
super(name, scene);
|
|
12
|
-
Object.assign(this, parameters);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class ParticleMeshPhysicsMaterial extends PBRMaterial {
|
|
17
|
-
readonly isParticleMeshPhysicsMaterial = true;
|
|
18
|
-
|
|
19
|
-
constructor(name: string, scene?: Scene, parameters: BabylonParticleMaterialParameters = {}) {
|
|
20
|
-
super(name, scene);
|
|
21
|
-
Object.assign(this, parameters);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
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
|
+
|
|
5
|
+
export type BabylonParticleMaterialParameters = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
export class ParticleMeshStandardMaterial extends StandardMaterial {
|
|
8
|
+
readonly isParticleMeshStandardMaterial = true;
|
|
9
|
+
|
|
10
|
+
constructor(name: string, scene?: Scene, parameters: BabylonParticleMaterialParameters = {}) {
|
|
11
|
+
super(name, scene);
|
|
12
|
+
Object.assign(this, parameters);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ParticleMeshPhysicsMaterial extends PBRMaterial {
|
|
17
|
+
readonly isParticleMeshPhysicsMaterial = true;
|
|
18
|
+
|
|
19
|
+
constructor(name: string, scene?: Scene, parameters: BabylonParticleMaterialParameters = {}) {
|
|
20
|
+
super(name, scene);
|
|
21
|
+
Object.assign(this, parameters);
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/materials/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ParticleMaterials';
|
|
1
|
+
export * from './ParticleMaterials';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './register-shader-chunks';
|
|
1
|
+
export * from './register-shader-chunks';
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import softFragment from './soft_fragment.glsl';
|
|
2
|
-
import softParsFragment from './soft_pars_fragment.glsl';
|
|
3
|
-
import softParsVertex from './soft_pars_vertex.glsl';
|
|
4
|
-
import softVertex from './soft_vertex.glsl';
|
|
5
|
-
import tileFragment from './tile_fragment.glsl';
|
|
6
|
-
import tileParsFragment from './tile_pars_fragment.glsl';
|
|
7
|
-
import tileParsVertex from './tile_pars_vertex.glsl';
|
|
8
|
-
import tileVertex from './tile_vertex.glsl';
|
|
9
|
-
|
|
10
|
-
const shaderChunks: Record<string, string> = {};
|
|
11
|
-
let registered = false;
|
|
12
|
-
|
|
13
|
-
export function registerShaderChunks(): void {
|
|
14
|
-
if (registered) return;
|
|
15
|
-
shaderChunks.tile_pars_vertex = tileParsVertex;
|
|
16
|
-
shaderChunks.tile_vertex = tileVertex;
|
|
17
|
-
shaderChunks.tile_pars_fragment = tileParsFragment;
|
|
18
|
-
shaderChunks.tile_fragment = tileFragment;
|
|
19
|
-
shaderChunks.soft_pars_vertex = softParsVertex;
|
|
20
|
-
shaderChunks.soft_vertex = softVertex;
|
|
21
|
-
shaderChunks.soft_pars_fragment = softParsFragment;
|
|
22
|
-
shaderChunks.soft_fragment = softFragment;
|
|
23
|
-
registered = true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function getShaderChunk(chunkName: string): string | undefined {
|
|
27
|
-
return shaderChunks[chunkName];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function getRegisteredShaderChunks(): Readonly<Record<string, string>> {
|
|
31
|
-
return shaderChunks;
|
|
32
|
-
}
|
|
1
|
+
import softFragment from './soft_fragment.glsl';
|
|
2
|
+
import softParsFragment from './soft_pars_fragment.glsl';
|
|
3
|
+
import softParsVertex from './soft_pars_vertex.glsl';
|
|
4
|
+
import softVertex from './soft_vertex.glsl';
|
|
5
|
+
import tileFragment from './tile_fragment.glsl';
|
|
6
|
+
import tileParsFragment from './tile_pars_fragment.glsl';
|
|
7
|
+
import tileParsVertex from './tile_pars_vertex.glsl';
|
|
8
|
+
import tileVertex from './tile_vertex.glsl';
|
|
9
|
+
|
|
10
|
+
const shaderChunks: Record<string, string> = {};
|
|
11
|
+
let registered = false;
|
|
12
|
+
|
|
13
|
+
export function registerShaderChunks(): void {
|
|
14
|
+
if (registered) return;
|
|
15
|
+
shaderChunks.tile_pars_vertex = tileParsVertex;
|
|
16
|
+
shaderChunks.tile_vertex = tileVertex;
|
|
17
|
+
shaderChunks.tile_pars_fragment = tileParsFragment;
|
|
18
|
+
shaderChunks.tile_fragment = tileFragment;
|
|
19
|
+
shaderChunks.soft_pars_vertex = softParsVertex;
|
|
20
|
+
shaderChunks.soft_vertex = softVertex;
|
|
21
|
+
shaderChunks.soft_pars_fragment = softParsFragment;
|
|
22
|
+
shaderChunks.soft_fragment = softFragment;
|
|
23
|
+
registered = true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getShaderChunk(chunkName: string): string | undefined {
|
|
27
|
+
return shaderChunks[chunkName];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getRegisteredShaderChunks(): Readonly<Record<string, string>> {
|
|
31
|
+
return shaderChunks;
|
|
32
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef SOFT_PARTICLES
|
|
3
|
-
|
|
4
|
-
vec2 p2 = projPosition.xy / projPosition.w;
|
|
5
|
-
p2 = 0.5 * p2 + 0.5;
|
|
6
|
-
|
|
7
|
-
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
8
|
-
float viewDepth = linearize_depth(readDepth);
|
|
9
|
-
float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));
|
|
10
|
-
|
|
11
|
-
gl_FragColor *= softParticlesFade;
|
|
12
|
-
#endif
|
|
13
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef SOFT_PARTICLES
|
|
3
|
+
|
|
4
|
+
vec2 p2 = projPosition.xy / projPosition.w;
|
|
5
|
+
p2 = 0.5 * p2 + 0.5;
|
|
6
|
+
|
|
7
|
+
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
8
|
+
float viewDepth = linearize_depth(readDepth);
|
|
9
|
+
float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));
|
|
10
|
+
|
|
11
|
+
gl_FragColor *= softParticlesFade;
|
|
12
|
+
#endif
|
|
13
|
+
`;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef SOFT_PARTICLES
|
|
3
|
-
uniform sampler2D depthTexture;
|
|
4
|
-
uniform vec4 projParams;
|
|
5
|
-
uniform vec2 softParams;
|
|
6
|
-
|
|
7
|
-
varying vec4 projPosition;
|
|
8
|
-
varying float linearDepth;
|
|
9
|
-
|
|
10
|
-
#define SOFT_NEAR_FADE softParams.x
|
|
11
|
-
#define SOFT_INV_FADE_DISTANCE softParams.y
|
|
12
|
-
|
|
13
|
-
#define zNear projParams.x
|
|
14
|
-
#define zFar projParams.y
|
|
15
|
-
|
|
16
|
-
float linearize_depth(float d) {
|
|
17
|
-
return (zFar * zNear) / (zFar - d * (zFar - zNear));
|
|
18
|
-
}
|
|
19
|
-
#endif
|
|
20
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef SOFT_PARTICLES
|
|
3
|
+
uniform sampler2D depthTexture;
|
|
4
|
+
uniform vec4 projParams;
|
|
5
|
+
uniform vec2 softParams;
|
|
6
|
+
|
|
7
|
+
varying vec4 projPosition;
|
|
8
|
+
varying float linearDepth;
|
|
9
|
+
|
|
10
|
+
#define SOFT_NEAR_FADE softParams.x
|
|
11
|
+
#define SOFT_INV_FADE_DISTANCE softParams.y
|
|
12
|
+
|
|
13
|
+
#define zNear projParams.x
|
|
14
|
+
#define zFar projParams.y
|
|
15
|
+
|
|
16
|
+
float linearize_depth(float d) {
|
|
17
|
+
return (zFar * zNear) / (zFar - d * (zFar - zNear));
|
|
18
|
+
}
|
|
19
|
+
#endif
|
|
20
|
+
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef SOFT_PARTICLES
|
|
3
|
-
varying vec4 projPosition;
|
|
4
|
-
varying float linearDepth;
|
|
5
|
-
#endif
|
|
6
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef SOFT_PARTICLES
|
|
3
|
+
varying vec4 projPosition;
|
|
4
|
+
varying float linearDepth;
|
|
5
|
+
#endif
|
|
6
|
+
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef SOFT_PARTICLES
|
|
3
|
-
projPosition = gl_Position;
|
|
4
|
-
linearDepth = -mvPosition.z;
|
|
5
|
-
#endif
|
|
6
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef SOFT_PARTICLES
|
|
3
|
+
projPosition = gl_Position;
|
|
4
|
+
linearDepth = -mvPosition.z;
|
|
5
|
+
#endif
|
|
6
|
+
`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#ifdef USE_MAP
|
|
3
|
-
vec4 texelColor = texture2D(map, vUv);
|
|
4
|
-
#ifdef TILE_BLEND
|
|
5
|
-
texelColor = mix(texelColor, texture2D(map, vUvNext), vUvBlend);
|
|
6
|
-
#endif
|
|
7
|
-
diffuseColor *= texelColor;
|
|
8
|
-
#endif
|
|
9
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#ifdef USE_MAP
|
|
3
|
+
vec4 texelColor = texture2D(map, vUv);
|
|
4
|
+
#ifdef TILE_BLEND
|
|
5
|
+
texelColor = mix(texelColor, texture2D(map, vUvNext), vUvBlend);
|
|
6
|
+
#endif
|
|
7
|
+
diffuseColor *= texelColor;
|
|
8
|
+
#endif
|
|
9
|
+
`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
#if defined(USE_UV)
|
|
3
|
-
varying vec2 vUv;
|
|
4
|
-
#ifdef TILE_BLEND
|
|
5
|
-
varying vec2 vUvNext;
|
|
6
|
-
varying float vUvBlend;
|
|
7
|
-
#endif
|
|
8
|
-
#endif
|
|
9
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
#if defined(USE_UV)
|
|
3
|
+
varying vec2 vUv;
|
|
4
|
+
#ifdef TILE_BLEND
|
|
5
|
+
varying vec2 vUvNext;
|
|
6
|
+
varying float vUvBlend;
|
|
7
|
+
#endif
|
|
8
|
+
#endif
|
|
9
|
+
`;
|