react-two.js 0.1.0 → 0.2.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.
@@ -1,508 +1,450 @@
1
- import { jsx as v, Fragment as y } from "react/jsx-runtime";
2
- import h, { createContext as I, useContext as L, useRef as m, useEffect as l, useState as T, useImperativeHandle as R, useLayoutEffect as G } from "react";
3
- import w from "two.js";
4
- const E = I({ two: null, parent: null, width: 0, height: 0 }), g = () => L(E), j = (o, a = []) => {
5
- const { two: u } = g(), r = m(o);
1
+ import { jsx as g, Fragment as R } from "react/jsx-runtime";
2
+ import w, { createContext as G, useContext as L, useRef as I, useEffect as l, useState as b, useImperativeHandle as y, useLayoutEffect as S, useMemo as P } from "react";
3
+ import m from "two.js";
4
+ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j = (r, o = []) => {
5
+ const { two: i } = h(), a = I(r);
6
6
  l(() => {
7
- r.current = o;
8
- }, [o, ...a]), l(() => {
9
- if (!u)
7
+ a.current = r;
8
+ }, [r, ...o]), l(() => {
9
+ if (!i)
10
10
  return;
11
- let i = 0;
12
- return u.bind("update", f), () => u.unbind("update", f);
13
- function f(t, n) {
11
+ let c = 0;
12
+ return i.bind("update", s), () => i.unbind("update", s);
13
+ function s(n, t) {
14
14
  var e;
15
- i += n / 1e3, (e = r.current) == null || e.call(r, i, n);
15
+ c += t / 1e3, (e = a.current) == null || e.call(a, c, t);
16
16
  }
17
- }, [u, ...a]);
18
- }, H = (o) => {
19
- const { two: a, parent: u } = g(), r = m(null), [i, f] = T({
20
- two: a,
21
- parent: u,
17
+ }, [i, ...o]);
18
+ }, H = (r) => {
19
+ const { two: o, parent: i } = h(), a = I(null), [c, s] = b({
20
+ two: o,
21
+ parent: i,
22
22
  width: 0,
23
23
  height: 0
24
24
  });
25
- l(t, [o]);
26
- function t() {
27
- let n = () => {
25
+ l(n, [r]);
26
+ function n() {
27
+ let t = () => {
28
28
  };
29
- if (!a) {
30
- let c = function() {
31
- const b = s.width !== k, C = !1;
32
- b && (k = s.width), (b || C) && f((q) => ({ ...q, width: k, height: S }));
29
+ if (!o) {
30
+ let f = function() {
31
+ const p = d.width !== v, k = !1;
32
+ p && (v = d.width), (p || k) && s((T) => ({ ...T, width: v, height: E }));
33
33
  };
34
- const d = { ...o };
35
- delete d.children;
36
- const s = new w(d).appendTo(r.current);
37
- let k = s.width, S = s.height;
38
- f({ two: s, parent: s.scene, width: k, height: S }), s.bind("update", c), n = () => {
39
- var C;
40
- (C = s.renderer.domElement.parentElement) == null || C.removeChild(
41
- s.renderer.domElement
42
- ), s.unbind("update", c);
43
- const b = w.Instances.indexOf(s);
44
- w.Instances.splice(b, 1), s.pause();
34
+ const u = { ...r };
35
+ delete u.children;
36
+ const d = new m(u).appendTo(a.current);
37
+ let v = d.width, E = d.height;
38
+ s({ two: d, parent: d.scene, width: v, height: E }), d.bind("update", f), t = () => {
39
+ var k;
40
+ (k = d.renderer.domElement.parentElement) == null || k.removeChild(
41
+ d.renderer.domElement
42
+ ), d.unbind("update", f);
43
+ const p = m.Instances.indexOf(d);
44
+ m.Instances.splice(p, 1), d.pause();
45
45
  };
46
46
  }
47
- return n;
47
+ return t;
48
48
  }
49
- return /* @__PURE__ */ v(E.Provider, { value: i, children: /* @__PURE__ */ v("div", { ref: r, children: o.children }) });
50
- }, O = h.forwardRef(
51
- ({ x: o, y: a, ...u }, r) => {
52
- const { two: i, parent: f, width: t, height: n } = g(), [e, c] = T(null);
53
- l(() => {
54
- if (i) {
55
- const s = new w.Group();
56
- return typeof o == "number" && (s.position.x = o), typeof a == "number" && (s.position.y = a), c(s), () => {
57
- c(null);
49
+ return /* @__PURE__ */ g(C.Provider, { value: c, children: /* @__PURE__ */ g("div", { ref: a, children: r.children }) });
50
+ }, M = w.forwardRef(
51
+ ({ x: r, y: o, ...i }, a) => {
52
+ const { two: c, parent: s, width: n, height: t } = h(), [e, f] = b(null);
53
+ return l(() => {
54
+ if (c) {
55
+ const u = new m.Group();
56
+ return f(u), () => {
57
+ f(null);
58
58
  };
59
59
  }
60
- }, [o, a, i]), l(() => {
61
- const s = e;
62
- if (f && s)
63
- return f.add(s), d(), () => {
64
- f.remove(s);
60
+ }, [c]), l(() => {
61
+ const u = e;
62
+ if (s && u)
63
+ return s.add(u), () => {
64
+ s.remove(u);
65
65
  };
66
- }, [e, f]), l(d, [u]);
67
- function d() {
68
- c((s) => {
69
- if (s) {
70
- const k = { ...u };
71
- delete k.children;
72
- for (const S in k)
73
- S in s && (s[S] = k[S]);
74
- }
75
- return s;
76
- });
77
- }
78
- return R(r, () => e, [e]), /* @__PURE__ */ v(E.Provider, { value: { two: i, parent: e, width: t, height: n }, children: u.children });
66
+ }, [e, s]), l(() => {
67
+ if (e) {
68
+ const u = e;
69
+ typeof r == "number" && (u.translation.x = r), typeof o == "number" && (u.translation.y = o);
70
+ const d = { ...i };
71
+ delete d.children;
72
+ for (const v in d)
73
+ v in u && (u[v] = d[v]);
74
+ }
75
+ }, [e, r, o, i]), y(a, () => e, [e]), /* @__PURE__ */ g(C.Provider, { value: { two: c, parent: e, width: n, height: t }, children: i.children });
79
76
  }
80
- ), _ = h.forwardRef(
81
- ({ manual: o, ...a }, u) => {
82
- const { two: r, parent: i } = g(), f = m(null);
83
- l(() => {
84
- const n = new w.Path();
85
- return f.current = n, o && (f.current.automatic = !1), () => {
86
- f.current = null;
77
+ ), O = w.forwardRef(
78
+ ({ manual: r, x: o, y: i, ...a }, c) => {
79
+ const { two: s, parent: n } = h(), [t, e] = b(null);
80
+ return l(() => {
81
+ const f = new m.Path();
82
+ return e(f), () => {
83
+ e(null);
87
84
  };
88
- }, [o, r]), l(() => {
89
- const n = f.current;
90
- if (i && n)
91
- return i.add(n), t(), () => {
92
- i.remove(n);
85
+ }, [s]), l(() => {
86
+ if (n && t)
87
+ return n.add(t), () => {
88
+ n.remove(t);
93
89
  };
94
- }, [i]), l(t, [a]);
95
- function t() {
96
- if (f.current) {
97
- const n = f.current;
98
- for (const e in a)
99
- e in n && (n[e] = a[e]);
90
+ }, [n, t]), l(() => {
91
+ if (t) {
92
+ const f = t;
93
+ typeof o == "number" && (f.translation.x = o), typeof i == "number" && (f.translation.y = i), typeof r < "u" && (f.automatic = !r);
94
+ for (const u in a)
95
+ u in f && (f[u] = a[u]);
100
96
  }
101
- }
102
- return R(u, () => f.current), /* @__PURE__ */ v(y, {});
97
+ }, [a, t, o, i, r]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
103
98
  }
104
- ), z = h.forwardRef(
105
- (o, a) => {
106
- const { two: u, parent: r } = g(), i = m(null);
107
- l(() => {
108
- const t = new w.Points();
109
- return i.current = t, () => {
110
- i.current = null;
99
+ ), _ = w.forwardRef(
100
+ ({ x: r, y: o, ...i }, a) => {
101
+ const { two: c, parent: s } = h(), [n, t] = b(null);
102
+ return l(() => {
103
+ const e = new m.Points();
104
+ return t(e), () => {
105
+ t(null);
111
106
  };
112
- }, [u]), l(() => {
113
- const t = i.current;
114
- if (r && t)
115
- return r.add(t), f(), () => {
116
- r.remove(t);
107
+ }, [c, r, o]), l(() => {
108
+ if (s && n)
109
+ return s.add(n), () => {
110
+ s.remove(n);
117
111
  };
118
- }, [r]), l(f, [o]);
119
- function f() {
120
- if (i.current) {
121
- const t = i.current;
122
- for (const n in o)
123
- n in t && (t[n] = o[n]);
112
+ }, [s, n]), l(() => {
113
+ if (n) {
114
+ const e = n;
115
+ typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
116
+ for (const f in i)
117
+ f in e && (e[f] = i[f]);
124
118
  }
125
- }
126
- return R(a, () => i.current), /* @__PURE__ */ v(y, {});
119
+ }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
127
120
  }
128
- ), B = h.forwardRef(
129
- ({ x: o, y: a, ...u }, r) => {
130
- const { two: i, parent: f } = g(), t = m(null);
131
- l(() => {
132
- const e = new w.Text(u.value, o, a);
133
- return t.current = e, () => {
134
- t.current = null;
121
+ ), z = w.forwardRef(
122
+ ({ x: r, y: o, ...i }, a) => {
123
+ const { two: c, parent: s } = h(), [n, t] = b(null);
124
+ return l(() => {
125
+ const e = new m.Text();
126
+ return t(e), () => {
127
+ t(null);
135
128
  };
136
- }, [o, a, i]), l(() => {
137
- const e = t.current;
138
- if (f && e)
139
- return f.add(e), n(), () => {
140
- f.remove(e);
129
+ }, [c]), l(() => {
130
+ if (s && n)
131
+ return s.add(n), () => {
132
+ s.remove(n);
141
133
  };
142
- }, [f]), l(n, [u]);
143
- function n() {
144
- if (t.current) {
145
- const e = t.current;
146
- for (const c in u)
147
- c in e && (e[c] = u[c]);
134
+ }, [s, n]), l(() => {
135
+ if (n) {
136
+ const e = n;
137
+ typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
138
+ for (const f in i)
139
+ f in e && (e[f] = i[f]);
148
140
  }
149
- }
150
- return R(r, () => t.current), /* @__PURE__ */ v(y, {});
141
+ }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
151
142
  }
152
- ), J = h.forwardRef(
153
- ({ x: o, y: a, resolution: u, ...r }, i) => {
154
- const { two: f, parent: t } = g(), n = m(null);
155
- l(() => {
156
- const c = new w.ArcSegment(
157
- o,
158
- a,
159
- r.innerRadius,
160
- r.outerRadius,
161
- r.startAngle,
162
- r.endAngle,
163
- u
164
- );
165
- return n.current = c, () => {
166
- n.current = null;
143
+ ), B = w.forwardRef(
144
+ ({ x: r, y: o, resolution: i, ...a }, c) => {
145
+ const { two: s, parent: n } = h(), [t, e] = b(null);
146
+ return l(() => {
147
+ const f = new m.ArcSegment(0, 0, 0, 0, 0, 0, i);
148
+ return e(f), () => {
149
+ e(null);
167
150
  };
168
- }, [o, a, u, f]), l(() => {
169
- const c = n.current;
170
- if (t && c)
171
- return t.add(c), e(), () => {
172
- t.remove(c);
151
+ }, [i, s]), l(() => {
152
+ if (n && t)
153
+ return n.add(t), () => {
154
+ n.remove(t);
173
155
  };
174
- }, [t]), l(e, [r]);
175
- function e() {
176
- if (n.current) {
177
- const c = n.current;
178
- for (const d in r)
179
- d in c && (c[d] = r[d]);
156
+ }, [n, t]), l(() => {
157
+ if (t) {
158
+ const f = t;
159
+ typeof r == "number" && (f.translation.x = r), typeof o == "number" && (f.translation.y = o);
160
+ for (const u in a)
161
+ u in f && (f[u] = a[u]);
180
162
  }
181
- }
182
- return R(i, () => n.current), /* @__PURE__ */ v(y, {});
163
+ }, [a, t, r, o]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
164
+ }
165
+ ), J = w.forwardRef(
166
+ ({ x: r, y: o, resolution: i, ...a }, c) => {
167
+ const { two: s, parent: n } = h(), [t, e] = b(null);
168
+ return l(() => {
169
+ const f = new m.Circle(0, 0, 0, i);
170
+ return e(f), () => {
171
+ e(null);
172
+ };
173
+ }, [i, s]), l(() => {
174
+ if (t) {
175
+ const f = t;
176
+ typeof r == "number" && (f.translation.x = r), typeof o == "number" && (f.translation.y = o);
177
+ for (const u in a)
178
+ u in f && (f[u] = a[u]);
179
+ }
180
+ }, [t, a, r, o]), l(() => {
181
+ if (n && t)
182
+ return n.add(t), () => {
183
+ n.remove(t);
184
+ };
185
+ }, [n, t]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
183
186
  }
184
- ), K = h.forwardRef(
185
- ({ x: o, y: a, resolution: u, ...r }, i) => {
186
- const { two: f, parent: t } = g(), n = m(null);
187
- l(() => {
188
- const c = new w.Circle(o, a, r.radius, u);
189
- return n.current = c, () => {
190
- n.current = null;
187
+ ), K = w.forwardRef(
188
+ ({ x: r, y: o, resolution: i, ...a }, c) => {
189
+ const { two: s, parent: n } = h(), [t, e] = b(null);
190
+ return l(() => {
191
+ const f = new m.Ellipse(0, 0, 0, 0, i);
192
+ return e(f), () => {
193
+ e(null);
191
194
  };
192
- }, [o, a, u, f]), l(() => {
193
- const c = n.current;
194
- if (t && c)
195
- return t.add(c), e(), () => {
196
- t.remove(c);
195
+ }, [i, s]), l(() => {
196
+ if (n && t)
197
+ return n.add(t), () => {
198
+ n.remove(t);
197
199
  };
198
- }, [t]), l(e, [r]);
199
- function e() {
200
- if (n.current) {
201
- const c = n.current;
202
- for (const d in r)
203
- d in c && (c[d] = r[d]);
200
+ }, [n]), l(() => {
201
+ if (t) {
202
+ const f = t;
203
+ typeof r == "number" && (f.translation.x = r), typeof o == "number" && (f.translation.y = o);
204
+ for (const u in a)
205
+ u in f && (f[u] = a[u]);
204
206
  }
205
- }
206
- return R(i, () => n.current), /* @__PURE__ */ v(y, {});
207
+ }, [t, r, o, a]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
207
208
  }
208
- ), M = h.forwardRef(
209
- ({ x: o, y: a, resolution: u, ...r }, i) => {
210
- const { two: f, parent: t } = g(), n = m(null);
211
- l(() => {
212
- const c = new w.Ellipse(
213
- o,
214
- a,
215
- typeof r.width == "number" ? r.width / 2 : void 0,
216
- typeof r.height == "number" ? r.height / 2 : void 0,
217
- u
218
- );
219
- return n.current = c, () => {
220
- n.current = null;
209
+ ), N = w.forwardRef(
210
+ ({ mode: r, texture: o, x: i, y: a, ...c }, s) => {
211
+ const { two: n, parent: t } = h(), [e, f] = b(null);
212
+ return S(() => {
213
+ const u = new m.Image();
214
+ return f(u), () => {
215
+ f(null);
221
216
  };
222
- }, [o, a, u, f]), l(() => {
223
- const c = n.current;
224
- if (t && c)
225
- return t.add(c), e(), () => {
226
- t.remove(c);
217
+ }, [n]), l(() => {
218
+ if (t && e)
219
+ return t.add(e), () => {
220
+ t.remove(e);
227
221
  };
228
- }, [t]), l(e, [r]);
229
- function e() {
230
- if (n.current) {
231
- const c = n.current;
232
- for (const d in r)
233
- d in c && (c[d] = r[d]);
222
+ }, [t, e]), l(() => {
223
+ if (e) {
224
+ const u = e;
225
+ typeof r < "u" && (u.mode = r), typeof o < "u" && (u.texture = o), typeof i == "number" && (u.translation.x = i), typeof a == "number" && (u.translation.y = a);
226
+ for (const d in c)
227
+ d in u && (u[d] = c[d]);
234
228
  }
235
- }
236
- return R(i, () => n.current), /* @__PURE__ */ v(y, {});
229
+ }, [e, c, r, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
237
230
  }
238
- ), N = h.forwardRef(
239
- ({ paths: o, x: a, y: u, autoPlay: r, ...i }, f) => {
240
- const { two: t, parent: n } = g(), e = m(null);
241
- G(() => {
242
- const d = new w.ImageSequence(o, a, u, i.frameRate);
243
- return e.current = d, r && e.current.play(), () => {
244
- e.current = null;
231
+ ), Q = w.forwardRef(
232
+ ({ paths: r, x: o, y: i, autoPlay: a, ...c }, s) => {
233
+ const { two: n, parent: t } = h(), [e, f] = b(null);
234
+ return S(() => {
235
+ const u = new m.ImageSequence(r);
236
+ return f(u), () => {
237
+ f(null);
245
238
  };
246
- }, [o, a, u, t]), l(() => {
247
- const d = e.current;
248
- if (n && d)
249
- return n.add(d), c(), () => {
250
- n.remove(d);
239
+ }, [n, r]), l(() => {
240
+ if (t && e)
241
+ return t.add(e), () => {
242
+ t.remove(e);
251
243
  };
252
- }, [n]), l(() => {
253
- var d, s;
254
- r ? (d = e.current) == null || d.play() : (s = e.current) == null || s.pause();
255
- }, [r]), l(c, [i]);
256
- function c() {
257
- if (e.current) {
258
- const d = e.current;
259
- for (const s in i)
260
- s in d && (d[s] = i[s]);
244
+ }, [t, e]), l(() => {
245
+ if (e) {
246
+ const u = e;
247
+ a ? u.play() : u.pause(), typeof o == "number" && (u.translation.x = o), typeof i == "number" && (u.translation.y = i);
248
+ for (const d in c)
249
+ d in u && (u[d] = c[d]);
261
250
  }
262
- }
263
- return R(f, () => e.current), /* @__PURE__ */ v(y, {});
251
+ }, [c, e, r, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
264
252
  }
265
- ), Q = h.forwardRef(
266
- ({ x1: o, y1: a, x2: u, y2: r, ...i }, f) => {
267
- const { two: t, parent: n } = g(), e = m(null);
268
- l(() => {
269
- const d = new w.Line(o, a, u, r);
270
- return e.current = d, () => {
271
- e.current = null;
253
+ ), U = w.forwardRef(
254
+ ({ x1: r, y1: o, x2: i, y2: a, ...c }, s) => {
255
+ const { two: n, parent: t } = h(), [e, f] = b(null);
256
+ return l(() => {
257
+ const u = new m.Line();
258
+ return f(u), () => {
259
+ f(null);
272
260
  };
273
- }, [o, a, u, r, t]), l(() => {
274
- const d = e.current;
275
- if (n && d)
276
- return n.add(d), c(), () => {
277
- n.remove(d);
261
+ }, [n]), l(() => {
262
+ const u = e;
263
+ if (t && u)
264
+ return t.add(u), () => {
265
+ t.remove(u);
278
266
  };
279
- }, [n]), l(c, [i]);
280
- function c() {
281
- if (e.current) {
282
- const d = e.current;
283
- for (const s in i)
284
- s in d && (d[s] = i[s]);
267
+ }, [t, e]), l(() => {
268
+ if (e) {
269
+ const u = e;
270
+ typeof r == "number" && (u.left.x = r), typeof o == "number" && (u.left.y = o), typeof i == "number" && (u.right.x = i), typeof a == "number" && (u.right.y = a);
271
+ for (const d in c)
272
+ d in u && (u[d] = c[d]);
285
273
  }
286
- }
287
- return R(f, () => e.current), /* @__PURE__ */ v(y, {});
274
+ }, [c, e, r, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
288
275
  }
289
- ), U = h.forwardRef(
290
- ({ x: o, y: a, radius: u, ...r }, i) => {
291
- const { two: f, parent: t } = g(), n = m(null);
292
- l(() => {
293
- const c = new w.Polygon(o, a, u, r.sides);
294
- return n.current = c, () => {
295
- n.current = null;
276
+ ), V = w.forwardRef(
277
+ ({ x: r, y: o, ...i }, a) => {
278
+ const { two: c, parent: s } = h(), [n, t] = b(null);
279
+ return l(() => {
280
+ const e = new m.Polygon();
281
+ return t(e), () => {
282
+ t(null);
296
283
  };
297
- }, [o, a, u, f]), l(() => {
298
- const c = n.current;
299
- if (t && c)
300
- return t.add(c), e(), () => {
301
- t.remove(c);
284
+ }, [c]), l(() => {
285
+ if (s && n)
286
+ return s.add(n), () => {
287
+ s.remove(n);
302
288
  };
303
- }, [t]), l(e, [r]);
304
- function e() {
305
- if (n.current) {
306
- const c = n.current;
307
- for (const d in r)
308
- d in c && (c[d] = r[d]);
289
+ }, [s, n]), l(() => {
290
+ if (n) {
291
+ const e = n;
292
+ typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
293
+ for (const f in i)
294
+ f in e && (e[f] = i[f]);
309
295
  }
310
- }
311
- return R(i, () => n.current), /* @__PURE__ */ v(y, {});
296
+ }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
312
297
  }
313
- ), V = h.forwardRef(
314
- ({ x: o, y: a, ...u }, r) => {
315
- const { two: i, parent: f } = g(), t = m(null);
316
- l(() => {
317
- const e = new w.Rectangle(o, a, u.width, u.height);
318
- return t.current = e, () => {
319
- t.current = null;
298
+ ), W = w.forwardRef(
299
+ ({ x: r, y: o, ...i }, a) => {
300
+ const { two: c, parent: s } = h(), [n, t] = b(null);
301
+ return l(() => {
302
+ const e = new m.Rectangle();
303
+ return t(e), () => {
304
+ t(null);
320
305
  };
321
- }, [o, a, i]), l(() => {
322
- const e = t.current;
323
- if (f && e)
324
- return f.add(e), n(), () => {
325
- f.remove(e);
306
+ }, [c]), l(() => {
307
+ if (s && n)
308
+ return s.add(n), () => {
309
+ s.remove(n);
326
310
  };
327
- }, [f]), l(n, [u]);
328
- function n() {
329
- if (t.current) {
330
- const e = t.current;
331
- for (const c in u)
332
- c in e && (e[c] = u[c]);
311
+ }, [s, n]), l(() => {
312
+ if (n) {
313
+ const e = n;
314
+ typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
315
+ for (const f in i)
316
+ f in e && (e[f] = i[f]);
333
317
  }
334
- }
335
- return R(r, () => t.current), /* @__PURE__ */ v(y, {});
318
+ }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
336
319
  }
337
- ), W = h.forwardRef(({ x: o, y: a, ...u }, r) => {
338
- const { two: i, parent: f } = g(), t = m(null);
339
- l(() => {
340
- const e = new w.RoundedRectangle(
341
- o,
342
- a,
343
- u.width,
344
- u.height,
345
- u.radius
346
- );
347
- return t.current = e, () => {
348
- t.current = null;
349
- };
350
- }, [o, a, i]), l(() => {
351
- const e = t.current;
352
- if (f && e)
353
- return f.add(e), n(), () => {
354
- f.remove(e);
320
+ ), Z = w.forwardRef(
321
+ ({ x: r, y: o, ...i }, a) => {
322
+ const { two: c, parent: s } = h(), [n, t] = b(null);
323
+ return l(() => {
324
+ const e = new m.RoundedRectangle();
325
+ return t(e), () => {
326
+ t(null);
355
327
  };
356
- }, [f]), l(n, [u]);
357
- function n() {
358
- if (t.current) {
359
- const e = t.current;
360
- for (const c in u)
361
- c in e && (e[c] = u[c]);
362
- }
328
+ }, [c]), l(() => {
329
+ if (s && n)
330
+ return s.add(n), () => {
331
+ s.remove(n);
332
+ };
333
+ }, [s, n]), l(() => {
334
+ if (n) {
335
+ const e = n;
336
+ typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
337
+ for (const f in i)
338
+ f in e && (e[f] = i[f]);
339
+ }
340
+ }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
363
341
  }
364
- return R(r, () => t.current), /* @__PURE__ */ v(y, {});
365
- }), Z = h.forwardRef(
366
- ({ path: o, x: a, y: u, autoPlay: r, ...i }, f) => {
367
- const { two: t, parent: n } = g(), e = m(null);
368
- G(() => {
369
- const d = new w.Sprite(
370
- o,
371
- a,
372
- u,
373
- i.columns,
374
- i.rows,
375
- i.frameRate
376
- );
377
- return e.current = d, r && e.current.play(), () => {
378
- e.current = null;
342
+ ), $ = w.forwardRef(
343
+ ({ path: r, x: o, y: i, autoPlay: a, ...c }, s) => {
344
+ const { two: n, parent: t } = h(), [e, f] = b(null);
345
+ return S(() => {
346
+ const u = new m.Sprite(r);
347
+ return f(u), () => {
348
+ f(null);
379
349
  };
380
- }, [o, a, u, t]), l(() => {
381
- const d = e.current;
382
- if (n && d)
383
- return n.add(d), c(), () => {
384
- n.remove(d);
350
+ }, [r, n]), l(() => {
351
+ if (t && e)
352
+ return t.add(e), () => {
353
+ t.remove(e);
385
354
  };
386
- }, [n]), l(() => {
387
- var d, s;
388
- r ? (d = e.current) == null || d.play() : (s = e.current) == null || s.pause();
389
- }, [r]), l(c, [i]);
390
- function c() {
391
- if (e.current) {
392
- const d = e.current;
393
- for (const s in i)
394
- s in d && (d[s] = i[s]);
355
+ }, [t]), l(() => {
356
+ if (e) {
357
+ const u = e;
358
+ typeof o == "number" && (u.translation.x = o), typeof i == "number" && (u.translation.y = i), a ? u.play() : u.pause();
359
+ for (const d in c)
360
+ d in u && (u[d] = c[d]);
395
361
  }
396
- }
397
- return R(f, () => e.current), /* @__PURE__ */ v(y, {});
362
+ }, [c, e, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
398
363
  }
399
- ), $ = h.forwardRef(
400
- ({ x: o, y: a, ...u }, r) => {
401
- const { two: i, parent: f } = g(), t = m(null);
402
- l(() => {
403
- const e = new w.Star(
404
- o,
405
- a,
406
- u.innerRadius,
407
- u.outerRadius,
408
- u.sides
409
- );
410
- return t.current = e, () => {
411
- t.current = null;
364
+ ), D = w.forwardRef(
365
+ ({ x: r, y: o, ...i }, a) => {
366
+ const { two: c, parent: s } = h(), [n, t] = b(null);
367
+ return l(() => {
368
+ const e = new m.Star();
369
+ return t(e), () => {
370
+ t(null);
412
371
  };
413
- }, [o, a, i]), l(() => {
414
- const e = t.current;
415
- if (f && e)
416
- return f.add(e), n(), () => {
417
- f.remove(e);
372
+ }, [c]), l(() => {
373
+ if (s && n)
374
+ return s.add(n), () => {
375
+ s.remove(n);
418
376
  };
419
- }, [f]), l(n, [u]);
420
- function n() {
421
- if (t.current) {
422
- const e = t.current;
423
- for (const c in u)
424
- c in e && (e[c] = u[c]);
377
+ }, [s, n]), l(() => {
378
+ if (n) {
379
+ const e = n;
380
+ typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
381
+ for (const f in i)
382
+ f in e && (e[f] = i[f]);
425
383
  }
426
- }
427
- return R(r, () => t.current), /* @__PURE__ */ v(y, {});
384
+ }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
428
385
  }
429
- ), D = h.forwardRef(
430
- ({ x1: o, y1: a, x2: u, y2: r, ...i }, f) => {
431
- const { two: t } = g(), n = m(null);
432
- !n.current && t && (n.current = new w.LinearGradient(o, a, u, r, i.stops)), l(() => {
433
- n.current && (typeof o == "number" && (n.current.left.x = o), typeof a == "number" && (n.current.left.y = a), typeof u == "number" && (n.current.right.x = u), typeof r == "number" && (n.current.right.y = r));
434
- }, [o, a, u, r]), l(e, [i]);
435
- function e() {
436
- if (n.current) {
437
- const c = n.current;
438
- for (const d in i)
439
- d in c && (c[d] = i[d]);
386
+ ), X = w.forwardRef(
387
+ ({ x1: r, y1: o, x2: i, y2: a, ...c }, s) => {
388
+ const n = P(() => new m.LinearGradient(), []);
389
+ return l(() => {
390
+ if (n) {
391
+ const t = n;
392
+ typeof r == "number" && (t.left.x = r), typeof o == "number" && (t.left.y = o), typeof i == "number" && (t.right.x = i), typeof a == "number" && (t.right.y = a);
393
+ for (const e in c)
394
+ e in t && (t[e] = c[e]);
440
395
  }
441
- }
442
- return R(f, () => n.current), null;
396
+ }, [n, r, o, i, a, c]), y(s, () => n, [n]), null;
443
397
  }
444
- ), x = h.forwardRef(
445
- ({ x: o, y: a, focalX: u, focalY: r, ...i }, f) => {
446
- const { two: t } = g(), n = m(null);
447
- !n.current && t && (n.current = new w.RadialGradient(
448
- o,
449
- a,
450
- i.radius,
451
- i.stops,
452
- u,
453
- r
454
- )), l(() => {
455
- n.current && (typeof o == "number" && (n.current.center.x = o), typeof a == "number" && (n.current.center.y = a));
456
- }, [o, a]), l(() => {
457
- n.current && (typeof u == "number" && (n.current.focal.x = u), typeof r == "number" && (n.current.focal.y = r));
458
- }, [u, r]), l(e, [i]);
459
- function e() {
460
- if (n.current) {
461
- const c = n.current;
462
- for (const d in i)
463
- d in c && (c[d] = i[d]);
398
+ ), Y = w.forwardRef(
399
+ ({ x: r, y: o, focalX: i, focalY: a, ...c }, s) => {
400
+ const n = P(() => new m.RadialGradient(), []);
401
+ return l(() => {
402
+ if (n) {
403
+ const t = n;
404
+ typeof r == "number" && (n.center.x = r), typeof o == "number" && (n.center.y = o), typeof i == "number" && (n.focal.x = i), typeof a == "number" && (n.focal.y = a);
405
+ for (const e in c)
406
+ e in t && (t[e] = c[e]);
464
407
  }
465
- }
466
- return R(f, () => n.current), null;
408
+ }, [c, n, r, o, i, a]), y(s, () => n, [n]), null;
467
409
  }
468
- ), X = h.forwardRef(
469
- ({ source: o, ...a }, u) => {
470
- const r = m(null);
471
- l(() => {
472
- const f = new w.Texture(o);
473
- return r.current = f, () => {
410
+ ), x = w.forwardRef(
411
+ ({ source: r, ...o }, i) => {
412
+ const [a, c] = b(null);
413
+ return l(() => {
414
+ const s = new m.Texture(r);
415
+ return c(s), () => {
416
+ c(null);
474
417
  };
475
- }, [o]), l(i, [a]);
476
- function i() {
477
- if (r.current) {
478
- const f = r.current;
479
- for (const t in a)
480
- t in f && (f[t] = a[t]);
418
+ }, [r]), l(() => {
419
+ if (a) {
420
+ const s = a;
421
+ for (const n in o)
422
+ n in s && (s[n] = o[n]);
481
423
  }
482
- }
483
- return R(u, () => r.current), null;
424
+ }, [o, a]), y(i, () => a, [a]), null;
484
425
  }
485
426
  );
486
427
  export {
487
- J as ArcSegment,
428
+ B as ArcSegment,
488
429
  H as Canvas,
489
- K as Circle,
490
- E as Context,
491
- M as Ellipse,
492
- O as Group,
493
- N as ImageSequence,
494
- Q as Line,
495
- D as LinearGradient,
496
- _ as Path,
497
- z as Points,
498
- U as Polygon,
499
- x as RadialGradient,
500
- V as Rectangle,
501
- W as RoundedRectangle,
502
- Z as Sprite,
503
- $ as Star,
504
- B as Text,
505
- X as Texture,
430
+ J as Circle,
431
+ C as Context,
432
+ K as Ellipse,
433
+ M as Group,
434
+ N as Image,
435
+ Q as ImageSequence,
436
+ U as Line,
437
+ X as LinearGradient,
438
+ O as Path,
439
+ _ as Points,
440
+ V as Polygon,
441
+ Y as RadialGradient,
442
+ W as Rectangle,
443
+ Z as RoundedRectangle,
444
+ $ as Sprite,
445
+ D as Star,
446
+ z as Text,
447
+ x as Texture,
506
448
  j as useFrame,
507
- g as useTwo
449
+ h as useTwo
508
450
  };