@onerjs/core 8.30.7 → 8.30.9

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.
Files changed (139) hide show
  1. package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
  2. package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
  3. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  4. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
  5. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
  6. package/AudioV2/audioParameter.d.ts +5 -1
  7. package/AudioV2/audioParameter.js +4 -0
  8. package/AudioV2/audioParameter.js.map +1 -1
  9. package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
  10. package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
  11. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
  12. package/Cameras/camera.js +1 -0
  13. package/Cameras/camera.js.map +1 -1
  14. package/Cameras/targetCamera.js +0 -4
  15. package/Cameras/targetCamera.js.map +1 -1
  16. package/Culling/ray.core.js +1 -1
  17. package/Culling/ray.core.js.map +1 -1
  18. package/Decorators/nodeDecorator.d.ts +9 -7
  19. package/Decorators/nodeDecorator.js +9 -7
  20. package/Decorators/nodeDecorator.js.map +1 -1
  21. package/Engines/WebGPU/webgpuTextureManager.js +2 -2
  22. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  23. package/Engines/abstractEngine.js +2 -2
  24. package/Engines/abstractEngine.js.map +1 -1
  25. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
  26. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
  27. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
  28. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
  30. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
  31. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
  32. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
  33. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
  34. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
  35. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
  36. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
  37. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
  38. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
  39. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
  40. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
  41. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
  42. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  43. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
  44. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
  45. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  46. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
  47. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  48. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
  49. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
  50. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
  51. package/FrameGraph/Node/nodeRenderGraph.js +2 -1
  52. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  53. package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
  54. package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
  55. package/FrameGraph/Passes/objectListPass.js.map +1 -0
  56. package/FrameGraph/Passes/renderPass.d.ts +6 -2
  57. package/FrameGraph/Passes/renderPass.js +14 -2
  58. package/FrameGraph/Passes/renderPass.js.map +1 -1
  59. package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
  60. package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
  61. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
  62. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
  63. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  64. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
  65. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
  66. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  67. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
  68. package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
  69. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  70. package/FrameGraph/frameGraph.d.ts +10 -4
  71. package/FrameGraph/frameGraph.js +22 -9
  72. package/FrameGraph/frameGraph.js.map +1 -1
  73. package/FrameGraph/frameGraphTask.js +3 -3
  74. package/FrameGraph/frameGraphTask.js.map +1 -1
  75. package/FrameGraph/index.d.ts +1 -1
  76. package/FrameGraph/index.js +1 -1
  77. package/FrameGraph/index.js.map +1 -1
  78. package/Materials/floatingOriginMatrixOverrides.js +19 -0
  79. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  80. package/Materials/shaderMaterial.d.ts +9 -0
  81. package/Materials/shaderMaterial.js +35 -0
  82. package/Materials/shaderMaterial.js.map +1 -1
  83. package/Particles/EmitterTypes/coneParticleEmitter.d.ts +6 -4
  84. package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
  85. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  86. package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
  87. package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
  88. package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
  89. package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
  90. package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
  91. package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
  92. package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
  93. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
  94. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  95. package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
  96. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
  97. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
  98. package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
  99. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
  100. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  101. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
  102. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
  103. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  104. package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
  105. package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
  106. package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
  107. package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
  108. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
  109. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  110. package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
  111. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
  112. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  113. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +16 -1
  114. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +67 -14
  115. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  116. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  117. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  118. package/Particles/Node/Blocks/systemBlock.d.ts +4 -4
  119. package/Particles/Node/Blocks/systemBlock.js +8 -12
  120. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  121. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  122. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  123. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  124. package/Particles/Node/nodeParticleBuildState.js +5 -0
  125. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  126. package/Particles/Node/nodeParticleSystemSet.helper.js +188 -27
  127. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  128. package/Particles/thinParticleSystem.function.d.ts +2 -2
  129. package/Particles/thinParticleSystem.function.js +2 -2
  130. package/Particles/thinParticleSystem.function.js.map +1 -1
  131. package/Particles/thinParticleSystem.js +1 -1
  132. package/Particles/thinParticleSystem.js.map +1 -1
  133. package/Rendering/prePassRenderer.js +4 -1
  134. package/Rendering/prePassRenderer.js.map +1 -1
  135. package/package.json +1 -1
  136. package/scene.d.ts +1 -3
  137. package/scene.js +8 -7
  138. package/scene.js.map +1 -1
  139. package/FrameGraph/Passes/cullPass.js.map +0 -1
