pixi-particles-engine 0.1.9 → 0.1.10
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/dist/cjs/behaviours/rotation-curve-behaviour.d.ts +21 -0
- package/dist/cjs/behaviours/rotation-curve-behaviour.d.ts.map +1 -0
- package/dist/cjs/behaviours/rotation-curve-behaviour.js +26 -0
- package/dist/cjs/behaviours/rotation-curve-behaviour.js.map +1 -0
- package/dist/cjs/behaviours/spawn-behaviours/circle-spawn-behaviour.d.ts +12 -5
- package/dist/cjs/behaviours/spawn-behaviours/circle-spawn-behaviour.d.ts.map +1 -1
- package/dist/cjs/behaviours/spawn-behaviours/circle-spawn-behaviour.js +15 -5
- package/dist/cjs/behaviours/spawn-behaviours/circle-spawn-behaviour.js.map +1 -1
- package/dist/cjs/behaviours/spawn-behaviours/rectangle-spawn-behaviour.d.ts +15 -5
- package/dist/cjs/behaviours/spawn-behaviours/rectangle-spawn-behaviour.d.ts.map +1 -1
- package/dist/cjs/behaviours/spawn-behaviours/rectangle-spawn-behaviour.js +36 -7
- package/dist/cjs/behaviours/spawn-behaviours/rectangle-spawn-behaviour.js.map +1 -1
- package/dist/cjs/behaviours/static-behaviours/static-rotation-behaviour.d.ts +41 -3
- package/dist/cjs/behaviours/static-behaviours/static-rotation-behaviour.d.ts.map +1 -1
- package/dist/cjs/behaviours/static-behaviours/static-rotation-behaviour.js +46 -5
- package/dist/cjs/behaviours/static-behaviours/static-rotation-behaviour.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/px-particle.d.ts +7 -2
- package/dist/cjs/px-particle.d.ts.map +1 -1
- package/dist/cjs/px-particle.js +17 -4
- package/dist/cjs/px-particle.js.map +1 -1
- package/dist/esm/behaviours/rotation-curve-behaviour.d.ts +21 -0
- package/dist/esm/behaviours/rotation-curve-behaviour.d.ts.map +1 -0
- package/dist/esm/behaviours/rotation-curve-behaviour.js +22 -0
- package/dist/esm/behaviours/rotation-curve-behaviour.js.map +1 -0
- package/dist/esm/behaviours/spawn-behaviours/circle-spawn-behaviour.d.ts +12 -5
- package/dist/esm/behaviours/spawn-behaviours/circle-spawn-behaviour.d.ts.map +1 -1
- package/dist/esm/behaviours/spawn-behaviours/circle-spawn-behaviour.js +15 -5
- package/dist/esm/behaviours/spawn-behaviours/circle-spawn-behaviour.js.map +1 -1
- package/dist/esm/behaviours/spawn-behaviours/rectangle-spawn-behaviour.d.ts +15 -5
- package/dist/esm/behaviours/spawn-behaviours/rectangle-spawn-behaviour.d.ts.map +1 -1
- package/dist/esm/behaviours/spawn-behaviours/rectangle-spawn-behaviour.js +36 -7
- package/dist/esm/behaviours/spawn-behaviours/rectangle-spawn-behaviour.js.map +1 -1
- package/dist/esm/behaviours/static-behaviours/static-rotation-behaviour.d.ts +41 -3
- package/dist/esm/behaviours/static-behaviours/static-rotation-behaviour.d.ts.map +1 -1
- package/dist/esm/behaviours/static-behaviours/static-rotation-behaviour.js +46 -5
- package/dist/esm/behaviours/static-behaviours/static-rotation-behaviour.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/px-particle.d.ts +7 -2
- package/dist/esm/px-particle.d.ts.map +1 -1
- package/dist/esm/px-particle.js +17 -4
- package/dist/esm/px-particle.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviours/rotation-curve-behaviour.ts +32 -0
- package/src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts +18 -5
- package/src/behaviours/spawn-behaviours/rectangle-spawn-behaviour.ts +41 -8
- package/src/behaviours/static-behaviours/static-rotation-behaviour.ts +77 -6
- package/src/index.ts +1 -0
- package/src/px-particle.ts +21 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Behaviour } from "../behaviour";
|
|
2
|
+
import { PxParticle } from "../px-particle";
|
|
3
|
+
import { CurveKeyframe, CurveOptions } from "./curved-behaviour/curve-key-frame";
|
|
4
|
+
import { Emitter } from "../emitter";
|
|
5
|
+
/**
|
|
6
|
+
* Rotation over lifetime driven by a curve.
|
|
7
|
+
*
|
|
8
|
+
* Keyframes are sampled using normalized lifetime t in [0..1].
|
|
9
|
+
* Output is clamped to [0..1].
|
|
10
|
+
*/
|
|
11
|
+
export declare class RotationCurveBehaviour implements Behaviour {
|
|
12
|
+
readonly requires: {
|
|
13
|
+
color: boolean;
|
|
14
|
+
};
|
|
15
|
+
readonly priority = 50;
|
|
16
|
+
private curve;
|
|
17
|
+
constructor(keyframes: CurveKeyframe[], opts?: CurveOptions);
|
|
18
|
+
onSpawn(p: PxParticle): void;
|
|
19
|
+
update(p: PxParticle, _dt?: number, _emitter?: Emitter): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=rotation-curve-behaviour.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation-curve-behaviour.d.ts","sourceRoot":"","sources":["../../../src/behaviours/rotation-curve-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,SAAS;IACpD,SAAgB,QAAQ;;MAAmB;IAE3C,SAAgB,QAAQ,MAAM;IAE9B,OAAO,CAAC,KAAK,CAAQ;gBAET,SAAS,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,EAAE,YAAY;IAIpD,OAAO,CAAC,CAAC,EAAE,UAAU;IAIrB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO;CAIhE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RotationCurveBehaviour = void 0;
|
|
4
|
+
const curve_sampler_1 = require("./curved-behaviour/curve-sampler");
|
|
5
|
+
/**
|
|
6
|
+
* Rotation over lifetime driven by a curve.
|
|
7
|
+
*
|
|
8
|
+
* Keyframes are sampled using normalized lifetime t in [0..1].
|
|
9
|
+
* Output is clamped to [0..1].
|
|
10
|
+
*/
|
|
11
|
+
class RotationCurveBehaviour {
|
|
12
|
+
constructor(keyframes, opts) {
|
|
13
|
+
this.requires = { color: true };
|
|
14
|
+
this.priority = 50;
|
|
15
|
+
this.curve = new curve_sampler_1.Curve(keyframes);
|
|
16
|
+
}
|
|
17
|
+
onSpawn(p) {
|
|
18
|
+
p.angleVScale = this.curve.sample(0);
|
|
19
|
+
}
|
|
20
|
+
update(p, _dt, _emitter) {
|
|
21
|
+
const t = p.life > 0 ? p.age / p.life : 1;
|
|
22
|
+
p.angleVScale = this.curve.sample(t);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.RotationCurveBehaviour = RotationCurveBehaviour;
|
|
26
|
+
//# sourceMappingURL=rotation-curve-behaviour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation-curve-behaviour.js","sourceRoot":"","sources":["../../../src/behaviours/rotation-curve-behaviour.ts"],"names":[],"mappings":";;;AAGA,oEAAyD;AAGzD;;;;;GAKG;AACH,MAAa,sBAAsB;IAO/B,YAAY,SAA0B,EAAE,IAAmB;QAN3C,aAAQ,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAE3B,aAAQ,GAAG,EAAE,CAAC;QAK1B,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAK,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAEM,OAAO,CAAC,CAAa;QACxB,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,CAAa,EAAE,GAAY,EAAE,QAAkB;QACzD,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACJ;AAnBD,wDAmBC"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { PxParticle } from "../../px-particle";
|
|
2
2
|
import { Behaviour } from "../../behaviour";
|
|
3
3
|
/**
|
|
4
|
-
* Spawns particles
|
|
4
|
+
* Spawns particles inside a circular ring centered at (0, 0).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Outer radius:
|
|
7
|
+
* radius
|
|
8
8
|
*
|
|
9
|
+
* Inner empty radius:
|
|
10
|
+
* innerRadius
|
|
11
|
+
*
|
|
12
|
+
* Particles spawn only between the outer and inner circles.
|
|
13
|
+
*
|
|
14
|
+
* Uses sqrt(random) to maintain uniform area distribution.
|
|
9
15
|
*/
|
|
10
16
|
export declare class CircleSpawnBehaviour implements Behaviour {
|
|
11
|
-
|
|
17
|
+
radius: number;
|
|
18
|
+
innerRadius: number;
|
|
12
19
|
readonly priority = -100;
|
|
13
|
-
constructor(radius: number);
|
|
20
|
+
constructor(radius: number, innerRadius?: number);
|
|
14
21
|
onSpawn(p: PxParticle): void;
|
|
15
22
|
}
|
|
16
23
|
//# sourceMappingURL=circle-spawn-behaviour.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle-spawn-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"circle-spawn-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,qBAAa,oBAAqB,YAAW,SAAS;IAIvC,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,MAAM;IAJ9B,SAAgB,QAAQ,QAAQ;gBAGrB,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,MAAU;IAG3B,OAAO,CAAC,CAAC,EAAE,UAAU;CAY/B"}
|
|
@@ -2,20 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CircleSpawnBehaviour = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Spawns particles
|
|
5
|
+
* Spawns particles inside a circular ring centered at (0, 0).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Outer radius:
|
|
8
|
+
* radius
|
|
9
9
|
*
|
|
10
|
+
* Inner empty radius:
|
|
11
|
+
* innerRadius
|
|
12
|
+
*
|
|
13
|
+
* Particles spawn only between the outer and inner circles.
|
|
14
|
+
*
|
|
15
|
+
* Uses sqrt(random) to maintain uniform area distribution.
|
|
10
16
|
*/
|
|
11
17
|
class CircleSpawnBehaviour {
|
|
12
|
-
constructor(radius) {
|
|
18
|
+
constructor(radius, innerRadius = 0) {
|
|
13
19
|
this.radius = radius;
|
|
20
|
+
this.innerRadius = innerRadius;
|
|
14
21
|
this.priority = -100;
|
|
15
22
|
}
|
|
16
23
|
onSpawn(p) {
|
|
17
24
|
const angle = Math.random() * Math.PI * 2;
|
|
18
|
-
const
|
|
25
|
+
const outerR2 = this.radius * this.radius;
|
|
26
|
+
const innerR2 = this.innerRadius * this.innerRadius;
|
|
27
|
+
// Uniform distribution across ring area
|
|
28
|
+
const r = Math.sqrt(innerR2 + Math.random() * (outerR2 - innerR2));
|
|
19
29
|
p.x = Math.cos(angle) * r;
|
|
20
30
|
p.y = Math.sin(angle) * r;
|
|
21
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle-spawn-behaviour.js","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts"],"names":[],"mappings":";;;AAGA
|
|
1
|
+
{"version":3,"file":"circle-spawn-behaviour.js","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;GAYG;AACH,MAAa,oBAAoB;IAG7B,YACW,MAAc,EACd,cAAsB,CAAC;QADvB,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAY;QAJlB,aAAQ,GAAG,CAAC,GAAG,CAAC;IAK7B,CAAC;IAEG,OAAO,CAAC,CAAa;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAE1C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAEpD,wCAAwC;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;QAEnE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACJ;AApBD,oDAoBC"}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { PxParticle } from "../../px-particle";
|
|
2
2
|
import { Behaviour } from "../../behaviour";
|
|
3
3
|
/**
|
|
4
|
-
* Spawns particles
|
|
5
|
-
*
|
|
4
|
+
* Spawns particles inside a rectangular border/ring centered at (0, 0).
|
|
5
|
+
*
|
|
6
|
+
* Outer size:
|
|
7
|
+
* width x height
|
|
8
|
+
*
|
|
9
|
+
* Inner empty area:
|
|
10
|
+
* innerWidth x innerHeight
|
|
11
|
+
*
|
|
12
|
+
* Particles spawn only in the area between the outer and inner rectangles.
|
|
13
|
+
*/
|
|
6
14
|
export declare class RectangleSpawnBehaviour implements Behaviour {
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
innerWidth: number;
|
|
18
|
+
innerHeight: number;
|
|
9
19
|
readonly priority = -100;
|
|
10
|
-
constructor(width: number, height: number);
|
|
20
|
+
constructor(width: number, height: number, innerWidth?: number, innerHeight?: number);
|
|
11
21
|
onSpawn(p: PxParticle): void;
|
|
12
22
|
/** Inclusive-exclusive uniform random. */
|
|
13
23
|
private rand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rectangle-spawn-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/rectangle-spawn-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"rectangle-spawn-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/rectangle-spawn-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,YAAW,SAAS;IAI1C,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IAGd,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,MAAM;IAR9B,SAAgB,QAAQ,QAAQ;gBAGrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EAGd,UAAU,GAAE,MAAU,EACtB,WAAW,GAAE,MAAU;IAG3B,OAAO,CAAC,CAAC,EAAE,UAAU;IA6B5B,0CAA0C;IAC1C,OAAO,CAAC,IAAI;CAGf"}
|
|
@@ -2,19 +2,48 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RectangleSpawnBehaviour = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Spawns particles
|
|
6
|
-
*
|
|
5
|
+
* Spawns particles inside a rectangular border/ring centered at (0, 0).
|
|
6
|
+
*
|
|
7
|
+
* Outer size:
|
|
8
|
+
* width x height
|
|
9
|
+
*
|
|
10
|
+
* Inner empty area:
|
|
11
|
+
* innerWidth x innerHeight
|
|
12
|
+
*
|
|
13
|
+
* Particles spawn only in the area between the outer and inner rectangles.
|
|
14
|
+
*/
|
|
7
15
|
class RectangleSpawnBehaviour {
|
|
8
|
-
constructor(width, height
|
|
16
|
+
constructor(width, height,
|
|
17
|
+
// Optional inner empty rectangle
|
|
18
|
+
innerWidth = 0, innerHeight = 0) {
|
|
9
19
|
this.width = width;
|
|
10
20
|
this.height = height;
|
|
21
|
+
this.innerWidth = innerWidth;
|
|
22
|
+
this.innerHeight = innerHeight;
|
|
11
23
|
this.priority = -100;
|
|
12
24
|
}
|
|
13
25
|
onSpawn(p) {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
const outerHW = this.width * 0.5;
|
|
27
|
+
const outerHH = this.height * 0.5;
|
|
28
|
+
const innerHW = this.innerWidth * 0.5;
|
|
29
|
+
const innerHH = this.innerHeight * 0.5;
|
|
30
|
+
// No inner hole -> normal rectangle spawn
|
|
31
|
+
if (this.innerWidth <= 0 || this.innerHeight <= 0) {
|
|
32
|
+
p.x = this.rand(-outerHW, outerHW);
|
|
33
|
+
p.y = this.rand(-outerHH, outerHH);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// Pick a random point until it lands outside the inner rectangle
|
|
37
|
+
while (true) {
|
|
38
|
+
const x = this.rand(-outerHW, outerHW);
|
|
39
|
+
const y = this.rand(-outerHH, outerHH);
|
|
40
|
+
const insideInner = x > -innerHW && x < innerHW && y > -innerHH && y < innerHH;
|
|
41
|
+
if (!insideInner) {
|
|
42
|
+
p.x = x;
|
|
43
|
+
p.y = y;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
18
47
|
}
|
|
19
48
|
/** Inclusive-exclusive uniform random. */
|
|
20
49
|
rand(min, max) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rectangle-spawn-behaviour.js","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/rectangle-spawn-behaviour.ts"],"names":[],"mappings":";;;AAGA
|
|
1
|
+
{"version":3,"file":"rectangle-spawn-behaviour.js","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/rectangle-spawn-behaviour.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;GAUG;AACH,MAAa,uBAAuB;IAGhC,YACW,KAAa,EACb,MAAc;IAErB,iCAAiC;IAC1B,aAAqB,CAAC,EACtB,cAAsB,CAAC;QALvB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;QAGd,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAY;QARlB,aAAQ,GAAG,CAAC,GAAG,CAAC;IAS7B,CAAC;IAEG,OAAO,CAAC,CAAa;QACxB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAElC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QAEvC,0CAA0C;QAC1C,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC;YAChD,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACnC,OAAO;QACX,CAAC;QAED,iEAAiE;QACjE,OAAO,IAAI,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACvC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEvC,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,OAAO,CAAC;YAE/E,IAAI,CAAC,WAAW,EAAE,CAAC;gBACf,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACR,OAAO;YACX,CAAC;QACL,CAAC;IACL,CAAC;IAED,0CAA0C;IAClC,IAAI,CAAC,GAAW,EAAE,GAAW;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC7C,CAAC;CACJ;AA7CD,0DA6CC"}
|
|
@@ -4,13 +4,38 @@ import { PxParticle } from "../../px-particle";
|
|
|
4
4
|
* Sets a particle's angular velocity at spawn time.
|
|
5
5
|
*
|
|
6
6
|
* Does NOT modify rotation per frame directly.
|
|
7
|
-
* Instead, it initializes `
|
|
7
|
+
* Instead, it initializes `angleVBase`, which the emitter integrates each tick.
|
|
8
8
|
*
|
|
9
|
+
* Supports:
|
|
10
|
+
*
|
|
11
|
+
* - Fixed value:
|
|
12
|
+
* 2
|
|
13
|
+
*
|
|
14
|
+
* - Random range:
|
|
15
|
+
* { min: -3, max: 3 }
|
|
16
|
+
*
|
|
17
|
+
* - Random range with minimum absolute magnitude:
|
|
18
|
+
* { min: -3, max: 3, minAbs: 2 }
|
|
19
|
+
*
|
|
20
|
+
* Result:
|
|
21
|
+
* [-3 .. -2] U [2 .. 3]
|
|
9
22
|
*/
|
|
10
23
|
export declare class StaticRotationBehaviour implements Behaviour {
|
|
11
24
|
speed: number | {
|
|
12
25
|
min: number;
|
|
13
26
|
max: number;
|
|
27
|
+
/**
|
|
28
|
+
* Optional minimum absolute value.
|
|
29
|
+
*
|
|
30
|
+
* Example:
|
|
31
|
+
* min=-3
|
|
32
|
+
* max=3
|
|
33
|
+
* minAbs=2
|
|
34
|
+
*
|
|
35
|
+
* Produces:
|
|
36
|
+
* [-3..-2] U [2..3]
|
|
37
|
+
*/
|
|
38
|
+
minAbs?: number;
|
|
14
39
|
};
|
|
15
40
|
readonly priority = -60;
|
|
16
41
|
readonly requires: {
|
|
@@ -18,13 +43,26 @@ export declare class StaticRotationBehaviour implements Behaviour {
|
|
|
18
43
|
};
|
|
19
44
|
/**
|
|
20
45
|
* @param speed
|
|
21
|
-
* - number → fixed angular velocity
|
|
22
|
-
* -
|
|
46
|
+
* - number → fixed angular velocity
|
|
47
|
+
* - object → randomized angular velocity
|
|
23
48
|
*/
|
|
24
49
|
constructor(speed: number | {
|
|
25
50
|
min: number;
|
|
26
51
|
max: number;
|
|
52
|
+
/**
|
|
53
|
+
* Optional minimum absolute value.
|
|
54
|
+
*
|
|
55
|
+
* Example:
|
|
56
|
+
* min=-3
|
|
57
|
+
* max=3
|
|
58
|
+
* minAbs=2
|
|
59
|
+
*
|
|
60
|
+
* Produces:
|
|
61
|
+
* [-3..-2] U [2..3]
|
|
62
|
+
*/
|
|
63
|
+
minAbs?: number;
|
|
27
64
|
});
|
|
28
65
|
onSpawn(p: PxParticle): void;
|
|
66
|
+
private randomRange;
|
|
29
67
|
}
|
|
30
68
|
//# sourceMappingURL=static-rotation-behaviour.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-rotation-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/static-behaviours/static-rotation-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"static-rotation-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/static-behaviours/static-rotation-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,uBAAwB,YAAW,SAAS;IAW1C,KAAK,EACN,MAAM,GACN;QACI,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QAEZ;;;;;;;;;;WAUG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACnB;IA5BX,SAAgB,QAAQ,OAAO;IAE/B,SAAgB,QAAQ;;MAAsB;IAE9C;;;;OAIG;gBAEQ,KAAK,EACN,MAAM,GACN;QACI,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QAEZ;;;;;;;;;;WAUG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACnB;IAGJ,OAAO,CAAC,CAAC,EAAE,UAAU;IAM5B,OAAO,CAAC,WAAW;CAqCtB"}
|
|
@@ -5,14 +5,27 @@ exports.StaticRotationBehaviour = void 0;
|
|
|
5
5
|
* Sets a particle's angular velocity at spawn time.
|
|
6
6
|
*
|
|
7
7
|
* Does NOT modify rotation per frame directly.
|
|
8
|
-
* Instead, it initializes `
|
|
8
|
+
* Instead, it initializes `angleVBase`, which the emitter integrates each tick.
|
|
9
9
|
*
|
|
10
|
+
* Supports:
|
|
11
|
+
*
|
|
12
|
+
* - Fixed value:
|
|
13
|
+
* 2
|
|
14
|
+
*
|
|
15
|
+
* - Random range:
|
|
16
|
+
* { min: -3, max: 3 }
|
|
17
|
+
*
|
|
18
|
+
* - Random range with minimum absolute magnitude:
|
|
19
|
+
* { min: -3, max: 3, minAbs: 2 }
|
|
20
|
+
*
|
|
21
|
+
* Result:
|
|
22
|
+
* [-3 .. -2] U [2 .. 3]
|
|
10
23
|
*/
|
|
11
24
|
class StaticRotationBehaviour {
|
|
12
25
|
/**
|
|
13
26
|
* @param speed
|
|
14
|
-
* - number → fixed angular velocity
|
|
15
|
-
* -
|
|
27
|
+
* - number → fixed angular velocity
|
|
28
|
+
* - object → randomized angular velocity
|
|
16
29
|
*/
|
|
17
30
|
constructor(speed) {
|
|
18
31
|
this.speed = speed;
|
|
@@ -20,8 +33,36 @@ class StaticRotationBehaviour {
|
|
|
20
33
|
this.requires = { rotation: true };
|
|
21
34
|
}
|
|
22
35
|
onSpawn(p) {
|
|
23
|
-
const s = typeof this.speed === "number" ? this.speed : this.speed.min
|
|
24
|
-
p.
|
|
36
|
+
const s = typeof this.speed === "number" ? this.speed : this.randomRange(this.speed.min, this.speed.max, this.speed.minAbs);
|
|
37
|
+
p.angleVBase = s;
|
|
38
|
+
}
|
|
39
|
+
randomRange(min, max, minAbs) {
|
|
40
|
+
// Normal range
|
|
41
|
+
if (minAbs == null || minAbs <= 0) {
|
|
42
|
+
return min + Math.random() * (max - min);
|
|
43
|
+
}
|
|
44
|
+
// If the excluded center does not intersect range,
|
|
45
|
+
// fallback to normal random
|
|
46
|
+
if (min >= minAbs || max <= -minAbs) {
|
|
47
|
+
return min + Math.random() * (max - min);
|
|
48
|
+
}
|
|
49
|
+
const leftMin = min;
|
|
50
|
+
const leftMax = Math.min(-minAbs, max);
|
|
51
|
+
const rightMin = Math.max(minAbs, min);
|
|
52
|
+
const rightMax = max;
|
|
53
|
+
const leftSize = Math.max(0, leftMax - leftMin);
|
|
54
|
+
const rightSize = Math.max(0, rightMax - rightMin);
|
|
55
|
+
const total = leftSize + rightSize;
|
|
56
|
+
if (total <= 0) {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
const pick = Math.random() * total;
|
|
60
|
+
// Left segment
|
|
61
|
+
if (pick < leftSize) {
|
|
62
|
+
return leftMin + Math.random() * leftSize;
|
|
63
|
+
}
|
|
64
|
+
// Right segment
|
|
65
|
+
return rightMin + Math.random() * rightSize;
|
|
25
66
|
}
|
|
26
67
|
}
|
|
27
68
|
exports.StaticRotationBehaviour = StaticRotationBehaviour;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-rotation-behaviour.js","sourceRoot":"","sources":["../../../../src/behaviours/static-behaviours/static-rotation-behaviour.ts"],"names":[],"mappings":";;;AAGA
|
|
1
|
+
{"version":3,"file":"static-rotation-behaviour.js","sourceRoot":"","sources":["../../../../src/behaviours/static-behaviours/static-rotation-behaviour.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,uBAAuB;IAKhC;;;;OAIG;IACH,YACW,KAkBA;QAlBA,UAAK,GAAL,KAAK,CAkBL;QA5BK,aAAQ,GAAG,CAAC,EAAE,CAAC;QAEf,aAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IA2B3C,CAAC;IAEG,OAAO,CAAC,CAAa;QACxB,MAAM,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE5H,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC;IACrB,CAAC;IAEO,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,MAAe;QACzD,eAAe;QACf,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAChC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QAC7C,CAAC;QAED,mDAAmD;QACnD,4BAA4B;QAC5B,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,CAAC;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAEvC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,GAAG,CAAC;QAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;QAEnD,MAAM,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;QAEnC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACb,OAAO,CAAC,CAAC;QACb,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;QAEnC,eAAe;QACf,IAAI,IAAI,GAAG,QAAQ,EAAE,CAAC;YAClB,OAAO,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC;QAC9C,CAAC;QAED,gBAAgB;QAChB,OAAO,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;IAChD,CAAC;CACJ;AA3ED,0DA2EC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./behaviours/spawn-behaviours/circle-spawn-behaviour";
|
|
|
13
13
|
export * from "./behaviours/spawn-behaviours/rectangle-spawn-behaviour";
|
|
14
14
|
export * from "./behaviours/static-behaviours/static-rotation-behaviour";
|
|
15
15
|
export * from "./behaviours/static-behaviours/static-scale-behaviour";
|
|
16
|
+
export * from "./behaviours/rotation-curve-behaviour";
|
|
16
17
|
export * from "./texture-providers/animated-texture-provider";
|
|
17
18
|
export * from "./texture-providers/single-texture-provider";
|
|
18
19
|
export * from "./texture-providers/weighted-texture-provider";
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oDAAoD,CAAC;AACnE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,yDAAyD,CAAC;AACxE,cAAc,sDAAsD,CAAC;AACrE,cAAc,yDAAyD,CAAC;AACxE,cAAc,0DAA0D,CAAC;AACzE,cAAc,uDAAuD,CAAC;AACtE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oDAAoD,CAAC;AACnE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,yDAAyD,CAAC;AACxE,cAAc,sDAAsD,CAAC;AACrE,cAAc,yDAAyD,CAAC;AACxE,cAAc,0DAA0D,CAAC;AACzE,cAAc,uDAAuD,CAAC;AACtE,cAAc,uCAAuC,CAAC;AACtD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __exportStar(require("./behaviours/spawn-behaviours/circle-spawn-behaviour"), ex
|
|
|
29
29
|
__exportStar(require("./behaviours/spawn-behaviours/rectangle-spawn-behaviour"), exports);
|
|
30
30
|
__exportStar(require("./behaviours/static-behaviours/static-rotation-behaviour"), exports);
|
|
31
31
|
__exportStar(require("./behaviours/static-behaviours/static-scale-behaviour"), exports);
|
|
32
|
+
__exportStar(require("./behaviours/rotation-curve-behaviour"), exports);
|
|
32
33
|
__exportStar(require("./texture-providers/animated-texture-provider"), exports);
|
|
33
34
|
__exportStar(require("./texture-providers/single-texture-provider"), exports);
|
|
34
35
|
__exportStar(require("./texture-providers/weighted-texture-provider"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B;AAC1B,qDAAmC;AACnC,+DAA6C;AAC7C,qEAAmD;AACnD,qEAAmD;AACnD,gFAA8D;AAC9D,8EAA4D;AAC5D,qFAAmE;AACnE,4FAA0E;AAC1E,0FAAwE;AACxE,uFAAqE;AACrE,0FAAwE;AACxE,2FAAyE;AACzE,wFAAsE;AACtE,gFAA8D;AAC9D,8EAA4D;AAC5D,gFAA8D"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B;AAC1B,qDAAmC;AACnC,+DAA6C;AAC7C,qEAAmD;AACnD,qEAAmD;AACnD,gFAA8D;AAC9D,8EAA4D;AAC5D,qFAAmE;AACnE,4FAA0E;AAC1E,0FAAwE;AACxE,uFAAqE;AACrE,0FAAwE;AACxE,2FAAyE;AACzE,wFAAsE;AACtE,wEAAsD;AACtD,gFAA8D;AAC9D,8EAA4D;AAC5D,gFAA8D"}
|
|
@@ -29,14 +29,19 @@ export declare class PxParticle extends Particle {
|
|
|
29
29
|
vx: number;
|
|
30
30
|
/** Velocity in pixels per second (Y axis). */
|
|
31
31
|
vy: number;
|
|
32
|
-
/**
|
|
33
|
-
|
|
32
|
+
/** Base angular velocity in radians per second. */
|
|
33
|
+
private _angleVBase;
|
|
34
|
+
/** Base angular velocity scale for angleVBase */
|
|
35
|
+
private _angleVScale;
|
|
34
36
|
/**
|
|
35
37
|
* Optional provider-specific animation state.
|
|
36
38
|
* Used by AnimatedTextureProvider (if present).
|
|
37
39
|
*/
|
|
38
40
|
animatedParticleState?: AnimatedParticleState;
|
|
39
41
|
constructor(options: ParticleOptions);
|
|
42
|
+
set angleVBase(base: number);
|
|
43
|
+
set angleVScale(scale: number);
|
|
44
|
+
get angleV(): number;
|
|
40
45
|
/**
|
|
41
46
|
* Resets the particle into pooled (inactive) state.
|
|
42
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"px-particle.d.ts","sourceRoot":"","sources":["../../src/px-particle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACpC,2BAA2B;IACpB,GAAG,SAAK;IAEf,uEAAuE;IAChE,IAAI,SAAK;IAEhB,8CAA8C;IACvC,EAAE,SAAK;IAEd,8CAA8C;IACvC,EAAE,SAAK;IAEd,
|
|
1
|
+
{"version":3,"file":"px-particle.d.ts","sourceRoot":"","sources":["../../src/px-particle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACpC,2BAA2B;IACpB,GAAG,SAAK;IAEf,uEAAuE;IAChE,IAAI,SAAK;IAEhB,8CAA8C;IACvC,EAAE,SAAK;IAEd,8CAA8C;IACvC,EAAE,SAAK;IAEd,mDAAmD;IACnD,OAAO,CAAC,WAAW,CAAK;IAExB,iDAAiD;IACjD,OAAO,CAAC,YAAY,CAAK;IAEzB;;;OAGG;IACI,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;gBAEzC,OAAO,EAAE,eAAe;IAWpC,IAAW,UAAU,CAAC,IAAI,EAAE,MAAM,EAEjC;IAED,IAAW,WAAW,CAAC,KAAK,EAAE,MAAM,EAEnC;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;;;;;;OAQG;IACI,MAAM,IAAI,IAAI;IAYrB;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI;CAsBzB"}
|
package/dist/cjs/px-particle.js
CHANGED
|
@@ -28,11 +28,22 @@ class PxParticle extends pixi_js_1.Particle {
|
|
|
28
28
|
this.vx = 0;
|
|
29
29
|
/** Velocity in pixels per second (Y axis). */
|
|
30
30
|
this.vy = 0;
|
|
31
|
-
/**
|
|
32
|
-
this.
|
|
31
|
+
/** Base angular velocity in radians per second. */
|
|
32
|
+
this._angleVBase = 0;
|
|
33
|
+
/** Base angular velocity scale for angleVBase */
|
|
34
|
+
this._angleVScale = 1;
|
|
33
35
|
// Start in pooled/inactive state.
|
|
34
36
|
this.onKill();
|
|
35
37
|
}
|
|
38
|
+
set angleVBase(base) {
|
|
39
|
+
this._angleVBase = base;
|
|
40
|
+
}
|
|
41
|
+
set angleVScale(scale) {
|
|
42
|
+
this._angleVScale = scale;
|
|
43
|
+
}
|
|
44
|
+
get angleV() {
|
|
45
|
+
return this._angleVBase * this._angleVScale;
|
|
46
|
+
}
|
|
36
47
|
/**
|
|
37
48
|
* Resets the particle into pooled (inactive) state.
|
|
38
49
|
*
|
|
@@ -47,7 +58,8 @@ class PxParticle extends pixi_js_1.Particle {
|
|
|
47
58
|
this.life = 1;
|
|
48
59
|
this.vx = 0;
|
|
49
60
|
this.vy = 0;
|
|
50
|
-
this.
|
|
61
|
+
this._angleVBase = 0;
|
|
62
|
+
this._angleVScale = 1;
|
|
51
63
|
this.animatedParticleState = undefined;
|
|
52
64
|
}
|
|
53
65
|
/**
|
|
@@ -64,7 +76,8 @@ class PxParticle extends pixi_js_1.Particle {
|
|
|
64
76
|
this.life = 1;
|
|
65
77
|
this.vx = 0;
|
|
66
78
|
this.vy = 0;
|
|
67
|
-
this.
|
|
79
|
+
this._angleVBase = 0;
|
|
80
|
+
this._angleVScale = 1;
|
|
68
81
|
this.animatedParticleState = undefined;
|
|
69
82
|
// Reset visual state
|
|
70
83
|
this.alpha = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"px-particle.js","sourceRoot":"","sources":["../../src/px-particle.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAYpD;;;;;;;;;;;GAWG;AACH,MAAa,UAAW,SAAQ,kBAAQ;
|
|
1
|
+
{"version":3,"file":"px-particle.js","sourceRoot":"","sources":["../../src/px-particle.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAYpD;;;;;;;;;;;GAWG;AACH,MAAa,UAAW,SAAQ,kBAAQ;IAyBpC,YAAY,OAAwB;QAChC,2BAA2B;QAC3B,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;QACtB,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QA7BnB,2BAA2B;QACpB,QAAG,GAAG,CAAC,CAAC;QAEf,uEAAuE;QAChE,SAAI,GAAG,CAAC,CAAC;QAEhB,8CAA8C;QACvC,OAAE,GAAG,CAAC,CAAC;QAEd,8CAA8C;QACvC,OAAE,GAAG,CAAC,CAAC;QAEd,mDAAmD;QAC3C,gBAAW,GAAG,CAAC,CAAC;QAExB,iDAAiD;QACzC,iBAAY,GAAG,CAAC,CAAC;QAerB,kCAAkC;QAClC,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;IAED,IAAW,UAAU,CAAC,IAAY;QAC9B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;IAChD,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM;QACT,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAEd,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QAEtB,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAC3C,CAAC;IAED;;;;;;;;OAQG;IACI,OAAO;QACV,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAEd,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QAEtB,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;QAEvC,qBAAqB;QACrB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QAErB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAEhB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACJ;AApGD,gCAoGC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Behaviour } from "../behaviour";
|
|
2
|
+
import { PxParticle } from "../px-particle";
|
|
3
|
+
import { CurveKeyframe, CurveOptions } from "./curved-behaviour/curve-key-frame";
|
|
4
|
+
import { Emitter } from "../emitter";
|
|
5
|
+
/**
|
|
6
|
+
* Rotation over lifetime driven by a curve.
|
|
7
|
+
*
|
|
8
|
+
* Keyframes are sampled using normalized lifetime t in [0..1].
|
|
9
|
+
* Output is clamped to [0..1].
|
|
10
|
+
*/
|
|
11
|
+
export declare class RotationCurveBehaviour implements Behaviour {
|
|
12
|
+
readonly requires: {
|
|
13
|
+
color: boolean;
|
|
14
|
+
};
|
|
15
|
+
readonly priority = 50;
|
|
16
|
+
private curve;
|
|
17
|
+
constructor(keyframes: CurveKeyframe[], opts?: CurveOptions);
|
|
18
|
+
onSpawn(p: PxParticle): void;
|
|
19
|
+
update(p: PxParticle, _dt?: number, _emitter?: Emitter): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=rotation-curve-behaviour.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation-curve-behaviour.d.ts","sourceRoot":"","sources":["../../../src/behaviours/rotation-curve-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,SAAS;IACpD,SAAgB,QAAQ;;MAAmB;IAE3C,SAAgB,QAAQ,MAAM;IAE9B,OAAO,CAAC,KAAK,CAAQ;gBAET,SAAS,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,EAAE,YAAY;IAIpD,OAAO,CAAC,CAAC,EAAE,UAAU;IAIrB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO;CAIhE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Curve } from "./curved-behaviour/curve-sampler.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rotation over lifetime driven by a curve.
|
|
4
|
+
*
|
|
5
|
+
* Keyframes are sampled using normalized lifetime t in [0..1].
|
|
6
|
+
* Output is clamped to [0..1].
|
|
7
|
+
*/
|
|
8
|
+
export class RotationCurveBehaviour {
|
|
9
|
+
constructor(keyframes, opts) {
|
|
10
|
+
this.requires = { color: true };
|
|
11
|
+
this.priority = 50;
|
|
12
|
+
this.curve = new Curve(keyframes);
|
|
13
|
+
}
|
|
14
|
+
onSpawn(p) {
|
|
15
|
+
p.angleVScale = this.curve.sample(0);
|
|
16
|
+
}
|
|
17
|
+
update(p, _dt, _emitter) {
|
|
18
|
+
const t = p.life > 0 ? p.age / p.life : 1;
|
|
19
|
+
p.angleVScale = this.curve.sample(t);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=rotation-curve-behaviour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation-curve-behaviour.js","sourceRoot":"","sources":["../../../src/behaviours/rotation-curve-behaviour.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAGzD;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAO/B,YAAY,SAA0B,EAAE,IAAmB;QAN3C,aAAQ,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAE3B,aAAQ,GAAG,EAAE,CAAC;QAK1B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAEM,OAAO,CAAC,CAAa;QACxB,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,CAAa,EAAE,GAAY,EAAE,QAAkB;QACzD,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACJ"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { PxParticle } from "../../px-particle";
|
|
2
2
|
import { Behaviour } from "../../behaviour";
|
|
3
3
|
/**
|
|
4
|
-
* Spawns particles
|
|
4
|
+
* Spawns particles inside a circular ring centered at (0, 0).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Outer radius:
|
|
7
|
+
* radius
|
|
8
8
|
*
|
|
9
|
+
* Inner empty radius:
|
|
10
|
+
* innerRadius
|
|
11
|
+
*
|
|
12
|
+
* Particles spawn only between the outer and inner circles.
|
|
13
|
+
*
|
|
14
|
+
* Uses sqrt(random) to maintain uniform area distribution.
|
|
9
15
|
*/
|
|
10
16
|
export declare class CircleSpawnBehaviour implements Behaviour {
|
|
11
|
-
|
|
17
|
+
radius: number;
|
|
18
|
+
innerRadius: number;
|
|
12
19
|
readonly priority = -100;
|
|
13
|
-
constructor(radius: number);
|
|
20
|
+
constructor(radius: number, innerRadius?: number);
|
|
14
21
|
onSpawn(p: PxParticle): void;
|
|
15
22
|
}
|
|
16
23
|
//# sourceMappingURL=circle-spawn-behaviour.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle-spawn-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"circle-spawn-behaviour.d.ts","sourceRoot":"","sources":["../../../../src/behaviours/spawn-behaviours/circle-spawn-behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,qBAAa,oBAAqB,YAAW,SAAS;IAIvC,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,MAAM;IAJ9B,SAAgB,QAAQ,QAAQ;gBAGrB,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,MAAU;IAG3B,OAAO,CAAC,CAAC,EAAE,UAAU;CAY/B"}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Spawns particles
|
|
2
|
+
* Spawns particles inside a circular ring centered at (0, 0).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Outer radius:
|
|
5
|
+
* radius
|
|
6
6
|
*
|
|
7
|
+
* Inner empty radius:
|
|
8
|
+
* innerRadius
|
|
9
|
+
*
|
|
10
|
+
* Particles spawn only between the outer and inner circles.
|
|
11
|
+
*
|
|
12
|
+
* Uses sqrt(random) to maintain uniform area distribution.
|
|
7
13
|
*/
|
|
8
14
|
export class CircleSpawnBehaviour {
|
|
9
|
-
constructor(radius) {
|
|
15
|
+
constructor(radius, innerRadius = 0) {
|
|
10
16
|
this.radius = radius;
|
|
17
|
+
this.innerRadius = innerRadius;
|
|
11
18
|
this.priority = -100;
|
|
12
19
|
}
|
|
13
20
|
onSpawn(p) {
|
|
14
21
|
const angle = Math.random() * Math.PI * 2;
|
|
15
|
-
const
|
|
22
|
+
const outerR2 = this.radius * this.radius;
|
|
23
|
+
const innerR2 = this.innerRadius * this.innerRadius;
|
|
24
|
+
// Uniform distribution across ring area
|
|
25
|
+
const r = Math.sqrt(innerR2 + Math.random() * (outerR2 - innerR2));
|
|
16
26
|
p.x = Math.cos(angle) * r;
|
|
17
27
|
p.y = Math.sin(angle) * r;
|
|
18
28
|
}
|