@series-inc/rundot-3d-engine 0.6.3 → 0.6.4

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.
@@ -1856,6 +1856,7 @@ interface CurvePropertyValue {
1856
1856
  interface ParticleSystemJSON extends ComponentJSON {
1857
1857
  type: "particle_system";
1858
1858
  main: {
1859
+ simulationSpace?: "local" | "world";
1859
1860
  duration: number;
1860
1861
  looping: boolean;
1861
1862
  startLifetimeMin: number;
@@ -1969,6 +1970,7 @@ interface ParticleSystemJSON extends ComponentJSON {
1969
1970
  declare class ParticleSystemPrefabComponent extends Component {
1970
1971
  private emitter;
1971
1972
  private json;
1973
+ private worldSpace;
1972
1974
  private static readonly _tempOrigin;
1973
1975
  /**
1974
1976
  * Create a ParticleSystemPrefabComponent from prefab JSON
@@ -5062,6 +5062,7 @@ function convertCurvePropertyToEngine(propValue, defaultValue = 1) {
5062
5062
  var ParticleSystemPrefabComponent = class extends Component {
5063
5063
  emitter = null;
5064
5064
  json;
5065
+ worldSpace = false;
5065
5066
  /**
5066
5067
  * Create a ParticleSystemPrefabComponent from prefab JSON
5067
5068
  */
@@ -5075,10 +5076,16 @@ var ParticleSystemPrefabComponent = class extends Component {
5075
5076
  onCreate() {
5076
5077
  const config = this.buildEmitterConfig();
5077
5078
  const assets = this.buildEmitterAssets();
5079
+ const main = this.json.main || {};
5080
+ this.worldSpace = (main.simulationSpace ?? "local") === "world";
5078
5081
  this.emitter = createParticleEmitter(config, assets);
5079
5082
  if (this.emitter?.object && this.gameObject) {
5080
- this.gameObject.add(this.emitter.object);
5081
- this.emitter.object.position.set(0, 0, 0);
5083
+ if (this.worldSpace) {
5084
+ this.scene.add(this.emitter.object);
5085
+ } else {
5086
+ this.gameObject.add(this.emitter.object);
5087
+ this.emitter.object.position.set(0, 0, 0);
5088
+ }
5082
5089
  this.emitter.object.frustumCulled = false;
5083
5090
  this.gameObject.userData.__particleEmitter = this.emitter;
5084
5091
  }
@@ -5321,7 +5328,13 @@ var ParticleSystemPrefabComponent = class extends Component {
5321
5328
  */
5322
5329
  update(deltaTime) {
5323
5330
  if (!this.emitter) return;
5324
- this.emitter.update(deltaTime, VenusGame.camera, this.gameObject?.matrixWorld);
5331
+ if (this.worldSpace) {
5332
+ this.gameObject.getWorldPosition(ParticleSystemPrefabComponent._tempOrigin);
5333
+ this.emitter.setOrigin(ParticleSystemPrefabComponent._tempOrigin);
5334
+ this.emitter.update(deltaTime, VenusGame.camera);
5335
+ } else {
5336
+ this.emitter.update(deltaTime, VenusGame.camera, this.gameObject?.matrixWorld);
5337
+ }
5325
5338
  }
5326
5339
  /**
5327
5340
  * Get the underlying particle system
@@ -5330,9 +5343,11 @@ var ParticleSystemPrefabComponent = class extends Component {
5330
5343
  return this.emitter;
5331
5344
  }
5332
5345
  onCleanup() {
5333
- if (this.emitter?.object && this.gameObject) {
5334
- this.gameObject.remove(this.emitter.object);
5335
- delete this.gameObject.userData.__particleEmitter;
5346
+ if (this.emitter?.object) {
5347
+ this.emitter.object.removeFromParent();
5348
+ if (this.gameObject) {
5349
+ delete this.gameObject.userData.__particleEmitter;
5350
+ }
5336
5351
  }
5337
5352
  this.emitter = null;
5338
5353
  }