@needle-tools/engine 2.41.0-pre → 2.43.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 +24 -0
- package/dist/needle-engine.d.ts +226 -76
- package/dist/needle-engine.js +3847 -433
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +51 -51
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_element.js +1 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.js +24 -3
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gizmos.d.ts +8 -22
- package/lib/engine/engine_gizmos.js +37 -3
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +3 -0
- package/lib/engine/engine_setup.js +15 -0
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_three_utils.d.ts +17 -1
- package/lib/engine/engine_three_utils.js +104 -54
- 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/engine_types.d.ts +6 -0
- package/lib/engine/engine_types.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.js +9 -1
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimationCurve.js +2 -2
- package/lib/engine-components/AnimationCurve.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/BoxHelperComponent.js +9 -10
- package/lib/engine-components/BoxHelperComponent.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 +41 -13
- package/lib/engine-components/ParticleSystem.js +587 -219
- 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 -22
- package/lib/engine-components/ParticleSystemModules.js +377 -60
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +29 -11
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -0
- package/lib/engine-components/Renderer.js +4 -2
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +5 -0
- package/lib/engine-components/codegen/components.js +5 -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 +3 -2
- package/src/engine/codegen/register_types.js +20 -0
- package/src/engine/dist/engine_three_utils.js +279 -0
- package/src/engine/engine_element.ts +1 -1
- package/src/engine/engine_element_loading.ts +23 -2
- package/src/engine/engine_gizmos.ts +45 -8
- package/src/engine/engine_setup.ts +25 -2
- package/src/engine/engine_three_utils.ts +113 -63
- package/src/engine/engine_time.ts +1 -0
- package/src/engine/engine_types.ts +8 -1
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +43 -1
- package/src/engine-components/Animation.ts +7 -1
- package/src/engine-components/AnimationCurve.ts +2 -2
- package/src/engine-components/AnimatorController.ts +5 -1
- package/src/engine-components/BoxHelperComponent.ts +12 -15
- package/src/engine-components/Camera.ts +17 -10
- package/src/engine-components/ParticleSystem.ts +660 -258
- package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
- package/src/engine-components/ParticleSystemModules.ts +379 -64
- package/src/engine-components/ReflectionProbe.ts +37 -13
- package/src/engine-components/Renderer.ts +4 -2
- package/src/engine-components/codegen/components.ts +5 -0
- package/src/engine-components/js-extensions/RGBAColor.ts +7 -0
|
@@ -6,21 +6,319 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Behaviour } from "./Component";
|
|
8
8
|
import * as THREE from "three";
|
|
9
|
-
import { MainModule, EmissionModule, ShapeModule, ColorOverLifetimeModule, SizeOverLifetimeModule, NoiseModule, ParticleSystemSimulationSpace } from "./ParticleSystemModules";
|
|
9
|
+
import { MainModule, EmissionModule, ShapeModule, ColorOverLifetimeModule, SizeOverLifetimeModule, NoiseModule, ParticleSystemSimulationSpace, ParticleBurst, ParticleSystemRenderMode, VelocityOverLifetimeModule, TextureSheetAnimationModule, RotationOverLifetimeModule } from "./ParticleSystemModules";
|
|
10
10
|
import { getParam } from "../engine/engine_utils";
|
|
11
|
-
import System, { Emitter, Position, Life, SpriteRenderer, Particle, } from 'three-nebula';
|
|
12
11
|
// https://github.dev/creativelifeform/three-nebula
|
|
12
|
+
// import System, { Emitter, Position, Life, SpriteRenderer, Particle, Body, MeshRenderer, } from 'three-nebula';
|
|
13
13
|
import { serializeable } from "../engine/engine_serialization";
|
|
14
|
-
import {
|
|
15
|
-
import { AxesHelper, Material, Vector3 } from "three";
|
|
16
|
-
import { getWorldQuaternion, getWorldScale } from "../engine/engine_three_utils";
|
|
14
|
+
import { RGBAColor } from "./js-extensions/RGBAColor";
|
|
15
|
+
import { AxesHelper, Material, Mesh, Object3D, Quaternion, Vector3, Vector4 } from "three";
|
|
16
|
+
import { getWorldPosition, getWorldQuaternion, getWorldScale } from "../engine/engine_three_utils";
|
|
17
|
+
import { assign } from "../engine/engine_serialization_core";
|
|
18
|
+
import { BatchedParticleRenderer, ConstantColor, ConstantValue, ParticleSystem as _ParticleSystem, RenderMode } from "three.quarks";
|
|
19
|
+
import { createFlatTexture } from "../engine/engine_shaders";
|
|
20
|
+
import { Mathf } from "../engine/engine_math";
|
|
17
21
|
const debug = getParam("debugparticles");
|
|
18
22
|
export class ParticleSystemRenderer extends Behaviour {
|
|
23
|
+
renderMode;
|
|
19
24
|
particleMaterial;
|
|
25
|
+
// @serializeable(Mesh)
|
|
26
|
+
particleMesh;
|
|
27
|
+
get transparent() {
|
|
28
|
+
const res = this.particleMaterial?.transparent ?? false;
|
|
29
|
+
// console.log(res, this.particleMaterial);
|
|
30
|
+
return res;
|
|
31
|
+
}
|
|
32
|
+
getMesh() {
|
|
33
|
+
let geo = null;
|
|
34
|
+
if (this.particleMesh instanceof Mesh) {
|
|
35
|
+
geo = this.particleMesh.geometry;
|
|
36
|
+
}
|
|
37
|
+
if (geo === null)
|
|
38
|
+
geo = new THREE.BoxGeometry(1, 1, 1);
|
|
39
|
+
const res = new Mesh(geo, this.particleMaterial);
|
|
40
|
+
return res;
|
|
41
|
+
}
|
|
20
42
|
}
|
|
43
|
+
__decorate([
|
|
44
|
+
serializeable()
|
|
45
|
+
], ParticleSystemRenderer.prototype, "renderMode", void 0);
|
|
21
46
|
__decorate([
|
|
22
47
|
serializeable(Material)
|
|
23
48
|
], ParticleSystemRenderer.prototype, "particleMaterial", void 0);
|
|
49
|
+
class MinMaxCurveFunction {
|
|
50
|
+
_curve;
|
|
51
|
+
constructor(curve) { this._curve = curve; }
|
|
52
|
+
type = "function";
|
|
53
|
+
genValue(t) {
|
|
54
|
+
return this._curve.evaluate(t, Math.random());
|
|
55
|
+
}
|
|
56
|
+
toJSON() {
|
|
57
|
+
throw new Error("Method not implemented.");
|
|
58
|
+
}
|
|
59
|
+
clone() {
|
|
60
|
+
throw new Error("Method not implemented.");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class MinMaxGradientFunction {
|
|
64
|
+
_curve;
|
|
65
|
+
constructor(curve) { this._curve = curve; }
|
|
66
|
+
type = "function";
|
|
67
|
+
genColor(color, t) {
|
|
68
|
+
const col = this._curve.evaluate(t, Math.random());
|
|
69
|
+
// TODO: incoming color should probably be blended?
|
|
70
|
+
color.set(col.r, col.g, col.b, col.alpha);
|
|
71
|
+
return color;
|
|
72
|
+
}
|
|
73
|
+
toJSON() {
|
|
74
|
+
throw new Error("Method not implemented.");
|
|
75
|
+
}
|
|
76
|
+
clone() {
|
|
77
|
+
throw new Error("Method not implemented.");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class BaseValueGenerator {
|
|
81
|
+
type = "value";
|
|
82
|
+
toJSON() {
|
|
83
|
+
throw new Error("Method not implemented.");
|
|
84
|
+
}
|
|
85
|
+
clone() {
|
|
86
|
+
throw new Error("Method not implemented.");
|
|
87
|
+
}
|
|
88
|
+
system;
|
|
89
|
+
constructor(system) {
|
|
90
|
+
this.system = system;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class TextureSheetStartFrameGenerator extends BaseValueGenerator {
|
|
94
|
+
genValue() {
|
|
95
|
+
return this.system.textureSheetAnimation.getStartIndex();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class ParticleSystemEmissionOverTime extends BaseValueGenerator {
|
|
99
|
+
_lastPosition = new Vector3();
|
|
100
|
+
_lastDistance = 0;
|
|
101
|
+
update() {
|
|
102
|
+
const currentPosition = getWorldPosition(this.system.gameObject);
|
|
103
|
+
this._lastDistance = this._lastPosition.distanceTo(currentPosition);
|
|
104
|
+
this._lastPosition.copy(currentPosition);
|
|
105
|
+
}
|
|
106
|
+
genValue() {
|
|
107
|
+
if (this.system.currentParticles >= this.system.maxParticles)
|
|
108
|
+
return 0;
|
|
109
|
+
// emission over time
|
|
110
|
+
let emission = this.system.emission.rateOverTime.evaluate(this.system.time / this.system.duration, Math.random());
|
|
111
|
+
// if(this.system.currentParticles + emission > this.system.maxParticles)
|
|
112
|
+
// emission = (this.system.maxParticles - this.system.currentParticles);
|
|
113
|
+
// const res = Mathf.clamp(emission, 0, this.system.maxParticles - this.system.currentParticles);
|
|
114
|
+
if (this.system.deltaTime > 0) {
|
|
115
|
+
const distanceEmission = this.system.emission.rateOverDistance.evaluate(this.system.time / this.system.duration, Math.random());
|
|
116
|
+
const meterPerSecond = this._lastDistance / this.system.deltaTime;
|
|
117
|
+
let distanceEmissionValue = meterPerSecond * distanceEmission;
|
|
118
|
+
if (!Number.isFinite(distanceEmissionValue))
|
|
119
|
+
distanceEmissionValue = 0;
|
|
120
|
+
emission += distanceEmissionValue;
|
|
121
|
+
}
|
|
122
|
+
const burst = this.system.emission.getBurst();
|
|
123
|
+
if (burst > 0)
|
|
124
|
+
emission += burst / this.system.deltaTime;
|
|
125
|
+
const maxEmission = (this.system.maxParticles - this.system.currentParticles);
|
|
126
|
+
return Mathf.clamp(emission, 0, maxEmission / this.system.deltaTime);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
class ParticleSystemEmissionOverDistance extends BaseValueGenerator {
|
|
130
|
+
genValue() {
|
|
131
|
+
// this seems not be called yet
|
|
132
|
+
return 0;
|
|
133
|
+
// if (this.system.currentParticles >= this.system.maxParticles) return 0;
|
|
134
|
+
// const emission = this.system.emission.rateOverDistance.evaluate(this.system.time / this.system.duration, Math.random());
|
|
135
|
+
// return emission;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class ParticleSystemBaseBehaviour {
|
|
139
|
+
system;
|
|
140
|
+
constructor(ps) {
|
|
141
|
+
this.system = ps;
|
|
142
|
+
}
|
|
143
|
+
initialize(_particle) {
|
|
144
|
+
}
|
|
145
|
+
update(_particle, _delta) {
|
|
146
|
+
}
|
|
147
|
+
frameUpdate(_delta) {
|
|
148
|
+
}
|
|
149
|
+
toJSON() { throw new Error("Method not implemented."); }
|
|
150
|
+
clone() { throw new Error("Method not implemented."); }
|
|
151
|
+
}
|
|
152
|
+
class TextureSheetAnimationBehaviour extends ParticleSystemBaseBehaviour {
|
|
153
|
+
type = "NeedleTextureSheet";
|
|
154
|
+
update(particle, _delta) {
|
|
155
|
+
const sheet = this.system.textureSheetAnimation;
|
|
156
|
+
if (sheet.enabled) {
|
|
157
|
+
const t01 = particle.age / particle.life;
|
|
158
|
+
const index = sheet.evaluate(t01);
|
|
159
|
+
;
|
|
160
|
+
if (index !== undefined)
|
|
161
|
+
particle.uvTile = index;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
class RotationBehaviour extends ParticleSystemBaseBehaviour {
|
|
166
|
+
type = "NeedleRotation";
|
|
167
|
+
update(particle, delta) {
|
|
168
|
+
if (particle.rotation === undefined)
|
|
169
|
+
return;
|
|
170
|
+
if (particle.rotation instanceof Quaternion) {
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (this.system.rotationOverLifetime.enabled) {
|
|
174
|
+
particle.rotation += this.system.rotationOverLifetime.evaluate(particle.age / particle.life) * delta;
|
|
175
|
+
}
|
|
176
|
+
// HACK flip y
|
|
177
|
+
else
|
|
178
|
+
particle.rotation = Math.PI;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
class SizeBehaviour extends ParticleSystemBaseBehaviour {
|
|
183
|
+
type = "NeedleSize";
|
|
184
|
+
update(particle, _delta) {
|
|
185
|
+
const t = particle.age / particle.life;
|
|
186
|
+
let size = 1;
|
|
187
|
+
if (this.system.sizeOverLifetime.enabled)
|
|
188
|
+
size *= this.system.sizeOverLifetime.evaluate(t).x;
|
|
189
|
+
const scaleFactor = this.system.scale / this.system.cameraScale;
|
|
190
|
+
particle.size = particle.startSize * size * scaleFactor;
|
|
191
|
+
// console.log(particle.startSize, size, this.system.scale, this.system.cameraScale);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const $startVelocity = Symbol("startVelocity");
|
|
195
|
+
const $gravityFactor = Symbol("gravityModifier");
|
|
196
|
+
const temp3 = new Vector3();
|
|
197
|
+
const temp4 = new Quaternion();
|
|
198
|
+
class VelocityBehaviour extends ParticleSystemBaseBehaviour {
|
|
199
|
+
type = "NeedleVelocity";
|
|
200
|
+
_gravityDirection = new Vector3();
|
|
201
|
+
initialize(particle) {
|
|
202
|
+
const scale = this.system.scale;
|
|
203
|
+
particle.startSpeed = this.system.main.startSpeed.evaluate(Math.random(), Math.random());
|
|
204
|
+
particle.velocity.copy(this.system.shape.getDirection(particle.position)).multiplyScalar(particle.startSpeed);
|
|
205
|
+
if (!particle[$startVelocity])
|
|
206
|
+
particle[$startVelocity] = particle.velocity.clone();
|
|
207
|
+
else
|
|
208
|
+
particle[$startVelocity].copy(particle.velocity);
|
|
209
|
+
let gravityFactor = Math.PI / scale;
|
|
210
|
+
gravityFactor = this.system.main.gravityModifier.evaluate(Math.random(), Math.random()) * gravityFactor;
|
|
211
|
+
particle[$gravityFactor] = gravityFactor;
|
|
212
|
+
this._gravityDirection.set(0, -1, 0).applyQuaternion(this.system.worldQuaternionInverted);
|
|
213
|
+
}
|
|
214
|
+
update(particle, delta) {
|
|
215
|
+
// const t = particle.age / particle.life;
|
|
216
|
+
// console.log(this.system.deltaTime, delta);
|
|
217
|
+
const baseVelocity = particle[$startVelocity];
|
|
218
|
+
let gravityFactor = particle[$gravityFactor];
|
|
219
|
+
if (gravityFactor !== 0) {
|
|
220
|
+
// gravityFactor *= -1;
|
|
221
|
+
temp3.copy(this._gravityDirection).multiplyScalar(gravityFactor * delta * Math.PI);
|
|
222
|
+
// Gizmos.DrawDirection(particle.position, temp3, 0xff0000, 0, false, 10);
|
|
223
|
+
baseVelocity.add(temp3);
|
|
224
|
+
}
|
|
225
|
+
particle.velocity.copy(baseVelocity);
|
|
226
|
+
const noise = this.system.noise;
|
|
227
|
+
if (noise.enabled) {
|
|
228
|
+
noise.apply(0, particle.position, particle.velocity, delta, particle.age, particle.life);
|
|
229
|
+
}
|
|
230
|
+
const velocity = this.system.velocityOverLifetime;
|
|
231
|
+
if (velocity.enabled) {
|
|
232
|
+
velocity.apply(0, particle.position, particle.velocity, delta, particle.age, particle.life);
|
|
233
|
+
}
|
|
234
|
+
// particle.velocity.multiplyScalar(1-delta);
|
|
235
|
+
// const vel = this.system.velocityOverLifetime.evaluate(particle.age / particle.life);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
class ColorBehaviour extends ParticleSystemBaseBehaviour {
|
|
239
|
+
type = "NeedleColor";
|
|
240
|
+
initialize(particle) {
|
|
241
|
+
const col = this.system.main.startColor.evaluate(particle.age / particle.life, Math.random());
|
|
242
|
+
particle.startColor.set(col.r, col.g, col.b, col.alpha);
|
|
243
|
+
particle.color.copy(particle.startColor);
|
|
244
|
+
}
|
|
245
|
+
update(particle, _delta) {
|
|
246
|
+
if (this.system.colorOverLifetime.enabled) {
|
|
247
|
+
const t = particle.age / particle.life;
|
|
248
|
+
const col = this.system.colorOverLifetime.color.evaluate(t);
|
|
249
|
+
particle.color.set(col.r, col.g, col.b, col.alpha).multiply(particle.startColor);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
class ParticleSystemInterface {
|
|
254
|
+
system;
|
|
255
|
+
emission;
|
|
256
|
+
get anim() {
|
|
257
|
+
return this.system.textureSheetAnimation;
|
|
258
|
+
}
|
|
259
|
+
constructor(system) {
|
|
260
|
+
this.system = system;
|
|
261
|
+
this.emission = new ParticleSystemEmissionOverTime(this.system);
|
|
262
|
+
}
|
|
263
|
+
update() {
|
|
264
|
+
this.emission.update();
|
|
265
|
+
}
|
|
266
|
+
autoDestroy;
|
|
267
|
+
get looping() { return this.system.main.loop; }
|
|
268
|
+
get duration() { return this.system.duration; }
|
|
269
|
+
get shape() { return this.system.shape; }
|
|
270
|
+
get startLife() { return new MinMaxCurveFunction(this.system.main.startLifetime); }
|
|
271
|
+
get startSpeed() { return new MinMaxCurveFunction(this.system.main.startSpeed); }
|
|
272
|
+
get startRotation() { return new MinMaxCurveFunction(this.system.main.startRotation); }
|
|
273
|
+
get startSize() { return new MinMaxCurveFunction(this.system.main.startSize); }
|
|
274
|
+
startLength; /** start length is for trails */
|
|
275
|
+
get startColor() { return new ConstantColor(new Vector4(1, 1, 1, 1)); }
|
|
276
|
+
get emissionOverTime() { return this.emission; }
|
|
277
|
+
/** this is not supported yet */
|
|
278
|
+
get emissionOverDistance() { return new ParticleSystemEmissionOverDistance(this.system); }
|
|
279
|
+
/** not used - burst is controled via emissionOverTime */
|
|
280
|
+
emissionBursts;
|
|
281
|
+
onlyUsedByOther;
|
|
282
|
+
behaviors = [];
|
|
283
|
+
get instancingGeometry() {
|
|
284
|
+
return this.system.renderer.getMesh().geometry;
|
|
285
|
+
}
|
|
286
|
+
get renderMode() {
|
|
287
|
+
if (this.system.trails["enabled"] === true) {
|
|
288
|
+
return RenderMode.Trail;
|
|
289
|
+
}
|
|
290
|
+
switch (this.system.renderer.renderMode) {
|
|
291
|
+
case ParticleSystemRenderMode.Billboard: return RenderMode.BillBoard;
|
|
292
|
+
// case ParticleSystemRenderMode.Stretch: return RenderMode.Stretch;
|
|
293
|
+
// case ParticleSystemRenderMode.HorizontalBillboard: return RenderMode.HorizontalBillboard;
|
|
294
|
+
// case ParticleSystemRenderMode.VerticalBillboard: return RenderMode.VerticalBillboard;
|
|
295
|
+
case ParticleSystemRenderMode.Mesh: return RenderMode.LocalSpace;
|
|
296
|
+
}
|
|
297
|
+
return RenderMode.BillBoard;
|
|
298
|
+
}
|
|
299
|
+
rendererEmitterSettings = {
|
|
300
|
+
startLength: new ConstantValue(220),
|
|
301
|
+
followLocalOrigin: false,
|
|
302
|
+
};
|
|
303
|
+
get speedFactor() { return this.system.main.simulationSpeed; }
|
|
304
|
+
get texture() {
|
|
305
|
+
const mat = this.system.renderer.particleMaterial;
|
|
306
|
+
if (mat && mat["map"]) {
|
|
307
|
+
const tex = mat["map"];
|
|
308
|
+
tex.premultiplyAlpha = false;
|
|
309
|
+
tex.encoding = THREE.LinearEncoding;
|
|
310
|
+
return tex;
|
|
311
|
+
}
|
|
312
|
+
return createFlatTexture(new RGBAColor(1, 1, 1, 1), 1);
|
|
313
|
+
}
|
|
314
|
+
get startTileIndex() { return new TextureSheetStartFrameGenerator(this.system); }
|
|
315
|
+
get uTileCount() { return this.anim.enabled ? this.anim?.numTilesX : undefined; }
|
|
316
|
+
get vTileCount() { return this.anim.enabled ? this.anim?.numTilesY : undefined; }
|
|
317
|
+
get renderOrder() { return 1; }
|
|
318
|
+
get blending() { return this.system.renderer.particleMaterial?.blending ?? THREE.NormalBlending; }
|
|
319
|
+
get transparent() { return this.system.renderer.transparent; }
|
|
320
|
+
get worldSpace() { return this.system.main.simulationSpace === ParticleSystemSimulationSpace.World; }
|
|
321
|
+
}
|
|
24
322
|
export class ParticleSystem extends Behaviour {
|
|
25
323
|
colorOverLifetime;
|
|
26
324
|
main;
|
|
@@ -28,84 +326,157 @@ export class ParticleSystem extends Behaviour {
|
|
|
28
326
|
sizeOverLifetime;
|
|
29
327
|
shape;
|
|
30
328
|
noise;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
329
|
+
// @serializeable(TrailModule)
|
|
330
|
+
trails;
|
|
331
|
+
velocityOverLifetime;
|
|
332
|
+
textureSheetAnimation;
|
|
333
|
+
rotationOverLifetime;
|
|
334
|
+
get renderer() {
|
|
335
|
+
return this._renderer;
|
|
336
|
+
}
|
|
337
|
+
get currentParticles() {
|
|
338
|
+
return this._particleSystem?.particleNum ?? 0;
|
|
339
|
+
}
|
|
340
|
+
get maxParticles() {
|
|
341
|
+
return this.main.maxParticles;
|
|
342
|
+
}
|
|
343
|
+
get time() {
|
|
344
|
+
return this._time;
|
|
345
|
+
}
|
|
346
|
+
get duration() {
|
|
347
|
+
return this.main.duration;
|
|
348
|
+
}
|
|
349
|
+
get deltaTime() {
|
|
350
|
+
return this.context.time.deltaTime * this.main.simulationSpeed;
|
|
351
|
+
}
|
|
352
|
+
get scale() {
|
|
353
|
+
return this.gameObject.scale.x;
|
|
354
|
+
}
|
|
355
|
+
get cameraScale() {
|
|
356
|
+
return this._cameraScale;
|
|
357
|
+
}
|
|
358
|
+
_cameraScale = 1;
|
|
359
|
+
get container() {
|
|
360
|
+
return this._container;
|
|
361
|
+
}
|
|
362
|
+
__worldQuaternion = new Quaternion();
|
|
363
|
+
get worldQuaternion() {
|
|
364
|
+
return this.__worldQuaternion;
|
|
365
|
+
}
|
|
366
|
+
_worldQuaternionInverted = new Quaternion();
|
|
367
|
+
get worldQuaternionInverted() {
|
|
368
|
+
return this._worldQuaternionInverted;
|
|
369
|
+
}
|
|
370
|
+
_renderer;
|
|
371
|
+
_batchSystem;
|
|
372
|
+
_particleSystem;
|
|
373
|
+
_interface;
|
|
374
|
+
// private _system!: System;
|
|
375
|
+
// private _emitter: Emitter;
|
|
376
|
+
// private _size!: SizeBehaviour;
|
|
377
|
+
_container;
|
|
378
|
+
_time = 0;
|
|
379
|
+
/** called from deserialization */
|
|
380
|
+
set bursts(arr) {
|
|
381
|
+
for (let i = 0; i < arr.length; i++) {
|
|
382
|
+
const burst = arr[i];
|
|
383
|
+
if ((burst instanceof ParticleBurst) === false) {
|
|
384
|
+
const instance = new ParticleBurst();
|
|
385
|
+
assign(instance, burst);
|
|
386
|
+
arr[i] = instance;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
this._bursts = arr;
|
|
390
|
+
}
|
|
391
|
+
_bursts;
|
|
35
392
|
awake() {
|
|
393
|
+
this._renderer = this.gameObject.getComponent(ParticleSystemRenderer);
|
|
394
|
+
this._container = new Object3D();
|
|
395
|
+
this._container.matrixAutoUpdate = false;
|
|
396
|
+
if (this.main.simulationSpace == ParticleSystemSimulationSpace.Local) {
|
|
397
|
+
this.gameObject.add(this._container);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
this.context.scene.add(this._container);
|
|
401
|
+
}
|
|
402
|
+
// else this._container = this.context.scene;
|
|
403
|
+
this._batchSystem = new BatchedParticleRenderer();
|
|
404
|
+
this._container.add(this._batchSystem);
|
|
405
|
+
this._interface = new ParticleSystemInterface(this);
|
|
406
|
+
this._particleSystem = new _ParticleSystem(this._batchSystem, this._interface);
|
|
407
|
+
this._particleSystem.addBehavior(new SizeBehaviour(this));
|
|
408
|
+
this._particleSystem.addBehavior(new VelocityBehaviour(this));
|
|
409
|
+
this._particleSystem.addBehavior(new ColorBehaviour(this));
|
|
410
|
+
this._particleSystem.addBehavior(new TextureSheetAnimationBehaviour(this));
|
|
411
|
+
this._particleSystem.addBehavior(new RotationBehaviour(this));
|
|
412
|
+
const emitter = this._particleSystem.emitter;
|
|
413
|
+
this.context.scene.add(emitter);
|
|
36
414
|
if (debug) {
|
|
37
415
|
console.log(this);
|
|
38
|
-
this.
|
|
39
|
-
}
|
|
40
|
-
this.renderer = this.gameObject.getComponent(ParticleSystemRenderer);
|
|
41
|
-
this._system = new System();
|
|
42
|
-
const container = this.main.simulationSpace == ParticleSystemSimulationSpace.Local ? this.gameObject : this.context.scene;
|
|
43
|
-
const renderer = new SpriteRenderer(container, THREE);
|
|
44
|
-
renderer.logRendererType = () => { };
|
|
45
|
-
if (this.renderer.particleMaterial) {
|
|
46
|
-
const sprite = renderer._body;
|
|
47
|
-
sprite.layers.disableAll();
|
|
48
|
-
sprite.layers.set(2); // ignore raycasting particles
|
|
49
|
-
sprite.renderOrder = 1;
|
|
50
|
-
sprite.material.map = this.renderer.particleMaterial.map;
|
|
51
|
-
sprite.material.transparent = true;
|
|
52
|
-
// sprite.material.sizeAttenuation = false;
|
|
53
|
-
sprite.material.blending = this.renderer.particleMaterial.blending;
|
|
54
|
-
sprite.material.blendDst = this.renderer.particleMaterial.blendDst;
|
|
55
|
-
sprite.material.blendDstAlpha = this.renderer.particleMaterial.blendDstAlpha;
|
|
56
|
-
sprite.material.blendEquation = this.renderer.particleMaterial.blendEquation;
|
|
57
|
-
sprite.material.blendEquationAlpha = this.renderer.particleMaterial.blendEquationAlpha;
|
|
58
|
-
sprite.material.blendSrc = this.renderer.particleMaterial.blendSrc;
|
|
59
|
-
sprite.material.blendSrcAlpha = this.renderer.particleMaterial.blendSrcAlpha;
|
|
60
|
-
sprite.material.premultipliedAlpha = this.renderer.particleMaterial.premultipliedAlpha;
|
|
61
|
-
sprite.material.depthWrite = false;
|
|
62
|
-
sprite.material.depthTest = true;
|
|
63
|
-
if (debug)
|
|
64
|
-
console.log(sprite);
|
|
416
|
+
this.container.add(new AxesHelper(1));
|
|
65
417
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
418
|
+
// renderer.logRendererType = () => { };
|
|
419
|
+
// if (renderMode === ParticleSystemRenderMode.Billboard) {
|
|
420
|
+
// if (this.renderer.particleMaterial) {
|
|
421
|
+
// const sprite = renderer._body as Sprite;
|
|
422
|
+
// sprite.layers.disableAll();
|
|
423
|
+
// sprite.layers.set(2); // ignore raycasting particles
|
|
424
|
+
// sprite.renderOrder = 1;
|
|
425
|
+
// sprite.material.map = this.renderer.particleMaterial.map;
|
|
426
|
+
// sprite.material.transparent = true;
|
|
427
|
+
// // sprite.material.sizeAttenuation = false;
|
|
428
|
+
// sprite.material.blending = this.renderer.particleMaterial.blending;
|
|
429
|
+
// sprite.material.blendDst = this.renderer.particleMaterial.blendDst;
|
|
430
|
+
// sprite.material.blendDstAlpha = this.renderer.particleMaterial.blendDstAlpha;
|
|
431
|
+
// sprite.material.blendEquation = this.renderer.particleMaterial.blendEquation;
|
|
432
|
+
// sprite.material.blendEquationAlpha = this.renderer.particleMaterial.blendEquationAlpha;
|
|
433
|
+
// sprite.material.blendSrc = this.renderer.particleMaterial.blendSrc;
|
|
434
|
+
// sprite.material.blendSrcAlpha = this.renderer.particleMaterial.blendSrcAlpha;
|
|
435
|
+
// sprite.material.premultipliedAlpha = this.renderer.particleMaterial.premultipliedAlpha;
|
|
436
|
+
// sprite.material.depthWrite = false;
|
|
437
|
+
// sprite.material.depthTest = true;
|
|
438
|
+
// if (debug) console.log(sprite);
|
|
439
|
+
// }
|
|
440
|
+
// }
|
|
88
441
|
}
|
|
89
442
|
onEnable() {
|
|
90
|
-
this.
|
|
91
|
-
this._system.addEmitter(this._emitter);
|
|
92
|
-
this._system.emit({ onStart: () => { }, onUpdate: () => { }, onEnd: () => { }, });
|
|
443
|
+
this._time = 0;
|
|
93
444
|
}
|
|
94
445
|
onDisable() {
|
|
95
|
-
this._system.removeEmitter(this._emitter);
|
|
96
446
|
}
|
|
97
447
|
onBeforeRender() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.noise.update(this.context);
|
|
102
|
-
this._system.update(this.context.time.deltaTime * this.main.simulationSpeed);
|
|
448
|
+
if (this._bursts) {
|
|
449
|
+
this.emission.bursts = this._bursts;
|
|
450
|
+
}
|
|
103
451
|
// sprite materials must be scaled in AR
|
|
104
452
|
const cam = this.context.mainCamera;
|
|
105
453
|
if (cam) {
|
|
106
454
|
const scale = getWorldScale(cam);
|
|
107
|
-
this.
|
|
455
|
+
this._cameraScale = scale.x;
|
|
456
|
+
}
|
|
457
|
+
let rotationSource = this._container;
|
|
458
|
+
if (this.main.simulationSpace === ParticleSystemSimulationSpace.World)
|
|
459
|
+
rotationSource = this.gameObject;
|
|
460
|
+
getWorldQuaternion(rotationSource, this.__worldQuaternion);
|
|
461
|
+
this._worldQuaternionInverted.copy(this.__worldQuaternion).invert();
|
|
462
|
+
if (this._container && this.gameObject?.parent) {
|
|
463
|
+
const scale = getWorldScale(this.gameObject.parent);
|
|
464
|
+
scale.x = 1 / scale.x;
|
|
465
|
+
scale.y = 1 / scale.y;
|
|
466
|
+
scale.z = 1 / scale.z;
|
|
467
|
+
this._container.matrix.identity();
|
|
468
|
+
this._container.matrix.scale(scale);
|
|
108
469
|
}
|
|
470
|
+
this.emission.system = this;
|
|
471
|
+
const dt = this.deltaTime;
|
|
472
|
+
this._interface.update();
|
|
473
|
+
this.shape.update(this.context, this.main.simulationSpace, this.gameObject);
|
|
474
|
+
this.noise.update(this.context);
|
|
475
|
+
this.velocityOverLifetime.update(this);
|
|
476
|
+
this._batchSystem?.update(dt);
|
|
477
|
+
this._time += dt;
|
|
478
|
+
if (this._time > this.duration)
|
|
479
|
+
this._time = 0;
|
|
109
480
|
}
|
|
110
481
|
}
|
|
111
482
|
__decorate([
|
|
@@ -126,155 +497,152 @@ __decorate([
|
|
|
126
497
|
__decorate([
|
|
127
498
|
serializeable(NoiseModule)
|
|
128
499
|
], ParticleSystem.prototype, "noise", void 0);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// console.log(particle);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
500
|
+
__decorate([
|
|
501
|
+
serializeable(VelocityOverLifetimeModule)
|
|
502
|
+
], ParticleSystem.prototype, "velocityOverLifetime", void 0);
|
|
503
|
+
__decorate([
|
|
504
|
+
serializeable(TextureSheetAnimationModule)
|
|
505
|
+
], ParticleSystem.prototype, "textureSheetAnimation", void 0);
|
|
506
|
+
__decorate([
|
|
507
|
+
serializeable(RotationOverLifetimeModule)
|
|
508
|
+
], ParticleSystem.prototype, "rotationOverLifetime", void 0);
|
|
509
|
+
// abstract class CustomBehaviour extends Behaviour {
|
|
510
|
+
// abstract applyBehaviour(target: Particle | Emitter, time: number, index: number);
|
|
511
|
+
// abstract initialize(particle: Particle);
|
|
512
|
+
// }
|
|
513
|
+
// abstract class MinMaxCurveBehaviour extends CustomBehaviour {
|
|
514
|
+
// readonly startCurve: MinMaxCurve;
|
|
515
|
+
// startMultiplier: number = 1;
|
|
516
|
+
// constructor(startCurve: MinMaxCurve, startMultiplier: number = 1) {
|
|
517
|
+
// super();
|
|
518
|
+
// this.startCurve = startCurve;
|
|
519
|
+
// this.startMultiplier = startMultiplier;
|
|
520
|
+
// }
|
|
521
|
+
// }
|
|
522
|
+
// declare type ParticleWithScale = Particle & { target: Object3D, start_scale: number };
|
|
523
|
+
// class SizeBehaviour extends MinMaxCurveBehaviour {
|
|
524
|
+
// sizeOverLifetimeModule!: SizeOverLifetimeModule;
|
|
525
|
+
// cameraScale: number = 1;
|
|
526
|
+
// applyBehaviour(particle: ParticleWithScale, _deltaTime: number, _index: number) {
|
|
527
|
+
// if (particle.target.type === "Sprite") {
|
|
528
|
+
// particle.radius = 1 / this.cameraScale;
|
|
529
|
+
// }
|
|
530
|
+
// else particle.radius = 1;
|
|
531
|
+
// // particle.target.scale.set(1,1,1);
|
|
532
|
+
// if (this.sizeOverLifetimeModule?.enabled) {
|
|
533
|
+
// const time = particle.age / particle.life;
|
|
534
|
+
// const scaleVector = particle.target.scale;
|
|
535
|
+
// this.sizeOverLifetimeModule.evaluate?.call(this.sizeOverLifetimeModule, time, scaleVector);
|
|
536
|
+
// // scaleVector.set(.1, .1, .1)
|
|
537
|
+
// particle.scale = particle.start_scale * scaleVector.x;
|
|
538
|
+
// // console.log(time, particle.scale);
|
|
539
|
+
// }
|
|
540
|
+
// }
|
|
541
|
+
// initialize(particle: ParticleWithScale) {
|
|
542
|
+
// particle.scale = this.startCurve.evaluate(0, Math.random());// * this.startMultiplier;
|
|
543
|
+
// particle.start_scale = particle.scale;
|
|
544
|
+
// }
|
|
545
|
+
// }
|
|
546
|
+
// declare type ParticleWithColor = Particle & { color_start: { r: number, g: number, b: number }, alpha_start: number };
|
|
547
|
+
// class GradientBehaviour extends CustomBehaviour {
|
|
548
|
+
// private startGradient: MinMaxGradient;
|
|
549
|
+
// private gradient?: MinMaxGradient;
|
|
550
|
+
// constructor(startGradient: MinMaxGradient, gradient?: MinMaxGradient) {
|
|
551
|
+
// super();
|
|
552
|
+
// this.startGradient = startGradient;
|
|
553
|
+
// this.gradient = gradient;
|
|
554
|
+
// }
|
|
555
|
+
// /** called from nebula */
|
|
556
|
+
// applyBehaviour(target: ParticleWithColor | Emitter, _deltaTime: number, _index: number) {
|
|
557
|
+
// // console.log(target, time, index)
|
|
558
|
+
// if (target instanceof Particle) {
|
|
559
|
+
// if (this.gradient) {
|
|
560
|
+
// const t = target.age / target.life;
|
|
561
|
+
// const ev = this.gradient.evaluate(t) as RGBAColor;
|
|
562
|
+
// const startColor = target.color_start;
|
|
563
|
+
// target.color.r = startColor.r * ev.r;
|
|
564
|
+
// target.color.g = startColor.g * ev.g;
|
|
565
|
+
// target.color.b = startColor.b * ev.b;
|
|
566
|
+
// target.alpha = ev.alpha * target.alpha_start;
|
|
567
|
+
// }
|
|
568
|
+
// }
|
|
569
|
+
// }
|
|
570
|
+
// private id = Symbol('gradientId');
|
|
571
|
+
// private _internalId: number = 0;
|
|
572
|
+
// /** called from nebula */
|
|
573
|
+
// initialize(particle: ParticleWithColor) {
|
|
574
|
+
// // console.log(particle);
|
|
575
|
+
// // const context = Context.Current;
|
|
576
|
+
// // const time = context.time.time;
|
|
577
|
+
// const ev = this.startGradient.evaluate(Math.random()) as RGBAColor;
|
|
578
|
+
// particle.color.r = ev.r;
|
|
579
|
+
// particle.color.g = ev.g;
|
|
580
|
+
// particle.color.b = ev.b;
|
|
581
|
+
// particle.alpha = ev.alpha
|
|
582
|
+
// particle.age = 0;
|
|
583
|
+
// particle.color_start = { r: ev.r, g: ev.g, b: ev.b };
|
|
584
|
+
// particle.alpha_start = ev.alpha;
|
|
585
|
+
// particle.useColor = true;
|
|
586
|
+
// particle.useAlpha = true;
|
|
587
|
+
// if (particle[this.id] === undefined)
|
|
588
|
+
// particle[this.id] = this._internalId++;
|
|
589
|
+
// }
|
|
590
|
+
// }
|
|
591
|
+
// declare type ParticleWithVelocity = Particle & { velocity_start: { x: number, y: number, u: number }, gravity: number };
|
|
592
|
+
// class VelocityBehaviour extends CustomBehaviour {
|
|
593
|
+
// container: Object3D;
|
|
594
|
+
// shape: ShapeModule;
|
|
595
|
+
// noise: NoiseModule;
|
|
596
|
+
// startSpeed: MinMaxCurve;
|
|
597
|
+
// startMultiplier: number = 1;
|
|
598
|
+
// gravity?: MinMaxCurve;
|
|
599
|
+
// gravityModifierMultiplier: number = 1;
|
|
600
|
+
// downDirection = new Vector3();
|
|
601
|
+
// private _temp: Vector3 = new Vector3();
|
|
602
|
+
// constructor(container: Object3D, shape: ShapeModule, noise: NoiseModule, startCurve: MinMaxCurve, startMultiplier: number) {
|
|
603
|
+
// super();
|
|
604
|
+
// this.container = container;
|
|
605
|
+
// this.shape = shape;
|
|
606
|
+
// this.noise = noise;
|
|
607
|
+
// this.startSpeed = startCurve;
|
|
608
|
+
// this.startMultiplier = startMultiplier;
|
|
609
|
+
// }
|
|
610
|
+
// applyBehaviour(target: ParticleWithVelocity | Emitter, deltaTime: number, index: number) {
|
|
611
|
+
// if (target instanceof Particle) {
|
|
612
|
+
// // target.velocity.x = target.velocity_start.x;
|
|
613
|
+
// // target.velocity.y = target.velocity_start.y;
|
|
614
|
+
// // target.velocity.z = target.velocity_start.z;
|
|
615
|
+
// if (target.gravity !== 0 && this.gravity) {
|
|
616
|
+
// // get world down vector
|
|
617
|
+
// this._temp.copy(this.downDirection);
|
|
618
|
+
// this._temp.multiplyScalar(target.gravity * deltaTime);
|
|
619
|
+
// target.velocity.add(this._temp);
|
|
620
|
+
// }
|
|
621
|
+
// if (this.noise) {
|
|
622
|
+
// this.noise.applyNoise(index, target.position, target.velocity, deltaTime, target.age, target.life);
|
|
623
|
+
// }
|
|
624
|
+
// }
|
|
625
|
+
// }
|
|
626
|
+
// initialize(particle: ParticleWithVelocity) {
|
|
627
|
+
// const dir = this.shape.getDirection(particle.position);
|
|
628
|
+
// // dir.applyQuaternion(quat);
|
|
629
|
+
// const speed = this.startSpeed.evaluate(0, Math.random()) * this.startMultiplier;
|
|
630
|
+
// particle.velocity.x = dir.x * speed;
|
|
631
|
+
// particle.velocity.y = dir.y * speed;
|
|
632
|
+
// particle.velocity.z = dir.z * speed;
|
|
633
|
+
// if (!particle.velocity_start)
|
|
634
|
+
// particle.velocity_start = {};
|
|
635
|
+
// particle.velocity_start.x = particle.velocity.x;
|
|
636
|
+
// particle.velocity_start.y = particle.velocity.y;
|
|
637
|
+
// particle.velocity_start.z = particle.velocity.z;
|
|
638
|
+
// if (this.gravity) {
|
|
639
|
+
// particle.gravity = this.gravity.evaluate(Math.random(), Math.random()) * 9.81;
|
|
640
|
+
// }
|
|
641
|
+
// else {
|
|
642
|
+
// particle.gravity = 0;
|
|
643
|
+
// }
|
|
644
|
+
// const quat = getWorldQuaternion(this.container);
|
|
645
|
+
// this.downDirection.set(0, -1, 0).applyQuaternion(quat);
|
|
646
|
+
// }
|
|
647
|
+
// }
|
|
280
648
|
//# sourceMappingURL=ParticleSystem.js.map
|