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.
Files changed (81) hide show
  1. package/README.md +70 -13
  2. package/dist/bloom.js +4 -4
  3. package/dist/bloom.js.map +1 -1
  4. package/dist/charts.js +538 -508
  5. package/dist/charts.js.map +1 -1
  6. package/dist/core.js +4270 -3652
  7. package/dist/core.js.map +1 -1
  8. package/dist/edit.js +65 -65
  9. package/dist/edit.js.map +1 -1
  10. package/dist/explain.js +6 -2
  11. package/dist/explain.js.map +1 -1
  12. package/dist/gltf.js +116 -116
  13. package/dist/gltf.js.map +1 -1
  14. package/dist/keyboard.js +188 -0
  15. package/dist/keyboard.js.map +1 -0
  16. package/dist/motion.js +35 -35
  17. package/dist/motion.js.map +1 -1
  18. package/dist/particles.js +188 -115
  19. package/dist/particles.js.map +1 -1
  20. package/dist/passes.js +29 -29
  21. package/dist/passes.js.map +1 -1
  22. package/dist/phoria2.js +1 -1
  23. package/dist/picking.js +32 -16
  24. package/dist/picking.js.map +1 -1
  25. package/dist/snapshot.js +1 -1
  26. package/dist/tooltip.js +1 -1
  27. package/dist/types/OrbitControl.d.ts +6 -2
  28. package/dist/types/Raycaster.d.ts +10 -0
  29. package/dist/types/View.d.ts +70 -1
  30. package/dist/types/area.d.ts +18 -0
  31. package/dist/types/charts/Chart.d.ts +7 -0
  32. package/dist/types/explain.d.ts +3 -0
  33. package/dist/types/frame.d.ts +7 -0
  34. package/dist/types/geometry/Geometry.d.ts +24 -2
  35. package/dist/types/index.d.ts +2 -0
  36. package/dist/types/keyboard.d.ts +48 -0
  37. package/dist/types/labels.d.ts +4 -0
  38. package/dist/types/material/Material.d.ts +15 -0
  39. package/dist/types/material/Texture.d.ts +18 -2
  40. package/dist/types/particles/Emitter.d.ts +39 -2
  41. package/dist/types/scene/Node.d.ts +19 -14
  42. package/dist/types/scene/drawables.d.ts +54 -15
  43. package/dist/types/scene/lights.d.ts +16 -2
  44. package/dist/types/shadow.d.ts +2 -1
  45. package/dist/types/types.d.ts +14 -0
  46. package/dist/types/value/Color.d.ts +0 -4
  47. package/dist/types/value/Quat.d.ts +4 -2
  48. package/dist/types/webgl/resources.d.ts +12 -2
  49. package/dist/types/webgl/shaders.d.ts +7 -2
  50. package/llms-full.txt +106 -10
  51. package/package.json +4 -1
  52. package/schema/scene.schema.json +67 -1
  53. package/src/OrbitControl.js +7 -3
  54. package/src/Raycaster.js +58 -0
  55. package/src/View.js +220 -41
  56. package/src/area.js +131 -0
  57. package/src/charts/Chart.js +20 -2
  58. package/src/charts/marks.js +29 -2
  59. package/src/explain.js +6 -2
  60. package/src/frame.js +29 -9
  61. package/src/geometry/Geometry.js +32 -4
  62. package/src/index.js +1 -0
  63. package/src/keyboard.js +298 -0
  64. package/src/labels.js +4 -1
  65. package/src/material/Material.js +9 -2
  66. package/src/material/Texture.js +55 -2
  67. package/src/particles/Emitter.js +121 -10
  68. package/src/scene/Node.js +20 -9
  69. package/src/scene/Scene.js +2 -0
  70. package/src/scene/cameras.js +4 -1
  71. package/src/scene/drawables.js +115 -15
  72. package/src/scene/lights.js +40 -6
  73. package/src/shadow.js +27 -4
  74. package/src/types.js +6 -0
  75. package/src/value/Color.js +21 -0
  76. package/src/value/Quat.js +15 -6
  77. package/src/watch.js +14 -2
  78. package/src/webgl/WebGLRenderer.js +36 -5
  79. package/src/webgl/picking.js +22 -1
  80. package/src/webgl/resources.js +168 -14
  81. package/src/webgl/shaders.js +110 -11
