@needle-tools/engine 2.42.0-pre → 2.44.0-pre
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 +22 -0
- package/dist/needle-engine.d.ts +224 -81
- package/dist/needle-engine.js +3836 -422
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +40 -40
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_element_loading.js +22 -6
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_input.js +17 -6
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js +60 -58
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_three_utils.d.ts +1 -0
- package/lib/engine/engine_three_utils.js +10 -0
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_time.js +2 -0
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +42 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +3 -1
- package/lib/engine-components/Animation.js +25 -1
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +4 -1
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +3 -0
- package/lib/engine-components/Camera.js +17 -9
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +33 -7
- package/lib/engine-components/ParticleSystem.js +464 -249
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemBehaviours.d.ts +0 -0
- package/lib/engine-components/ParticleSystemBehaviours.js +2 -0
- package/lib/engine-components/ParticleSystemBehaviours.js.map +1 -0
- package/lib/engine-components/ParticleSystemModules.d.ts +123 -20
- package/lib/engine-components/ParticleSystemModules.js +461 -63
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/WebXRController.d.ts +1 -0
- package/lib/engine-components/WebXRController.js +2 -1
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +6 -0
- package/lib/engine-components/codegen/components.js +6 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/RGBAColor.d.ts +1 -0
- package/lib/engine-components/js-extensions/RGBAColor.js +7 -0
- package/lib/engine-components/js-extensions/RGBAColor.js.map +1 -1
- package/package.json +2 -1
- package/src/engine/codegen/register_types.js +24 -0
- package/src/engine/engine_element_loading.ts +22 -5
- package/src/engine/engine_input.ts +16 -7
- package/src/engine/engine_serialization_builtin_serializer.ts +59 -57
- package/src/engine/engine_three_utils.ts +11 -2
- package/src/engine/engine_time.ts +1 -0
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +43 -1
- package/src/engine-components/Animation.ts +18 -2
- package/src/engine-components/AnimatorController.ts +5 -1
- package/src/engine-components/Camera.ts +17 -10
- package/src/engine-components/ParticleSystem.ts +526 -303
- package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
- package/src/engine-components/ParticleSystemModules.ts +408 -66
- package/src/engine-components/WebXRController.ts +2 -1
- package/src/engine-components/codegen/components.ts +6 -0
- package/src/engine-components/js-extensions/RGBAColor.ts +7 -0
|
@@ -143,12 +143,12 @@ export class MinMaxCurve {
|
|
|
143
143
|
case ParticleSystemCurveMode.Constant:
|
|
144
144
|
return this.constant;
|
|
145
145
|
case ParticleSystemCurveMode.Curve:
|
|
146
|
-
t01
|
|
147
|
-
return this.curve.evaluate(t01);
|
|
146
|
+
t01 = Mathf.clamp01(t01);
|
|
147
|
+
return this.curve.evaluate(t01) * this.curveMultiplier;
|
|
148
148
|
case ParticleSystemCurveMode.TwoCurves:
|
|
149
149
|
const t1 = t01 * this.curveMin.duration;
|
|
150
150
|
const t2 = t01 * this.curveMax.duration;
|
|
151
|
-
return Mathf.lerp(this.curveMin.evaluate(t1), this.curveMax.evaluate(t2), t % 1);
|
|
151
|
+
return Mathf.lerp(this.curveMin.evaluate(t1), this.curveMax.evaluate(t2), t % 1) * this.curveMultiplier;
|
|
152
152
|
case ParticleSystemCurveMode.TwoConstants:
|
|
153
153
|
return Mathf.lerp(this.constantMin, this.constantMax, t % 1);
|
|
154
154
|
default:
|
|
@@ -201,7 +201,8 @@ export class MinMaxGradient {
|
|
|
201
201
|
this.gradient.evaluate(t01, MinMaxGradient._temp);
|
|
202
202
|
return MinMaxGradient._temp;
|
|
203
203
|
case ParticleSystemGradientMode.TwoColors:
|
|
204
|
-
|
|
204
|
+
const col1 = MinMaxGradient._temp.lerpColors(this.colorMin, this.colorMax, t);
|
|
205
|
+
return col1;
|
|
205
206
|
case ParticleSystemGradientMode.TwoGradients:
|
|
206
207
|
const t2 = Math.random();
|
|
207
208
|
this.gradientMin.evaluate(t2, MinMaxGradient._temp);
|
|
@@ -371,34 +372,21 @@ export class EmissionModule {
|
|
|
371
372
|
rateOverDistanceMultiplier;
|
|
372
373
|
/** set from system */
|
|
373
374
|
system;
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
// private _didEmit: boolean = false;
|
|
377
|
-
/** called by nebula */
|
|
378
|
-
init() {
|
|
375
|
+
reset() {
|
|
376
|
+
this.bursts?.forEach(b => b.reset());
|
|
379
377
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
if (this.system.currentParticles >= this.system.maxParticles)
|
|
383
|
-
return 0;
|
|
384
|
-
if (!this.enabled)
|
|
385
|
-
return 0;
|
|
386
|
-
let count = this.rateOverTime.evaluate(this.time / this.system.duration, Math.random());
|
|
387
|
-
this._summed += count * deltaTime;
|
|
388
|
-
let amount = Math.floor(this._summed);
|
|
389
|
-
this._summed -= amount;
|
|
378
|
+
getBurst() {
|
|
379
|
+
let amount = 0;
|
|
390
380
|
if (this.burstCount > 0) {
|
|
391
381
|
for (let i = 0; i < this.burstCount; i++) {
|
|
392
382
|
const burst = this.bursts[i];
|
|
393
|
-
if (burst.time >= this.time) {
|
|
383
|
+
if (burst.time >= this.system.time) {
|
|
394
384
|
burst.reset();
|
|
395
|
-
continue;
|
|
396
385
|
}
|
|
397
|
-
amount += Math.round(burst.run(this.time));
|
|
386
|
+
amount += Math.round(burst.run(this.system.time));
|
|
398
387
|
}
|
|
399
388
|
}
|
|
400
|
-
|
|
401
|
-
return amount; //Mathf.clamp(amount, 0, this.system.maxParticles - this.system.currentParticles);
|
|
389
|
+
return amount;
|
|
402
390
|
}
|
|
403
391
|
}
|
|
404
392
|
__decorate([
|
|
@@ -431,14 +419,21 @@ export class SizeOverLifetimeModule {
|
|
|
431
419
|
separateAxes;
|
|
432
420
|
size;
|
|
433
421
|
sizeMultiplier;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
422
|
+
x;
|
|
423
|
+
xMultiplier;
|
|
424
|
+
y;
|
|
425
|
+
yMultiplier;
|
|
426
|
+
z;
|
|
427
|
+
zMultiplier;
|
|
440
428
|
_time = 0;
|
|
429
|
+
_temp = new Vector3();
|
|
441
430
|
evaluate(t01, target) {
|
|
431
|
+
if (!target)
|
|
432
|
+
target = this._temp;
|
|
433
|
+
if (!this.enabled) {
|
|
434
|
+
target.x = target.y = target.z = 1;
|
|
435
|
+
return target;
|
|
436
|
+
}
|
|
442
437
|
if (!this.separateAxes) {
|
|
443
438
|
const scale = this.size.evaluate(t01) * this.sizeMultiplier;
|
|
444
439
|
target.x = scale;
|
|
@@ -446,9 +441,9 @@ export class SizeOverLifetimeModule {
|
|
|
446
441
|
// target.z = scale;
|
|
447
442
|
}
|
|
448
443
|
else {
|
|
449
|
-
target.x = this.
|
|
450
|
-
|
|
451
|
-
|
|
444
|
+
target.x = this.x.evaluate(t01) * this.xMultiplier;
|
|
445
|
+
target.y = this.y.evaluate(t01) * this.yMultiplier;
|
|
446
|
+
target.z = this.z.evaluate(t01) * this.zMultiplier;
|
|
452
447
|
}
|
|
453
448
|
return target;
|
|
454
449
|
}
|
|
@@ -458,14 +453,27 @@ __decorate([
|
|
|
458
453
|
], SizeOverLifetimeModule.prototype, "size", void 0);
|
|
459
454
|
__decorate([
|
|
460
455
|
serializeable(MinMaxCurve)
|
|
461
|
-
], SizeOverLifetimeModule.prototype, "
|
|
456
|
+
], SizeOverLifetimeModule.prototype, "x", void 0);
|
|
462
457
|
__decorate([
|
|
463
458
|
serializeable(MinMaxCurve)
|
|
464
|
-
], SizeOverLifetimeModule.prototype, "
|
|
459
|
+
], SizeOverLifetimeModule.prototype, "y", void 0);
|
|
465
460
|
__decorate([
|
|
466
461
|
serializeable(MinMaxCurve)
|
|
467
|
-
], SizeOverLifetimeModule.prototype, "
|
|
462
|
+
], SizeOverLifetimeModule.prototype, "z", void 0);
|
|
468
463
|
export class ShapeModule {
|
|
464
|
+
get type() {
|
|
465
|
+
return ParticleSystemShapeType[this.shapeType];
|
|
466
|
+
}
|
|
467
|
+
initialize(particle) {
|
|
468
|
+
this.getPosition();
|
|
469
|
+
particle.position.copy(this._vector);
|
|
470
|
+
}
|
|
471
|
+
toJSON() {
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
clone() {
|
|
475
|
+
return new ShapeModule();
|
|
476
|
+
}
|
|
469
477
|
shapeType = ParticleSystemShapeType.Box;
|
|
470
478
|
enabled = true;
|
|
471
479
|
alignToDirection = false;
|
|
@@ -482,16 +490,20 @@ export class ShapeModule {
|
|
|
482
490
|
radius;
|
|
483
491
|
radiusThickness;
|
|
484
492
|
sphericalDirectionAmount;
|
|
493
|
+
system;
|
|
485
494
|
_space;
|
|
486
|
-
|
|
487
|
-
|
|
495
|
+
_worldSpaceMatrix = new Matrix4();
|
|
496
|
+
_worldSpaceMatrixInverse = new Matrix4();
|
|
497
|
+
update(system, _context, simulationSpace, obj) {
|
|
498
|
+
this.system = system;
|
|
488
499
|
this._space = simulationSpace;
|
|
489
500
|
if (simulationSpace === ParticleSystemSimulationSpace.World) {
|
|
490
|
-
this.
|
|
501
|
+
this._worldSpaceMatrix.copy(obj.matrixWorld);
|
|
491
502
|
// set scale to 1
|
|
492
|
-
this.
|
|
493
|
-
this.
|
|
494
|
-
this.
|
|
503
|
+
this._worldSpaceMatrix.elements[0] = 1;
|
|
504
|
+
this._worldSpaceMatrix.elements[5] = 1;
|
|
505
|
+
this._worldSpaceMatrix.elements[10] = 1;
|
|
506
|
+
this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert();
|
|
495
507
|
}
|
|
496
508
|
}
|
|
497
509
|
/** nebula implementations: */
|
|
@@ -502,7 +514,6 @@ export class ShapeModule {
|
|
|
502
514
|
get vector() {
|
|
503
515
|
return this._vector;
|
|
504
516
|
}
|
|
505
|
-
/** called by nebula */
|
|
506
517
|
getPosition() {
|
|
507
518
|
switch (this.shapeType) {
|
|
508
519
|
case ParticleSystemShapeType.Box:
|
|
@@ -511,28 +522,42 @@ export class ShapeModule {
|
|
|
511
522
|
this._vector.z = Math.random() * this.scale.z - this.scale.z / 2;
|
|
512
523
|
break;
|
|
513
524
|
case ParticleSystemShapeType.Sphere:
|
|
514
|
-
randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius, this.radiusThickness, this.arc, this._vector);
|
|
525
|
+
randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius * this.system.worldScale.x, this.radiusThickness, this.arc, this._vector);
|
|
526
|
+
// this._vector.y += 1;
|
|
527
|
+
break;
|
|
528
|
+
default:
|
|
529
|
+
this._vector.set(0, 0, 0);
|
|
515
530
|
break;
|
|
516
531
|
// case ParticleSystemShapeType.Hemisphere:
|
|
517
532
|
// randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius, this.radiusThickness, 180, this._vector);
|
|
518
533
|
// break;
|
|
519
534
|
}
|
|
520
535
|
if (this._space === ParticleSystemSimulationSpace.World) {
|
|
521
|
-
this._vector.applyMatrix4(this.
|
|
536
|
+
this._vector.applyMatrix4(this._worldSpaceMatrix);
|
|
522
537
|
}
|
|
523
538
|
}
|
|
524
539
|
_dir = new Vector3();
|
|
525
540
|
getDirection(position) {
|
|
526
541
|
switch (this.shapeType) {
|
|
527
542
|
case ParticleSystemShapeType.Box:
|
|
528
|
-
|
|
543
|
+
this._dir.set(0, 0, 1);
|
|
544
|
+
break;
|
|
529
545
|
case ParticleSystemShapeType.Sphere:
|
|
530
546
|
const rx = position.x;
|
|
531
547
|
const ry = position.y;
|
|
532
548
|
const rz = position.z;
|
|
533
|
-
|
|
549
|
+
this._dir.set(rx, ry, rz);
|
|
550
|
+
break;
|
|
551
|
+
default:
|
|
552
|
+
this._dir.set(0, 0, 1);
|
|
553
|
+
break;
|
|
534
554
|
}
|
|
535
|
-
|
|
555
|
+
if (this._space === ParticleSystemSimulationSpace.World) {
|
|
556
|
+
this._dir.applyMatrix4(this._worldSpaceMatrixInverse);
|
|
557
|
+
}
|
|
558
|
+
this._dir.normalize();
|
|
559
|
+
// Gizmos.DrawDirection(position, this._dir, 0xff0000, .5);
|
|
560
|
+
return this._dir;
|
|
536
561
|
}
|
|
537
562
|
}
|
|
538
563
|
__decorate([
|
|
@@ -588,7 +613,6 @@ function randomSpherePoint(x0, y0, z0, radius, thickness, arc, vec) {
|
|
|
588
613
|
vec.z = z;
|
|
589
614
|
}
|
|
590
615
|
import { createNoise4D } from 'simplex-noise';
|
|
591
|
-
import { Context } from "../engine/engine_setup";
|
|
592
616
|
export class NoiseModule {
|
|
593
617
|
damping;
|
|
594
618
|
enabled;
|
|
@@ -623,33 +647,33 @@ export class NoiseModule {
|
|
|
623
647
|
}
|
|
624
648
|
/** nebula implementations: */
|
|
625
649
|
_temp = new Vector3();
|
|
626
|
-
|
|
650
|
+
apply(_index, pos, vel, _deltaTime, age, life) {
|
|
627
651
|
if (!this.enabled)
|
|
628
652
|
return;
|
|
629
653
|
if (!this._noise) {
|
|
630
654
|
this._noise = createNoise4D(() => 0);
|
|
631
655
|
}
|
|
632
|
-
const t = age / life;
|
|
633
|
-
const dt = Context.Current.time.deltaTime;
|
|
634
656
|
const temp = this._temp.set(pos.x, pos.y, pos.z).multiplyScalar(this.frequency);
|
|
635
657
|
const nx = this._noise(temp.x, temp.y, temp.z, this._time);
|
|
636
|
-
const ny = this._noise(temp.x, temp.y, temp.z, this._time + .
|
|
637
|
-
const nz = this._noise(temp.x, temp.y, temp.z, this._time +
|
|
658
|
+
const ny = this._noise(temp.x, temp.y, temp.z, this._time + .3);
|
|
659
|
+
const nz = this._noise(temp.x, temp.y, temp.z, this._time + 1);
|
|
638
660
|
this._temp.set(nx, ny, nz).normalize();
|
|
661
|
+
const t = age / life;
|
|
639
662
|
let strengthFactor = this.positionAmount.evaluate(t);
|
|
640
663
|
if (!this.separateAxes) {
|
|
641
|
-
if (this.strengthX)
|
|
642
|
-
strengthFactor *= this.strengthX.evaluate(t
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
strengthFactor *= deltaTime;
|
|
664
|
+
if (this.strengthX) {
|
|
665
|
+
strengthFactor *= this.strengthX.evaluate(t) * Math.PI;
|
|
666
|
+
}
|
|
667
|
+
// strengthFactor *= this.strengthMultiplier;
|
|
668
|
+
// strengthFactor *= deltaTime;
|
|
646
669
|
this._temp.multiplyScalar(strengthFactor);
|
|
647
670
|
}
|
|
648
|
-
|
|
649
|
-
this._temp.x *= strengthFactor *
|
|
650
|
-
this._temp.y *= strengthFactor *
|
|
651
|
-
this._temp.z *= strengthFactor *
|
|
671
|
+
else {
|
|
672
|
+
this._temp.x *= strengthFactor * this.strengthXMultiplier;
|
|
673
|
+
this._temp.y *= strengthFactor * this.strengthYMultiplier;
|
|
674
|
+
this._temp.z *= strengthFactor * this.strengthZMultiplier;
|
|
652
675
|
}
|
|
676
|
+
// this._temp.setLength(strengthFactor * deltaTime);
|
|
653
677
|
vel.x += this._temp.x;
|
|
654
678
|
vel.y += this._temp.y;
|
|
655
679
|
vel.z += this._temp.z;
|
|
@@ -733,4 +757,378 @@ __decorate([
|
|
|
733
757
|
__decorate([
|
|
734
758
|
serializeable()
|
|
735
759
|
], NoiseModule.prototype, "strengthZMultiplier", void 0);
|
|
760
|
+
export class TrailModule {
|
|
761
|
+
enabled;
|
|
762
|
+
}
|
|
763
|
+
__decorate([
|
|
764
|
+
serializeable()
|
|
765
|
+
], TrailModule.prototype, "enabled", void 0);
|
|
766
|
+
export class VelocityOverLifetimeModule {
|
|
767
|
+
enabled;
|
|
768
|
+
/* orbital settings */
|
|
769
|
+
space = ParticleSystemSimulationSpace.Local;
|
|
770
|
+
speedModifier;
|
|
771
|
+
speedModifierMultiplier;
|
|
772
|
+
x;
|
|
773
|
+
xMultiplier;
|
|
774
|
+
y;
|
|
775
|
+
yMultiplier;
|
|
776
|
+
z;
|
|
777
|
+
zMultiplier;
|
|
778
|
+
_system;
|
|
779
|
+
// private _worldRotation: Quaternion = new Quaternion();
|
|
780
|
+
update(system) {
|
|
781
|
+
this._system = system;
|
|
782
|
+
}
|
|
783
|
+
_temp = new Vector3();
|
|
784
|
+
apply(_index, _pos, vel, _dt, age, life) {
|
|
785
|
+
if (!this.enabled)
|
|
786
|
+
return;
|
|
787
|
+
const t = age / life;
|
|
788
|
+
const speed = this.speedModifier.evaluate(t) * this.speedModifierMultiplier;
|
|
789
|
+
const x = this.x.evaluate(t) * speed;
|
|
790
|
+
const y = this.y.evaluate(t) * speed;
|
|
791
|
+
const z = this.z.evaluate(t) * speed;
|
|
792
|
+
this._temp.set(-x, y, z);
|
|
793
|
+
if (this._system) {
|
|
794
|
+
if (this.space === ParticleSystemSimulationSpace.World) {
|
|
795
|
+
this._temp.applyQuaternion(this._system.worldQuaternionInverted);
|
|
796
|
+
}
|
|
797
|
+
if (this._system.main.simulationSpace === ParticleSystemSimulationSpace.World) {
|
|
798
|
+
this._temp.applyQuaternion(this._system.worldQuaternion);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
vel.x += this._temp.x;
|
|
802
|
+
vel.y += this._temp.y;
|
|
803
|
+
vel.z += this._temp.z;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
__decorate([
|
|
807
|
+
serializeable()
|
|
808
|
+
], VelocityOverLifetimeModule.prototype, "enabled", void 0);
|
|
809
|
+
__decorate([
|
|
810
|
+
serializeable()
|
|
811
|
+
], VelocityOverLifetimeModule.prototype, "space", void 0);
|
|
812
|
+
__decorate([
|
|
813
|
+
serializeable(MinMaxCurve)
|
|
814
|
+
], VelocityOverLifetimeModule.prototype, "speedModifier", void 0);
|
|
815
|
+
__decorate([
|
|
816
|
+
serializeable()
|
|
817
|
+
], VelocityOverLifetimeModule.prototype, "speedModifierMultiplier", void 0);
|
|
818
|
+
__decorate([
|
|
819
|
+
serializeable(MinMaxCurve)
|
|
820
|
+
], VelocityOverLifetimeModule.prototype, "x", void 0);
|
|
821
|
+
__decorate([
|
|
822
|
+
serializeable()
|
|
823
|
+
], VelocityOverLifetimeModule.prototype, "xMultiplier", void 0);
|
|
824
|
+
__decorate([
|
|
825
|
+
serializeable(MinMaxCurve)
|
|
826
|
+
], VelocityOverLifetimeModule.prototype, "y", void 0);
|
|
827
|
+
__decorate([
|
|
828
|
+
serializeable()
|
|
829
|
+
], VelocityOverLifetimeModule.prototype, "yMultiplier", void 0);
|
|
830
|
+
__decorate([
|
|
831
|
+
serializeable(MinMaxCurve)
|
|
832
|
+
], VelocityOverLifetimeModule.prototype, "z", void 0);
|
|
833
|
+
__decorate([
|
|
834
|
+
serializeable()
|
|
835
|
+
], VelocityOverLifetimeModule.prototype, "zMultiplier", void 0);
|
|
836
|
+
var ParticleSystemAnimationTimeMode;
|
|
837
|
+
(function (ParticleSystemAnimationTimeMode) {
|
|
838
|
+
ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["Lifetime"] = 0] = "Lifetime";
|
|
839
|
+
ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["Speed"] = 1] = "Speed";
|
|
840
|
+
ParticleSystemAnimationTimeMode[ParticleSystemAnimationTimeMode["FPS"] = 2] = "FPS";
|
|
841
|
+
})(ParticleSystemAnimationTimeMode || (ParticleSystemAnimationTimeMode = {}));
|
|
842
|
+
var ParticleSystemAnimationMode;
|
|
843
|
+
(function (ParticleSystemAnimationMode) {
|
|
844
|
+
ParticleSystemAnimationMode[ParticleSystemAnimationMode["Grid"] = 0] = "Grid";
|
|
845
|
+
ParticleSystemAnimationMode[ParticleSystemAnimationMode["Sprites"] = 1] = "Sprites";
|
|
846
|
+
})(ParticleSystemAnimationMode || (ParticleSystemAnimationMode = {}));
|
|
847
|
+
var ParticleSystemAnimationRowMode;
|
|
848
|
+
(function (ParticleSystemAnimationRowMode) {
|
|
849
|
+
ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["Custom"] = 0] = "Custom";
|
|
850
|
+
ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["Random"] = 1] = "Random";
|
|
851
|
+
ParticleSystemAnimationRowMode[ParticleSystemAnimationRowMode["MeshIndex"] = 2] = "MeshIndex";
|
|
852
|
+
})(ParticleSystemAnimationRowMode || (ParticleSystemAnimationRowMode = {}));
|
|
853
|
+
var ParticleSystemAnimationType;
|
|
854
|
+
(function (ParticleSystemAnimationType) {
|
|
855
|
+
ParticleSystemAnimationType[ParticleSystemAnimationType["WholeSheet"] = 0] = "WholeSheet";
|
|
856
|
+
ParticleSystemAnimationType[ParticleSystemAnimationType["SingleRow"] = 1] = "SingleRow";
|
|
857
|
+
})(ParticleSystemAnimationType || (ParticleSystemAnimationType = {}));
|
|
858
|
+
export class TextureSheetAnimationModule {
|
|
859
|
+
animation;
|
|
860
|
+
enabled;
|
|
861
|
+
cycleCount;
|
|
862
|
+
frameOverTime;
|
|
863
|
+
frameOverTimeMultiplier;
|
|
864
|
+
numTilesX;
|
|
865
|
+
numTilesY;
|
|
866
|
+
startFrame;
|
|
867
|
+
startFrameMultiplier;
|
|
868
|
+
rowMode;
|
|
869
|
+
rowIndex;
|
|
870
|
+
spriteCount;
|
|
871
|
+
timeMode;
|
|
872
|
+
sampleOnceAtStart() {
|
|
873
|
+
if (this.timeMode === ParticleSystemAnimationTimeMode.Lifetime) {
|
|
874
|
+
switch (this.frameOverTime.mode) {
|
|
875
|
+
case ParticleSystemCurveMode.Constant:
|
|
876
|
+
case ParticleSystemCurveMode.TwoConstants:
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
getStartIndex() {
|
|
883
|
+
if (this.sampleOnceAtStart()) {
|
|
884
|
+
return this.frameOverTime.evaluate(Math.random());
|
|
885
|
+
}
|
|
886
|
+
return 0;
|
|
887
|
+
}
|
|
888
|
+
evaluate(t01) {
|
|
889
|
+
if (this.sampleOnceAtStart()) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
return this.getIndex(t01);
|
|
893
|
+
}
|
|
894
|
+
getIndex(t01) {
|
|
895
|
+
const tiles = this.numTilesX * this.numTilesY;
|
|
896
|
+
// let pos = t01 * this.cycleCount;
|
|
897
|
+
let index = this.frameOverTime.evaluate(t01 % 1);
|
|
898
|
+
index *= this.frameOverTimeMultiplier;
|
|
899
|
+
index *= tiles;
|
|
900
|
+
index = index % tiles;
|
|
901
|
+
index = Math.floor(index);
|
|
902
|
+
// console.log(index);
|
|
903
|
+
return index;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
__decorate([
|
|
907
|
+
serializeable()
|
|
908
|
+
], TextureSheetAnimationModule.prototype, "animation", void 0);
|
|
909
|
+
__decorate([
|
|
910
|
+
serializeable()
|
|
911
|
+
], TextureSheetAnimationModule.prototype, "enabled", void 0);
|
|
912
|
+
__decorate([
|
|
913
|
+
serializeable()
|
|
914
|
+
], TextureSheetAnimationModule.prototype, "cycleCount", void 0);
|
|
915
|
+
__decorate([
|
|
916
|
+
serializeable(MinMaxCurve)
|
|
917
|
+
], TextureSheetAnimationModule.prototype, "frameOverTime", void 0);
|
|
918
|
+
__decorate([
|
|
919
|
+
serializeable()
|
|
920
|
+
], TextureSheetAnimationModule.prototype, "frameOverTimeMultiplier", void 0);
|
|
921
|
+
__decorate([
|
|
922
|
+
serializeable()
|
|
923
|
+
], TextureSheetAnimationModule.prototype, "numTilesX", void 0);
|
|
924
|
+
__decorate([
|
|
925
|
+
serializeable()
|
|
926
|
+
], TextureSheetAnimationModule.prototype, "numTilesY", void 0);
|
|
927
|
+
__decorate([
|
|
928
|
+
serializeable(MinMaxCurve)
|
|
929
|
+
], TextureSheetAnimationModule.prototype, "startFrame", void 0);
|
|
930
|
+
__decorate([
|
|
931
|
+
serializeable()
|
|
932
|
+
], TextureSheetAnimationModule.prototype, "startFrameMultiplier", void 0);
|
|
933
|
+
__decorate([
|
|
934
|
+
serializeable()
|
|
935
|
+
], TextureSheetAnimationModule.prototype, "rowMode", void 0);
|
|
936
|
+
__decorate([
|
|
937
|
+
serializeable()
|
|
938
|
+
], TextureSheetAnimationModule.prototype, "rowIndex", void 0);
|
|
939
|
+
__decorate([
|
|
940
|
+
serializeable()
|
|
941
|
+
], TextureSheetAnimationModule.prototype, "spriteCount", void 0);
|
|
942
|
+
__decorate([
|
|
943
|
+
serializeable()
|
|
944
|
+
], TextureSheetAnimationModule.prototype, "timeMode", void 0);
|
|
945
|
+
export class RotationOverLifetimeModule {
|
|
946
|
+
enabled;
|
|
947
|
+
separateAxes;
|
|
948
|
+
x;
|
|
949
|
+
xMultiplier;
|
|
950
|
+
y;
|
|
951
|
+
yMultiplier;
|
|
952
|
+
z;
|
|
953
|
+
zMultiplier;
|
|
954
|
+
evaluate(t01) {
|
|
955
|
+
if (!this.enabled)
|
|
956
|
+
return 0;
|
|
957
|
+
if (!this.separateAxes) {
|
|
958
|
+
const rot = this.z.evaluate(t01) * -1;
|
|
959
|
+
return rot;
|
|
960
|
+
}
|
|
961
|
+
return 0;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
__decorate([
|
|
965
|
+
serializeable()
|
|
966
|
+
], RotationOverLifetimeModule.prototype, "enabled", void 0);
|
|
967
|
+
__decorate([
|
|
968
|
+
serializeable()
|
|
969
|
+
], RotationOverLifetimeModule.prototype, "separateAxes", void 0);
|
|
970
|
+
__decorate([
|
|
971
|
+
serializeable(MinMaxCurve)
|
|
972
|
+
], RotationOverLifetimeModule.prototype, "x", void 0);
|
|
973
|
+
__decorate([
|
|
974
|
+
serializeable()
|
|
975
|
+
], RotationOverLifetimeModule.prototype, "xMultiplier", void 0);
|
|
976
|
+
__decorate([
|
|
977
|
+
serializeable(MinMaxCurve)
|
|
978
|
+
], RotationOverLifetimeModule.prototype, "y", void 0);
|
|
979
|
+
__decorate([
|
|
980
|
+
serializeable()
|
|
981
|
+
], RotationOverLifetimeModule.prototype, "yMultiplier", void 0);
|
|
982
|
+
__decorate([
|
|
983
|
+
serializeable(MinMaxCurve)
|
|
984
|
+
], RotationOverLifetimeModule.prototype, "z", void 0);
|
|
985
|
+
__decorate([
|
|
986
|
+
serializeable()
|
|
987
|
+
], RotationOverLifetimeModule.prototype, "zMultiplier", void 0);
|
|
988
|
+
export class RotationBySpeedModule {
|
|
989
|
+
enabled;
|
|
990
|
+
range;
|
|
991
|
+
separateAxes;
|
|
992
|
+
x;
|
|
993
|
+
xMultiplier;
|
|
994
|
+
y;
|
|
995
|
+
yMultiplier;
|
|
996
|
+
z;
|
|
997
|
+
zMultiplier;
|
|
998
|
+
evaluate(_t01, speed) {
|
|
999
|
+
if (!this.enabled)
|
|
1000
|
+
return 0;
|
|
1001
|
+
if (!this.separateAxes) {
|
|
1002
|
+
const t = Mathf.lerp(this.range.x, this.range.y, speed);
|
|
1003
|
+
const rot = this.z.evaluate(t) * -1;
|
|
1004
|
+
return rot;
|
|
1005
|
+
}
|
|
1006
|
+
return 0;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
__decorate([
|
|
1010
|
+
serializeable()
|
|
1011
|
+
], RotationBySpeedModule.prototype, "enabled", void 0);
|
|
1012
|
+
__decorate([
|
|
1013
|
+
serializeable()
|
|
1014
|
+
], RotationBySpeedModule.prototype, "range", void 0);
|
|
1015
|
+
__decorate([
|
|
1016
|
+
serializeable()
|
|
1017
|
+
], RotationBySpeedModule.prototype, "separateAxes", void 0);
|
|
1018
|
+
__decorate([
|
|
1019
|
+
serializeable(MinMaxCurve)
|
|
1020
|
+
], RotationBySpeedModule.prototype, "x", void 0);
|
|
1021
|
+
__decorate([
|
|
1022
|
+
serializeable()
|
|
1023
|
+
], RotationBySpeedModule.prototype, "xMultiplier", void 0);
|
|
1024
|
+
__decorate([
|
|
1025
|
+
serializeable(MinMaxCurve)
|
|
1026
|
+
], RotationBySpeedModule.prototype, "y", void 0);
|
|
1027
|
+
__decorate([
|
|
1028
|
+
serializeable()
|
|
1029
|
+
], RotationBySpeedModule.prototype, "yMultiplier", void 0);
|
|
1030
|
+
__decorate([
|
|
1031
|
+
serializeable(MinMaxCurve)
|
|
1032
|
+
], RotationBySpeedModule.prototype, "z", void 0);
|
|
1033
|
+
__decorate([
|
|
1034
|
+
serializeable()
|
|
1035
|
+
], RotationBySpeedModule.prototype, "zMultiplier", void 0);
|
|
1036
|
+
export class LimitVelocityOverLifetimeModule {
|
|
1037
|
+
enabled;
|
|
1038
|
+
dampen;
|
|
1039
|
+
drag;
|
|
1040
|
+
dragMultiplier;
|
|
1041
|
+
limit;
|
|
1042
|
+
limitMultiplier;
|
|
1043
|
+
separateAxes;
|
|
1044
|
+
limitX;
|
|
1045
|
+
limitXMultiplier;
|
|
1046
|
+
limitY;
|
|
1047
|
+
limitYMultiplier;
|
|
1048
|
+
limitZ;
|
|
1049
|
+
limitZMultiplier;
|
|
1050
|
+
multiplyDragByParticleSize = false;
|
|
1051
|
+
multiplyDragByParticleVelocity = false;
|
|
1052
|
+
space;
|
|
1053
|
+
_temp = new Vector3();
|
|
1054
|
+
_temp2 = new Vector3();
|
|
1055
|
+
apply(_position, baseVelocity, currentVelocity, _size, t01, _dt, _scale) {
|
|
1056
|
+
if (!this.enabled)
|
|
1057
|
+
return;
|
|
1058
|
+
// if (this.separateAxes) {
|
|
1059
|
+
// // const maxX = this.limitX.evaluate(t01) * this.limitXMultiplier;
|
|
1060
|
+
// // const maxY = this.limitY.evaluate(t01) * this.limitYMultiplier;
|
|
1061
|
+
// // const maxZ = this.limitZ.evaluate(t01) * this.limitZMultiplier;
|
|
1062
|
+
// }
|
|
1063
|
+
// else
|
|
1064
|
+
{
|
|
1065
|
+
const max = this.limit.evaluate(t01) * this.limitMultiplier;
|
|
1066
|
+
const speed = baseVelocity.length();
|
|
1067
|
+
if (speed > max) {
|
|
1068
|
+
this._temp.copy(baseVelocity).normalize().multiplyScalar(max);
|
|
1069
|
+
let t = this.dampen * .5;
|
|
1070
|
+
// t *= scale;
|
|
1071
|
+
baseVelocity.x = Mathf.lerp(baseVelocity.x, this._temp.x, t);
|
|
1072
|
+
baseVelocity.y = Mathf.lerp(baseVelocity.y, this._temp.y, t);
|
|
1073
|
+
baseVelocity.z = Mathf.lerp(baseVelocity.z, this._temp.z, t);
|
|
1074
|
+
// this._temp2.set(0, 0, 0);
|
|
1075
|
+
currentVelocity.x = Mathf.lerp(currentVelocity.x, this._temp.x, t);
|
|
1076
|
+
currentVelocity.y = Mathf.lerp(currentVelocity.y, this._temp.y, t);
|
|
1077
|
+
currentVelocity.z = Mathf.lerp(currentVelocity.z, this._temp.z, t);
|
|
1078
|
+
}
|
|
1079
|
+
// vel.multiplyScalar(dragFactor);
|
|
1080
|
+
}
|
|
1081
|
+
// vel.x *= 0.3;
|
|
1082
|
+
// vel.y *= 0.3;
|
|
1083
|
+
// vel.z *= 0.3;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
__decorate([
|
|
1087
|
+
serializeable()
|
|
1088
|
+
], LimitVelocityOverLifetimeModule.prototype, "enabled", void 0);
|
|
1089
|
+
__decorate([
|
|
1090
|
+
serializeable()
|
|
1091
|
+
], LimitVelocityOverLifetimeModule.prototype, "dampen", void 0);
|
|
1092
|
+
__decorate([
|
|
1093
|
+
serializeable(MinMaxCurve)
|
|
1094
|
+
], LimitVelocityOverLifetimeModule.prototype, "drag", void 0);
|
|
1095
|
+
__decorate([
|
|
1096
|
+
serializeable()
|
|
1097
|
+
], LimitVelocityOverLifetimeModule.prototype, "dragMultiplier", void 0);
|
|
1098
|
+
__decorate([
|
|
1099
|
+
serializeable(MinMaxCurve)
|
|
1100
|
+
], LimitVelocityOverLifetimeModule.prototype, "limit", void 0);
|
|
1101
|
+
__decorate([
|
|
1102
|
+
serializeable()
|
|
1103
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitMultiplier", void 0);
|
|
1104
|
+
__decorate([
|
|
1105
|
+
serializeable()
|
|
1106
|
+
], LimitVelocityOverLifetimeModule.prototype, "separateAxes", void 0);
|
|
1107
|
+
__decorate([
|
|
1108
|
+
serializeable(MinMaxCurve)
|
|
1109
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitX", void 0);
|
|
1110
|
+
__decorate([
|
|
1111
|
+
serializeable()
|
|
1112
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitXMultiplier", void 0);
|
|
1113
|
+
__decorate([
|
|
1114
|
+
serializeable(MinMaxCurve)
|
|
1115
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitY", void 0);
|
|
1116
|
+
__decorate([
|
|
1117
|
+
serializeable()
|
|
1118
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitYMultiplier", void 0);
|
|
1119
|
+
__decorate([
|
|
1120
|
+
serializeable(MinMaxCurve)
|
|
1121
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitZ", void 0);
|
|
1122
|
+
__decorate([
|
|
1123
|
+
serializeable()
|
|
1124
|
+
], LimitVelocityOverLifetimeModule.prototype, "limitZMultiplier", void 0);
|
|
1125
|
+
__decorate([
|
|
1126
|
+
serializeable()
|
|
1127
|
+
], LimitVelocityOverLifetimeModule.prototype, "multiplyDragByParticleSize", void 0);
|
|
1128
|
+
__decorate([
|
|
1129
|
+
serializeable()
|
|
1130
|
+
], LimitVelocityOverLifetimeModule.prototype, "multiplyDragByParticleVelocity", void 0);
|
|
1131
|
+
__decorate([
|
|
1132
|
+
serializeable()
|
|
1133
|
+
], LimitVelocityOverLifetimeModule.prototype, "space", void 0);
|
|
736
1134
|
//# sourceMappingURL=ParticleSystemModules.js.map
|