@@ -1,8 +1,11 @@
1
+ import { __decorate } from "../../../../tslib.es6.js";
1
2
  import { RegisterClass } from "../../../../Misc/typeStore.js";
2
3
  import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
3
4
  import { NodeParticleBlock } from "../../nodeParticleBlock.js";
4
5
  import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
5
- import { TmpVectors, Vector3 } from "../../../../Maths/math.vector.js";
6
+ import { Vector3 } from "../../../../Maths/math.vector.js";
7
+ import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
8
+ import { _CreateLocalPositionData } from "./emitters.functions.js";
6
9
  /**
7
10
  * Block used to provide a flow of particles emitted from a cone shape.
8
11
  */
@@ -13,13 +16,19 @@ export class ConeShapeBlock extends NodeParticleBlock {
13
16
  */
14
17
  constructor(name) {
15
18
  super(name);
19
+ /**
20
+ * Gets or sets a boolean indicating if the system should emit only from the spawn point
21
+ * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
22
+ */
23
+ this.emitFromSpawnPointOnly = false;
16
24
  this.registerInput("particle", NodeParticleBlockConnectionPointTypes.Particle);
17
25
  this.registerInput("radius", NodeParticleBlockConnectionPointTypes.Float, true, 1);
18
26
  this.registerInput("angle", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);
19
27
  this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1);
20
28
  this.registerInput("heightRange", NodeParticleBlockConnectionPointTypes.Float, true, 1);
21
- this.registerInput("emitFromSpawnPointOnly", NodeParticleBlockConnectionPointTypes.Int, true, 0);
22
29
  this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0);
30
+ this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
31
+ this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
23
32
  this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
24
33
  }
25
34
  /**
@@ -60,17 +69,23 @@ export class ConeShapeBlock extends NodeParticleBlock {
60
69
  return this._inputs[4];
61
70
  }
62
71
  /**
63
- * Gets the emitFromSpawnPointOnly input component
72
+ * Gets the directionRandomizer input component
64
73
  */
