@needle-tools/engine 2.40.0-pre → 2.41.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 +7 -0
- package/dist/needle-engine.d.ts +269 -123
- package/dist/needle-engine.js +389 -389
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +41 -41
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_gizmos.d.ts +1 -0
- package/lib/engine/engine_gizmos.js +16 -4
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_math.d.ts +9 -6
- package/lib/engine/engine_math.js +9 -0
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_physics.js +14 -6
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +2 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +3 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine-components/AnimationCurve.js +20 -5
- package/lib/engine-components/AnimationCurve.js.map +1 -1
- package/lib/engine-components/Light.d.ts +2 -0
- package/lib/engine-components/Light.js +33 -9
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +15 -26
- package/lib/engine-components/ParticleSystem.js +251 -184
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +208 -63
- package/lib/engine-components/ParticleSystemModules.js +640 -153
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/WebXR.js +8 -3
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +6 -0
- package/lib/engine-components/codegen/components.js +6 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/package.json +3 -1
- package/src/engine/codegen/register_types.js +24 -0
- package/src/engine/engine_gizmos.ts +19 -4
- package/src/engine/engine_math.ts +19 -6
- package/src/engine/engine_physics.ts +17 -7
- package/src/engine/engine_serialization_core.ts +1 -0
- package/src/engine/engine_utils.ts +5 -0
- package/src/engine-components/AnimationCurve.ts +25 -11
- package/src/engine-components/Light.ts +39 -8
- package/src/engine-components/ParticleSystem.ts +314 -194
- package/src/engine-components/ParticleSystemModules.ts +537 -154
- package/src/engine-components/WebXR.ts +11 -8
- package/src/engine-components/codegen/components.ts +6 -0
- package/src/engine/dist/engine_physics.js +0 -739
- package/src/engine/dist/engine_setup.js +0 -777
- package/src/engine-components/dist/CharacterController.js +0 -123
- package/src/engine-components/dist/RigidBody.js +0 -458
|
@@ -1,61 +1,389 @@
|
|
|
1
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Matrix4, Vector3 } from "three";
|
|
8
|
+
import { Mathf } from "../engine/engine_math";
|
|
9
|
+
import { serializeable } from "../engine/engine_serialization";
|
|
10
|
+
import { RGBAColor } from "./js-extensions/RGBAColor";
|
|
11
|
+
import { AnimationCurve } from "./AnimationCurve";
|
|
12
|
+
export class Gradient {
|
|
13
|
+
alphaKeys;
|
|
14
|
+
colorKeys;
|
|
15
|
+
get duration() {
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
evaluate(time, target) {
|
|
19
|
+
// target.r = this.colorKeys[0].color.r;
|
|
20
|
+
// target.g = this.colorKeys[0].color.g;
|
|
21
|
+
// target.b = this.colorKeys[0].color.b;
|
|
22
|
+
// target.alpha = this.alphaKeys[0].alpha;
|
|
23
|
+
// return;
|
|
24
|
+
let closestAlpha = undefined;
|
|
25
|
+
let closestAlphaIndex = 0;
|
|
26
|
+
let closestColor = null;
|
|
27
|
+
let closestColorIndex = 0;
|
|
28
|
+
for (let i = 0; i < this.alphaKeys.length; i++) {
|
|
29
|
+
const key = this.alphaKeys[i];
|
|
30
|
+
if (key.time < time || !closestAlpha) {
|
|
31
|
+
closestAlpha = key;
|
|
32
|
+
closestAlphaIndex = i;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (let i = 0; i < this.colorKeys.length; i++) {
|
|
36
|
+
const key = this.colorKeys[i];
|
|
37
|
+
if (key.time < time || !closestColor) {
|
|
38
|
+
closestColor = key;
|
|
39
|
+
closestColorIndex = i;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (closestColor) {
|
|
43
|
+
const hasNextColor = closestColorIndex + 1 < this.colorKeys.length;
|
|
44
|
+
if (hasNextColor) {
|
|
45
|
+
const nextColor = this.colorKeys[closestColorIndex + 1];
|
|
46
|
+
const t = Mathf.remap(time, closestColor.time, nextColor.time, 0, 1);
|
|
47
|
+
target.r = Mathf.lerp(closestColor.color.r, nextColor.color.r, t);
|
|
48
|
+
target.g = Mathf.lerp(closestColor.color.g, nextColor.color.g, t);
|
|
49
|
+
target.b = Mathf.lerp(closestColor.color.b, nextColor.color.b, t);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
target.r = closestColor.color.r;
|
|
53
|
+
target.g = closestColor.color.g;
|
|
54
|
+
target.b = closestColor.color.b;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (closestAlpha) {
|
|
58
|
+
const hasNextAlpha = closestAlphaIndex + 1 < this.alphaKeys.length;
|
|
59
|
+
if (hasNextAlpha) {
|
|
60
|
+
const nextAlpha = this.alphaKeys[closestAlphaIndex + 1];
|
|
61
|
+
const t = Mathf.remap(time, closestAlpha.time, nextAlpha.time, 0, 1);
|
|
62
|
+
target.alpha = Mathf.lerp(closestAlpha.alpha, nextAlpha.alpha, t);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
target.alpha = closestAlpha.alpha;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return target;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
__decorate([
|
|
72
|
+
serializeable()
|
|
73
|
+
], Gradient.prototype, "alphaKeys", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
serializeable()
|
|
76
|
+
], Gradient.prototype, "colorKeys", void 0);
|
|
77
|
+
export var ParticleSystemCurveMode;
|
|
78
|
+
(function (ParticleSystemCurveMode) {
|
|
79
|
+
ParticleSystemCurveMode[ParticleSystemCurveMode["Constant"] = 0] = "Constant";
|
|
80
|
+
ParticleSystemCurveMode[ParticleSystemCurveMode["Curve"] = 1] = "Curve";
|
|
81
|
+
ParticleSystemCurveMode[ParticleSystemCurveMode["TwoCurves"] = 2] = "TwoCurves";
|
|
82
|
+
ParticleSystemCurveMode[ParticleSystemCurveMode["TwoConstants"] = 3] = "TwoConstants";
|
|
83
|
+
})(ParticleSystemCurveMode || (ParticleSystemCurveMode = {}));
|
|
84
|
+
export var ParticleSystemGradientMode;
|
|
85
|
+
(function (ParticleSystemGradientMode) {
|
|
86
|
+
ParticleSystemGradientMode[ParticleSystemGradientMode["Color"] = 0] = "Color";
|
|
87
|
+
ParticleSystemGradientMode[ParticleSystemGradientMode["Gradient"] = 1] = "Gradient";
|
|
88
|
+
ParticleSystemGradientMode[ParticleSystemGradientMode["TwoColors"] = 2] = "TwoColors";
|
|
89
|
+
ParticleSystemGradientMode[ParticleSystemGradientMode["TwoGradients"] = 3] = "TwoGradients";
|
|
90
|
+
ParticleSystemGradientMode[ParticleSystemGradientMode["RandomColor"] = 4] = "RandomColor";
|
|
91
|
+
})(ParticleSystemGradientMode || (ParticleSystemGradientMode = {}));
|
|
92
|
+
export var ParticleSystemSimulationSpace;
|
|
93
|
+
(function (ParticleSystemSimulationSpace) {
|
|
94
|
+
ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["Local"] = 0] = "Local";
|
|
95
|
+
ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["World"] = 1] = "World";
|
|
96
|
+
ParticleSystemSimulationSpace[ParticleSystemSimulationSpace["Custom"] = 2] = "Custom";
|
|
97
|
+
})(ParticleSystemSimulationSpace || (ParticleSystemSimulationSpace = {}));
|
|
98
|
+
export var ParticleSystemShapeType;
|
|
99
|
+
(function (ParticleSystemShapeType) {
|
|
100
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Sphere"] = 0] = "Sphere";
|
|
101
|
+
ParticleSystemShapeType[ParticleSystemShapeType["SphereShell"] = 1] = "SphereShell";
|
|
102
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Hemisphere"] = 2] = "Hemisphere";
|
|
103
|
+
ParticleSystemShapeType[ParticleSystemShapeType["HemisphereShell"] = 3] = "HemisphereShell";
|
|
104
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Cone"] = 4] = "Cone";
|
|
105
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Box"] = 5] = "Box";
|
|
106
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Mesh"] = 6] = "Mesh";
|
|
107
|
+
ParticleSystemShapeType[ParticleSystemShapeType["ConeShell"] = 7] = "ConeShell";
|
|
108
|
+
ParticleSystemShapeType[ParticleSystemShapeType["ConeVolume"] = 8] = "ConeVolume";
|
|
109
|
+
ParticleSystemShapeType[ParticleSystemShapeType["ConeVolumeShell"] = 9] = "ConeVolumeShell";
|
|
110
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Circle"] = 10] = "Circle";
|
|
111
|
+
ParticleSystemShapeType[ParticleSystemShapeType["CircleEdge"] = 11] = "CircleEdge";
|
|
112
|
+
ParticleSystemShapeType[ParticleSystemShapeType["SingleSidedEdge"] = 12] = "SingleSidedEdge";
|
|
113
|
+
ParticleSystemShapeType[ParticleSystemShapeType["MeshRenderer"] = 13] = "MeshRenderer";
|
|
114
|
+
ParticleSystemShapeType[ParticleSystemShapeType["SkinnedMeshRenderer"] = 14] = "SkinnedMeshRenderer";
|
|
115
|
+
ParticleSystemShapeType[ParticleSystemShapeType["BoxShell"] = 15] = "BoxShell";
|
|
116
|
+
ParticleSystemShapeType[ParticleSystemShapeType["BoxEdge"] = 16] = "BoxEdge";
|
|
117
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Donut"] = 17] = "Donut";
|
|
118
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Rectangle"] = 18] = "Rectangle";
|
|
119
|
+
ParticleSystemShapeType[ParticleSystemShapeType["Sprite"] = 19] = "Sprite";
|
|
120
|
+
ParticleSystemShapeType[ParticleSystemShapeType["SpriteRenderer"] = 20] = "SpriteRenderer";
|
|
121
|
+
})(ParticleSystemShapeType || (ParticleSystemShapeType = {}));
|
|
122
|
+
export class MinMaxCurve {
|
|
123
|
+
mode;
|
|
124
|
+
constant;
|
|
125
|
+
constantMin;
|
|
126
|
+
constantMax;
|
|
127
|
+
curve;
|
|
128
|
+
curveMin;
|
|
129
|
+
curveMax;
|
|
130
|
+
curveMultiplier;
|
|
131
|
+
evaluate(t01, lerpFactor) {
|
|
132
|
+
const t = lerpFactor === undefined ? Math.random() : lerpFactor;
|
|
133
|
+
switch (this.mode) {
|
|
134
|
+
case ParticleSystemCurveMode.Constant:
|
|
135
|
+
return this.constant;
|
|
136
|
+
case ParticleSystemCurveMode.Curve:
|
|
137
|
+
t01 %= this.curve.duration;
|
|
138
|
+
return this.curve.evaluate(t01);
|
|
139
|
+
case ParticleSystemCurveMode.TwoCurves:
|
|
140
|
+
const t1 = t01 * this.curveMin.duration;
|
|
141
|
+
const t2 = t01 * this.curveMax.duration;
|
|
142
|
+
return Mathf.lerp(this.curveMin.evaluate(t1), this.curveMax.evaluate(t2), t % 1);
|
|
143
|
+
case ParticleSystemCurveMode.TwoConstants:
|
|
144
|
+
return Mathf.lerp(this.constantMin, this.constantMax, t % 1);
|
|
145
|
+
default:
|
|
146
|
+
this.curveMax.evaluate(t01) * this.curveMultiplier;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
__decorate([
|
|
153
|
+
serializeable()
|
|
154
|
+
], MinMaxCurve.prototype, "mode", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
serializeable()
|
|
157
|
+
], MinMaxCurve.prototype, "constant", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
serializeable()
|
|
160
|
+
], MinMaxCurve.prototype, "constantMin", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
serializeable()
|
|
163
|
+
], MinMaxCurve.prototype, "constantMax", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
serializeable(AnimationCurve)
|
|
166
|
+
], MinMaxCurve.prototype, "curve", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
serializeable(AnimationCurve)
|
|
169
|
+
], MinMaxCurve.prototype, "curveMin", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
serializeable(AnimationCurve)
|
|
172
|
+
], MinMaxCurve.prototype, "curveMax", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
serializeable()
|
|
175
|
+
], MinMaxCurve.prototype, "curveMultiplier", void 0);
|
|
176
|
+
export class MinMaxGradient {
|
|
177
|
+
mode;
|
|
178
|
+
color;
|
|
179
|
+
colorMin;
|
|
180
|
+
colorMax;
|
|
181
|
+
gradient;
|
|
182
|
+
gradientMin;
|
|
183
|
+
gradientMax;
|
|
184
|
+
_temp = new RGBAColor(0, 0, 0, 1);
|
|
185
|
+
evaluate(t01, lerpFactor) {
|
|
186
|
+
const t = lerpFactor === undefined ? Math.random() : lerpFactor;
|
|
187
|
+
switch (this.mode) {
|
|
188
|
+
case ParticleSystemGradientMode.Color:
|
|
189
|
+
return this.color;
|
|
190
|
+
case ParticleSystemGradientMode.Gradient:
|
|
191
|
+
this.gradient.evaluate(t01, this._temp);
|
|
192
|
+
return this._temp;
|
|
193
|
+
case ParticleSystemGradientMode.TwoColors:
|
|
194
|
+
return this._temp.lerpColors(this.colorMin, this.colorMax, t);
|
|
195
|
+
}
|
|
196
|
+
// console.warn("Not implemented", ParticleSystemGradientMode[this.mode]);
|
|
197
|
+
this._temp.set(0xff00ff);
|
|
198
|
+
this._temp.alpha = 1;
|
|
199
|
+
return this._temp;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
__decorate([
|
|
203
|
+
serializeable(RGBAColor)
|
|
204
|
+
], MinMaxGradient.prototype, "color", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
serializeable(RGBAColor)
|
|
207
|
+
], MinMaxGradient.prototype, "colorMin", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
serializeable(RGBAColor)
|
|
210
|
+
], MinMaxGradient.prototype, "colorMax", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
serializeable(Gradient)
|
|
213
|
+
], MinMaxGradient.prototype, "gradient", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
serializeable(Gradient)
|
|
216
|
+
], MinMaxGradient.prototype, "gradientMin", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
serializeable(Gradient)
|
|
219
|
+
], MinMaxGradient.prototype, "gradientMax", void 0);
|
|
2
220
|
export class MainModule {
|
|
3
|
-
|
|
4
|
-
duration
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
startRotation
|
|
24
|
-
startRotationMultiplier
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
ringBufferMode = 0;
|
|
46
|
-
ringBufferLoopRange = new THREE.Vector2(0, 1);
|
|
47
|
-
cullingMode = 0;
|
|
221
|
+
cullingMode;
|
|
222
|
+
duration;
|
|
223
|
+
emitterVelocityMode;
|
|
224
|
+
flipRotation;
|
|
225
|
+
gravityModifier;
|
|
226
|
+
gravityModifierMultiplier;
|
|
227
|
+
loop;
|
|
228
|
+
maxParticles;
|
|
229
|
+
playOnAwake;
|
|
230
|
+
prewarm;
|
|
231
|
+
ringBufferLoopRange;
|
|
232
|
+
ringBufferMode;
|
|
233
|
+
scalingMode;
|
|
234
|
+
simulationSpace;
|
|
235
|
+
simulationSpeed;
|
|
236
|
+
startColor;
|
|
237
|
+
startDelay;
|
|
238
|
+
startDelayMultiplier;
|
|
239
|
+
startLifetime;
|
|
240
|
+
startLifetimeMultiplier;
|
|
241
|
+
startRotation;
|
|
242
|
+
startRotationMultiplier;
|
|
243
|
+
startRotation3D;
|
|
244
|
+
startRotationX;
|
|
245
|
+
startRotationXMultiplier;
|
|
246
|
+
startRotationY;
|
|
247
|
+
startRotationYMultiplier;
|
|
248
|
+
startRotationZ;
|
|
249
|
+
startRotationZMultiplier;
|
|
250
|
+
startSize;
|
|
251
|
+
startSize3D;
|
|
252
|
+
startSizeMultiplier;
|
|
253
|
+
startSizeX;
|
|
254
|
+
startSizeXMultiplier;
|
|
255
|
+
startSizeY;
|
|
256
|
+
startSizeYMultiplier;
|
|
257
|
+
startSizeZ;
|
|
258
|
+
startSizeZMultiplier;
|
|
259
|
+
startSpeed;
|
|
260
|
+
startSpeedMultiplier;
|
|
261
|
+
stopAction;
|
|
262
|
+
useUnscaledTime;
|
|
48
263
|
}
|
|
264
|
+
__decorate([
|
|
265
|
+
serializeable(MinMaxCurve)
|
|
266
|
+
], MainModule.prototype, "gravityModifier", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
serializeable(MinMaxGradient)
|
|
269
|
+
], MainModule.prototype, "startColor", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
serializeable(MinMaxCurve)
|
|
272
|
+
], MainModule.prototype, "startDelay", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
serializeable(MinMaxCurve)
|
|
275
|
+
], MainModule.prototype, "startLifetime", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
serializeable(MinMaxCurve)
|
|
278
|
+
], MainModule.prototype, "startRotation", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
serializeable(MinMaxCurve)
|
|
281
|
+
], MainModule.prototype, "startRotationX", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
serializeable(MinMaxCurve)
|
|
284
|
+
], MainModule.prototype, "startRotationY", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
serializeable(MinMaxCurve)
|
|
287
|
+
], MainModule.prototype, "startRotationZ", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
serializeable(MinMaxCurve)
|
|
290
|
+
], MainModule.prototype, "startSize", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
serializeable(MinMaxCurve)
|
|
293
|
+
], MainModule.prototype, "startSizeX", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
serializeable(MinMaxCurve)
|
|
296
|
+
], MainModule.prototype, "startSizeY", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
serializeable(MinMaxCurve)
|
|
299
|
+
], MainModule.prototype, "startSizeZ", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
serializeable(MinMaxCurve)
|
|
302
|
+
], MainModule.prototype, "startSpeed", void 0);
|
|
49
303
|
export class EmissionModule {
|
|
50
|
-
burstCount
|
|
51
|
-
enabled
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
rateOverDistance
|
|
55
|
-
rateOverDistanceMultiplier
|
|
56
|
-
|
|
57
|
-
|
|
304
|
+
burstCount;
|
|
305
|
+
enabled;
|
|
306
|
+
rateOverTime;
|
|
307
|
+
rateOverTimeMultiplier;
|
|
308
|
+
rateOverDistance;
|
|
309
|
+
rateOverDistanceMultiplier;
|
|
310
|
+
currentParticles = 0;
|
|
311
|
+
maxParticles = Infinity;
|
|
312
|
+
_time = 0;
|
|
313
|
+
_summed = 0;
|
|
314
|
+
// private _didEmit: boolean = false;
|
|
315
|
+
/** called by nebula */
|
|
316
|
+
init() {
|
|
317
|
+
}
|
|
318
|
+
/** called by nebula */
|
|
319
|
+
getValue(deltaTime) {
|
|
320
|
+
if (this.currentParticles >= this.maxParticles)
|
|
321
|
+
return 0;
|
|
322
|
+
// if (this._didEmit) return 0;
|
|
323
|
+
// this._didEmit = true;
|
|
324
|
+
// return 1;
|
|
325
|
+
if (!this.enabled)
|
|
326
|
+
return 0;
|
|
327
|
+
const time = this._time += deltaTime;
|
|
328
|
+
let count = this.rateOverTime.evaluate(time, Math.random());
|
|
329
|
+
this._summed += count * deltaTime;
|
|
330
|
+
const amount = Math.floor(this._summed);
|
|
331
|
+
this._summed -= amount;
|
|
332
|
+
return amount;
|
|
333
|
+
}
|
|
58
334
|
}
|
|
335
|
+
__decorate([
|
|
336
|
+
serializeable(MinMaxCurve)
|
|
337
|
+
], EmissionModule.prototype, "rateOverTime", void 0);
|
|
338
|
+
__decorate([
|
|
339
|
+
serializeable(MinMaxCurve)
|
|
340
|
+
], EmissionModule.prototype, "rateOverDistance", void 0);
|
|
341
|
+
export class ColorOverLifetimeModule {
|
|
342
|
+
enabled;
|
|
343
|
+
color;
|
|
344
|
+
}
|
|
345
|
+
__decorate([
|
|
346
|
+
serializeable(MinMaxGradient)
|
|
347
|
+
], ColorOverLifetimeModule.prototype, "color", void 0);
|
|
348
|
+
export class SizeOverLifetimeModule {
|
|
349
|
+
enabled;
|
|
350
|
+
separateAxes;
|
|
351
|
+
size;
|
|
352
|
+
sizeMultiplier;
|
|
353
|
+
sizeX;
|
|
354
|
+
sizeXMultiplier;
|
|
355
|
+
sizeY;
|
|
356
|
+
sizeYMultiplier;
|
|
357
|
+
sizeZ;
|
|
358
|
+
sizeZMultiplier;
|
|
359
|
+
_time = 0;
|
|
360
|
+
evaluate(t01, target) {
|
|
361
|
+
if (!this.separateAxes) {
|
|
362
|
+
const scale = this.size.evaluate(t01) * this.sizeMultiplier;
|
|
363
|
+
target.x = scale;
|
|
364
|
+
// target.y = scale;
|
|
365
|
+
// target.z = scale;
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
target.x = this.sizeX.evaluate(this._time) * this.sizeXMultiplier;
|
|
369
|
+
// target.y = this.sizeY.evaluate(this._time) * this.sizeYMultiplier;
|
|
370
|
+
// target.z = this.sizeZ.evaluate(this._time) * this.sizeZMultiplier;
|
|
371
|
+
}
|
|
372
|
+
return target;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
__decorate([
|
|
376
|
+
serializeable(MinMaxCurve)
|
|
377
|
+
], SizeOverLifetimeModule.prototype, "size", void 0);
|
|
378
|
+
__decorate([
|
|
379
|
+
serializeable(MinMaxCurve)
|
|
380
|
+
], SizeOverLifetimeModule.prototype, "sizeX", void 0);
|
|
381
|
+
__decorate([
|
|
382
|
+
serializeable(MinMaxCurve)
|
|
383
|
+
], SizeOverLifetimeModule.prototype, "sizeY", void 0);
|
|
384
|
+
__decorate([
|
|
385
|
+
serializeable(MinMaxCurve)
|
|
386
|
+
], SizeOverLifetimeModule.prototype, "sizeZ", void 0);
|
|
59
387
|
export class ShapeModule {
|
|
60
388
|
shapeType = ParticleSystemShapeType.Box;
|
|
61
389
|
enabled = true;
|
|
@@ -64,104 +392,263 @@ export class ShapeModule {
|
|
|
64
392
|
arc = 360;
|
|
65
393
|
arcmode = 0; // TODO: enum?
|
|
66
394
|
// arcSpeed, arcSpeedMult, arcSpread
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
395
|
+
// @serializeable(Vector3)
|
|
396
|
+
// box!: Vector3;
|
|
397
|
+
boxThickness;
|
|
398
|
+
position;
|
|
399
|
+
rotation;
|
|
400
|
+
scale;
|
|
401
|
+
radius;
|
|
402
|
+
radiusThickness;
|
|
403
|
+
sphericalDirectionAmount;
|
|
404
|
+
_space;
|
|
405
|
+
_worldSpacePosition = new Matrix4();
|
|
406
|
+
update(_context, simulationSpace, obj) {
|
|
407
|
+
this._space = simulationSpace;
|
|
408
|
+
if (simulationSpace === ParticleSystemSimulationSpace.World) {
|
|
409
|
+
this._worldSpacePosition.copy(obj.matrixWorld);
|
|
410
|
+
// set scale to 1
|
|
411
|
+
this._worldSpacePosition.elements[0] = 1;
|
|
412
|
+
this._worldSpacePosition.elements[5] = 1;
|
|
413
|
+
this._worldSpacePosition.elements[10] = 1;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/** nebula implementations: */
|
|
417
|
+
/** initializer implementation */
|
|
418
|
+
_vector = new Vector3(0, 0, 0);
|
|
419
|
+
_temp = new Vector3(0, 0, 0);
|
|
420
|
+
/** called by nebula on initialize */
|
|
421
|
+
get vector() {
|
|
422
|
+
return this._vector;
|
|
423
|
+
}
|
|
424
|
+
/** called by nebula */
|
|
425
|
+
getPosition() {
|
|
426
|
+
switch (this.shapeType) {
|
|
427
|
+
case ParticleSystemShapeType.Box:
|
|
428
|
+
this._vector.x = Math.random() * this.scale.x - this.scale.x / 2;
|
|
429
|
+
this._vector.y = Math.random() * this.scale.y - this.scale.y / 2;
|
|
430
|
+
this._vector.z = Math.random() * this.scale.z - this.scale.z / 2;
|
|
431
|
+
break;
|
|
432
|
+
case ParticleSystemShapeType.Sphere:
|
|
433
|
+
randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius, this.radiusThickness, this.arc, this._vector);
|
|
434
|
+
break;
|
|
435
|
+
// case ParticleSystemShapeType.Hemisphere:
|
|
436
|
+
// randomSpherePoint(this.position.x, this.position.y, this.position.z, this.radius, this.radiusThickness, 180, this._vector);
|
|
437
|
+
// break;
|
|
438
|
+
}
|
|
439
|
+
if (this._space === ParticleSystemSimulationSpace.World) {
|
|
440
|
+
this._vector.applyMatrix4(this._worldSpacePosition);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
_dir = new Vector3();
|
|
444
|
+
getDirection(position) {
|
|
445
|
+
switch (this.shapeType) {
|
|
446
|
+
case ParticleSystemShapeType.Box:
|
|
447
|
+
return this._dir.set(0, 0, 1);
|
|
448
|
+
case ParticleSystemShapeType.Sphere:
|
|
449
|
+
const rx = position.x;
|
|
450
|
+
const ry = position.y;
|
|
451
|
+
const rz = position.z;
|
|
452
|
+
return this._dir.set(rx, ry, rz).normalize();
|
|
453
|
+
}
|
|
454
|
+
return this._dir.set(0, 1, 0);
|
|
455
|
+
}
|
|
74
456
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
457
|
+
__decorate([
|
|
458
|
+
serializeable()
|
|
459
|
+
], ShapeModule.prototype, "shapeType", void 0);
|
|
460
|
+
__decorate([
|
|
461
|
+
serializeable()
|
|
462
|
+
], ShapeModule.prototype, "enabled", void 0);
|
|
463
|
+
__decorate([
|
|
464
|
+
serializeable()
|
|
465
|
+
], ShapeModule.prototype, "alignToDirection", void 0);
|
|
466
|
+
__decorate([
|
|
467
|
+
serializeable()
|
|
468
|
+
], ShapeModule.prototype, "angle", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
serializeable()
|
|
471
|
+
], ShapeModule.prototype, "arc", void 0);
|
|
472
|
+
__decorate([
|
|
473
|
+
serializeable()
|
|
474
|
+
], ShapeModule.prototype, "arcmode", void 0);
|
|
475
|
+
__decorate([
|
|
476
|
+
serializeable(Vector3)
|
|
477
|
+
], ShapeModule.prototype, "boxThickness", void 0);
|
|
478
|
+
__decorate([
|
|
479
|
+
serializeable(Vector3)
|
|
480
|
+
], ShapeModule.prototype, "position", void 0);
|
|
481
|
+
__decorate([
|
|
482
|
+
serializeable(Vector3)
|
|
483
|
+
], ShapeModule.prototype, "rotation", void 0);
|
|
484
|
+
__decorate([
|
|
485
|
+
serializeable(Vector3)
|
|
486
|
+
], ShapeModule.prototype, "scale", void 0);
|
|
487
|
+
__decorate([
|
|
488
|
+
serializeable()
|
|
489
|
+
], ShapeModule.prototype, "radius", void 0);
|
|
490
|
+
__decorate([
|
|
491
|
+
serializeable()
|
|
492
|
+
], ShapeModule.prototype, "radiusThickness", void 0);
|
|
493
|
+
__decorate([
|
|
494
|
+
serializeable()
|
|
495
|
+
], ShapeModule.prototype, "sphericalDirectionAmount", void 0);
|
|
496
|
+
function randomSpherePoint(x0, y0, z0, radius, thickness, arc, vec) {
|
|
497
|
+
const u = Math.random();
|
|
498
|
+
const v = Math.random();
|
|
499
|
+
const theta = 2 * Math.PI * u * (arc / 360);
|
|
500
|
+
const phi = Math.acos(2 * v - 1);
|
|
501
|
+
const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * radius;
|
|
502
|
+
const x = x0 + (-r * Math.sin(phi) * Math.cos(theta));
|
|
503
|
+
const y = y0 + (r * Math.sin(phi) * Math.sin(theta));
|
|
504
|
+
const z = z0 + (r * Math.cos(phi));
|
|
505
|
+
vec.x = x;
|
|
506
|
+
vec.y = y;
|
|
507
|
+
vec.z = z;
|
|
508
|
+
}
|
|
509
|
+
import { createNoise4D } from 'simplex-noise';
|
|
510
|
+
import { Context } from "../engine/engine_setup";
|
|
511
|
+
export class NoiseModule {
|
|
512
|
+
damping;
|
|
513
|
+
enabled;
|
|
514
|
+
frequency;
|
|
515
|
+
octaveCount;
|
|
516
|
+
octaveMultiplier;
|
|
517
|
+
octaveScale;
|
|
518
|
+
positionAmount;
|
|
519
|
+
quality;
|
|
520
|
+
remap;
|
|
521
|
+
remapEnabled;
|
|
522
|
+
remapMultiplier;
|
|
523
|
+
remapX;
|
|
524
|
+
remapXMultiplier;
|
|
525
|
+
remapY;
|
|
526
|
+
remapYMultiplier;
|
|
527
|
+
remapZ;
|
|
528
|
+
remapZMultiplier;
|
|
529
|
+
scrollSpeedMultiplier;
|
|
530
|
+
separateAxes;
|
|
531
|
+
strengthMultiplier;
|
|
532
|
+
strengthX;
|
|
533
|
+
strengthXMultiplier;
|
|
534
|
+
strengthY;
|
|
535
|
+
strengthYMultiplier;
|
|
536
|
+
strengthZ;
|
|
537
|
+
strengthZMultiplier;
|
|
538
|
+
_noise;
|
|
539
|
+
_time = 0;
|
|
540
|
+
update(context) {
|
|
541
|
+
this._time += context.time.deltaTime * this.scrollSpeedMultiplier;
|
|
542
|
+
}
|
|
543
|
+
/** nebula implementations: */
|
|
544
|
+
_temp = new Vector3();
|
|
545
|
+
applyNoise(index, pos, vel, deltaTime, age, life) {
|
|
546
|
+
if (!this.enabled)
|
|
547
|
+
return;
|
|
548
|
+
if (!this._noise) {
|
|
549
|
+
this._noise = createNoise4D(() => 0);
|
|
550
|
+
}
|
|
551
|
+
const t = age / life;
|
|
552
|
+
const dt = Context.Current.time.deltaTime;
|
|
553
|
+
const temp = this._temp.set(pos.x, pos.y, pos.z).multiplyScalar(this.frequency);
|
|
554
|
+
const nx = this._noise(temp.x, temp.y, temp.z, this._time);
|
|
555
|
+
const ny = this._noise(temp.x, temp.y, temp.z, this._time + .2);
|
|
556
|
+
const nz = this._noise(temp.x, temp.y, temp.z, this._time + .5);
|
|
557
|
+
this._temp.set(nx, ny, nz).normalize();
|
|
558
|
+
let strengthFactor = this.positionAmount.evaluate(t);
|
|
559
|
+
if (!this.separateAxes) {
|
|
560
|
+
if (this.strengthX)
|
|
561
|
+
strengthFactor *= this.strengthX.evaluate(t, index * 1.1);
|
|
562
|
+
strengthFactor *= this.strengthMultiplier;
|
|
563
|
+
strengthFactor *= .1;
|
|
564
|
+
this._temp.multiplyScalar(strengthFactor);
|
|
565
|
+
}
|
|
566
|
+
if (this.separateAxes) {
|
|
567
|
+
this._temp.x *= strengthFactor * deltaTime * this.strengthXMultiplier;
|
|
568
|
+
this._temp.y *= strengthFactor * deltaTime * this.strengthYMultiplier;
|
|
569
|
+
this._temp.z *= strengthFactor * deltaTime * this.strengthZMultiplier;
|
|
570
|
+
}
|
|
571
|
+
vel.x += this._temp.x;
|
|
572
|
+
vel.y += this._temp.y;
|
|
573
|
+
vel.z += this._temp.z;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
__decorate([
|
|
577
|
+
serializeable()
|
|
578
|
+
], NoiseModule.prototype, "damping", void 0);
|
|
579
|
+
__decorate([
|
|
580
|
+
serializeable()
|
|
581
|
+
], NoiseModule.prototype, "enabled", void 0);
|
|
582
|
+
__decorate([
|
|
583
|
+
serializeable()
|
|
584
|
+
], NoiseModule.prototype, "frequency", void 0);
|
|
585
|
+
__decorate([
|
|
586
|
+
serializeable()
|
|
587
|
+
], NoiseModule.prototype, "octaveCount", void 0);
|
|
588
|
+
__decorate([
|
|
589
|
+
serializeable()
|
|
590
|
+
], NoiseModule.prototype, "octaveMultiplier", void 0);
|
|
591
|
+
__decorate([
|
|
592
|
+
serializeable()
|
|
593
|
+
], NoiseModule.prototype, "octaveScale", void 0);
|
|
594
|
+
__decorate([
|
|
595
|
+
serializeable(MinMaxCurve)
|
|
596
|
+
], NoiseModule.prototype, "positionAmount", void 0);
|
|
597
|
+
__decorate([
|
|
598
|
+
serializeable()
|
|
599
|
+
], NoiseModule.prototype, "quality", void 0);
|
|
600
|
+
__decorate([
|
|
601
|
+
serializeable(MinMaxCurve)
|
|
602
|
+
], NoiseModule.prototype, "remap", void 0);
|
|
603
|
+
__decorate([
|
|
604
|
+
serializeable()
|
|
605
|
+
], NoiseModule.prototype, "remapEnabled", void 0);
|
|
606
|
+
__decorate([
|
|
607
|
+
serializeable()
|
|
608
|
+
], NoiseModule.prototype, "remapMultiplier", void 0);
|
|
609
|
+
__decorate([
|
|
610
|
+
serializeable(MinMaxCurve)
|
|
611
|
+
], NoiseModule.prototype, "remapX", void 0);
|
|
612
|
+
__decorate([
|
|
613
|
+
serializeable()
|
|
614
|
+
], NoiseModule.prototype, "remapXMultiplier", void 0);
|
|
615
|
+
__decorate([
|
|
616
|
+
serializeable(MinMaxCurve)
|
|
617
|
+
], NoiseModule.prototype, "remapY", void 0);
|
|
618
|
+
__decorate([
|
|
619
|
+
serializeable()
|
|
620
|
+
], NoiseModule.prototype, "remapYMultiplier", void 0);
|
|
621
|
+
__decorate([
|
|
622
|
+
serializeable(MinMaxCurve)
|
|
623
|
+
], NoiseModule.prototype, "remapZ", void 0);
|
|
624
|
+
__decorate([
|
|
625
|
+
serializeable()
|
|
626
|
+
], NoiseModule.prototype, "remapZMultiplier", void 0);
|
|
627
|
+
__decorate([
|
|
628
|
+
serializeable()
|
|
629
|
+
], NoiseModule.prototype, "scrollSpeedMultiplier", void 0);
|
|
630
|
+
__decorate([
|
|
631
|
+
serializeable()
|
|
632
|
+
], NoiseModule.prototype, "separateAxes", void 0);
|
|
633
|
+
__decorate([
|
|
634
|
+
serializeable()
|
|
635
|
+
], NoiseModule.prototype, "strengthMultiplier", void 0);
|
|
636
|
+
__decorate([
|
|
637
|
+
serializeable(MinMaxCurve)
|
|
638
|
+
], NoiseModule.prototype, "strengthX", void 0);
|
|
639
|
+
__decorate([
|
|
640
|
+
serializeable()
|
|
641
|
+
], NoiseModule.prototype, "strengthXMultiplier", void 0);
|
|
642
|
+
__decorate([
|
|
643
|
+
serializeable(MinMaxCurve)
|
|
644
|
+
], NoiseModule.prototype, "strengthY", void 0);
|
|
645
|
+
__decorate([
|
|
646
|
+
serializeable()
|
|
647
|
+
], NoiseModule.prototype, "strengthYMultiplier", void 0);
|
|
648
|
+
__decorate([
|
|
649
|
+
serializeable(MinMaxCurve)
|
|
650
|
+
], NoiseModule.prototype, "strengthZ", void 0);
|
|
651
|
+
__decorate([
|
|
652
|
+
serializeable()
|
|
653
|
+
], NoiseModule.prototype, "strengthZMultiplier", void 0);
|
|
167
654
|
//# sourceMappingURL=ParticleSystemModules.js.map
|