package/dist/particles.js CHANGED
@@ -1,4 +1,4 @@
1
- import { At as e, Ct as t, Dt as n, Ft as r, L as i, Ot as a, R as o, Tt as s, _t as c, at as l, w as u } from "./core.js";
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
- ], p = {
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
- }, m = {
30
+ }, h = {
25
31
  size: .1,
26
32
  vertexColors: !0,
27
33
  blending: "additive",
28
34
  depthWrite: !1
29
- }, h = /* @__PURE__ */ new Float32Array(16), g = class extends u {
35
+ }, g = /* @__PURE__ */ new Float32Array(16), _ = class extends c {
30
36
  static type = "emitter";
31
37
  static get OPTIONS() {
32
- return f;
38
+ return p;
33
39
  }
34
40
  static get HINTS() {
35
41
  return {
36
- ...u.HINTS,
37
- ...p
42
+ ...c.HINTS,
43
+ ...m
38
44
  };
39
45
  }
40
46
  rate = 100;
41
- gravity = new t();
47
+ gravity = new u();
42
48
  drag = 0;
43
- origin = new t();
49
+ origin = new u();
44
50
  originSpread = 0;
45
- velocity = new t(0, 1, 0);
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 = null;
65
- #d = {
66
- position: new t(),
67
- velocity: new t(),
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(t = {}) {
72
- t?.geometry !== void 0 && e("Emitter", "an Emitter makes its own geometry - size it with 'max'");
73
- let n = t?.max ?? 1e3;
74
- (!Number.isInteger(n) || n < 1) && e("Emitter", `'max' must be a whole number of 1 or more, got ${a(n)}`);
75
- let r = t?.material;
76
- r === void 0 || r instanceof i || r && typeof r == "object" && !Array.isArray(r) || e("Emitter", `'material' is a Material or material options such as { size: 0.2 }, got ${a(r)}`);
77
- let s = r instanceof i ? r : {
78
- ...m,
79
- ...r
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(n * 3),
82
- colors: new Float32Array(n * 3)
93
+ positions: new Float32Array(t * 3),
94
+ colors: new Float32Array(t * 3)
83
95
  });
84
96
  c.drawCount = 0, super({
85
- ...t,
97
+ ...e,
86
98
  geometry: c,
87
- material: s
88
- }), this.#e = n, this.#r = new Float32Array(n * 3), this.#i = new Float32Array(n), this.#a = new Float32Array(n), this.#c = new Uint8Array(n), t.frustumCulled === void 0 && (this.frustumCulled = !1), this.#v(t), this.#_(t), this.onUpdate((e, t) => this.step(t));
89
- }
90
- set(t) {
91
- let n = [
92
- ...d,
93
- "rate",
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] = y(e);
114
+ this.#o[0] = w(e);
110
115
  }
111
116
  get color() {
112
117
  return this.#o[0].map((e) => [...e]);
113
118
  }
