phoria2 1.1.0 → 1.3.0
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/README.md +70 -13
- package/dist/bloom.js +4 -4
- package/dist/bloom.js.map +1 -1
- package/dist/charts.js +538 -508
- package/dist/charts.js.map +1 -1
- package/dist/core.js +4270 -3652
- package/dist/core.js.map +1 -1
- package/dist/edit.js +65 -65
- package/dist/edit.js.map +1 -1
- package/dist/explain.js +6 -2
- package/dist/explain.js.map +1 -1
- package/dist/gltf.js +116 -116
- package/dist/gltf.js.map +1 -1
- package/dist/keyboard.js +188 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/motion.js +35 -35
- package/dist/motion.js.map +1 -1
- package/dist/particles.js +188 -115
- package/dist/particles.js.map +1 -1
- package/dist/passes.js +29 -29
- package/dist/passes.js.map +1 -1
- package/dist/phoria2.js +1 -1
- package/dist/picking.js +32 -16
- package/dist/picking.js.map +1 -1
- package/dist/snapshot.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/types/OrbitControl.d.ts +6 -2
- package/dist/types/Raycaster.d.ts +10 -0
- package/dist/types/View.d.ts +70 -1
- package/dist/types/area.d.ts +18 -0
- package/dist/types/charts/Chart.d.ts +7 -0
- package/dist/types/explain.d.ts +3 -0
- package/dist/types/frame.d.ts +7 -0
- package/dist/types/geometry/Geometry.d.ts +24 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/keyboard.d.ts +48 -0
- package/dist/types/labels.d.ts +4 -0
- package/dist/types/material/Material.d.ts +15 -0
- package/dist/types/material/Texture.d.ts +18 -2
- package/dist/types/particles/Emitter.d.ts +39 -2
- package/dist/types/scene/Node.d.ts +19 -14
- package/dist/types/scene/drawables.d.ts +54 -15
- package/dist/types/scene/lights.d.ts +16 -2
- package/dist/types/shadow.d.ts +2 -1
- package/dist/types/types.d.ts +14 -0
- package/dist/types/value/Color.d.ts +0 -4
- package/dist/types/value/Quat.d.ts +4 -2
- package/dist/types/webgl/resources.d.ts +12 -2
- package/dist/types/webgl/shaders.d.ts +7 -2
- package/llms-full.txt +106 -10
- package/package.json +4 -1
- package/schema/scene.schema.json +67 -1
- package/src/OrbitControl.js +7 -3
- package/src/Raycaster.js +58 -0
- package/src/View.js +220 -41
- package/src/area.js +131 -0
- package/src/charts/Chart.js +20 -2
- package/src/charts/marks.js +29 -2
- package/src/explain.js +6 -2
- package/src/frame.js +29 -9
- package/src/geometry/Geometry.js +32 -4
- package/src/index.js +1 -0
- package/src/keyboard.js +298 -0
- package/src/labels.js +4 -1
- package/src/material/Material.js +9 -2
- package/src/material/Texture.js +55 -2
- package/src/particles/Emitter.js +121 -10
- package/src/scene/Node.js +20 -9
- package/src/scene/Scene.js +2 -0
- package/src/scene/cameras.js +4 -1
- package/src/scene/drawables.js +115 -15
- package/src/scene/lights.js +40 -6
- package/src/shadow.js +27 -4
- package/src/types.js +6 -0
- package/src/value/Color.js +21 -0
- package/src/value/Quat.js +15 -6
- package/src/watch.js +14 -2
- package/src/webgl/WebGLRenderer.js +36 -5
- package/src/webgl/picking.js +22 -1
- package/src/webgl/resources.js +168 -14
- package/src/webgl/shaders.js +110 -11
package/dist/particles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Et as e, It as t, Ot as n, at as r, jt as i, kt as a, lt as o, ot as s, tt as c, vt as l, wt as u } from "./core.js";
|
|
2
2
|
// src/particles/Emitter.js
|
|
3
3
|
var d = [
|
|
4
4
|
"origin",
|
|
@@ -8,41 +8,47 @@ var d = [
|
|
|
8
8
|
"lifetime",
|
|
9
9
|
"color"
|
|
10
10
|
], f = [
|
|
11
|
-
...u.OPTIONS,
|
|
12
|
-
...d,
|
|
13
|
-
"max",
|
|
14
11
|
"rate",
|
|
15
12
|
"gravity",
|
|
16
13
|
"drag",
|
|
17
14
|
"follow",
|
|
18
|
-
"onParticle"
|
|
19
|
-
|
|
15
|
+
"onParticle",
|
|
16
|
+
"size",
|
|
17
|
+
"sizeSpread",
|
|
18
|
+
"opacity",
|
|
19
|
+
"spin"
|
|
20
|
+
], p = [
|
|
21
|
+
...c.OPTIONS,
|
|
22
|
+
...d,
|
|
23
|
+
"max",
|
|
24
|
+
...f
|
|
25
|
+
], m = {
|
|
20
26
|
count: "use 'max' for the most particles alive at once, 'rate' for how many are born per second",
|
|
21
27
|
lifetimeRnd: "give 'lifetime' a [min, max] range",
|
|
22
28
|
velocityRnd: "use 'velocitySpread'",
|
|
23
29
|
positionRnd: "use 'originSpread'"
|
|
24
|
-
},
|
|
30
|
+
}, h = {
|
|
25
31
|
size: .1,
|
|
26
32
|
vertexColors: !0,
|
|
27
33
|
blending: "additive",
|
|
28
34
|
depthWrite: !1
|
|
29
|
-
},
|
|
35
|
+
}, g = /* @__PURE__ */ new Float32Array(16), _ = class extends c {
|
|
30
36
|
static type = "emitter";
|
|
31
37
|
static get OPTIONS() {
|
|
32
|
-
return
|
|
38
|
+
return p;
|
|
33
39
|
}
|
|
34
40
|
static get HINTS() {
|
|
35
41
|
return {
|
|
36
|
-
...
|
|
37
|
-
...
|
|
42
|
+
...c.HINTS,
|
|
43
|
+
...m
|
|
38
44
|
};
|
|
39
45
|
}
|
|
40
46
|
rate = 100;
|
|
41
|
-
gravity = new
|
|
47
|
+
gravity = new u();
|
|
42
48
|
drag = 0;
|
|
43
|
-
origin = new
|
|
49
|
+
origin = new u();
|
|
44
50
|
originSpread = 0;
|
|
45
|
-
velocity = new
|
|
51
|
+
velocity = new u(0, 1, 0);
|
|
46
52
|
velocitySpread = 0;
|
|
47
53
|
lifetime = [1, 1];
|
|
48
54
|
follow = null;
|
|
@@ -61,43 +67,42 @@ var d = [
|
|
|
61
67
|
#s = /* @__PURE__ */ new Map();
|
|
62
68
|
#c;
|
|
63
69
|
#l = 0;
|
|
64
|
-
#u =
|
|
65
|
-
#d =
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
#u = [1];
|
|
71
|
+
#d = 0;
|
|
72
|
+
#f = [1];
|
|
73
|
+
#p = [0, 0];
|
|
74
|
+
#m = null;
|
|
75
|
+
#h = null;
|
|
76
|
+
#g = null;
|
|
77
|
+
#_ = {
|
|
78
|
+
position: new u(),
|
|
79
|
+
velocity: new u(),
|
|
68
80
|
age: 0,
|
|
69
81
|
lifetime: 0
|
|
70
82
|
};
|
|
71
|
-
constructor(
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
(!Number.isInteger(
|
|
75
|
-
let
|
|
76
|
-
|
|
77
|
-
let
|
|
78
|
-
...
|
|
79
|
-
...
|
|
83
|
+
constructor(e = {}) {
|
|
84
|
+
e?.geometry !== void 0 && i("Emitter", "an Emitter makes its own geometry - size it with 'max'");
|
|
85
|
+
let t = e?.max ?? 1e3;
|
|
86
|
+
(!Number.isInteger(t) || t < 1) && i("Emitter", `'max' must be a whole number of 1 or more, got ${a(t)}`);
|
|
87
|
+
let n = e?.material;
|
|
88
|
+
n === void 0 || n instanceof s || n && typeof n == "object" && !Array.isArray(n) || i("Emitter", `'material' is a Material or material options such as { size: 0.2 }, got ${a(n)}`);
|
|
89
|
+
let r = n instanceof s ? n : {
|
|
90
|
+
...h,
|
|
91
|
+
...n
|
|
80
92
|
}, c = new o({
|
|
81
|
-
positions: new Float32Array(
|
|
82
|
-
colors: new Float32Array(
|
|
93
|
+
positions: new Float32Array(t * 3),
|
|
94
|
+
colors: new Float32Array(t * 3)
|
|
83
95
|
});
|
|
84
96
|
c.drawCount = 0, super({
|
|
85
|
-
...
|
|
97
|
+
...e,
|
|
86
98
|
geometry: c,
|
|
87
|
-
material:
|
|
88
|
-
}), this.#e =
|
|
89
|
-
}
|
|
90
|
-
set(
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"gravity",
|
|
95
|
-
"drag",
|
|
96
|
-
"follow",
|
|
97
|
-
"onParticle"
|
|
98
|
-
];
|
|
99
|
-
for (let r of Object.keys(t ?? {})) n.includes(r) || e("Emitter", `set() doesn't take '${r}' - it takes ${n.join(", ")}`);
|
|
100
|
-
return this.#v(t), this.#_(t), this;
|
|
99
|
+
material: r
|
|
100
|
+
}), this.#e = t, this.#r = new Float32Array(t * 3), this.#i = new Float32Array(t), this.#a = new Float32Array(t), this.#c = new Uint8Array(t), e.frustumCulled === void 0 && (this.frustumCulled = !1), this.#w(e), this.#C(e), this.onUpdate((e, t) => this.step(t));
|
|
101
|
+
}
|
|
102
|
+
set(e) {
|
|
103
|
+
let t = [...d, ...f];
|
|
104
|
+
for (let n of Object.keys(e ?? {})) t.includes(n) || i("Emitter", `set() doesn't take '${n}' - it takes ${t.join(", ")}`);
|
|
105
|
+
return this.#w(e), this.#C(e), this;
|
|
101
106
|
}
|
|
102
107
|
get max() {
|
|
103
108
|
return this.#e;
|
|
@@ -106,61 +111,86 @@ var d = [
|
|
|
106
111
|
return this.#t;
|
|
107
112
|
}
|
|
108
113
|
set color(e) {
|
|
109
|
-
this.#o[0] =
|
|
114
|
+
this.#o[0] = w(e);
|
|
110
115
|
}
|
|
111
116
|
get color() {
|
|
112
117
|
return this.#o[0].map((e) => [...e]);
|
|
113
118
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
set size(e) {
|
|
120
|
+
this.#T({ size: e });
|
|
121
|
+
}
|
|
122
|
+
get size() {
|
|
123
|
+
return [...this.#u];
|
|
124
|
+
}
|
|
125
|
+
set sizeSpread(e) {
|
|
126
|
+
this.#T({ sizeSpread: e });
|
|
127
|
+
}
|
|
128
|
+
get sizeSpread() {
|
|
129
|
+
return this.#d;
|
|
130
|
+
}
|
|
131
|
+
set opacity(e) {
|
|
132
|
+
this.#T({ opacity: e });
|
|
133
|
+
}
|
|
134
|
+
get opacity() {
|
|
135
|
+
return [...this.#f];
|
|
136
|
+
}
|
|
137
|
+
set spin(e) {
|
|
138
|
+
this.#T({ spin: e });
|
|
139
|
+
}
|
|
140
|
+
get spin() {
|
|
141
|
+
return [...this.#p];
|
|
142
|
+
}
|
|
143
|
+
burst(e, t = {}) {
|
|
144
|
+
for (let e of Object.keys(t)) d.includes(e) || i("Emitter", `burst() doesn't take '${e}' - it takes ${d.join(", ")}`);
|
|
145
|
+
let { color: n, ...r } = t, a = this.#D();
|
|
146
|
+
this.#C(r), n !== void 0 && (this.#l = this.#O(w(n)));
|
|
118
147
|
let o = this.origin.clone();
|
|
119
|
-
for (let
|
|
120
|
-
return this.#
|
|
148
|
+
for (let t = 0; t < e; t++) this.#v(o, o, 0);
|
|
149
|
+
return this.#C(a), this.#l = 0, this.#x(), this;
|
|
121
150
|
}
|
|
122
151
|
clear() {
|
|
123
|
-
return this.#t = 0, this.#n = 0, this.#
|
|
152
|
+
return this.#t = 0, this.#n = 0, this.#x(), this;
|
|
124
153
|
}
|
|
125
154
|
step(e) {
|
|
126
155
|
if (e <= 0) return;
|
|
127
|
-
let t = this.geometry.positions, n = this.#r, r = this.#i, i = this.#a, a = this.gravity, o = Math.exp(-this.drag * e), s = this.onParticle, c = this.#
|
|
128
|
-
for (let
|
|
129
|
-
let
|
|
130
|
-
if (
|
|
131
|
-
this.#
|
|
156
|
+
let t = this.geometry.positions, n = this.#r, r = this.#i, i = this.#a, a = this.gravity, o = Math.exp(-this.drag * e), s = this.onParticle, c = this.#_, l = this.geometry.angles, u = this.#h;
|
|
157
|
+
for (let d = 0; d < this.#t;) {
|
|
158
|
+
let f = r[d] += e;
|
|
159
|
+
if (f >= i[d]) {
|
|
160
|
+
this.#y(d);
|
|
132
161
|
continue;
|
|
133
162
|
}
|
|
134
|
-
let
|
|
135
|
-
for (let r = 0; r < 3; r++) n[
|
|
136
|
-
if (this.#
|
|
137
|
-
if (c.position.set(t[
|
|
138
|
-
this.#
|
|
163
|
+
let p = d * 3;
|
|
164
|
+
for (let r = 0; r < 3; r++) n[p + r] = (n[p + r] + a[r] * e) * o, t[p + r] += n[p + r] * e;
|
|
165
|
+
if (l && u && (l[d] += u[d] * e), this.#b(d, f / i[d]), s) {
|
|
166
|
+
if (c.position.set(t[p], t[p + 1], t[p + 2]), c.velocity.set(n[p], n[p + 1], n[p + 2]), c.age = f, c.lifetime = i[d], s(c) === !1) {
|
|
167
|
+
this.#y(d);
|
|
139
168
|
continue;
|
|
140
169
|
}
|
|
141
|
-
t.set(c.position,
|
|
170
|
+
t.set(c.position, p), n.set(c.velocity, p);
|
|
142
171
|
}
|
|
143
|
-
|
|
172
|
+
d++;
|
|
144
173
|
}
|
|
145
|
-
let
|
|
174
|
+
let d = this.#S(), f = this.#g ?? d;
|
|
146
175
|
this.#n += this.rate * e;
|
|
147
|
-
let
|
|
148
|
-
this.#n -=
|
|
149
|
-
for (let t = 0; t <
|
|
150
|
-
this.#
|
|
176
|
+
let p = Math.floor(this.#n);
|
|
177
|
+
this.#n -= p;
|
|
178
|
+
for (let t = 0; t < p; t++) this.#v(f, d, (t + Math.random()) / p * e);
|
|
179
|
+
this.#g = d.clone(), this.#x();
|
|
151
180
|
}
|
|
152
181
|
cloneOptions() {
|
|
153
182
|
let e = super.cloneOptions();
|
|
154
183
|
return delete e.geometry, {
|
|
155
184
|
...e,
|
|
156
|
-
...this.#
|
|
185
|
+
...this.#D(),
|
|
157
186
|
max: this.#e,
|
|
158
187
|
rate: this.rate,
|
|
159
188
|
gravity: this.gravity.clone(),
|
|
160
189
|
drag: this.drag,
|
|
161
190
|
follow: this.follow,
|
|
162
191
|
onParticle: this.onParticle,
|
|
163
|
-
color: this.color
|
|
192
|
+
color: this.color,
|
|
193
|
+
...this.#E()
|
|
164
194
|
};
|
|
165
195
|
}
|
|
166
196
|
jsonOptions() {
|
|
@@ -176,56 +206,83 @@ var d = [
|
|
|
176
206
|
velocity: this.velocity.toArray(),
|
|
177
207
|
velocitySpread: typeof this.velocitySpread == "number" ? this.velocitySpread : this.velocitySpread.toArray(),
|
|
178
208
|
lifetime: [...this.lifetime],
|
|
179
|
-
color: this.#o[0].map((e) => new
|
|
209
|
+
color: this.#o[0].map((e) => new l().setSRGB(e[0], e[1], e[2]).toJSON()),
|
|
210
|
+
...this.#E()
|
|
180
211
|
};
|
|
181
212
|
}
|
|
182
|
-
#
|
|
213
|
+
#v(e, t, n) {
|
|
183
214
|
if (this.#t >= this.#e) return;
|
|
184
|
-
let r = this.#t++, i = r * 3, a = this.geometry.positions, o = this.#r, s = Math.random(), c =
|
|
215
|
+
let r = this.#t++, i = r * 3, a = this.geometry.positions, o = this.#r, s = Math.random(), c = T(this.originSpread), l = this.velocitySpread, u = typeof l == "number" ? T(l) : [
|
|
185
216
|
(Math.random() * 2 - 1) * l[0],
|
|
186
217
|
(Math.random() * 2 - 1) * l[1],
|
|
187
218
|
(Math.random() * 2 - 1) * l[2]
|
|
188
219
|
];
|
|
189
220
|
for (let r = 0; r < 3; r++) o[i + r] = this.velocity[r] + u[r], a[i + r] = e[r] + (t[r] - e[r]) * s + c[r] + o[i + r] * n;
|
|
190
221
|
let [d, f] = this.lifetime;
|
|
191
|
-
this.#a[r] = d + Math.random() * (f - d), this.#i[r] = n, this.#c[r] = this.#l, this.#m
|
|
222
|
+
this.#a[r] = d + Math.random() * (f - d), this.#i[r] = n, this.#c[r] = this.#l, this.#m && (this.#m[r] = 1 + (Math.random() * 2 - 1) * this.#d);
|
|
223
|
+
let p = this.geometry.angles, m = this.#h;
|
|
224
|
+
p && m && (m[r] = this.#p[0] + Math.random() * (this.#p[1] - this.#p[0]), p[r] = Math.random() * Math.PI * 2 + m[r] * n), this.#b(r, n / this.#a[r]);
|
|
192
225
|
}
|
|
193
|
-
#
|
|
226
|
+
#y(e) {
|
|
194
227
|
let t = --this.#t;
|
|
195
228
|
if (e === t) return;
|
|
196
229
|
let n = this.geometry.positions, r = this.geometry.colors, i = this.#r;
|
|
197
230
|
n.copyWithin(e * 3, t * 3, t * 3 + 3), r.copyWithin(e * 3, t * 3, t * 3 + 3), i.copyWithin(e * 3, t * 3, t * 3 + 3), this.#i[e] = this.#i[t], this.#a[e] = this.#a[t], this.#c[e] = this.#c[t];
|
|
231
|
+
for (let n of [
|
|
232
|
+
this.geometry.sizes,
|
|
233
|
+
this.geometry.opacities,
|
|
234
|
+
this.geometry.angles,
|
|
235
|
+
this.#m,
|
|
236
|
+
this.#h
|
|
237
|
+
]) n && (n[e] = n[t]);
|
|
198
238
|
}
|
|
199
|
-
#
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
|
|
239
|
+
#b(e, t) {
|
|
240
|
+
let { sizes: n, opacities: r } = this.geometry;
|
|
241
|
+
n && (n[e] = S(this.#u, t) * (this.#m ? this.#m[e] : 1)), r && (r[e] = S(this.#f, t));
|
|
242
|
+
let i = this.geometry.colors, a = this.#o[this.#c[e]];
|
|
243
|
+
if (a.length === 1) {
|
|
244
|
+
i.set(a[0], e * 3);
|
|
203
245
|
return;
|
|
204
246
|
}
|
|
205
|
-
let
|
|
206
|
-
|
|
247
|
+
let o = Math.min(Math.max(t, 0), 1) * (a.length - 1), s = Math.min(Math.floor(o), a.length - 2), c = o - s, l = a[s], u = a[s + 1];
|
|
248
|
+
i[e * 3] = l[0] + (u[0] - l[0]) * c, i[e * 3 + 1] = l[1] + (u[1] - l[1]) * c, i[e * 3 + 2] = l[2] + (u[2] - l[2]) * c;
|
|
207
249
|
}
|
|
208
|
-
#
|
|
250
|
+
#x() {
|
|
209
251
|
this.geometry.drawCount = this.#t, this.geometry.needsUpdate();
|
|
210
252
|
}
|
|
211
|
-
#
|
|
253
|
+
#S() {
|
|
212
254
|
if (!this.follow) return this.origin;
|
|
213
255
|
let e = this.follow.worldPosition;
|
|
214
|
-
return
|
|
256
|
+
return t(g, this.worldMatrix) ? this.origin.copy(e).applyMatrix4(g) : this.origin;
|
|
215
257
|
}
|
|
216
|
-
#
|
|
258
|
+
#C(t) {
|
|
217
259
|
let n = "Emitter";
|
|
218
|
-
if (
|
|
219
|
-
let r =
|
|
220
|
-
typeof r == "number" ? this.velocitySpread =
|
|
260
|
+
if (t.origin !== void 0 && this.origin.copy(t.origin, n), t.originSpread !== void 0 && (this.originSpread = Math.max(0, e(n, "originSpread", t.originSpread))), t.velocity !== void 0 && this.velocity.copy(t.velocity, n), t.velocitySpread !== void 0) {
|
|
261
|
+
let r = t.velocitySpread;
|
|
262
|
+
typeof r == "number" ? this.velocitySpread = e(n, "velocitySpread", r) : this.velocitySpread instanceof u ? this.velocitySpread.copy(r, n) : this.velocitySpread = u.fromInput(r, n);
|
|
221
263
|
}
|
|
222
|
-
|
|
264
|
+
t.lifetime !== void 0 && (this.lifetime = y(t.lifetime)), t.color !== void 0 && (this.#o[0] = w(t.color));
|
|
223
265
|
}
|
|
224
|
-
#
|
|
225
|
-
|
|
226
|
-
|
|
266
|
+
#w(t) {
|
|
267
|
+
this.#T(t);
|
|
268
|
+
let n = "Emitter";
|
|
269
|
+
t.rate !== void 0 && (this.rate = Math.max(0, e(n, "rate", t.rate))), t.gravity !== void 0 && this.gravity.copy(t.gravity, n), t.drag !== void 0 && (this.drag = Math.max(0, e(n, "drag", t.drag))), t.follow !== void 0 && (this.follow = v(t.follow)), t.onParticle !== void 0 && (this.onParticle = t.onParticle);
|
|
270
|
+
}
|
|
271
|
+
#T(t) {
|
|
272
|
+
let n = this.geometry, r = this.#e;
|
|
273
|
+
t.size !== void 0 && (this.#u = b("size", t.size, Infinity)), t.sizeSpread !== void 0 && (this.#d = Math.min(Math.max(e("Emitter", "sizeSpread", t.sizeSpread), 0), 1)), t.opacity !== void 0 && (this.#f = b("opacity", t.opacity, 1)), t.spin !== void 0 && (this.#p = C(t.spin));
|
|
274
|
+
let i = (e) => e.length === 1 && e[0] === 1;
|
|
275
|
+
!n.sizes && (!i(this.#u) || this.#d) && (n.sizes = new Float32Array(r).fill(1)), !this.#m && this.#d && (this.#m = new Float32Array(r).fill(1)), !n.opacities && !i(this.#f) && (n.opacities = new Float32Array(r).fill(1)), !n.angles && (this.#p[0] || this.#p[1]) && (n.angles = new Float32Array(r), this.#h = new Float32Array(r));
|
|
276
|
+
}
|
|
277
|
+
#E() {
|
|
278
|
+
return {
|
|
279
|
+
size: x(this.#u),
|
|
280
|
+
sizeSpread: this.#d,
|
|
281
|
+
opacity: x(this.#f),
|
|
282
|
+
spin: [...this.#p]
|
|
283
|
+
};
|
|
227
284
|
}
|
|
228
|
-
#
|
|
285
|
+
#D() {
|
|
229
286
|
return {
|
|
230
287
|
origin: this.origin.clone(),
|
|
231
288
|
originSpread: this.originSpread,
|
|
@@ -234,7 +291,7 @@ var d = [
|
|
|
234
291
|
lifetime: [...this.lifetime]
|
|
235
292
|
};
|
|
236
293
|
}
|
|
237
|
-
#
|
|
294
|
+
#O(e) {
|
|
238
295
|
let t = e.flat().join(), n = this.#s.get(t);
|
|
239
296
|
if (n === void 0) {
|
|
240
297
|
n = this.#o.length < 256 ? this.#o.length : 1 + this.#s.size % 255;
|
|
@@ -244,18 +301,34 @@ var d = [
|
|
|
244
301
|
return this.#o[n] = e, n;
|
|
245
302
|
}
|
|
246
303
|
};
|
|
247
|
-
function
|
|
248
|
-
return
|
|
304
|
+
function v(e) {
|
|
305
|
+
return e === null || e instanceof r ? e : i("Emitter", `'follow' must be a node, got ${a(e)}`);
|
|
306
|
+
}
|
|
307
|
+
function y(e) {
|
|
308
|
+
let t = typeof e == "number" ? [e, e] : e;
|
|
309
|
+
return Array.isArray(t) && t.length === 2 && t.every((e) => typeof e == "number" && e > 0) || i("Emitter", `'lifetime' must be seconds above 0, or a [min, max] range, got ${a(e)}`), [Math.min(t[0], t[1]), Math.max(t[0], t[1])];
|
|
310
|
+
}
|
|
311
|
+
function b(e, t, n) {
|
|
312
|
+
let r = Array.isArray(t) ? t : [t];
|
|
313
|
+
return r.length && r.every((e) => typeof e == "number" && Number.isFinite(e) && e >= 0) || i("Emitter", `'${e}' must be a number of 0 or more, or a list of them a particle goes through, got ${a(t)}`), r.map((e) => Math.min(e, n));
|
|
314
|
+
}
|
|
315
|
+
function x(e) {
|
|
316
|
+
return e.length === 1 ? e[0] : [...e];
|
|
249
317
|
}
|
|
250
|
-
function
|
|
251
|
-
|
|
252
|
-
|
|
318
|
+
function S(e, t) {
|
|
319
|
+
if (e.length === 1) return e[0];
|
|
320
|
+
let n = Math.min(Math.max(t, 0), 1) * (e.length - 1), r = Math.min(Math.floor(n), e.length - 2);
|
|
321
|
+
return e[r] + (e[r + 1] - e[r]) * (n - r);
|
|
253
322
|
}
|
|
254
|
-
function
|
|
255
|
-
let
|
|
256
|
-
return
|
|
323
|
+
function C(e) {
|
|
324
|
+
let t = typeof e == "number" ? [-Math.abs(e), Math.abs(e)] : e;
|
|
325
|
+
return Array.isArray(t) && t.length === 2 && t.every((e) => typeof e == "number" && Number.isFinite(e)) || i("Emitter", `'spin' must be radians per second, or a [min, max] range, got ${a(e)}`), [Math.min(t[0], t[1]), Math.max(t[0], t[1])];
|
|
257
326
|
}
|
|
258
|
-
function
|
|
327
|
+
function w(e) {
|
|
328
|
+
let t = Array.isArray(e) && !(e.length === 3 && e.every((e) => typeof e == "number")) ? e : [e];
|
|
329
|
+
return t.length || i("Emitter", "'color' needs at least one colour"), t.map((e) => l.fromInput(e, "Emitter").toSRGB());
|
|
330
|
+
}
|
|
331
|
+
function T(e) {
|
|
259
332
|
if (!e) return [
|
|
260
333
|
0,
|
|
261
334
|
0,
|
|
@@ -272,30 +345,30 @@ function b(e) {
|
|
|
272
345
|
];
|
|
273
346
|
}
|
|
274
347
|
// src/particles/Body.js
|
|
275
|
-
var
|
|
348
|
+
var E = [
|
|
276
349
|
"velocity",
|
|
277
350
|
"gravity",
|
|
278
351
|
"drag"
|
|
279
|
-
],
|
|
352
|
+
], D = {
|
|
280
353
|
impulse: "call body.impulse([x, y, z]) after creating it",
|
|
281
354
|
mass: "a Body has no mass - impulse() changes velocity directly"
|
|
282
|
-
},
|
|
283
|
-
static OPTIONS =
|
|
284
|
-
static HINTS =
|
|
285
|
-
velocity = new
|
|
286
|
-
gravity = new
|
|
355
|
+
}, O = class {
|
|
356
|
+
static OPTIONS = E;
|
|
357
|
+
static HINTS = D;
|
|
358
|
+
velocity = new u();
|
|
359
|
+
gravity = new u();
|
|
287
360
|
drag = 0;
|
|
288
|
-
constructor(
|
|
289
|
-
n("Body",
|
|
361
|
+
constructor(t = {}) {
|
|
362
|
+
n("Body", t, E, D), t.velocity !== void 0 && this.velocity.copy(t.velocity, "Body"), t.gravity !== void 0 && this.gravity.copy(t.gravity, "Body"), t.drag !== void 0 && (this.drag = Math.max(0, e("Body", "drag", t.drag)));
|
|
290
363
|
}
|
|
291
364
|
impulse(e) {
|
|
292
|
-
return this.velocity.add(
|
|
365
|
+
return this.velocity.add(u.fromInput(e, "Body")), this;
|
|
293
366
|
}
|
|
294
367
|
update = (e, t) => {
|
|
295
368
|
let n = this.velocity, r = Math.exp(-this.drag * t);
|
|
296
369
|
for (let i = 0; i < 3; i++) n[i] = (n[i] + this.gravity[i] * t) * r, e.position[i] += n[i] * t;
|
|
297
370
|
};
|
|
298
371
|
};
|
|
299
|
-
export {
|
|
372
|
+
export { O as Body, _ as Emitter };
|
|
300
373
|
|
|
301
374
|
//# sourceMappingURL=particles.js.map
|