react-two.js 0.8.22-r.5 → 0.8.23-r.1
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/dist/Provider.d.ts +2 -0
- package/dist/Text.d.ts +2 -2
- package/dist/Texture.d.ts +1 -1
- package/dist/react-two-main.es.js +312 -318
- package/package.json +3 -2
package/dist/Provider.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ type TwoConstructorProps = ConstructorParameters<typeof Two>[0];
|
|
|
4
4
|
type TwoConstructorPropsKeys = NonNullable<TwoConstructorProps>;
|
|
5
5
|
type ComponentProps = React.PropsWithChildren<TwoConstructorPropsKeys & {
|
|
6
6
|
onPointerMissed?: (event: PointerEvent) => void;
|
|
7
|
+
} & {
|
|
8
|
+
container?: React.ComponentProps<'div'>;
|
|
7
9
|
}>;
|
|
8
10
|
export declare const Provider: React.FC<ComponentProps>;
|
|
9
11
|
export {};
|
package/dist/Text.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type EventHandlers } from './Properties';
|
|
|
4
4
|
export type RefText = Instance;
|
|
5
5
|
export declare const Text: React.ForwardRefExoticComponent<{
|
|
6
6
|
visible?: boolean | undefined;
|
|
7
|
+
value?: string | undefined;
|
|
7
8
|
renderer?: {
|
|
8
9
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
9
10
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -26,12 +27,11 @@ export declare const Text: React.ForwardRefExoticComponent<{
|
|
|
26
27
|
dashes?: (number[] & {
|
|
27
28
|
offset?: number;
|
|
28
29
|
}) | undefined;
|
|
29
|
-
value?: string | undefined;
|
|
30
30
|
size?: number | undefined;
|
|
31
|
+
style?: import("two.js/src/text").StyleProperties | undefined;
|
|
31
32
|
family?: string | undefined;
|
|
32
33
|
leading?: number | undefined;
|
|
33
34
|
alignment?: import("two.js/src/text").AlignmentProperties | undefined;
|
|
34
|
-
style?: import("two.js/src/text").StyleProperties | undefined;
|
|
35
35
|
weight?: string | number | undefined;
|
|
36
36
|
decoration?: import("two.js/src/text").DecorationProperties | undefined;
|
|
37
37
|
direction?: import("two.js/src/text").DirectionProperties | undefined;
|
package/dist/Texture.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ export declare const Texture: React.ForwardRefExoticComponent<{
|
|
|
14
14
|
className?: string | undefined;
|
|
15
15
|
repeat?: import("two.js/src/effects/texture").RepeatProperties | undefined;
|
|
16
16
|
src?: string | undefined;
|
|
17
|
+
image?: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | undefined;
|
|
17
18
|
loaded?: boolean | undefined;
|
|
18
19
|
offset?: import("two.js/src/vector").Vector | undefined;
|
|
19
|
-
image?: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | undefined;
|
|
20
20
|
} & {
|
|
21
21
|
src?: string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;
|
|
22
22
|
} & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import k, { createContext as Z, useContext as X, useRef as
|
|
1
|
+
import { jsx as b, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import k, { createContext as Z, useContext as X, useRef as N, useEffect as h, useState as $, useCallback as oe, useMemo as g, useImperativeHandle as R } from "react";
|
|
3
3
|
import H from "two.js";
|
|
4
4
|
const ee = Z({
|
|
5
5
|
two: null,
|
|
@@ -13,13 +13,13 @@ const ee = Z({
|
|
|
13
13
|
width: 0,
|
|
14
14
|
height: 0
|
|
15
15
|
}), ce = ee, C = () => {
|
|
16
|
-
const t = X(ee),
|
|
17
|
-
return { ...t, ...
|
|
18
|
-
}, ve = (t,
|
|
19
|
-
const { two: r } = C(), l =
|
|
16
|
+
const t = X(ee), i = X(J), r = X(Q);
|
|
17
|
+
return { ...t, ...i, ...r };
|
|
18
|
+
}, ve = (t, i = []) => {
|
|
19
|
+
const { two: r } = C(), l = N(t);
|
|
20
20
|
h(() => {
|
|
21
21
|
l.current = t;
|
|
22
|
-
}, [t, ...
|
|
22
|
+
}, [t, ...i]), h(() => {
|
|
23
23
|
if (!r)
|
|
24
24
|
return;
|
|
25
25
|
let n = 0;
|
|
@@ -27,8 +27,8 @@ const ee = Z({
|
|
|
27
27
|
function u(a, e) {
|
|
28
28
|
n += e / 1e3, l.current?.(n, e);
|
|
29
29
|
}
|
|
30
|
-
}, [r, ...
|
|
31
|
-
},
|
|
30
|
+
}, [r, ...i]);
|
|
31
|
+
}, L = [
|
|
32
32
|
"onClick",
|
|
33
33
|
"onContextMenu",
|
|
34
34
|
"onDoubleClick",
|
|
@@ -42,19 +42,19 @@ const ee = Z({
|
|
|
42
42
|
"onPointerMove",
|
|
43
43
|
"onPointerCancel"
|
|
44
44
|
];
|
|
45
|
-
function
|
|
46
|
-
const l =
|
|
45
|
+
function se(t, i, r) {
|
|
46
|
+
const l = i.getBoundingClientRect(), n = t.clientX - l.left - r.width / 2, u = t.clientY - l.top - r.height / 2;
|
|
47
47
|
return { x: n, y: u };
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const r =
|
|
49
|
+
function A(t, i) {
|
|
50
|
+
const r = i.getBoundingClientRect(), l = t.clientX - r.left, n = t.clientY - r.top;
|
|
51
51
|
return { x: l, y: n };
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function ie(t, i, r, l) {
|
|
54
54
|
let n = !1;
|
|
55
55
|
return {
|
|
56
56
|
nativeEvent: t,
|
|
57
|
-
target:
|
|
57
|
+
target: i,
|
|
58
58
|
currentTarget: r,
|
|
59
59
|
point: l,
|
|
60
60
|
stopPropagation: () => {
|
|
@@ -65,29 +65,29 @@ function se(t, s, r, l) {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function ae(t,
|
|
69
|
-
return "visible" in t && !t.visible ? !1 : typeof t.contains == "function" ? t.contains(
|
|
68
|
+
function ae(t, i, r) {
|
|
69
|
+
return "visible" in t && !t.visible ? !1 : typeof t.contains == "function" ? t.contains(i, r) : !1;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function U(t, i, r) {
|
|
72
72
|
const l = [];
|
|
73
73
|
for (const [n] of t)
|
|
74
|
-
ae(n,
|
|
74
|
+
ae(n, i, r) && l.push(n);
|
|
75
75
|
return l;
|
|
76
76
|
}
|
|
77
|
-
function le(t,
|
|
78
|
-
const r = [t], l =
|
|
77
|
+
function le(t, i) {
|
|
78
|
+
const r = [t], l = i.get(t);
|
|
79
79
|
if (l?.parent) {
|
|
80
80
|
let n = l.parent;
|
|
81
81
|
for (; n; )
|
|
82
|
-
r.push(n), n =
|
|
82
|
+
r.push(n), n = i.get(n)?.parent;
|
|
83
83
|
}
|
|
84
84
|
return r;
|
|
85
85
|
}
|
|
86
86
|
function Y(t) {
|
|
87
|
-
process.env.NODE_ENV !== "production" && k.Children.forEach(t, (
|
|
88
|
-
if (!k.isValidElement(
|
|
87
|
+
process.env.NODE_ENV !== "production" && k.Children.forEach(t, (i) => {
|
|
88
|
+
if (!k.isValidElement(i))
|
|
89
89
|
return;
|
|
90
|
-
const r =
|
|
90
|
+
const r = i.type;
|
|
91
91
|
if (typeof r == "string") {
|
|
92
92
|
console.warn(
|
|
93
93
|
`[react-two.js] <${r}> is not compatible with Canvas.
|
|
@@ -99,64 +99,62 @@ See: https://github.com/jonobr1/react-two.js#usage`
|
|
|
99
99
|
}
|
|
100
100
|
if (r === k.Fragment) {
|
|
101
101
|
Y(
|
|
102
|
-
|
|
102
|
+
i.props.children
|
|
103
103
|
);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
typeof r == "function" &&
|
|
107
|
-
|
|
106
|
+
typeof r == "function" && i.props.children && Y(
|
|
107
|
+
i.props.children
|
|
108
108
|
);
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
const pe = (t) => {
|
|
112
|
-
const { two:
|
|
113
|
-
(m, S,
|
|
114
|
-
n.current.set(m, { shape: m, handlers: S, parent:
|
|
112
|
+
const { two: i, parent: r } = C(), l = N(null), n = N(/* @__PURE__ */ new Map()), u = N(/* @__PURE__ */ new Set()), a = N(null), [e, o] = $(i), [c, s] = $(r), [d, f] = $(0), [v, p] = $(0), j = oe(
|
|
113
|
+
(m, S, E) => {
|
|
114
|
+
n.current.set(m, { shape: m, handlers: S, parent: E });
|
|
115
115
|
},
|
|
116
116
|
[]
|
|
117
|
-
),
|
|
117
|
+
), V = oe((m) => {
|
|
118
118
|
n.current.delete(m), u.current.delete(m), a.current === m && (a.current = null);
|
|
119
119
|
}, []);
|
|
120
120
|
h(() => {
|
|
121
|
-
if (!
|
|
121
|
+
if (!i) {
|
|
122
122
|
const S = { ...t };
|
|
123
123
|
delete S.children;
|
|
124
|
-
const
|
|
125
|
-
return o(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
),
|
|
129
|
-
const
|
|
130
|
-
|
|
124
|
+
const E = new H(S).appendTo(l.current);
|
|
125
|
+
return o(E), s(E.scene), f(E.width), p(E.height), () => {
|
|
126
|
+
E.renderer.domElement.parentElement?.removeChild(
|
|
127
|
+
E.renderer.domElement
|
|
128
|
+
), E.pause(), E.unbind(), E.release();
|
|
129
|
+
const q = H.Instances.indexOf(E);
|
|
130
|
+
q >= 0 && H.Instances.splice(q, 1), E.clear();
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
}, []), h(() => {
|
|
134
|
-
!
|
|
135
|
-
}, [
|
|
136
|
-
if (!
|
|
134
|
+
!i && (typeof t.width == "number" && (e && (e.width = t.width), f(t.width)), typeof t.height == "number" && (e && (e.height = t.height), p(t.height)));
|
|
135
|
+
}, [i, e, t.width, t.height]), h(() => {
|
|
136
|
+
if (!i && e) {
|
|
137
137
|
let S = function() {
|
|
138
|
-
|
|
139
|
-
V && (I = b.width), G && (L = b.height), (V || G) && (f(I), p(L));
|
|
138
|
+
f(E.width), p(E.height);
|
|
140
139
|
};
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
b.unbind("update", S);
|
|
140
|
+
const E = e;
|
|
141
|
+
return E.renderer.bind("resize", S), () => {
|
|
142
|
+
E.renderer.unbind("resize", S);
|
|
145
143
|
};
|
|
146
144
|
}
|
|
147
|
-
}, [
|
|
145
|
+
}, [i, e]), h(() => {
|
|
148
146
|
process.env.NODE_ENV !== "production" && Y(t.children);
|
|
149
147
|
}, [t.children]), h(() => {
|
|
150
148
|
if (!e) return;
|
|
151
|
-
const m = e.renderer.domElement, S = (y,
|
|
149
|
+
const m = e.renderer.domElement, S = (y, P, w) => {
|
|
152
150
|
if (y.length === 0) return;
|
|
153
|
-
const
|
|
154
|
-
for (const ne of
|
|
155
|
-
const te = n.current.get(ne)?.handlers[
|
|
151
|
+
const I = y[0], B = se(w, m, e), z = le(I, n.current);
|
|
152
|
+
for (const ne of z) {
|
|
153
|
+
const te = n.current.get(ne)?.handlers[P];
|
|
156
154
|
if (te) {
|
|
157
|
-
const re =
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
const re = ie(
|
|
156
|
+
w,
|
|
157
|
+
I,
|
|
160
158
|
ne,
|
|
161
159
|
B
|
|
162
160
|
);
|
|
@@ -164,104 +162,100 @@ const pe = (t) => {
|
|
|
164
162
|
break;
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
|
-
},
|
|
168
|
-
const
|
|
165
|
+
}, E = (y) => {
|
|
166
|
+
const P = A(y, m), w = U(
|
|
169
167
|
n.current,
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
P.x,
|
|
169
|
+
P.y
|
|
172
170
|
);
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
const
|
|
171
|
+
w.length > 0 && S(w, "onClick", y);
|
|
172
|
+
}, q = (y) => {
|
|
173
|
+
const P = A(y, m), w = U(
|
|
176
174
|
n.current,
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
P.x,
|
|
176
|
+
P.y
|
|
179
177
|
);
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
const
|
|
178
|
+
w.length > 0 && S(w, "onContextMenu", y);
|
|
179
|
+
}, G = (y) => {
|
|
180
|
+
const P = A(y, m), w = U(
|
|
183
181
|
n.current,
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
P.x,
|
|
183
|
+
P.y
|
|
186
184
|
);
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
const
|
|
185
|
+
w.length > 0 && S(w, "onDoubleClick", y);
|
|
186
|
+
}, T = (y) => {
|
|
187
|
+
const P = A(y, m), w = U(
|
|
190
188
|
n.current,
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
P.x,
|
|
190
|
+
P.y
|
|
193
191
|
);
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
const
|
|
192
|
+
w.length > 0 && S(w, "onWheel", y);
|
|
193
|
+
}, D = (y) => {
|
|
194
|
+
const P = A(y, m), w = U(
|
|
197
195
|
n.current,
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
P.x,
|
|
197
|
+
P.y
|
|
200
198
|
);
|
|
201
|
-
|
|
199
|
+
w.length > 0 && (S(w, "onPointerDown", y), y.target instanceof Element && y.target.hasPointerCapture?.(y.pointerId) && (a.current = w[0]));
|
|
202
200
|
}, _ = (y) => {
|
|
203
201
|
if (a.current) {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
const B =
|
|
202
|
+
const I = n.current.get(a.current);
|
|
203
|
+
if (I?.handlers.onPointerUp) {
|
|
204
|
+
const B = se(y, m, e), z = ie(
|
|
207
205
|
y,
|
|
208
206
|
a.current,
|
|
209
207
|
a.current,
|
|
210
208
|
B
|
|
211
209
|
);
|
|
212
|
-
|
|
210
|
+
I.handlers.onPointerUp(z);
|
|
213
211
|
}
|
|
214
212
|
a.current = null;
|
|
215
213
|
return;
|
|
216
214
|
}
|
|
217
|
-
const
|
|
215
|
+
const P = A(y, m), w = U(
|
|
218
216
|
n.current,
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
P.x,
|
|
218
|
+
P.y
|
|
221
219
|
);
|
|
222
|
-
|
|
223
|
-
},
|
|
224
|
-
const
|
|
220
|
+
w.length > 0 ? S(w, "onPointerUp", y) : t.onPointerMissed && t.onPointerMissed(y);
|
|
221
|
+
}, F = (y) => {
|
|
222
|
+
const P = A(y, m), w = U(
|
|
225
223
|
n.current,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
),
|
|
229
|
-
|
|
224
|
+
P.x,
|
|
225
|
+
P.y
|
|
226
|
+
), I = new Set(w);
|
|
227
|
+
w.length > 0 && S(w, "onPointerMove", y);
|
|
230
228
|
const B = u.current;
|
|
231
|
-
for (const
|
|
232
|
-
B.has(
|
|
233
|
-
for (const
|
|
234
|
-
|
|
235
|
-
u.current =
|
|
229
|
+
for (const z of I)
|
|
230
|
+
B.has(z) || (S([z], "onPointerEnter", y), S([z], "onPointerOver", y));
|
|
231
|
+
for (const z of B)
|
|
232
|
+
I.has(z) || (S([z], "onPointerLeave", y), S([z], "onPointerOut", y));
|
|
233
|
+
u.current = I;
|
|
236
234
|
}, W = (y) => {
|
|
237
|
-
const
|
|
235
|
+
const P = A(y, m), w = U(
|
|
238
236
|
n.current,
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
P.x,
|
|
238
|
+
P.y
|
|
241
239
|
);
|
|
242
|
-
|
|
240
|
+
w.length > 0 && S(w, "onPointerCancel", y), a.current = null;
|
|
243
241
|
};
|
|
244
|
-
return m.addEventListener("click",
|
|
245
|
-
m.removeEventListener("click",
|
|
242
|
+
return m.addEventListener("click", E), m.addEventListener("contextmenu", q), m.addEventListener("dblclick", G), m.addEventListener("wheel", T), m.addEventListener("pointerdown", D), m.addEventListener("pointerup", _), m.addEventListener("pointermove", F), m.addEventListener("pointercancel", W), () => {
|
|
243
|
+
m.removeEventListener("click", E), m.removeEventListener("contextmenu", q), m.removeEventListener("dblclick", G), m.removeEventListener("wheel", T), m.removeEventListener("pointerdown", D), m.removeEventListener("pointerup", _), m.removeEventListener("pointermove", F), m.removeEventListener("pointercancel", W);
|
|
246
244
|
};
|
|
247
245
|
}, [
|
|
248
246
|
e,
|
|
249
247
|
t.onPointerMissed,
|
|
250
248
|
j,
|
|
251
|
-
|
|
249
|
+
V
|
|
252
250
|
]);
|
|
253
|
-
const
|
|
251
|
+
const M = g(
|
|
254
252
|
() => ({
|
|
255
253
|
two: e,
|
|
256
254
|
registerEventShape: j,
|
|
257
|
-
unregisterEventShape:
|
|
255
|
+
unregisterEventShape: V
|
|
258
256
|
}),
|
|
259
|
-
[
|
|
260
|
-
|
|
261
|
-
j,
|
|
262
|
-
M
|
|
263
|
-
]
|
|
264
|
-
), D = g(
|
|
257
|
+
[e, j, V]
|
|
258
|
+
), x = g(
|
|
265
259
|
() => ({
|
|
266
260
|
parent: c
|
|
267
261
|
}),
|
|
@@ -273,9 +267,9 @@ const pe = (t) => {
|
|
|
273
267
|
}),
|
|
274
268
|
[d, v]
|
|
275
269
|
);
|
|
276
|
-
return /* @__PURE__ */
|
|
270
|
+
return /* @__PURE__ */ b(ee.Provider, { value: M, children: /* @__PURE__ */ b(J.Provider, { value: x, children: /* @__PURE__ */ b(Q.Provider, { value: K, children: /* @__PURE__ */ b("div", { ref: l, ...t.container, children: t.children }) }) }) });
|
|
277
271
|
}, ge = k.forwardRef(
|
|
278
|
-
({ x: t, y:
|
|
272
|
+
({ x: t, y: i, ...r }, l) => {
|
|
279
273
|
const {
|
|
280
274
|
two: n,
|
|
281
275
|
parent: u,
|
|
@@ -283,38 +277,38 @@ const pe = (t) => {
|
|
|
283
277
|
height: e,
|
|
284
278
|
registerEventShape: o,
|
|
285
279
|
unregisterEventShape: c
|
|
286
|
-
} = C(),
|
|
287
|
-
const
|
|
288
|
-
for (const
|
|
289
|
-
|
|
290
|
-
|
|
280
|
+
} = C(), s = g(() => new H.Group(), []), { eventHandlers: d, shapeProps: f } = g(() => {
|
|
281
|
+
const V = {}, M = {};
|
|
282
|
+
for (const x in r)
|
|
283
|
+
L.includes(x) ? V[x] = r[
|
|
284
|
+
x
|
|
291
285
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
292
|
-
] : x
|
|
293
|
-
return { eventHandlers:
|
|
286
|
+
] : M[x] = r[x];
|
|
287
|
+
return { eventHandlers: V, shapeProps: M };
|
|
294
288
|
}, [r]);
|
|
295
289
|
h(() => {
|
|
296
290
|
if (u)
|
|
297
|
-
return u.add(
|
|
298
|
-
u.remove(
|
|
299
|
-
};
|
|
300
|
-
}, [u,
|
|
301
|
-
typeof t == "number" && (
|
|
302
|
-
const
|
|
303
|
-
delete
|
|
304
|
-
for (const
|
|
305
|
-
|
|
306
|
-
}, [
|
|
291
|
+
return u.add(s), () => {
|
|
292
|
+
u.remove(s);
|
|
293
|
+
};
|
|
294
|
+
}, [u, s]), h(() => {
|
|
295
|
+
typeof t == "number" && (s.translation.x = t), typeof i == "number" && (s.translation.y = i);
|
|
296
|
+
const V = { ...f };
|
|
297
|
+
delete V.children;
|
|
298
|
+
for (const M in V)
|
|
299
|
+
M in s && (s[M] = V[M]);
|
|
300
|
+
}, [s, t, i, f]), h(() => {
|
|
307
301
|
if (Object.keys(d).length > 0)
|
|
308
|
-
return o(
|
|
309
|
-
c(
|
|
302
|
+
return o(s, d, u ?? void 0), () => {
|
|
303
|
+
c(s);
|
|
310
304
|
};
|
|
311
305
|
}, [
|
|
312
|
-
|
|
306
|
+
s,
|
|
313
307
|
o,
|
|
314
308
|
c,
|
|
315
309
|
u,
|
|
316
310
|
d
|
|
317
|
-
]), R(l, () =>
|
|
311
|
+
]), R(l, () => s, [s]);
|
|
318
312
|
const v = g(
|
|
319
313
|
() => ({
|
|
320
314
|
two: n,
|
|
@@ -324,9 +318,9 @@ const pe = (t) => {
|
|
|
324
318
|
[n, o, c]
|
|
325
319
|
), p = g(
|
|
326
320
|
() => ({
|
|
327
|
-
parent:
|
|
321
|
+
parent: s
|
|
328
322
|
}),
|
|
329
|
-
[
|
|
323
|
+
[s]
|
|
330
324
|
), j = g(
|
|
331
325
|
() => ({
|
|
332
326
|
width: a,
|
|
@@ -334,31 +328,31 @@ const pe = (t) => {
|
|
|
334
328
|
}),
|
|
335
329
|
[a, e]
|
|
336
330
|
);
|
|
337
|
-
return /* @__PURE__ */
|
|
331
|
+
return /* @__PURE__ */ b(ce.Provider, { value: v, children: /* @__PURE__ */ b(J.Provider, { value: p, children: /* @__PURE__ */ b(Q.Provider, { value: j, children: r.children }) }) });
|
|
338
332
|
}
|
|
339
333
|
), ye = k.forwardRef(
|
|
340
|
-
({ x: t, y:
|
|
334
|
+
({ x: t, y: i, src: r, content: l, onLoad: n, onError: u, ...a }, e) => {
|
|
341
335
|
const {
|
|
342
336
|
two: o,
|
|
343
337
|
parent: c,
|
|
344
|
-
width:
|
|
338
|
+
width: s,
|
|
345
339
|
height: d,
|
|
346
340
|
registerEventShape: f,
|
|
347
341
|
unregisterEventShape: v
|
|
348
|
-
} = C(), p = g(() => new H.Group(), []), j =
|
|
342
|
+
} = C(), p = g(() => new H.Group(), []), j = N(null), V = N(n), M = N(u), x = N({ two: null, key: null });
|
|
349
343
|
h(() => {
|
|
350
|
-
|
|
344
|
+
V.current = n;
|
|
351
345
|
}, [n]), h(() => {
|
|
352
|
-
|
|
346
|
+
M.current = u;
|
|
353
347
|
}, [u]);
|
|
354
348
|
const { eventHandlers: K, shapeProps: m } = g(() => {
|
|
355
|
-
const
|
|
356
|
-
for (const
|
|
357
|
-
|
|
358
|
-
|
|
349
|
+
const G = {}, T = {};
|
|
350
|
+
for (const D in a)
|
|
351
|
+
L.includes(D) ? G[D] = a[
|
|
352
|
+
D
|
|
359
353
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
360
|
-
] :
|
|
361
|
-
return { eventHandlers:
|
|
354
|
+
] : T[D] = a[D];
|
|
355
|
+
return { eventHandlers: G, shapeProps: T };
|
|
362
356
|
}, [a]);
|
|
363
357
|
h(() => {
|
|
364
358
|
j.current = p;
|
|
@@ -375,56 +369,56 @@ const pe = (t) => {
|
|
|
375
369
|
);
|
|
376
370
|
}, [r, l]), h(() => {
|
|
377
371
|
if (!o) return;
|
|
378
|
-
const
|
|
379
|
-
if (!
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
372
|
+
const G = r || l;
|
|
373
|
+
if (!G) return;
|
|
374
|
+
const T = G, D = x.current;
|
|
375
|
+
if (D.two === o && D.key === T)
|
|
382
376
|
return;
|
|
383
377
|
let _ = !0;
|
|
384
|
-
|
|
378
|
+
x.current = { two: o, key: T };
|
|
385
379
|
try {
|
|
386
380
|
o.load(
|
|
387
|
-
|
|
388
|
-
(
|
|
381
|
+
G,
|
|
382
|
+
(F, W) => {
|
|
389
383
|
if (!_) return;
|
|
390
|
-
j.current?.add(
|
|
391
|
-
const y =
|
|
384
|
+
j.current?.add(F.children);
|
|
385
|
+
const y = V.current;
|
|
392
386
|
if (y)
|
|
393
387
|
try {
|
|
394
388
|
requestAnimationFrame(() => y(j.current, W));
|
|
395
|
-
} catch (
|
|
389
|
+
} catch (P) {
|
|
396
390
|
console.error(
|
|
397
391
|
"[react-two.js] Error in SVG onLoad callback:",
|
|
398
|
-
|
|
392
|
+
P
|
|
399
393
|
);
|
|
400
394
|
}
|
|
401
395
|
}
|
|
402
396
|
);
|
|
403
|
-
} catch (
|
|
397
|
+
} catch (F) {
|
|
404
398
|
if (!_) return;
|
|
405
|
-
const W =
|
|
399
|
+
const W = F instanceof Error ? F : new Error("Failed to load SVG"), y = M.current;
|
|
406
400
|
if (y)
|
|
407
401
|
try {
|
|
408
402
|
y(W);
|
|
409
|
-
} catch (
|
|
403
|
+
} catch (P) {
|
|
410
404
|
console.error(
|
|
411
405
|
"[react-two.js] Error in SVG onError callback:",
|
|
412
|
-
|
|
406
|
+
P
|
|
413
407
|
);
|
|
414
408
|
}
|
|
415
409
|
else
|
|
416
410
|
console.error("[react-two.js] SVG loading error:", W);
|
|
417
411
|
}
|
|
418
412
|
return () => {
|
|
419
|
-
_ = !1,
|
|
413
|
+
_ = !1, x.current = { two: null, key: null }, j.current?.remove(j.current.children);
|
|
420
414
|
};
|
|
421
415
|
}, [o, r, l]), h(() => {
|
|
422
|
-
typeof t == "number" && (p.translation.x = t), typeof
|
|
423
|
-
const
|
|
424
|
-
delete
|
|
425
|
-
for (const
|
|
426
|
-
|
|
427
|
-
}, [p, t,
|
|
416
|
+
typeof t == "number" && (p.translation.x = t), typeof i == "number" && (p.translation.y = i);
|
|
417
|
+
const G = { ...m };
|
|
418
|
+
delete G.children;
|
|
419
|
+
for (const T in G)
|
|
420
|
+
T in p && (p[T] = G[T]);
|
|
421
|
+
}, [p, t, i, m]), h(() => {
|
|
428
422
|
if (Object.keys(K).length > 0)
|
|
429
423
|
return f(p, K, c ?? void 0), () => {
|
|
430
424
|
v(p);
|
|
@@ -437,26 +431,26 @@ const pe = (t) => {
|
|
|
437
431
|
unregisterEventShape: v
|
|
438
432
|
}),
|
|
439
433
|
[o, f, v]
|
|
440
|
-
),
|
|
434
|
+
), E = g(
|
|
441
435
|
() => ({
|
|
442
436
|
parent: p
|
|
443
437
|
}),
|
|
444
438
|
[p]
|
|
445
|
-
),
|
|
439
|
+
), q = g(
|
|
446
440
|
() => ({
|
|
447
|
-
width:
|
|
441
|
+
width: s,
|
|
448
442
|
height: d
|
|
449
443
|
}),
|
|
450
|
-
[
|
|
444
|
+
[s, d]
|
|
451
445
|
);
|
|
452
|
-
return /* @__PURE__ */
|
|
446
|
+
return /* @__PURE__ */ b(ce.Provider, { value: S, children: /* @__PURE__ */ b(J.Provider, { value: E, children: /* @__PURE__ */ b(Q.Provider, { value: q, children: a.children }) }) });
|
|
453
447
|
}
|
|
454
448
|
), me = k.forwardRef(
|
|
455
|
-
({ manual: t, x:
|
|
456
|
-
const { parent: u, registerEventShape: a, unregisterEventShape: e } = C(), o = g(() => new H.Path(), []), { eventHandlers: c, shapeProps:
|
|
449
|
+
({ manual: t, x: i, y: r, ...l }, n) => {
|
|
450
|
+
const { parent: u, registerEventShape: a, unregisterEventShape: e } = C(), o = g(() => new H.Path(), []), { eventHandlers: c, shapeProps: s } = g(() => {
|
|
457
451
|
const d = {}, f = {};
|
|
458
452
|
for (const v in l)
|
|
459
|
-
|
|
453
|
+
L.includes(v) ? d[v] = l[
|
|
460
454
|
v
|
|
461
455
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
462
456
|
] : f[v] = l[v];
|
|
@@ -473,21 +467,21 @@ const pe = (t) => {
|
|
|
473
467
|
e(o);
|
|
474
468
|
};
|
|
475
469
|
}, [o, a, e, u, c]), h(() => {
|
|
476
|
-
typeof
|
|
477
|
-
for (const d in
|
|
478
|
-
d in o && (o[d] =
|
|
479
|
-
}, [
|
|
470
|
+
typeof i == "number" && (o.translation.x = i), typeof r == "number" && (o.translation.y = r), typeof t < "u" && (o.automatic = !t);
|
|
471
|
+
for (const d in s)
|
|
472
|
+
d in o && (o[d] = s[d]);
|
|
473
|
+
}, [s, o, i, r, t]), R(n, () => o, [o]), /* @__PURE__ */ b(O, {});
|
|
480
474
|
}
|
|
481
|
-
),
|
|
482
|
-
({ x: t, y:
|
|
475
|
+
), Pe = k.forwardRef(
|
|
476
|
+
({ x: t, y: i, ...r }, l) => {
|
|
483
477
|
const { parent: n, registerEventShape: u, unregisterEventShape: a } = C(), e = g(() => new H.Points(), []), { eventHandlers: o, shapeProps: c } = g(() => {
|
|
484
|
-
const
|
|
478
|
+
const s = {}, d = {};
|
|
485
479
|
for (const f in r)
|
|
486
|
-
|
|
480
|
+
L.includes(f) ? s[f] = r[
|
|
487
481
|
f
|
|
488
482
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
489
483
|
] : d[f] = r[f];
|
|
490
|
-
return { eventHandlers:
|
|
484
|
+
return { eventHandlers: s, shapeProps: d };
|
|
491
485
|
}, [r]);
|
|
492
486
|
return h(() => {
|
|
493
487
|
if (n)
|
|
@@ -495,10 +489,10 @@ const pe = (t) => {
|
|
|
495
489
|
n.remove(e);
|
|
496
490
|
};
|
|
497
491
|
}, [n, e]), h(() => {
|
|
498
|
-
typeof t == "number" && (e.translation.x = t), typeof
|
|
499
|
-
for (const
|
|
500
|
-
|
|
501
|
-
}, [c, e, t,
|
|
492
|
+
typeof t == "number" && (e.translation.x = t), typeof i == "number" && (e.translation.y = i);
|
|
493
|
+
for (const s in c)
|
|
494
|
+
s in e && (e[s] = c[s]);
|
|
495
|
+
}, [c, e, t, i]), h(() => {
|
|
502
496
|
if (Object.keys(o).length > 0)
|
|
503
497
|
return u(e, o, n ?? void 0), () => {
|
|
504
498
|
a(e);
|
|
@@ -509,18 +503,18 @@ const pe = (t) => {
|
|
|
509
503
|
a,
|
|
510
504
|
n,
|
|
511
505
|
o
|
|
512
|
-
]), R(l, () => e, [e]), /* @__PURE__ */
|
|
506
|
+
]), R(l, () => e, [e]), /* @__PURE__ */ b(O, {});
|
|
513
507
|
}
|
|
514
|
-
),
|
|
515
|
-
({ x: t, y:
|
|
508
|
+
), we = k.forwardRef(
|
|
509
|
+
({ x: t, y: i, ...r }, l) => {
|
|
516
510
|
const { parent: n, registerEventShape: u, unregisterEventShape: a } = C(), e = g(() => new H.Text(), []), { eventHandlers: o, shapeProps: c } = g(() => {
|
|
517
|
-
const
|
|
511
|
+
const s = {}, d = {};
|
|
518
512
|
for (const f in r)
|
|
519
|
-
|
|
513
|
+
L.includes(f) ? s[f] = r[
|
|
520
514
|
f
|
|
521
515
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
522
516
|
] : d[f] = r[f];
|
|
523
|
-
return { eventHandlers:
|
|
517
|
+
return { eventHandlers: s, shapeProps: d };
|
|
524
518
|
}, [r]);
|
|
525
519
|
return h(() => {
|
|
526
520
|
if (n)
|
|
@@ -528,25 +522,25 @@ const pe = (t) => {
|
|
|
528
522
|
n.remove(e);
|
|
529
523
|
};
|
|
530
524
|
}, [n, e]), h(() => {
|
|
531
|
-
typeof t == "number" && (e.translation.x = t), typeof
|
|
532
|
-
for (const
|
|
533
|
-
|
|
534
|
-
}, [c, e, t,
|
|
525
|
+
typeof t == "number" && (e.translation.x = t), typeof i == "number" && (e.translation.y = i);
|
|
526
|
+
for (const s in c)
|
|
527
|
+
s in e && (e[s] = c[s]);
|
|
528
|
+
}, [c, e, t, i]), h(() => {
|
|
535
529
|
if (Object.keys(o).length > 0)
|
|
536
530
|
return u(e, o, n ?? void 0), () => {
|
|
537
531
|
a(e);
|
|
538
532
|
};
|
|
539
|
-
}, [e, u, a, n, o]), R(l, () => e, [e]), /* @__PURE__ */
|
|
533
|
+
}, [e, u, a, n, o]), R(l, () => e, [e]), /* @__PURE__ */ b(O, {});
|
|
540
534
|
}
|
|
541
535
|
), be = k.forwardRef(
|
|
542
|
-
({ x: t, y:
|
|
536
|
+
({ x: t, y: i, resolution: r, ...l }, n) => {
|
|
543
537
|
const { parent: u, registerEventShape: a, unregisterEventShape: e } = C(), o = g(
|
|
544
538
|
() => new H.ArcSegment(0, 0, 0, 0, 0, 0, r),
|
|
545
539
|
[r]
|
|
546
|
-
), { eventHandlers: c, shapeProps:
|
|
540
|
+
), { eventHandlers: c, shapeProps: s } = g(() => {
|
|
547
541
|
const d = {}, f = {};
|
|
548
542
|
for (const v in l)
|
|
549
|
-
|
|
543
|
+
L.includes(v) ? d[v] = l[
|
|
550
544
|
v
|
|
551
545
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
552
546
|
] : f[v] = l[v];
|
|
@@ -558,10 +552,10 @@ const pe = (t) => {
|
|
|
558
552
|
u.remove(o);
|
|
559
553
|
};
|
|
560
554
|
}, [u, o]), h(() => {
|
|
561
|
-
typeof t == "number" && (o.translation.x = t), typeof
|
|
562
|
-
for (const d in
|
|
563
|
-
d in o && (o[d] =
|
|
564
|
-
}, [
|
|
555
|
+
typeof t == "number" && (o.translation.x = t), typeof i == "number" && (o.translation.y = i);
|
|
556
|
+
for (const d in s)
|
|
557
|
+
d in o && (o[d] = s[d]);
|
|
558
|
+
}, [s, o, t, i]), h(() => {
|
|
565
559
|
if (Object.keys(c).length > 0)
|
|
566
560
|
return a(o, c, u ?? void 0), () => {
|
|
567
561
|
e(o);
|
|
@@ -572,27 +566,27 @@ const pe = (t) => {
|
|
|
572
566
|
e,
|
|
573
567
|
u,
|
|
574
568
|
c
|
|
575
|
-
]), R(n, () => o, [o]), /* @__PURE__ */
|
|
569
|
+
]), R(n, () => o, [o]), /* @__PURE__ */ b(O, {});
|
|
576
570
|
}
|
|
577
571
|
), Ee = k.forwardRef(
|
|
578
|
-
({ x: t, y:
|
|
572
|
+
({ x: t, y: i, resolution: r, ...l }, n) => {
|
|
579
573
|
const { parent: u, registerEventShape: a, unregisterEventShape: e } = C(), o = g(
|
|
580
574
|
() => new H.Circle(0, 0, 0, r),
|
|
581
575
|
[r]
|
|
582
|
-
), { eventHandlers: c, shapeProps:
|
|
576
|
+
), { eventHandlers: c, shapeProps: s } = g(() => {
|
|
583
577
|
const d = {}, f = {};
|
|
584
578
|
for (const v in l)
|
|
585
|
-
|
|
579
|
+
L.includes(v) ? d[v] = l[
|
|
586
580
|
v
|
|
587
581
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
588
582
|
] : f[v] = l[v];
|
|
589
583
|
return { eventHandlers: d, shapeProps: f };
|
|
590
584
|
}, [l]);
|
|
591
585
|
return h(() => {
|
|
592
|
-
typeof t == "number" && (o.translation.x = t), typeof
|
|
593
|
-
for (const d in
|
|
594
|
-
d in o && (o[d] =
|
|
595
|
-
}, [o,
|
|
586
|
+
typeof t == "number" && (o.translation.x = t), typeof i == "number" && (o.translation.y = i);
|
|
587
|
+
for (const d in s)
|
|
588
|
+
d in o && (o[d] = s[d]);
|
|
589
|
+
}, [o, s, t, i]), h(() => {
|
|
596
590
|
if (u)
|
|
597
591
|
return u.add(o), () => {
|
|
598
592
|
u.remove(o);
|
|
@@ -608,17 +602,17 @@ const pe = (t) => {
|
|
|
608
602
|
e,
|
|
609
603
|
u,
|
|
610
604
|
c
|
|
611
|
-
]), R(n, () => o, [o]), /* @__PURE__ */
|
|
605
|
+
]), R(n, () => o, [o]), /* @__PURE__ */ b(O, {});
|
|
612
606
|
}
|
|
613
607
|
), Se = k.forwardRef(
|
|
614
|
-
({ x: t, y:
|
|
608
|
+
({ x: t, y: i, resolution: r, ...l }, n) => {
|
|
615
609
|
const { parent: u, registerEventShape: a, unregisterEventShape: e } = C(), o = g(
|
|
616
610
|
() => new H.Ellipse(0, 0, 0, 0, r),
|
|
617
611
|
[r]
|
|
618
|
-
), { eventHandlers: c, shapeProps:
|
|
612
|
+
), { eventHandlers: c, shapeProps: s } = g(() => {
|
|
619
613
|
const d = {}, f = {};
|
|
620
614
|
for (const v in l)
|
|
621
|
-
|
|
615
|
+
L.includes(v) ? d[v] = l[
|
|
622
616
|
v
|
|
623
617
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
624
618
|
] : f[v] = l[v];
|
|
@@ -630,10 +624,10 @@ const pe = (t) => {
|
|
|
630
624
|
u.remove(o);
|
|
631
625
|
};
|
|
632
626
|
}, [u, o]), h(() => {
|
|
633
|
-
typeof t == "number" && (o.translation.x = t), typeof
|
|
634
|
-
for (const d in
|
|
635
|
-
d in o && (o[d] =
|
|
636
|
-
}, [o, t,
|
|
627
|
+
typeof t == "number" && (o.translation.x = t), typeof i == "number" && (o.translation.y = i);
|
|
628
|
+
for (const d in s)
|
|
629
|
+
d in o && (o[d] = s[d]);
|
|
630
|
+
}, [o, t, i, s]), h(() => {
|
|
637
631
|
if (Object.keys(c).length > 0)
|
|
638
632
|
return a(o, c, u ?? void 0), () => {
|
|
639
633
|
e(o);
|
|
@@ -644,14 +638,14 @@ const pe = (t) => {
|
|
|
644
638
|
e,
|
|
645
639
|
u,
|
|
646
640
|
c
|
|
647
|
-
]), R(n, () => o, [o]), /* @__PURE__ */
|
|
641
|
+
]), R(n, () => o, [o]), /* @__PURE__ */ b(O, {});
|
|
648
642
|
}
|
|
649
643
|
), ke = k.forwardRef(
|
|
650
|
-
({ mode: t, src:
|
|
651
|
-
const { parent: e, registerEventShape: o, unregisterEventShape: c } = C(),
|
|
644
|
+
({ mode: t, src: i, texture: r, x: l, y: n, ...u }, a) => {
|
|
645
|
+
const { parent: e, registerEventShape: o, unregisterEventShape: c } = C(), s = g(() => new H.Image(i), [i]), { eventHandlers: d, shapeProps: f } = g(() => {
|
|
652
646
|
const v = {}, p = {};
|
|
653
647
|
for (const j in u)
|
|
654
|
-
|
|
648
|
+
L.includes(j) ? v[j] = u[
|
|
655
649
|
j
|
|
656
650
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
657
651
|
] : p[j] = u[j];
|
|
@@ -659,32 +653,32 @@ const pe = (t) => {
|
|
|
659
653
|
}, [u]);
|
|
660
654
|
return h(() => {
|
|
661
655
|
if (e)
|
|
662
|
-
return e.add(
|
|
663
|
-
e.remove(
|
|
656
|
+
return e.add(s), () => {
|
|
657
|
+
e.remove(s);
|
|
664
658
|
};
|
|
665
|
-
}, [e,
|
|
666
|
-
typeof t < "u" && (
|
|
659
|
+
}, [e, s]), h(() => {
|
|
660
|
+
typeof t < "u" && (s.mode = t), typeof r < "u" && (s.texture = r), typeof l == "number" && (s.translation.x = l), typeof n == "number" && (s.translation.y = n);
|
|
667
661
|
for (const v in f)
|
|
668
|
-
v in
|
|
669
|
-
}, [
|
|
662
|
+
v in s && (s[v] = f[v]);
|
|
663
|
+
}, [s, f, t, r, l, n]), h(() => {
|
|
670
664
|
if (Object.keys(d).length > 0)
|
|
671
|
-
return o(
|
|
672
|
-
c(
|
|
665
|
+
return o(s, d, e ?? void 0), () => {
|
|
666
|
+
c(s);
|
|
673
667
|
};
|
|
674
668
|
}, [
|
|
675
|
-
|
|
669
|
+
s,
|
|
676
670
|
o,
|
|
677
671
|
c,
|
|
678
672
|
e,
|
|
679
673
|
d
|
|
680
|
-
]), R(a, () =>
|
|
674
|
+
]), R(a, () => s, [s]), /* @__PURE__ */ b(O, {});
|
|
681
675
|
}
|
|
682
676
|
), He = k.forwardRef(
|
|
683
|
-
({ src: t, x:
|
|
684
|
-
const { parent: a, registerEventShape: e, unregisterEventShape: o } = C(), c = g(() => new H.ImageSequence(t), [t]), { eventHandlers:
|
|
677
|
+
({ src: t, x: i, y: r, autoPlay: l, ...n }, u) => {
|
|
678
|
+
const { parent: a, registerEventShape: e, unregisterEventShape: o } = C(), c = g(() => new H.ImageSequence(t), [t]), { eventHandlers: s, shapeProps: d } = g(() => {
|
|
685
679
|
const f = {}, v = {};
|
|
686
680
|
for (const p in n)
|
|
687
|
-
|
|
681
|
+
L.includes(p) ? f[p] = n[
|
|
688
682
|
p
|
|
689
683
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
690
684
|
] : v[p] = n[p];
|
|
@@ -696,12 +690,12 @@ const pe = (t) => {
|
|
|
696
690
|
a.remove(c);
|
|
697
691
|
};
|
|
698
692
|
}, [a, c]), h(() => {
|
|
699
|
-
l ? c.play() : c.pause(), typeof
|
|
693
|
+
l ? c.play() : c.pause(), typeof i == "number" && (c.translation.x = i), typeof r == "number" && (c.translation.y = r);
|
|
700
694
|
for (const f in d)
|
|
701
695
|
f in c && (c[f] = d[f]);
|
|
702
|
-
}, [d, c,
|
|
703
|
-
if (Object.keys(
|
|
704
|
-
return e(c,
|
|
696
|
+
}, [d, c, i, r, l]), h(() => {
|
|
697
|
+
if (Object.keys(s).length > 0)
|
|
698
|
+
return e(c, s, a ?? void 0), () => {
|
|
705
699
|
o(c);
|
|
706
700
|
};
|
|
707
701
|
}, [
|
|
@@ -709,15 +703,15 @@ const pe = (t) => {
|
|
|
709
703
|
e,
|
|
710
704
|
o,
|
|
711
705
|
a,
|
|
712
|
-
|
|
713
|
-
]), R(u, () => c, [c]), /* @__PURE__ */
|
|
706
|
+
s
|
|
707
|
+
]), R(u, () => c, [c]), /* @__PURE__ */ b(O, {});
|
|
714
708
|
}
|
|
715
709
|
), Re = k.forwardRef(
|
|
716
|
-
({ x1: t, y1:
|
|
717
|
-
const { parent: a, registerEventShape: e, unregisterEventShape: o } = C(), c = g(() => new H.Line(), []), { eventHandlers:
|
|
710
|
+
({ x1: t, y1: i, x2: r, y2: l, ...n }, u) => {
|
|
711
|
+
const { parent: a, registerEventShape: e, unregisterEventShape: o } = C(), c = g(() => new H.Line(), []), { eventHandlers: s, shapeProps: d } = g(() => {
|
|
718
712
|
const f = {}, v = {};
|
|
719
713
|
for (const p in n)
|
|
720
|
-
|
|
714
|
+
L.includes(p) ? f[p] = n[
|
|
721
715
|
p
|
|
722
716
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
723
717
|
] : v[p] = n[p];
|
|
@@ -729,26 +723,26 @@ const pe = (t) => {
|
|
|
729
723
|
a.remove(c);
|
|
730
724
|
};
|
|
731
725
|
}, [a, c]), h(() => {
|
|
732
|
-
typeof t == "number" && (c.left.x = t), typeof
|
|
726
|
+
typeof t == "number" && (c.left.x = t), typeof i == "number" && (c.left.y = i), typeof r == "number" && (c.right.x = r), typeof l == "number" && (c.right.y = l);
|
|
733
727
|
for (const f in d)
|
|
734
728
|
f in c && (c[f] = d[f]);
|
|
735
|
-
}, [d, c, t,
|
|
736
|
-
if (Object.keys(
|
|
737
|
-
return e(c,
|
|
729
|
+
}, [d, c, t, i, r, l]), h(() => {
|
|
730
|
+
if (Object.keys(s).length > 0)
|
|
731
|
+
return e(c, s, a ?? void 0), () => {
|
|
738
732
|
o(c);
|
|
739
733
|
};
|
|
740
|
-
}, [c, e, o, a,
|
|
734
|
+
}, [c, e, o, a, s]), R(u, () => c, [c]), /* @__PURE__ */ b(O, {});
|
|
741
735
|
}
|
|
742
736
|
), Ce = k.forwardRef(
|
|
743
|
-
({ x: t, y:
|
|
737
|
+
({ x: t, y: i, ...r }, l) => {
|
|
744
738
|
const { parent: n, registerEventShape: u, unregisterEventShape: a } = C(), e = g(() => new H.Polygon(), []), { eventHandlers: o, shapeProps: c } = g(() => {
|
|
745
|
-
const
|
|
739
|
+
const s = {}, d = {};
|
|
746
740
|
for (const f in r)
|
|
747
|
-
|
|
741
|
+
L.includes(f) ? s[f] = r[
|
|
748
742
|
f
|
|
749
743
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
750
744
|
] : d[f] = r[f];
|
|
751
|
-
return { eventHandlers:
|
|
745
|
+
return { eventHandlers: s, shapeProps: d };
|
|
752
746
|
}, [r]);
|
|
753
747
|
return h(() => {
|
|
754
748
|
if (n)
|
|
@@ -756,10 +750,10 @@ const pe = (t) => {
|
|
|
756
750
|
n.remove(e);
|
|
757
751
|
};
|
|
758
752
|
}, [n, e]), h(() => {
|
|
759
|
-
typeof t == "number" && (e.translation.x = t), typeof
|
|
760
|
-
for (const
|
|
761
|
-
|
|
762
|
-
}, [c, e, t,
|
|
753
|
+
typeof t == "number" && (e.translation.x = t), typeof i == "number" && (e.translation.y = i);
|
|
754
|
+
for (const s in c)
|
|
755
|
+
s in e && (e[s] = c[s]);
|
|
756
|
+
}, [c, e, t, i]), h(() => {
|
|
763
757
|
if (Object.keys(o).length > 0)
|
|
764
758
|
return u(e, o, n ?? void 0), () => {
|
|
765
759
|
a(e);
|
|
@@ -770,18 +764,18 @@ const pe = (t) => {
|
|
|
770
764
|
a,
|
|
771
765
|
n,
|
|
772
766
|
o
|
|
773
|
-
]), R(l, () => e, [e]), /* @__PURE__ */
|
|
767
|
+
]), R(l, () => e, [e]), /* @__PURE__ */ b(O, {});
|
|
774
768
|
}
|
|
775
769
|
), je = k.forwardRef(
|
|
776
|
-
({ x: t, y:
|
|
770
|
+
({ x: t, y: i, ...r }, l) => {
|
|
777
771
|
const { parent: n, registerEventShape: u, unregisterEventShape: a } = C(), e = g(() => new H.Rectangle(), []), { eventHandlers: o, shapeProps: c } = g(() => {
|
|
778
|
-
const
|
|
772
|
+
const s = {}, d = {};
|
|
779
773
|
for (const f in r)
|
|
780
|
-
|
|
774
|
+
L.includes(f) ? s[f] = r[
|
|
781
775
|
f
|
|
782
776
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
783
777
|
] : d[f] = r[f];
|
|
784
|
-
return { eventHandlers:
|
|
778
|
+
return { eventHandlers: s, shapeProps: d };
|
|
785
779
|
}, [r]);
|
|
786
780
|
return h(() => {
|
|
787
781
|
if (n)
|
|
@@ -789,10 +783,10 @@ const pe = (t) => {
|
|
|
789
783
|
n.remove(e);
|
|
790
784
|
};
|
|
791
785
|
}, [n, e]), h(() => {
|
|
792
|
-
typeof t == "number" && (e.translation.x = t), typeof
|
|
793
|
-
for (const
|
|
794
|
-
|
|
795
|
-
}, [c, e, t,
|
|
786
|
+
typeof t == "number" && (e.translation.x = t), typeof i == "number" && (e.translation.y = i);
|
|
787
|
+
for (const s in c)
|
|
788
|
+
s in e && (e[s] = c[s]);
|
|
789
|
+
}, [c, e, t, i]), h(() => {
|
|
796
790
|
if (Object.keys(o).length > 0)
|
|
797
791
|
return u(e, o, n ?? void 0), () => {
|
|
798
792
|
a(e);
|
|
@@ -803,18 +797,18 @@ const pe = (t) => {
|
|
|
803
797
|
a,
|
|
804
798
|
n,
|
|
805
799
|
o
|
|
806
|
-
]), R(l, () => e, [e]), /* @__PURE__ */
|
|
800
|
+
]), R(l, () => e, [e]), /* @__PURE__ */ b(O, {});
|
|
807
801
|
}
|
|
808
802
|
), Le = k.forwardRef(
|
|
809
|
-
({ x: t, y:
|
|
803
|
+
({ x: t, y: i, ...r }, l) => {
|
|
810
804
|
const { parent: n, registerEventShape: u, unregisterEventShape: a } = C(), e = g(() => new H.RoundedRectangle(), []), { eventHandlers: o, shapeProps: c } = g(() => {
|
|
811
|
-
const
|
|
805
|
+
const s = {}, d = {};
|
|
812
806
|
for (const f in r)
|
|
813
|
-
|
|
807
|
+
L.includes(f) ? s[f] = r[
|
|
814
808
|
f
|
|
815
809
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
816
810
|
] : d[f] = r[f];
|
|
817
|
-
return { eventHandlers:
|
|
811
|
+
return { eventHandlers: s, shapeProps: d };
|
|
818
812
|
}, [r]);
|
|
819
813
|
return h(() => {
|
|
820
814
|
if (n)
|
|
@@ -822,10 +816,10 @@ const pe = (t) => {
|
|
|
822
816
|
n.remove(e);
|
|
823
817
|
};
|
|
824
818
|
}, [n, e]), h(() => {
|
|
825
|
-
typeof t == "number" && (e.translation.x = t), typeof
|
|
826
|
-
for (const
|
|
827
|
-
|
|
828
|
-
}, [c, e, t,
|
|
819
|
+
typeof t == "number" && (e.translation.x = t), typeof i == "number" && (e.translation.y = i);
|
|
820
|
+
for (const s in c)
|
|
821
|
+
s in e && (e[s] = c[s]);
|
|
822
|
+
}, [c, e, t, i]), h(() => {
|
|
829
823
|
if (Object.keys(o).length > 0)
|
|
830
824
|
return u(
|
|
831
825
|
e,
|
|
@@ -842,14 +836,14 @@ const pe = (t) => {
|
|
|
842
836
|
o
|
|
843
837
|
]), R(l, () => e, [
|
|
844
838
|
e
|
|
845
|
-
]), /* @__PURE__ */
|
|
839
|
+
]), /* @__PURE__ */ b(O, {});
|
|
846
840
|
}
|
|
847
841
|
), Oe = k.forwardRef(
|
|
848
|
-
({ src: t, x:
|
|
849
|
-
const { parent: a, registerEventShape: e, unregisterEventShape: o } = C(), c = g(() => new H.Sprite(t), [t]), { eventHandlers:
|
|
842
|
+
({ src: t, x: i, y: r, autoPlay: l, ...n }, u) => {
|
|
843
|
+
const { parent: a, registerEventShape: e, unregisterEventShape: o } = C(), c = g(() => new H.Sprite(t), [t]), { eventHandlers: s, shapeProps: d } = g(() => {
|
|
850
844
|
const f = {}, v = {};
|
|
851
845
|
for (const p in n)
|
|
852
|
-
|
|
846
|
+
L.includes(p) ? f[p] = n[
|
|
853
847
|
p
|
|
854
848
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
855
849
|
] : v[p] = n[p];
|
|
@@ -861,12 +855,12 @@ const pe = (t) => {
|
|
|
861
855
|
a.remove(c);
|
|
862
856
|
};
|
|
863
857
|
}, [a, c]), h(() => {
|
|
864
|
-
typeof
|
|
858
|
+
typeof i == "number" && (c.translation.x = i), typeof r == "number" && (c.translation.y = r), l ? c.play() : c.pause();
|
|
865
859
|
for (const f in d)
|
|
866
860
|
f in c && (c[f] = d[f]);
|
|
867
|
-
}, [d, c,
|
|
868
|
-
if (Object.keys(
|
|
869
|
-
return e(c,
|
|
861
|
+
}, [d, c, i, r, l]), h(() => {
|
|
862
|
+
if (Object.keys(s).length > 0)
|
|
863
|
+
return e(c, s, a ?? void 0), () => {
|
|
870
864
|
o(c);
|
|
871
865
|
};
|
|
872
866
|
}, [
|
|
@@ -874,19 +868,19 @@ const pe = (t) => {
|
|
|
874
868
|
e,
|
|
875
869
|
o,
|
|
876
870
|
a,
|
|
877
|
-
|
|
878
|
-
]), R(u, () => c, [c]), /* @__PURE__ */
|
|
871
|
+
s
|
|
872
|
+
]), R(u, () => c, [c]), /* @__PURE__ */ b(O, {});
|
|
879
873
|
}
|
|
880
874
|
), Ve = k.forwardRef(
|
|
881
|
-
({ x: t, y:
|
|
875
|
+
({ x: t, y: i, ...r }, l) => {
|
|
882
876
|
const { parent: n, registerEventShape: u, unregisterEventShape: a } = C(), e = g(() => new H.Star(), []), { eventHandlers: o, shapeProps: c } = g(() => {
|
|
883
|
-
const
|
|
877
|
+
const s = {}, d = {};
|
|
884
878
|
for (const f in r)
|
|
885
|
-
|
|
879
|
+
L.includes(f) ? s[f] = r[
|
|
886
880
|
f
|
|
887
881
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
888
882
|
] : d[f] = r[f];
|
|
889
|
-
return { eventHandlers:
|
|
883
|
+
return { eventHandlers: s, shapeProps: d };
|
|
890
884
|
}, [r]);
|
|
891
885
|
return h(() => {
|
|
892
886
|
if (n)
|
|
@@ -894,41 +888,41 @@ const pe = (t) => {
|
|
|
894
888
|
n.remove(e);
|
|
895
889
|
};
|
|
896
890
|
}, [n, e]), h(() => {
|
|
897
|
-
typeof t == "number" && (e.translation.x = t), typeof
|
|
898
|
-
for (const
|
|
899
|
-
|
|
900
|
-
}, [c, e, t,
|
|
891
|
+
typeof t == "number" && (e.translation.x = t), typeof i == "number" && (e.translation.y = i);
|
|
892
|
+
for (const s in c)
|
|
893
|
+
s in e && (e[s] = c[s]);
|
|
894
|
+
}, [c, e, t, i]), h(() => {
|
|
901
895
|
if (Object.keys(o).length > 0)
|
|
902
896
|
return u(e, o, n ?? void 0), () => {
|
|
903
897
|
a(e);
|
|
904
898
|
};
|
|
905
|
-
}, [e, u, a, n, o]), R(l, () => e, [e]), /* @__PURE__ */
|
|
899
|
+
}, [e, u, a, n, o]), R(l, () => e, [e]), /* @__PURE__ */ b(O, {});
|
|
906
900
|
}
|
|
907
901
|
), Ge = k.forwardRef(
|
|
908
|
-
({ x1: t, y1:
|
|
902
|
+
({ x1: t, y1: i, x2: r, y2: l, ...n }, u) => {
|
|
909
903
|
const a = g(() => new H.LinearGradient(), []);
|
|
910
904
|
return h(() => {
|
|
911
|
-
typeof t == "number" && (a.left.x = t), typeof
|
|
905
|
+
typeof t == "number" && (a.left.x = t), typeof i == "number" && (a.left.y = i), typeof r == "number" && (a.right.x = r), typeof l == "number" && (a.right.y = l);
|
|
912
906
|
for (const e in n)
|
|
913
907
|
e in a && (a[e] = n[e]);
|
|
914
|
-
}, [a, t,
|
|
908
|
+
}, [a, t, i, r, l, n]), R(u, () => a, [a]), null;
|
|
915
909
|
}
|
|
916
910
|
), Te = k.forwardRef(
|
|
917
|
-
({ x: t, y:
|
|
911
|
+
({ x: t, y: i, focalX: r, focalY: l, ...n }, u) => {
|
|
918
912
|
const a = g(() => new H.RadialGradient(), []);
|
|
919
913
|
return h(() => {
|
|
920
|
-
typeof t == "number" && (a.center.x = t), typeof
|
|
914
|
+
typeof t == "number" && (a.center.x = t), typeof i == "number" && (a.center.y = i), typeof r == "number" && (a.focal.x = r), typeof l == "number" && (a.focal.y = l);
|
|
921
915
|
for (const e in n)
|
|
922
916
|
e in a && (a[e] = n[e]);
|
|
923
|
-
}, [n, a, t,
|
|
917
|
+
}, [n, a, t, i, r, l]), R(u, () => a, [a]), null;
|
|
924
918
|
}
|
|
925
919
|
), Me = k.forwardRef(
|
|
926
|
-
({ src: t, ...
|
|
920
|
+
({ src: t, ...i }, r) => {
|
|
927
921
|
const l = g(() => new H.Texture(t), [t]);
|
|
928
922
|
return h(() => {
|
|
929
|
-
for (const n in
|
|
930
|
-
n in l && (l[n] =
|
|
931
|
-
}, [
|
|
923
|
+
for (const n in i)
|
|
924
|
+
n in l && (l[n] = i[n]);
|
|
925
|
+
}, [i, l]), R(r, () => l, [l]), null;
|
|
932
926
|
}
|
|
933
927
|
);
|
|
934
928
|
export {
|
|
@@ -943,7 +937,7 @@ export {
|
|
|
943
937
|
Re as Line,
|
|
944
938
|
Ge as LinearGradient,
|
|
945
939
|
me as Path,
|
|
946
|
-
|
|
940
|
+
Pe as Points,
|
|
947
941
|
Ce as Polygon,
|
|
948
942
|
Te as RadialGradient,
|
|
949
943
|
je as Rectangle,
|
|
@@ -951,7 +945,7 @@ export {
|
|
|
951
945
|
ye as SVG,
|
|
952
946
|
Oe as Sprite,
|
|
953
947
|
Ve as Star,
|
|
954
|
-
|
|
948
|
+
we as Text,
|
|
955
949
|
Me as Texture,
|
|
956
950
|
ve as useFrame,
|
|
957
951
|
C as useTwo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-two.js",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.23-r.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React virtual DOM for Two.js — a renderer agnostic two-dimensional drawing API for the web",
|
|
6
6
|
"main": "./dist/react-two-main.es.js",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@types/react-dom": "^18.3.1",
|
|
64
64
|
"@vitejs/plugin-react": "^4.3.3",
|
|
65
65
|
"@vitest/ui": "^3.2.4",
|
|
66
|
+
"baseline-browser-mapping": "^2.9.14",
|
|
66
67
|
"clsx": "^2.1.1",
|
|
67
68
|
"eslint": "^9.13.0",
|
|
68
69
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
@@ -80,6 +81,6 @@
|
|
|
80
81
|
"peerDependencies": {
|
|
81
82
|
"react": ">=19",
|
|
82
83
|
"react-dom": ">=19",
|
|
83
|
-
"two.js": ">=v0.8.
|
|
84
|
+
"two.js": ">=v0.8.23"
|
|
84
85
|
}
|
|
85
86
|
}
|