114
- burst(t, n = {}) {
115
- for (let t of Object.keys(n)) d.includes(t) || e("Emitter", `burst() doesn't take '${t}' - it takes ${d.join(", ")}`);
116
- let { color: r, ...i } = n, a = this.#y();
117
- this.#_(i), r !== void 0 && (this.#l = this.#b(y(r)));
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 e = 0; e < t; e++) this.#f(o, o, 0);
120
- return this.#_(a), this.#l = 0, this.#h(), 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.#h(), 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.#d;
128
- for (let l = 0; l < this.#t;) {
129
- let u = r[l] += e;
130
- if (u >= i[l]) {
131
- this.#p(l);
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 d = l * 3;
135
- for (let r = 0; r < 3; r++) n[d + r] = (n[d + r] + a[r] * e) * o, t[d + r] += n[d + r] * e;
136
- if (this.#m(l, u / i[l]), s) {
137
- if (c.position.set(t[d], t[d + 1], t[d + 2]), c.velocity.set(n[d], n[d + 1], n[d + 2]), c.age = u, c.lifetime = i[l], s(c) === !1) {
138
- this.#p(l);
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, d), n.set(c.velocity, d);
170
+ t.set(c.position, p), n.set(c.velocity, p);
142
171
  }
143
- l++;
172
+ d++;
144
173
  }
145
- let l = this.#g(), u = this.#u ?? l;
174
+ let d = this.#S(), f = this.#g ?? d;
146
175
  this.#n += this.rate * e;
147
- let d = Math.floor(this.#n);
148
- this.#n -= d;
149
- for (let t = 0; t < d; t++) this.#f(u, l, (t + Math.random()) / d * e);
150
- this.#u = l.clone(), this.#h();
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.#y(),
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 c().setSRGB(e[0], e[1], e[2]).toJSON())
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
- #f(e, t, n) {
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 = b(this.originSpread), l = this.velocitySpread, u = typeof l == "number" ? b(l) : [
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(r, n / this.#a[r]);
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
- #p(e) {
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
- #m(e, t) {
200
- let n = this.geometry.colors, r = this.#o[this.#c[e]];
201
- if (r.length === 1) {
202
- n.set(r[0], e * 3);
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 i = Math.min(Math.max(t, 0), 1) * (r.length - 1), a = Math.min(Math.floor(i), r.length - 2), o = i - a, s = r[a], c = r[a + 1];
206
- n[e * 3] = s[0] + (c[0] - s[0]) * o, n[e * 3 + 1] = s[1] + (c[1] - s[1]) * o, n[e * 3 + 2] = s[2] + (c[2] - s[2]) * o;
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
- #h() {
250
+ #x() {
209
251
  this.geometry.drawCount = this.#t, this.geometry.needsUpdate();
210
252
  }
211
- #g() {
253
+ #S() {
212
254
  if (!this.follow) return this.origin;
213
255
  let e = this.follow.worldPosition;
214
- return r(h, this.worldMatrix) ? this.origin.copy(e).applyMatrix4(h) : this.origin;
256
+ return t(g, this.worldMatrix) ? this.origin.copy(e).applyMatrix4(g) : this.origin;
215
257
  }
216
- #_(e) {
258
+ #C(t) {
217
259
  let n = "Emitter";
218
- if (e.origin !== void 0 && this.origin.copy(e.origin, n), e.originSpread !== void 0 && (this.originSpread = Math.max(0, s(n, "originSpread", e.originSpread))), e.velocity !== void 0 && this.velocity.copy(e.velocity, n), e.velocitySpread !== void 0) {
219
- let r = e.velocitySpread;
220
- typeof r == "number" ? this.velocitySpread = s(n, "velocitySpread", r) : this.velocitySpread instanceof t ? this.velocitySpread.copy(r, n) : this.velocitySpread = t.fromInput(r, n);
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
- e.lifetime !== void 0 && (this.lifetime = v(e.lifetime)), e.color !== void 0 && (this.#o[0] = y(e.color));
264
+ t.lifetime !== void 0 && (this.lifetime = y(t.lifetime)), t.color !== void 0 && (this.#o[0] = w(t.color));
223
265
  }
224
- #v(e) {
225
- let t = "Emitter";
226
- e.rate !== void 0 && (this.rate = Math.max(0, s(t, "rate", e.rate))), e.gravity !== void 0 && this.gravity.copy(e.gravity, t), e.drag !== void 0 && (this.drag = Math.max(0, s(t, "drag", e.drag))), e.follow !== void 0 && (this.follow = _(e.follow)), e.onParticle !== void 0 && (this.onParticle = e.onParticle);
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
- #y() {
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
- #b(e) {
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 _(t) {
248
- return t === null || t instanceof l ? t : e("Emitter", `'follow' must be a node, got ${a(t)}`);
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 v(t) {
251
- let n = typeof t == "number" ? [t, t] : t;
252
- return Array.isArray(n) && n.length === 2 && n.every((e) => typeof e == "number" && e > 0) || e("Emitter", `'lifetime' must be seconds above 0, or a [min, max] range, got ${a(t)}`), [Math.min(n[0], n[1]), Math.max(n[0], n[1])];
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 y(t) {
255
- let n = Array.isArray(t) && !(t.length === 3 && t.every((e) => typeof e == "number")) ? t : [t];
256
- return n.length || e("Emitter", "'color' needs at least one colour"), n.map((e) => c.fromInput(e, "Emitter").toSRGB());
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 b(e) {
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 x = [
348
+ var E = [
276
349
  "velocity",
277
350
  "gravity",
278
351
  "drag"
279
- ], S = {
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
- }, C = class {
283
- static OPTIONS = x;
284
- static HINTS = S;
285
- velocity = new t();
286
- gravity = new t();
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(e = {}) {
289
- n("Body", e, x, S), e.velocity !== void 0 && this.velocity.copy(e.velocity, "Body"), e.gravity !== void 0 && this.gravity.copy(e.gravity, "Body"), e.drag !== void 0 && (this.drag = Math.max(0, s("Body", "drag", e.drag)));
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(t.fromInput(e, "Body")), this;
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 { C as Body, g as Emitter };
372
+ export { O as Body, _ as Emitter };
300
373
 
301
374
  //# sourceMappingURL=particles.js.map