@newkrok/three-particles 2.15.0 → 2.15.1

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/index.js CHANGED
@@ -1171,6 +1171,10 @@ var _particleSystemId = 0;
1171
1171
  var createdParticleSystems = [];
1172
1172
  var _subEmitterPosition = new THREE4.Vector3();
1173
1173
  var _lastWorldPositionSnapshot = new THREE4.Vector3();
1174
+ var _localForceFieldPos = new THREE4.Vector3();
1175
+ var _localForceFieldDir = new THREE4.Vector3();
1176
+ var _inverseQuat = new THREE4.Quaternion();
1177
+ var _localForceFields = [];
1174
1178
  new THREE4.Vector3();
1175
1179
  new THREE4.Vector3();
1176
1180
  new THREE4.Vector3();
@@ -2527,6 +2531,37 @@ var updateParticleSystemInstance = (props, { now, delta, elapsed }) => {
2527
2531
  );
2528
2532
  particleSystem.worldToLocal(gravityVelocity);
2529
2533
  }
2534
+ if (hasForceFields) {
2535
+ _inverseQuat.copy(worldQuaternion).invert();
2536
+ _localForceFields.length = normalizedForceFields.length;
2537
+ for (let i = 0; i < normalizedForceFields.length; i++) {
2538
+ const src = normalizedForceFields[i];
2539
+ let dst = _localForceFields[i];
2540
+ if (!dst) {
2541
+ dst = {
2542
+ isActive: true,
2543
+ type: "POINT" /* POINT */,
2544
+ position: new THREE4.Vector3(),
2545
+ direction: new THREE4.Vector3(),
2546
+ strength: 0,
2547
+ range: 0,
2548
+ falloff: "LINEAR" /* LINEAR */
2549
+ };
2550
+ _localForceFields[i] = dst;
2551
+ }
2552
+ dst.isActive = src.isActive;
2553
+ dst.type = src.type;
2554
+ dst.strength = src.strength;
2555
+ dst.range = src.range;
2556
+ dst.falloff = src.falloff;
2557
+ _localForceFieldPos.copy(src.position);
2558
+ particleSystem.worldToLocal(_localForceFieldPos);
2559
+ dst.position.copy(_localForceFieldPos);
2560
+ _localForceFieldDir.copy(src.direction);
2561
+ _localForceFieldDir.applyQuaternion(_inverseQuat);
2562
+ dst.direction.copy(_localForceFieldDir);
2563
+ }
2564
+ }
2530
2565
  const creationTimes = generalData.creationTimes;
2531
2566
  const isActiveArr = ma.isActive.array;
2532
2567
  const startLifetimeArr = ma.startLifetime.array;
@@ -2554,7 +2589,7 @@ var updateParticleSystemInstance = (props, { now, delta, elapsed }) => {
2554
2589
  if (hasForceFields) {
2555
2590
  applyForceFields({
2556
2591
  particleSystemId: generalData.particleSystemId,
2557
- forceFields: normalizedForceFields,
2592
+ forceFields: _localForceFields,
2558
2593
  velocity,
2559
2594
  positionArr,
2560
2595
  positionIndex: index * 3,