65
- get emitFromSpawnPointOnly() {
74
+ get directionRandomizer() {
66
75
  return this._inputs[5];
67
76
  }
68
77
  /**
69
- * Gets the directionRandomizer input component
78
+ * Gets the direction1 input component
70
79
  */
71
- get directionRandomizer() {
80
+ get direction1() {
72
81
  return this._inputs[6];
73
82
  }
83
+ /**
84
+ * Gets the direction2 input component
85
+ */
86
+ get direction2() {
87
+ return this._inputs[7];
88
+ }
74
89
  /**
75
90
  * Gets the output component
76
91
  */
@@ -86,29 +101,36 @@ export class ConeShapeBlock extends NodeParticleBlock {
86
101
  system._directionCreation.process = (particle) => {
87
102
  state.particleContext = particle;
88
103
  state.systemContext = system;
89
- // Connected values
90
- let directionRandomizer = this.directionRandomizer.getConnectedValue(state);
91
- directionRandomizer = Math.max(0, Math.min(directionRandomizer, 1));
92
- // Calculate create direction logic
93
- if (system.isLocal) {
94
- TmpVectors.Vector3[0].copyFrom(particle.position).normalize();
104
+ // We always use directionRandomizer unless both directions are connected
105
+ if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
106
+ const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
107
+ const direction = particle.position.subtract(state.emitterPosition).normalize();
108
+ const randX = RandomRange(0, directionRandomizer);
109
+ const randY = RandomRange(0, directionRandomizer);
110
+ const randZ = RandomRange(0, directionRandomizer);
111
+ direction.x += randX;
112
+ direction.y += randY;
113
+ direction.z += randZ;
114
+ direction.normalize();
115
+ if (system.isLocal) {
116
+ particle.direction.copyFromFloats(direction.x, direction.y, direction.z);
117
+ }
118
+ else {
119
+ Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix, particle.direction);
120
+ }
95
121
  }
96
122
  else {
97
- particle.position.subtractToRef(state.emitterWorldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();
98
- }
99
- const randX = RandomRange(0, directionRandomizer);
100
- const randY = RandomRange(0, directionRandomizer);
101
- const randZ = RandomRange(0, directionRandomizer);
102
- const directionToUpdate = new Vector3();
103
- directionToUpdate.x = TmpVectors.Vector3[0].x + randX;
104
- directionToUpdate.y = TmpVectors.Vector3[0].y + randY;
105
- directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;
106
- directionToUpdate.normalize();
107
- if (system.isLocal) {
108
- particle.direction.copyFromFloats(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z);
109
- }
110
- else {
111
- Vector3.TransformNormalFromFloatsToRef(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z, state.emitterWorldMatrix, particle.direction);
123
+ const direction1 = this.direction1.getConnectedValue(state);
124
+ const direction2 = this.direction2.getConnectedValue(state);
125
+ const randX = RandomRange(direction1.x, direction2.x);
126
+ const randY = RandomRange(direction1.y, direction2.y);
127
+ const randZ = RandomRange(direction1.z, direction2.z);
128
+ if (system.isLocal) {
129
+ particle.direction.copyFromFloats(randX, randY, randZ);
130
+ }
131
+ else {
132
+ Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
133
+ }
112
134
  }
113
135
  particle._initialDirection = particle.direction.clone();
114
136
  };
@@ -118,14 +140,11 @@ export class ConeShapeBlock extends NodeParticleBlock {
118
140
  // Connected values
119
141
  const radius = this.radius.getConnectedValue(state);
120
142
  const angle = this.angle.getConnectedValue(state);
121
- let radiusRange = this.radiusRange.getConnectedValue(state);
122
- radiusRange = Math.max(0, Math.min(radiusRange, 1));
123
- let heightRange = this.heightRange.getConnectedValue(state);
124
- heightRange = Math.max(0, Math.min(heightRange, 1));
125
- const emitFromSpawnPointOnly = this.emitFromSpawnPointOnly.getConnectedValue(state) !== 0;
143
+ const radiusRange = this.radiusRange.getConnectedValue(state);
144
+ const heightRange = this.heightRange.getConnectedValue(state);
126
145
  // Calculate position creation logic
127
146
  let h;
128
- if (!emitFromSpawnPointOnly) {
147
+ if (!this.emitFromSpawnPointOnly) {
129
148
  h = RandomRange(0, heightRange);
130
149
  // Better distribution in a cone at normal angles.
131
150
  h = 1 - h * h;
@@ -136,17 +155,16 @@ export class ConeShapeBlock extends NodeParticleBlock {
136
155
  let newRadius = radius - RandomRange(0, radius * radiusRange);
137
156
  newRadius = newRadius * h;
138
157
  const s = RandomRange(0, Math.PI * 2);
139
- const height = this._calculateHeight(angle, radius);
140
158
  const randX = newRadius * Math.sin(s);
141
159
  const randZ = newRadius * Math.cos(s);
142
- const randY = h * height;
160
+ const randY = h * this._calculateHeight(angle, radius);
143
161
  if (system.isLocal) {
144
162
  particle.position.copyFromFloats(randX, randY, randZ);
145
- particle.position.addInPlace(state.emitterPosition);
146
163
  }
147
164
  else {
148
165
  Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
149
166
  }
167
+ _CreateLocalPositionData(particle);
150
168
  };
151
169
  this.output._storedValue = system;
152
170
  }
@@ -158,6 +176,18 @@ export class ConeShapeBlock extends NodeParticleBlock {
158
176
  return 1;
159
177
  }
160
178
  }
179
+ serialize() {
180
+ const serializationObject = super.serialize();
181
+ serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;
182
+ return serializationObject;
183
+ }
184
+ _deserialize(serializationObject) {
185
+ super._deserialize(serializationObject);
186
+ this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly;
187
+ }
161
188
  }
189
+ __decorate([
190
+ editableInPropertyPage("Emit from spawn point only", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { embedded: true, notifiers: { rebuild: true } })
191
+ ], ConeShapeBlock.prototype, "emitFromSpawnPointOnly", void 0);
162
192
  RegisterClass("BABYLON.ConeShapeBlock", ConeShapeBlock);
163
193
  //# sourceMappingURL=coneShapeBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coneShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/coneShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,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Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cone shape.\r\n */\r\nexport class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new ConeShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"heightRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"emitFromSpawnPointOnly\", NodeParticleBlockConnectionPointTypes.Int, true, 0);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ConeShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the heightRange input component\r\n */\r\n public get heightRange(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the emitFromSpawnPointOnly input component\r\n */\r\n public get emitFromSpawnPointOnly(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // Connected values\r\n let directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n directionRandomizer = Math.max(0, Math.min(directionRandomizer, 1));\r\n\r\n // Calculate create direction logic\r\n if (system.isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle.position).normalize();\r\n } else {\r\n particle.position.subtractToRef(state.emitterWorldMatrix!.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n const directionToUpdate = new Vector3();\r\n directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // Connected values\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const angle = this.angle.getConnectedValue(state) as number;\r\n let radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n radiusRange = Math.max(0, Math.min(radiusRange, 1));\r\n let heightRange = this.heightRange.getConnectedValue(state) as number;\r\n heightRange = Math.max(0, Math.min(heightRange, 1));\r\n const emitFromSpawnPointOnly = (this.emitFromSpawnPointOnly.getConnectedValue(state) as number) !== 0;\r\n\r\n // Calculate position creation logic\r\n let h: number;\r\n if (!emitFromSpawnPointOnly) {\r\n h = RandomRange(0, heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n\r\n let newRadius = radius - RandomRange(0, radius * radiusRange);\r\n newRadius = newRadius * h;\r\n\r\n const s = RandomRange(0, Math.PI * 2);\r\n const height = this._calculateHeight(angle, radius);\r\n\r\n const randX = newRadius * Math.sin(s);\r\n const randZ = newRadius * Math.cos(s);\r\n const randY = h * height;\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n private _calculateHeight(angle: number, radius: number): number {\r\n if (angle !== 0) {\r\n return radius / Math.tan(angle / 2);\r\n } else {\r\n return 1;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConeShapeBlock\", ConeShapeBlock);\r\n"]}
1
+ {"version":3,"file":"coneShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/coneShapeBlock.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,sBAAsB,EAA0B,gDAAsC;AAC/F,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IAQjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB;;;WAGG;QAEI,2BAAsB,GAAG,KAAK,CAAC;QASlC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,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mB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;IAEO,gBAAgB,CAAC,KAAa,EAAE,MAAc;QAClD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACd,OAAO,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;IAEe,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC;QAEzE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,sBAAsB,GAAG,mBAAmB,CAAC,sBAAsB,CAAC;IAC7E,CAAC;CACJ;AAvMU;IADN,sBAAsB,CAAC,4BAA4B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;8DAC7G;AAyM1C,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { IShapeBlock } from \"./IShapeBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"core/Decorators/nodeDecorator\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cone shape.\r\n */\r\nexport class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Gets or sets a boolean indicating if the system should emit only from the spawn point\r\n * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.\r\n */\r\n @editableInPropertyPage(\"Emit from spawn point only\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Create a new ConeShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"heightRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ConeShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the heightRange input component\r\n */\r\n public get heightRange(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[7];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // We always use directionRandomizer unless both directions are connected\r\n if (this.direction1.isConnected === false || this.direction2.isConnected === false) {\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n\r\n const direction = particle.position.subtract(state.emitterPosition!).normalize();\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(direction.x, direction.y, direction.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n } else {\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // Connected values\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const angle = this.angle.getConnectedValue(state) as number;\r\n const radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n const heightRange = this.heightRange.getConnectedValue(state) as number;\r\n\r\n // Calculate position creation logic\r\n let h: number;\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = RandomRange(0, heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n\r\n let newRadius = radius - RandomRange(0, radius * radiusRange);\r\n newRadius = newRadius * h;\r\n const s = RandomRange(0, Math.PI * 2);\r\n\r\n const randX = newRadius * Math.sin(s);\r\n const randZ = newRadius * Math.cos(s);\r\n const randY = h * this._calculateHeight(angle, radius);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n private _calculateHeight(angle: number, radius: number): number {\r\n if (angle !== 0) {\r\n return radius / Math.tan(angle / 2);\r\n } else {\r\n return 1;\r\n }\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConeShapeBlock\", ConeShapeBlock);\r\n"]}
@@ -1,11 +1,22 @@
1
+ import type { Nullable } from "../../../../types.js";
2
+ import type { Particle } from "../../../particle.js";
1
3
  import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
2
4
  import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
3
- import { NodeParticleBlock } from "../../nodeParticleBlock.js";
4
5
  import type { IShapeBlock } from "./IShapeBlock.js";
6
+ import { Vector3 } from "../../../../Maths/math.vector.js";
7
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
8
+ /** Function that generates particle position/direction data */
9
+ type ParticleGeneratorFunction = (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
5
10
  /**
6
11
  * Block used to provide a flow of particles emitted from a custom position.
7
12
  */
8
13
  export declare class CustomShapeBlock extends NodeParticleBlock implements IShapeBlock {
14
+ /** The particle position generator function */
15
+ particlePositionGenerator: ParticleGeneratorFunction;
16
+ /** The particle destination generator function */
17
+ particleDestinationGenerator: ParticleGeneratorFunction;
18
+ /** The particle direction generator function */
19
+ particleDirectionGenerator: ParticleGeneratorFunction;
9
20
  /**
10
21
  * Create a new CustomShapeBlock
11
22
  * @param name defines the block name
@@ -20,14 +31,6 @@ export declare class CustomShapeBlock extends NodeParticleBlock implements IShap
20
31
  * Gets the particle component
21
32
  */
22
33
  get particle(): NodeParticleConnectionPoint;
23
- /**
24
- * Gets the position input component
25
- */
26
- get position(): NodeParticleConnectionPoint;
27
- /**
28
- * Gets the direction input component
29
- */
30
- get direction(): NodeParticleConnectionPoint;
31
34
  /**
32
35
  * Gets the output component
33
36
  */
@@ -38,3 +41,4 @@ export declare class CustomShapeBlock extends NodeParticleBlock implements IShap
38
41
  */
39
42
  _build(state: NodeParticleBuildState): void;
40
43
  }
44
+ export {};
@@ -1,7 +1,9 @@
1
+ import { TmpVectors, Vector3 } from "../../../../Maths/math.vector.js";
1
2
  import { RegisterClass } from "../../../../Misc/typeStore.js";
2
- import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
3
- import { Vector3 } from "../../../../Maths/math.vector.js";
3
+ import { EmptyGeneratorFunc } from "../../../EmitterTypes/customParticleEmitter.js";
4
4
  import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
+ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
6
+ import { _CreateLocalPositionData } from "./emitters.functions.js";
5
7
  /**
6
8
  * Block used to provide a flow of particles emitted from a custom position.
7
9
  */
@@ -12,9 +14,13 @@ export class CustomShapeBlock extends NodeParticleBlock {
12
14
  */
13
15
  constructor(name) {
14
16
  super(name);
17
+ /** The particle position generator function */
18
+ this.particlePositionGenerator = EmptyGeneratorFunc;
19
+ /** The particle destination generator function */
20
+ this.particleDestinationGenerator = EmptyGeneratorFunc;
21
+ /** The particle direction generator function */
22
+ this.particleDirectionGenerator = EmptyGeneratorFunc;
15
23
  this.registerInput("particle", NodeParticleBlockConnectionPointTypes.Particle);
16
- this.registerInput("position", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 0, 0));
17
- this.registerInput("direction", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));
18
24
  this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
19
25
  }
20
26
  /**
@@ -30,18 +36,6 @@ export class CustomShapeBlock extends NodeParticleBlock {
30
36
  get particle() {
31
37
  return this._inputs[0];
32
38
  }
33
- /**
34
- * Gets the position input component
35
- */
36
- get position() {
37
- return this._inputs[1];
38
- }
39
- /**
40
- * Gets the direction input component
41
- */
42
- get direction() {
43
- return this._inputs[2];
44
- }
45
39
  /**
46
40
  * Gets the output component
47
41
  */
@@ -57,26 +51,45 @@ export class CustomShapeBlock extends NodeParticleBlock {
57
51
  system._directionCreation.process = (particle) => {
58
52
  state.particleContext = particle;
59
53
  state.systemContext = system;
60
- const direction = this.direction.getConnectedValue(state);
54
+ const tmpVector = TmpVectors.Vector3[0];
55
+ if (this.particleDirectionGenerator && this.particleDirectionGenerator !== EmptyGeneratorFunc) {
56
+ this.particleDirectionGenerator(-1, particle, tmpVector);
57
+ }
58
+ else if (this.particleDestinationGenerator && this.particleDestinationGenerator !== EmptyGeneratorFunc) {
59
+ this.particleDestinationGenerator(-1, particle, tmpVector);
60
+ // Get direction
61
+ const diffVector = TmpVectors.Vector3[1];
62
+ tmpVector.subtractToRef(particle.position, diffVector);
63
+ diffVector.scaleToRef(1 / particle.lifeTime, tmpVector);
64
+ }
65
+ else {
66
+ tmpVector.set(0, 0, 0);
67
+ }
61
68
  if (system.isLocal) {
62
- particle.direction.copyFrom(direction);
69
+ particle.direction.copyFrom(tmpVector);
63
70
  }
64
71
  else {
65
- Vector3.TransformNormalToRef(direction, state.emitterWorldMatrix, particle.direction);
72
+ Vector3.TransformNormalToRef(tmpVector, state.emitterWorldMatrix, particle.direction);
66
73
  }
67
74
  particle._initialDirection = particle.direction.clone();
68
75
  };
69
76
  system._positionCreation.process = (particle) => {
70
77
  state.particleContext = particle;
71
78
  state.systemContext = system;
72
- const position = this.position.getConnectedValue(state);
79
+ const tmpVector = TmpVectors.Vector3[0];
80
+ if (this.particlePositionGenerator && this.particlePositionGenerator !== EmptyGeneratorFunc) {
81
+ this.particlePositionGenerator(-1, particle, tmpVector);
82
+ }
83
+ else {
84
+ tmpVector.set(0, 0, 0);
85
+ }
73
86
  if (system.isLocal) {
74
- particle.position.copyFrom(position);
75
- particle.position.addInPlace(state.emitterPosition);
87
+ particle.position.copyFrom(tmpVector);
76
88
  }
77
89
  else {
78
- Vector3.TransformCoordinatesToRef(position, state.emitterWorldMatrix, particle.position);
90
+ Vector3.TransformCoordinatesToRef(tmpVector, state.emitterWorldMatrix, particle.position);
79
91
  }
92
+ _CreateLocalPositionData(particle);
80
93
  };
81
94
  this.output._storedValue = system;
82
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"customShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/customShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;I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AAG,QAAQ,CAAC;YACjC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;YAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAExD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACrC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,yBAAyB,CAAC,QAAQ,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC9F,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a custom position.\r\n */\r\nexport class CustomShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new CustomShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"position\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 0, 0));\r\n this.registerInput(\"direction\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"CustomShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the position input component\r\n */\r\n public get position(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction input component\r\n */\r\n public get direction(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction = this.direction.getConnectedValue(state);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(direction);\r\n } else {\r\n Vector3.TransformNormalToRef(direction, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n const position = this.position.getConnectedValue(state);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFrom(position);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesToRef(position, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CustomShapeBlock\", CustomShapeBlock);\r\n"]}
1
+ {"version":3,"file":"customShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/customShapeBlock.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,yCAA+B;AAC7D,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,kBAAkB,EAAE,uDAA0D;AACvF,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAKhE;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAQnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB,+CAA+C;QACxC,8BAAyB,GAA8B,kBAAkB,CAAC;QACjF,kDAAkD;QAC3C,iCAA4B,GAA8B,kBAAkB,CAAC;QACpF,gDAAgD;QACzC,+BAA0B,GAA8B,kBAAkB,CAAC;QAS9E,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACa,MAAM,CAAC,KAA6B;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAEtD,MAAM,CAAC,kBAAkB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AC;QAC5D,CAAC,CAAC;QAEF,MAAM,CAAC,iBAAiB,CAAC,OAAO,GAAG,CAAC,QAAkB,EAAE,EAAE;YACtD,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YACjC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;YAE7B,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAExC,IAAI,IAAI,CAAC,yBAAyB,IAAI,IAAI,CAAC,yBAAyB,KAAK,kBAAkB,EAAE,CAAC;gBAC1F,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACJ,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3B,CAAC;YAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC1C,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,yBAAyB,CAAC,SAAS,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/F,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { EmptyGeneratorFunc } from \"core/Particles/EmitterTypes/customParticleEmitter\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/** Function that generates particle position/direction data */\r\ntype ParticleGeneratorFunction = (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a custom position.\r\n */\r\nexport class CustomShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /** The particle position generator function */\r\n public particlePositionGenerator: ParticleGeneratorFunction = EmptyGeneratorFunc;\r\n /** The particle destination generator function */\r\n public particleDestinationGenerator: ParticleGeneratorFunction = EmptyGeneratorFunc;\r\n /** The particle direction generator function */\r\n public particleDirectionGenerator: ParticleGeneratorFunction = EmptyGeneratorFunc;\r\n\r\n /**\r\n * Create a new CustomShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"CustomShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const tmpVector = TmpVectors.Vector3[0];\r\n\r\n if (this.particleDirectionGenerator && this.particleDirectionGenerator !== EmptyGeneratorFunc) {\r\n this.particleDirectionGenerator(-1, particle, tmpVector);\r\n } else if (this.particleDestinationGenerator && this.particleDestinationGenerator !== EmptyGeneratorFunc) {\r\n this.particleDestinationGenerator(-1, particle, tmpVector);\r\n\r\n // Get direction\r\n const diffVector = TmpVectors.Vector3[1];\r\n tmpVector.subtractToRef(particle.position, diffVector);\r\n\r\n diffVector.scaleToRef(1 / particle.lifeTime, tmpVector);\r\n } else {\r\n tmpVector.set(0, 0, 0);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(tmpVector);\r\n } else {\r\n Vector3.TransformNormalToRef(tmpVector, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const tmpVector = TmpVectors.Vector3[0];\r\n\r\n if (this.particlePositionGenerator && this.particlePositionGenerator !== EmptyGeneratorFunc) {\r\n this.particlePositionGenerator(-1, particle, tmpVector);\r\n } else {\r\n tmpVector.set(0, 0, 0);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFrom(tmpVector);\r\n } else {\r\n Vector3.TransformCoordinatesToRef(tmpVector, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CustomShapeBlock\", CustomShapeBlock);\r\n"]}
@@ -1,9 +1,10 @@
1
- import { NodeParticleBlock } from "../../nodeParticleBlock.js";
2
1
  import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
3
2
  import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
4
3
  import type { IShapeBlock } from "./IShapeBlock.js";
4
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  /**
6
6
  * Block used to provide a flow of particles emitted from a cylinder shape.
7
+ * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
7
8
  */
8
9
  export declare class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {
9
10
  private _tempVector;
@@ -37,6 +38,14 @@ export declare class CylinderShapeBlock extends NodeParticleBlock implements ISh
37
38
  * Gets the directionRandomizer input component
38
39
  */
39
40
  get directionRandomizer(): NodeParticleConnectionPoint;
41
+ /**
42
+ * Gets the direction1 input component
43
+ */
44
+ get direction1(): NodeParticleConnectionPoint;
45
+ /**
46
+ * Gets the direction2 input component
47
+ */
48
+ get direction2(): NodeParticleConnectionPoint;
40
49
  /**
41
50
  * Gets the output component
42
51
  */
@@ -3,8 +3,10 @@ import { RegisterClass } from "../../../../Misc/typeStore.js";
3
3
  import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
4
4
  import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  import { Vector3 } from "../../../../Maths/math.vector.js";
6
+ import { _CreateLocalPositionData } from "./emitters.functions.js";
6
7
  /**
7
8
  * Block used to provide a flow of particles emitted from a cylinder shape.
9
+ * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
8
10
  */
9
11
  export class CylinderShapeBlock extends NodeParticleBlock {
10
12
  /**
@@ -19,6 +21,8 @@ export class CylinderShapeBlock extends NodeParticleBlock {
19
21
  this.registerInput("height", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);
20
22
  this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);
21
23
  this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);
24
+ this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
25
+ this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
22
26
  this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
23
27
  }
24
28
  /**
@@ -58,6 +62,18 @@ export class CylinderShapeBlock extends NodeParticleBlock {
58
62
  get directionRandomizer() {
59
63
  return this._inputs[4];
60
64
  }
65
+ /**
66
+ * Gets the direction1 input component
67
+ */
68
+ get direction1() {
69
+ return this._inputs[5];
70
+ }
71
+ /**
72
+ * Gets the direction2 input component
73
+ */
74
+ get direction2() {
75
+ return this._inputs[6];
76
+ }
61
77
  /**
62
78
  * Gets the output component
63
79
  */
@@ -73,24 +89,40 @@ export class CylinderShapeBlock extends NodeParticleBlock {
73
89
  system._directionCreation.process = (particle) => {
74
90
  state.particleContext = particle;
75
91
  state.systemContext = system;
76
- const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
77
- particle.position.subtractToRef(state.emitterPosition, this._tempVector);
78
- this._tempVector.normalize();
79
- if (state.emitterInverseWorldMatrix) {
80
- Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);
81
- }
82
- const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);
83
- let angle = Math.atan2(this._tempVector.x, this._tempVector.z);
84
- angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;
85
- this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface
86
- this._tempVector.x = Math.sin(angle);
87
- this._tempVector.z = Math.cos(angle);
88
- this._tempVector.normalize();
89
- if (system.isLocal) {
90
- particle.direction.copyFrom(this._tempVector);
92
+ // We always use directionRandomizer unless both directions are connected
93
+ if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
94
+ const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
95
+ particle.position.subtractToRef(state.emitterPosition, this._tempVector);
96
+ this._tempVector.normalize();
97
+ if (state.emitterInverseWorldMatrix) {
98
+ Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);
99
+ }
100
+ const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);
101
+ let angle = Math.atan2(this._tempVector.x, this._tempVector.z);
102
+ angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;
103
+ this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface
104
+ this._tempVector.x = Math.sin(angle);
105
+ this._tempVector.z = Math.cos(angle);
106
+ this._tempVector.normalize();
107
+ if (system.isLocal) {
108
+ particle.direction.copyFrom(this._tempVector);
109
+ }
110
+ else {
111
+ Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix, particle.direction);
112
+ }
91
113
  }
92
114
  else {
93
- Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix, particle.direction);
115
+ const direction1 = this.direction1.getConnectedValue(state);
116
+ const direction2 = this.direction2.getConnectedValue(state);
117
+ const randX = RandomRange(direction1.x, direction2.x);
118
+ const randY = RandomRange(direction1.y, direction2.y);
119
+ const randZ = RandomRange(direction1.z, direction2.z);
120
+ if (system.isLocal) {
121
+ particle.direction.copyFromFloats(randX, randY, randZ);
122
+ }
123
+ else {
124
+ Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
125
+ }
94
126
  }
95
127
  particle._initialDirection = particle.direction.clone();
96
128
  };
@@ -102,17 +134,18 @@ export class CylinderShapeBlock extends NodeParticleBlock {
102
134
  const radius = this.radius.getConnectedValue(state);
103
135
  const yPos = RandomRange(-height / 2, height / 2);
104
136
  const angle = RandomRange(0, 2 * Math.PI);
137
+ // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
105
138
  const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);
106
139
  const positionRadius = Math.sqrt(radiusDistribution) * radius;
107
140
  const xPos = positionRadius * Math.cos(angle);
108
141
  const zPos = positionRadius * Math.sin(angle);
109
142
  if (system.isLocal) {
110
143
  particle.position.copyFromFloats(xPos, yPos, zPos);
111
- particle.position.addInPlace(state.emitterPosition);
112
144
  }
113
145
  else {
114
146
  Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix, particle.position);
115
147
  }
148
+ _CreateLocalPositionData(particle);
116
149
  };
117
150
  this.output._storedValue = system;
118
151
  }