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
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
// Per-vertex attributes
|
|
3
|
-
attribute vec3 position;
|
|
4
|
-
attribute vec2 uv;
|
|
5
|
-
|
|
6
|
-
// Per-instance attributes
|
|
7
|
-
attribute vec3 offset;
|
|
8
|
-
attribute vec4 color;
|
|
9
|
-
attribute vec3 size;
|
|
10
|
-
attribute float rotation;
|
|
11
|
-
attribute float uvTile;
|
|
12
|
-
|
|
13
|
-
// Uniforms
|
|
14
|
-
uniform mat4 world;
|
|
15
|
-
uniform mat4 view;
|
|
16
|
-
uniform mat4 projection;
|
|
17
|
-
uniform mat4 worldViewProjection;
|
|
18
|
-
|
|
19
|
-
#ifdef UV_TILE
|
|
20
|
-
uniform float tileCountX;
|
|
21
|
-
uniform float tileCountY;
|
|
22
|
-
#endif
|
|
23
|
-
|
|
24
|
-
// Varyings
|
|
25
|
-
varying vec2 vUV;
|
|
26
|
-
varying vec4 vColor;
|
|
27
|
-
#ifdef TILE_BLEND
|
|
28
|
-
varying vec2 vUV2;
|
|
29
|
-
varying float vTileBlend;
|
|
30
|
-
#endif
|
|
31
|
-
#ifdef SOFT_PARTICLES
|
|
32
|
-
varying vec4 projPosition;
|
|
33
|
-
varying float linearDepth;
|
|
34
|
-
#endif
|
|
35
|
-
|
|
36
|
-
void main() {
|
|
37
|
-
float c = cos(rotation);
|
|
38
|
-
float s = sin(rotation);
|
|
39
|
-
|
|
40
|
-
vec2 alignedPosition = position.xy * size.xy;
|
|
41
|
-
vec2 rotatedPosition;
|
|
42
|
-
rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;
|
|
43
|
-
rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;
|
|
44
|
-
|
|
45
|
-
#ifdef HORIZONTAL
|
|
46
|
-
vec4 mvPosition = world * vec4(offset, 1.0);
|
|
47
|
-
mvPosition.x += rotatedPosition.x;
|
|
48
|
-
mvPosition.z -= rotatedPosition.y;
|
|
49
|
-
mvPosition = view * mvPosition;
|
|
50
|
-
#elif defined(VERTICAL)
|
|
51
|
-
vec4 mvPosition = world * vec4(offset, 1.0);
|
|
52
|
-
mvPosition.y += rotatedPosition.y;
|
|
53
|
-
mvPosition = view * mvPosition;
|
|
54
|
-
mvPosition.x += rotatedPosition.x;
|
|
55
|
-
#else
|
|
56
|
-
vec4 mvPosition = view * world * vec4(offset, 1.0);
|
|
57
|
-
mvPosition.xy += rotatedPosition;
|
|
58
|
-
#endif
|
|
59
|
-
|
|
60
|
-
gl_Position = projection * mvPosition;
|
|
61
|
-
#ifdef SOFT_PARTICLES
|
|
62
|
-
projPosition = gl_Position;
|
|
63
|
-
linearDepth = -mvPosition.z;
|
|
64
|
-
#endif
|
|
65
|
-
|
|
66
|
-
#ifdef UV_TILE
|
|
67
|
-
vec2 tc = vec2(tileCountX, tileCountY);
|
|
68
|
-
float baseTile = floor(uvTile);
|
|
69
|
-
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
70
|
-
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
71
|
-
vUV = uv / tc + vec2(tileU, tileV);
|
|
72
|
-
#ifdef TILE_BLEND
|
|
73
|
-
float nextTile = ceil(uvTile);
|
|
74
|
-
float nextU = mod(nextTile, tc.x) / tc.x;
|
|
75
|
-
float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
76
|
-
vUV2 = uv / tc + vec2(nextU, nextV);
|
|
77
|
-
vTileBlend = fract(uvTile);
|
|
78
|
-
#endif
|
|
79
|
-
#else
|
|
80
|
-
vUV = uv;
|
|
81
|
-
#endif
|
|
82
|
-
|
|
83
|
-
vColor = color;
|
|
84
|
-
}
|
|
85
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
// Per-vertex attributes
|
|
3
|
+
attribute vec3 position;
|
|
4
|
+
attribute vec2 uv;
|
|
5
|
+
|
|
6
|
+
// Per-instance attributes
|
|
7
|
+
attribute vec3 offset;
|
|
8
|
+
attribute vec4 color;
|
|
9
|
+
attribute vec3 size;
|
|
10
|
+
attribute float rotation;
|
|
11
|
+
attribute float uvTile;
|
|
12
|
+
|
|
13
|
+
// Uniforms
|
|
14
|
+
uniform mat4 world;
|
|
15
|
+
uniform mat4 view;
|
|
16
|
+
uniform mat4 projection;
|
|
17
|
+
uniform mat4 worldViewProjection;
|
|
18
|
+
|
|
19
|
+
#ifdef UV_TILE
|
|
20
|
+
uniform float tileCountX;
|
|
21
|
+
uniform float tileCountY;
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
// Varyings
|
|
25
|
+
varying vec2 vUV;
|
|
26
|
+
varying vec4 vColor;
|
|
27
|
+
#ifdef TILE_BLEND
|
|
28
|
+
varying vec2 vUV2;
|
|
29
|
+
varying float vTileBlend;
|
|
30
|
+
#endif
|
|
31
|
+
#ifdef SOFT_PARTICLES
|
|
32
|
+
varying vec4 projPosition;
|
|
33
|
+
varying float linearDepth;
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
void main() {
|
|
37
|
+
float c = cos(rotation);
|
|
38
|
+
float s = sin(rotation);
|
|
39
|
+
|
|
40
|
+
vec2 alignedPosition = position.xy * size.xy;
|
|
41
|
+
vec2 rotatedPosition;
|
|
42
|
+
rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;
|
|
43
|
+
rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;
|
|
44
|
+
|
|
45
|
+
#ifdef HORIZONTAL
|
|
46
|
+
vec4 mvPosition = world * vec4(offset, 1.0);
|
|
47
|
+
mvPosition.x += rotatedPosition.x;
|
|
48
|
+
mvPosition.z -= rotatedPosition.y;
|
|
49
|
+
mvPosition = view * mvPosition;
|
|
50
|
+
#elif defined(VERTICAL)
|
|
51
|
+
vec4 mvPosition = world * vec4(offset, 1.0);
|
|
52
|
+
mvPosition.y += rotatedPosition.y;
|
|
53
|
+
mvPosition = view * mvPosition;
|
|
54
|
+
mvPosition.x += rotatedPosition.x;
|
|
55
|
+
#else
|
|
56
|
+
vec4 mvPosition = view * world * vec4(offset, 1.0);
|
|
57
|
+
mvPosition.xy += rotatedPosition;
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
gl_Position = projection * mvPosition;
|
|
61
|
+
#ifdef SOFT_PARTICLES
|
|
62
|
+
projPosition = gl_Position;
|
|
63
|
+
linearDepth = -mvPosition.z;
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
#ifdef UV_TILE
|
|
67
|
+
vec2 tc = vec2(tileCountX, tileCountY);
|
|
68
|
+
float baseTile = floor(uvTile);
|
|
69
|
+
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
70
|
+
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
71
|
+
vUV = uv / tc + vec2(tileU, tileV);
|
|
72
|
+
#ifdef TILE_BLEND
|
|
73
|
+
float nextTile = ceil(uvTile);
|
|
74
|
+
float nextU = mod(nextTile, tc.x) / tc.x;
|
|
75
|
+
float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
76
|
+
vUV2 = uv / tc + vec2(nextU, nextV);
|
|
77
|
+
vTileBlend = fract(uvTile);
|
|
78
|
+
#endif
|
|
79
|
+
#else
|
|
80
|
+
vUV = uv;
|
|
81
|
+
#endif
|
|
82
|
+
|
|
83
|
+
vColor = color;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
@@ -1,74 +1,76 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
// Per-vertex attributes
|
|
3
|
-
attribute vec3 position;
|
|
4
|
-
attribute vec2 uv;
|
|
5
|
-
|
|
6
|
-
// Per-instance attributes
|
|
7
|
-
attribute vec3 offset;
|
|
8
|
-
attribute vec4 color;
|
|
9
|
-
attribute vec3 size;
|
|
10
|
-
attribute float rotation;
|
|
11
|
-
attribute float uvTile;
|
|
12
|
-
attribute vec4 velocity;
|
|
13
|
-
|
|
14
|
-
// Uniforms
|
|
15
|
-
uniform mat4 world;
|
|
16
|
-
uniform mat4 view;
|
|
17
|
-
uniform mat4 projection;
|
|
18
|
-
uniform float speedFactor;
|
|
19
|
-
|
|
20
|
-
#ifdef UV_TILE
|
|
21
|
-
uniform float tileCountX;
|
|
22
|
-
uniform float tileCountY;
|
|
23
|
-
#endif
|
|
24
|
-
|
|
25
|
-
// Varyings
|
|
26
|
-
varying vec2 vUV;
|
|
27
|
-
varying vec4 vColor;
|
|
28
|
-
#ifdef TILE_BLEND
|
|
29
|
-
varying vec2 vUV2;
|
|
30
|
-
varying float vTileBlend;
|
|
31
|
-
#endif
|
|
32
|
-
#ifdef SOFT_PARTICLES
|
|
33
|
-
varying vec4 projPosition;
|
|
34
|
-
varying float linearDepth;
|
|
35
|
-
#endif
|
|
36
|
-
|
|
37
|
-
void main() {
|
|
38
|
-
float lengthFactor = velocity.w;
|
|
39
|
-
float avgSize = (size.x + size.y) * 0.5;
|
|
40
|
-
vec4 mvPosition = view * world * vec4(offset, 1.0);
|
|
41
|
-
vec3 viewVelocity = mat3(view * world) * velocity.xyz;
|
|
42
|
-
float vlength = length(viewVelocity);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
float
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
float
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
// Per-vertex attributes
|
|
3
|
+
attribute vec3 position;
|
|
4
|
+
attribute vec2 uv;
|
|
5
|
+
|
|
6
|
+
// Per-instance attributes
|
|
7
|
+
attribute vec3 offset;
|
|
8
|
+
attribute vec4 color;
|
|
9
|
+
attribute vec3 size;
|
|
10
|
+
attribute float rotation;
|
|
11
|
+
attribute float uvTile;
|
|
12
|
+
attribute vec4 velocity;
|
|
13
|
+
|
|
14
|
+
// Uniforms
|
|
15
|
+
uniform mat4 world;
|
|
16
|
+
uniform mat4 view;
|
|
17
|
+
uniform mat4 projection;
|
|
18
|
+
uniform float speedFactor;
|
|
19
|
+
|
|
20
|
+
#ifdef UV_TILE
|
|
21
|
+
uniform float tileCountX;
|
|
22
|
+
uniform float tileCountY;
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
// Varyings
|
|
26
|
+
varying vec2 vUV;
|
|
27
|
+
varying vec4 vColor;
|
|
28
|
+
#ifdef TILE_BLEND
|
|
29
|
+
varying vec2 vUV2;
|
|
30
|
+
varying float vTileBlend;
|
|
31
|
+
#endif
|
|
32
|
+
#ifdef SOFT_PARTICLES
|
|
33
|
+
varying vec4 projPosition;
|
|
34
|
+
varying float linearDepth;
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
void main() {
|
|
38
|
+
float lengthFactor = velocity.w;
|
|
39
|
+
float avgSize = (size.x + size.y) * 0.5;
|
|
40
|
+
vec4 mvPosition = view * world * vec4(offset, 1.0);
|
|
41
|
+
vec3 viewVelocity = mat3(view * world) * velocity.xyz;
|
|
42
|
+
float vlength = length(viewVelocity);
|
|
43
|
+
// Stretch direction is the velocity direction; only a genuinely motionless particle has none.
|
|
44
|
+
// Deriving it via normalize keeps the stretch aligned even when the speed contribution is ~0
|
|
45
|
+
// (e.g. speedFactor 0), instead of collapsing the whole burst onto a fixed screen axis.
|
|
46
|
+
vec3 vdir = vlength > 0.000001 ? viewVelocity / vlength : vec3(0.0, 0.0, 1.0);
|
|
47
|
+
mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, vdir)) * avgSize;
|
|
48
|
+
// Equivalent to viewVelocity * (1.0 + lengthFactor / vlength) for moving particles, but the
|
|
49
|
+
// size-based term (vdir * lengthFactor) survives when the velocity contribution vanishes.
|
|
50
|
+
mvPosition.xyz -= (position.x + 0.5) * (viewVelocity + vdir * lengthFactor) * avgSize;
|
|
51
|
+
gl_Position = projection * mvPosition;
|
|
52
|
+
#ifdef SOFT_PARTICLES
|
|
53
|
+
projPosition = gl_Position;
|
|
54
|
+
linearDepth = -mvPosition.z;
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
#ifdef UV_TILE
|
|
58
|
+
vec2 tc = vec2(tileCountX, tileCountY);
|
|
59
|
+
float baseTile = floor(uvTile);
|
|
60
|
+
float tileU = mod(baseTile, tc.x) / tc.x;
|
|
61
|
+
float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
62
|
+
vUV = uv / tc + vec2(tileU, tileV);
|
|
63
|
+
#ifdef TILE_BLEND
|
|
64
|
+
float nextTile = ceil(uvTile);
|
|
65
|
+
float nextU = mod(nextTile, tc.x) / tc.x;
|
|
66
|
+
float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;
|
|
67
|
+
vUV2 = uv / tc + vec2(nextU, nextV);
|
|
68
|
+
vTileBlend = fract(uvTile);
|
|
69
|
+
#endif
|
|
70
|
+
#else
|
|
71
|
+
vUV = uv;
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
vColor = color;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
varying vec2 vUV;
|
|
3
|
-
varying vec4 vColor;
|
|
4
|
-
|
|
5
|
-
#ifdef USE_MAP
|
|
6
|
-
uniform sampler2D map;
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
void main() {
|
|
10
|
-
vec4 baseColor = vColor;
|
|
11
|
-
|
|
12
|
-
#ifdef USE_MAP
|
|
13
|
-
vec4 texColor = texture2D(map, vUV);
|
|
14
|
-
baseColor *= texColor;
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
if (baseColor.a < 0.01) discard;
|
|
18
|
-
|
|
19
|
-
gl_FragColor = baseColor;
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
varying vec2 vUV;
|
|
3
|
+
varying vec4 vColor;
|
|
4
|
+
|
|
5
|
+
#ifdef USE_MAP
|
|
6
|
+
uniform sampler2D map;
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
void main() {
|
|
10
|
+
vec4 baseColor = vColor;
|
|
11
|
+
|
|
12
|
+
#ifdef USE_MAP
|
|
13
|
+
vec4 texColor = texture2D(map, vUV);
|
|
14
|
+
baseColor *= texColor;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
if (baseColor.a < 0.01) discard;
|
|
18
|
+
|
|
19
|
+
gl_FragColor = baseColor;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
export default /* glsl */ `
|
|
2
|
-
attribute vec3 position;
|
|
3
|
-
attribute vec3 previous;
|
|
4
|
-
attribute vec3 next;
|
|
5
|
-
attribute float side;
|
|
6
|
-
attribute float width;
|
|
7
|
-
attribute vec2 uv;
|
|
8
|
-
attribute vec4 color;
|
|
9
|
-
|
|
10
|
-
uniform mat4 view;
|
|
11
|
-
uniform mat4 projection;
|
|
12
|
-
uniform float lineWidth;
|
|
13
|
-
uniform vec2 resolution;
|
|
14
|
-
uniform float sizeAttenuation;
|
|
15
|
-
|
|
16
|
-
varying vec2 vUV;
|
|
17
|
-
varying vec4 vColor;
|
|
18
|
-
|
|
19
|
-
vec2 fix(vec4 i, float aspect) {
|
|
20
|
-
vec2 res = i.xy / i.w;
|
|
21
|
-
res.x *= aspect;
|
|
22
|
-
return res;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
void main() {
|
|
26
|
-
float aspect = resolution.x / resolution.y;
|
|
27
|
-
vec4 finalPosition = projection * view * vec4(position, 1.0);
|
|
28
|
-
vec4 prevPos = projection * view * vec4(previous, 1.0);
|
|
29
|
-
vec4 nextPos = projection * view * vec4(next, 1.0);
|
|
30
|
-
|
|
31
|
-
vec2 currentP = fix(finalPosition, aspect);
|
|
32
|
-
vec2 prevP = fix(prevPos, aspect);
|
|
33
|
-
vec2 nextP = fix(nextPos, aspect);
|
|
34
|
-
|
|
35
|
-
float w = lineWidth * width;
|
|
36
|
-
vec2 dir;
|
|
37
|
-
if (distance(nextP, currentP) < 0.0001) {
|
|
38
|
-
dir = normalize(currentP - prevP);
|
|
39
|
-
} else if (distance(prevP, currentP) < 0.0001) {
|
|
40
|
-
dir = normalize(nextP - currentP);
|
|
41
|
-
} else {
|
|
42
|
-
vec2 dir1 = normalize(currentP - prevP);
|
|
43
|
-
vec2 dir2 = normalize(nextP - currentP);
|
|
44
|
-
dir = normalize(dir1 + dir2);
|
|
45
|
-
}
|
|
46
|
-
vec4 normal = vec4(-dir.y, dir.x, 0.0, 1.0);
|
|
47
|
-
normal.xy *= 0.5 * w;
|
|
48
|
-
normal *= projection;
|
|
49
|
-
if (sizeAttenuation == 0.0) {
|
|
50
|
-
normal.xy *= finalPosition.w;
|
|
51
|
-
normal.xy /= (vec4(resolution, 0.0, 1.0) * projection).xy;
|
|
52
|
-
}
|
|
53
|
-
finalPosition.xy += normal.xy * side;
|
|
54
|
-
gl_Position = finalPosition;
|
|
55
|
-
vUV = uv;
|
|
56
|
-
vColor = color;
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
1
|
+
export default /* glsl */ `
|
|
2
|
+
attribute vec3 position;
|
|
3
|
+
attribute vec3 previous;
|
|
4
|
+
attribute vec3 next;
|
|
5
|
+
attribute float side;
|
|
6
|
+
attribute float width;
|
|
7
|
+
attribute vec2 uv;
|
|
8
|
+
attribute vec4 color;
|
|
9
|
+
|
|
10
|
+
uniform mat4 view;
|
|
11
|
+
uniform mat4 projection;
|
|
12
|
+
uniform float lineWidth;
|
|
13
|
+
uniform vec2 resolution;
|
|
14
|
+
uniform float sizeAttenuation;
|
|
15
|
+
|
|
16
|
+
varying vec2 vUV;
|
|
17
|
+
varying vec4 vColor;
|
|
18
|
+
|
|
19
|
+
vec2 fix(vec4 i, float aspect) {
|
|
20
|
+
vec2 res = i.xy / i.w;
|
|
21
|
+
res.x *= aspect;
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void main() {
|
|
26
|
+
float aspect = resolution.x / resolution.y;
|
|
27
|
+
vec4 finalPosition = projection * view * vec4(position, 1.0);
|
|
28
|
+
vec4 prevPos = projection * view * vec4(previous, 1.0);
|
|
29
|
+
vec4 nextPos = projection * view * vec4(next, 1.0);
|
|
30
|
+
|
|
31
|
+
vec2 currentP = fix(finalPosition, aspect);
|
|
32
|
+
vec2 prevP = fix(prevPos, aspect);
|
|
33
|
+
vec2 nextP = fix(nextPos, aspect);
|
|
34
|
+
|
|
35
|
+
float w = lineWidth * width;
|
|
36
|
+
vec2 dir;
|
|
37
|
+
if (distance(nextP, currentP) < 0.0001) {
|
|
38
|
+
dir = normalize(currentP - prevP);
|
|
39
|
+
} else if (distance(prevP, currentP) < 0.0001) {
|
|
40
|
+
dir = normalize(nextP - currentP);
|
|
41
|
+
} else {
|
|
42
|
+
vec2 dir1 = normalize(currentP - prevP);
|
|
43
|
+
vec2 dir2 = normalize(nextP - currentP);
|
|
44
|
+
dir = normalize(dir1 + dir2);
|
|
45
|
+
}
|
|
46
|
+
vec4 normal = vec4(-dir.y, dir.x, 0.0, 1.0);
|
|
47
|
+
normal.xy *= 0.5 * w;
|
|
48
|
+
normal *= projection;
|
|
49
|
+
if (sizeAttenuation == 0.0) {
|
|
50
|
+
normal.xy *= finalPosition.w;
|
|
51
|
+
normal.xy /= (vec4(resolution, 0.0, 1.0) * projection).xy;
|
|
52
|
+
}
|
|
53
|
+
finalPosition.xy += normal.xy * side;
|
|
54
|
+
gl_Position = finalPosition;
|
|
55
|
+
vUV = uv;
|
|
56
|
+
vColor = color;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
@@ -1,59 +0,0 @@
|
|
|
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 interface AdaptivePerformanceOptions {
|
|
29
|
-
targetFrameMs: number;
|
|
30
|
-
minQuality: number;
|
|
31
|
-
maxQuality: number;
|
|
32
|
-
decreaseStep: number;
|
|
33
|
-
increaseStep: number;
|
|
34
|
-
}
|
|
35
|
-
export interface AdaptivePerformanceState extends AdaptivePerformanceOptions {
|
|
36
|
-
enabled: boolean;
|
|
37
|
-
currentQuality: number;
|
|
38
|
-
lastFrameCpuMs: number;
|
|
39
|
-
}
|
|
40
|
-
export declare class BatchedRenderer extends TransformNode {
|
|
41
|
-
batches: Array<VFXBatch>;
|
|
42
|
-
systemToBatchIndex: Map<IParticleSystem, number>;
|
|
43
|
-
depthTexture: BaseTexture | null;
|
|
44
|
-
private adaptivePerformanceState;
|
|
45
|
-
private lastAppliedQuality;
|
|
46
|
-
constructor(name: string, scene: Scene);
|
|
47
|
-
private static clamp;
|
|
48
|
-
private static equals;
|
|
49
|
-
addSystem(system: IParticleSystem): void;
|
|
50
|
-
deleteSystem(system: IParticleSystem): void;
|
|
51
|
-
updateSystem(system: IParticleSystem): void;
|
|
52
|
-
setDepthTexture(depthTexture: BaseTexture | null): void;
|
|
53
|
-
configureAdaptivePerformance(options?: Partial<AdaptivePerformanceOptions>): void;
|
|
54
|
-
disableAdaptivePerformance(resetQuality?: boolean): void;
|
|
55
|
-
getAdaptivePerformanceState(): AdaptivePerformanceState;
|
|
56
|
-
private applyAdaptiveQuality;
|
|
57
|
-
update(delta: number): void;
|
|
58
|
-
dispose(): void;
|
|
59
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|