react-two.js 0.2.4 → 0.8.22-r.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -3
- package/dist/ArcSegment.d.ts +3 -2
- package/dist/Circle.d.ts +3 -2
- package/dist/Context.d.ts +8 -8
- package/dist/Ellipse.d.ts +3 -2
- package/dist/Events.d.ts +97 -0
- package/dist/Group.d.ts +2 -1
- package/dist/Image.d.ts +4 -2
- package/dist/ImageSequence.d.ts +4 -3
- package/dist/Line.d.ts +3 -2
- package/dist/Path.d.ts +3 -3
- package/dist/Points.d.ts +3 -2
- package/dist/Polygon.d.ts +3 -2
- package/dist/Properties.d.ts +1 -0
- package/dist/Provider.d.ts +3 -1
- package/dist/Rectangle.d.ts +3 -2
- package/dist/RoundedRectangle.d.ts +3 -2
- package/dist/SVG.d.ts +22 -0
- package/dist/Sprite.d.ts +4 -3
- package/dist/Star.d.ts +3 -2
- package/dist/Text.d.ts +4 -3
- package/dist/Texture.d.ts +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/react-two-main.es.js +891 -416
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -67,8 +67,8 @@ npm install react-two.js react react-dom two.js
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
**Requirements** as peer dependencies:
|
|
70
|
-
- React
|
|
71
|
-
- Two.js v0.8.
|
|
70
|
+
- React 19+
|
|
71
|
+
- Two.js v0.8.22+
|
|
72
72
|
|
|
73
73
|
> [!IMPORTANT]
|
|
74
74
|
> react-two.js is a React renderer, it must pair with a major version of React, like react-dom.
|
|
@@ -96,6 +96,25 @@ function App() {
|
|
|
96
96
|
}
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
+
> [!IMPORTANT]
|
|
100
|
+
> **Canvas Children Restrictions:** Similar to [react-three-fiber](https://github.com/pmndrs/react-three-fiber), the `<Canvas>` component only accepts react-two.js components as children. DOM elements like `<div>` or `<span>` cannot be used inside Canvas. Place UI elements outside the Canvas:
|
|
101
|
+
>
|
|
102
|
+
> ```jsx
|
|
103
|
+
> // ✅ Correct
|
|
104
|
+
> <div>
|
|
105
|
+
> <Canvas>
|
|
106
|
+
> <Circle radius={50} />
|
|
107
|
+
> </Canvas>
|
|
108
|
+
> <div className="controls">UI here</div>
|
|
109
|
+
> </div>
|
|
110
|
+
>
|
|
111
|
+
> // ❌ Incorrect - will trigger warnings
|
|
112
|
+
> <Canvas>
|
|
113
|
+
> <div>This will warn</div>
|
|
114
|
+
> <Circle radius={50} />
|
|
115
|
+
> </Canvas>
|
|
116
|
+
> ```
|
|
117
|
+
|
|
99
118
|
### Adding Shapes
|
|
100
119
|
|
|
101
120
|
All Two.js primitives are available as React components:
|
|
@@ -139,10 +158,11 @@ function Component() {
|
|
|
139
158
|
const { two, width, height } = useTwo()
|
|
140
159
|
|
|
141
160
|
useEffect(() => {
|
|
161
|
+
if (!two) return;
|
|
142
162
|
two.play();
|
|
143
163
|
console.log('Canvas size:', width, height)
|
|
144
164
|
console.log('Two.js instance:', instance)
|
|
145
|
-
}, [])
|
|
165
|
+
}, [two])
|
|
146
166
|
}
|
|
147
167
|
```
|
|
148
168
|
|
|
@@ -170,6 +190,7 @@ function Component() {
|
|
|
170
190
|
- **`<Text>`** — Text rendering
|
|
171
191
|
|
|
172
192
|
#### Advanced
|
|
193
|
+
- **`<SVG>`** — Load and interpret SVG files or inline SVG markup
|
|
173
194
|
- **`<Image>`** - Basic image class inspired by Figma
|
|
174
195
|
- **`<Sprite>`** — Animated sprite sheets
|
|
175
196
|
- **`<ImageSequence>`** — Animated image sequence
|
|
@@ -288,6 +309,75 @@ function () {
|
|
|
288
309
|
}
|
|
289
310
|
```
|
|
290
311
|
|
|
312
|
+
### Loading SVG Files
|
|
313
|
+
|
|
314
|
+
Load external SVG files or use inline SVG markup with the `<SVG>` component:
|
|
315
|
+
|
|
316
|
+
```jsx
|
|
317
|
+
import { SVG } from 'react-two.js'
|
|
318
|
+
|
|
319
|
+
// Load from external URL
|
|
320
|
+
function Logo() {
|
|
321
|
+
return (
|
|
322
|
+
<SVG
|
|
323
|
+
src="/assets/logo.svg"
|
|
324
|
+
x={100}
|
|
325
|
+
y={100}
|
|
326
|
+
onLoad={(group, svg) => {
|
|
327
|
+
console.log('SVG loaded with', group.children.length, 'objects')
|
|
328
|
+
}}
|
|
329
|
+
onError={(error) => {
|
|
330
|
+
console.error('Failed to load SVG:', error)
|
|
331
|
+
}}
|
|
332
|
+
/>
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Use inline SVG markup
|
|
337
|
+
function Icon() {
|
|
338
|
+
return (
|
|
339
|
+
<SVG
|
|
340
|
+
content={`
|
|
341
|
+
<svg viewBox="0 0 100 100">
|
|
342
|
+
<circle cx="50" cy="50" r="40" fill="#FF6B6B" />
|
|
343
|
+
<circle cx="35" cy="40" r="8" fill="white" />
|
|
344
|
+
<circle cx="65" cy="40" r="8" fill="white" />
|
|
345
|
+
</svg>
|
|
346
|
+
`}
|
|
347
|
+
x={200}
|
|
348
|
+
y={200}
|
|
349
|
+
scale={0.5}
|
|
350
|
+
/>
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Animate loaded SVG
|
|
355
|
+
function AnimatedIcon() {
|
|
356
|
+
const svgRef = useRef()
|
|
357
|
+
|
|
358
|
+
useFrame((elapsed) => {
|
|
359
|
+
if (svgRef.current) {
|
|
360
|
+
svgRef.current.rotation = Math.sin(elapsed) * 0.5
|
|
361
|
+
svgRef.current.scale = 1 + Math.sin(elapsed * 2) * 0.1
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
return <SVG ref={svgRef} src="/icon.svg" x={400} y={300} />
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**SVG Props:**
|
|
370
|
+
- `src` — URL to external .svg file
|
|
371
|
+
- `content` — Inline SVG markup string
|
|
372
|
+
- `x`, `y` — Position
|
|
373
|
+
- `scale`, `rotation` — Transform properties
|
|
374
|
+
- `onLoad(group, svg)` — Callback when SVG loads successfully
|
|
375
|
+
- `onError(error)` — Callback when loading fails
|
|
376
|
+
- All Two.js Group properties (fill, stroke, opacity, etc.)
|
|
377
|
+
|
|
378
|
+
> [!NOTE]
|
|
379
|
+
> The SVG component uses Two.js's `load()` method which supports a subset of SVG 1.1 features. Complex SVG features like filters, animations (SMIL), and some advanced elements may not be fully supported. Refer to [Two.js SVG documentation](https://two.js.org/docs/two/#two-interpret) for details on supported features.
|
|
380
|
+
|
|
291
381
|
## Learn More
|
|
292
382
|
|
|
293
383
|
- **[Two.js Documentation](https://two.js.org/docs/)** — Complete Two.js API reference
|
package/dist/ArcSegment.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ArcSegment as Instance } from 'two.js/src/shapes/arc-segment';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefArcSegment = Instance;
|
|
4
5
|
export declare const ArcSegment: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const ArcSegment: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -42,6 +43,6 @@ export declare const ArcSegment: React.ForwardRefExoticComponent<{
|
|
|
42
43
|
x?: number;
|
|
43
44
|
y?: number;
|
|
44
45
|
resolution?: number;
|
|
45
|
-
} & {
|
|
46
|
+
} & Partial<EventHandlers> & {
|
|
46
47
|
children?: React.ReactNode | undefined;
|
|
47
48
|
} & React.RefAttributes<Instance>>;
|
package/dist/Circle.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Circle as Instance } from 'two.js/src/shapes/circle';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefCircle = Instance;
|
|
4
5
|
export declare const Circle: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const Circle: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -39,6 +40,6 @@ export declare const Circle: React.ForwardRefExoticComponent<{
|
|
|
39
40
|
x?: number;
|
|
40
41
|
y?: number;
|
|
41
42
|
resolution?: number;
|
|
42
|
-
} & {
|
|
43
|
+
} & Partial<EventHandlers> & {
|
|
43
44
|
children?: React.ReactNode | undefined;
|
|
44
45
|
} & React.RefAttributes<Instance>>;
|
package/dist/Context.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import Two from 'two.js';
|
|
2
2
|
import type { Group } from 'two.js/src/group';
|
|
3
|
-
|
|
3
|
+
import type { Shape } from 'two.js/src/shape';
|
|
4
|
+
import type { EventHandlers } from './Events';
|
|
5
|
+
export interface TwoContext {
|
|
4
6
|
two: Two | null;
|
|
5
7
|
parent: Group | null;
|
|
6
8
|
width: number;
|
|
7
9
|
height: number;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
height: number;
|
|
14
|
-
};
|
|
10
|
+
registerEventShape: (shape: Shape | Group, handlers: Partial<EventHandlers>, parent?: Group) => void;
|
|
11
|
+
unregisterEventShape: (shape: Shape | Group) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const Context: import("react").Context<TwoContext>;
|
|
14
|
+
export declare const useTwo: () => TwoContext;
|
|
15
15
|
export declare const useFrame: (callback: (elapsed: number, frameDelta: number) => void, deps?: unknown[]) => void;
|
package/dist/Ellipse.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Ellipse as Instance } from 'two.js/src/shapes/ellipse';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefEllipse = Instance;
|
|
4
5
|
export declare const Ellipse: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const Ellipse: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -40,6 +41,6 @@ export declare const Ellipse: React.ForwardRefExoticComponent<{
|
|
|
40
41
|
x?: number;
|
|
41
42
|
y?: number;
|
|
42
43
|
resolution?: number;
|
|
43
|
-
} & {
|
|
44
|
+
} & Partial<EventHandlers> & {
|
|
44
45
|
children?: React.ReactNode | undefined;
|
|
45
46
|
} & React.RefAttributes<Instance | null>>;
|
package/dist/Events.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event system for react-two.js
|
|
3
|
+
* Implements R3F-style event handlers using Two.js hit testing
|
|
4
|
+
*/
|
|
5
|
+
import Two from 'two.js';
|
|
6
|
+
import type { Shape } from 'two.js/src/shape';
|
|
7
|
+
import type { Group } from 'two.js/src/group';
|
|
8
|
+
/**
|
|
9
|
+
* Event object passed to event handlers
|
|
10
|
+
* Similar to React Three Fiber's ThreeEvent
|
|
11
|
+
*/
|
|
12
|
+
export interface TwoEvent<T = Shape> {
|
|
13
|
+
/** The original DOM event */
|
|
14
|
+
nativeEvent: PointerEvent | MouseEvent | WheelEvent;
|
|
15
|
+
/** The shape that was directly hit */
|
|
16
|
+
target: T;
|
|
17
|
+
/** The shape that has the event handler (may be ancestor due to bubbling) */
|
|
18
|
+
currentTarget: T;
|
|
19
|
+
/** The point in Two.js coordinate space (center origin) */
|
|
20
|
+
point: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
24
|
+
/** Stop event from bubbling to parent groups */
|
|
25
|
+
stopPropagation: () => void;
|
|
26
|
+
/** Whether propagation was stopped */
|
|
27
|
+
stopped: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Event handler function type
|
|
31
|
+
*/
|
|
32
|
+
export type EventHandler<T = Shape> = (event: TwoEvent<T>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* All supported event handlers (matching R3F API)
|
|
35
|
+
*/
|
|
36
|
+
export interface EventHandlers {
|
|
37
|
+
onClick?: EventHandler;
|
|
38
|
+
onContextMenu?: EventHandler;
|
|
39
|
+
onDoubleClick?: EventHandler;
|
|
40
|
+
onWheel?: EventHandler;
|
|
41
|
+
onPointerDown?: EventHandler;
|
|
42
|
+
onPointerUp?: EventHandler;
|
|
43
|
+
onPointerOver?: EventHandler;
|
|
44
|
+
onPointerOut?: EventHandler;
|
|
45
|
+
onPointerEnter?: EventHandler;
|
|
46
|
+
onPointerLeave?: EventHandler;
|
|
47
|
+
onPointerMove?: EventHandler;
|
|
48
|
+
onPointerCancel?: EventHandler;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Event handler names for iteration
|
|
52
|
+
*/
|
|
53
|
+
export declare const EVENT_HANDLER_NAMES: readonly ["onClick", "onContextMenu", "onDoubleClick", "onWheel", "onPointerDown", "onPointerUp", "onPointerOver", "onPointerOut", "onPointerEnter", "onPointerLeave", "onPointerMove", "onPointerCancel"];
|
|
54
|
+
/**
|
|
55
|
+
* Shape registration entry for event system
|
|
56
|
+
*/
|
|
57
|
+
export interface EventShape {
|
|
58
|
+
shape: Shape | Group;
|
|
59
|
+
handlers: Partial<EventHandlers>;
|
|
60
|
+
parent?: Group;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Convert DOM event coordinates to Two.js coordinate space
|
|
64
|
+
* Two.js uses center origin (0,0 at center of canvas)
|
|
65
|
+
*/
|
|
66
|
+
export declare function getCanvasCoordinates(nativeEvent: PointerEvent | MouseEvent, canvas: HTMLElement, two: Two): {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Convert DOM event coordinates to world-space coordinates for hit testing
|
|
72
|
+
* World-space uses top-left origin (same as DOM but relative to canvas)
|
|
73
|
+
*/
|
|
74
|
+
export declare function getWorldCoordinates(nativeEvent: PointerEvent | MouseEvent, canvas: HTMLElement): {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Create a TwoEvent object from a DOM event
|
|
80
|
+
*/
|
|
81
|
+
export declare function createTwoEvent<T extends Shape | Group>(nativeEvent: PointerEvent | MouseEvent | WheelEvent, target: T, currentTarget: T, point: {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
}): TwoEvent<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a shape contains a point using Two.js hit testing
|
|
87
|
+
*/
|
|
88
|
+
export declare function hitTest(shape: Shape | Group, x: number, y: number): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Get all shapes at a point, sorted by depth (front to back)
|
|
91
|
+
* Uses scene graph traversal to maintain z-order
|
|
92
|
+
*/
|
|
93
|
+
export declare function getShapesAtPoint(shapes: Map<Shape | Group, EventShape>, x: number, y: number): Array<Shape | Group>;
|
|
94
|
+
/**
|
|
95
|
+
* Get the parent hierarchy for event bubbling
|
|
96
|
+
*/
|
|
97
|
+
export declare function getParentHierarchy(shape: Shape | Group, shapes: Map<Shape | Group, EventShape>): Array<Shape | Group>;
|
package/dist/Group.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Group as Instance } from 'two.js/src/group';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefGroup = Instance;
|
|
4
5
|
export declare const Group: React.ForwardRefExoticComponent<{
|
|
5
6
|
renderer?: {
|
|
@@ -29,6 +30,6 @@ export declare const Group: React.ForwardRefExoticComponent<{
|
|
|
29
30
|
} & {
|
|
30
31
|
x?: number;
|
|
31
32
|
y?: number;
|
|
32
|
-
} & {
|
|
33
|
+
} & Partial<EventHandlers> & {
|
|
33
34
|
children?: React.ReactNode | undefined;
|
|
34
35
|
} & React.RefAttributes<Instance>>;
|
package/dist/Image.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Image as Instance } from 'two.js/src/effects/image';
|
|
3
3
|
import type { Texture } from 'two.js/src/effects/texture';
|
|
4
|
+
import { type EventHandlers } from './Properties';
|
|
4
5
|
export type RefImage = Instance;
|
|
5
6
|
export declare const Image: React.ForwardRefExoticComponent<{
|
|
7
|
+
visible?: boolean | undefined;
|
|
6
8
|
renderer?: {
|
|
7
9
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
8
10
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -22,7 +24,6 @@ export declare const Image: React.ForwardRefExoticComponent<{
|
|
|
22
24
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | Texture | undefined;
|
|
23
25
|
linewidth?: number | undefined;
|
|
24
26
|
opacity?: number | undefined;
|
|
25
|
-
visible?: boolean | undefined;
|
|
26
27
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
27
28
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
28
29
|
miter?: number | undefined;
|
|
@@ -43,7 +44,8 @@ export declare const Image: React.ForwardRefExoticComponent<{
|
|
|
43
44
|
x?: number;
|
|
44
45
|
y?: number;
|
|
45
46
|
mode?: string;
|
|
47
|
+
src?: string | Texture;
|
|
46
48
|
texture?: Texture;
|
|
47
|
-
} & {
|
|
49
|
+
} & Partial<EventHandlers> & {
|
|
48
50
|
children?: React.ReactNode | undefined;
|
|
49
51
|
} & React.RefAttributes<Instance>>;
|
package/dist/ImageSequence.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ImageSequence as Instance } from 'two.js/src/effects/image-sequence';
|
|
3
3
|
import type { Texture } from 'two.js/src/effects/texture';
|
|
4
|
+
import { type EventHandlers } from './Properties';
|
|
4
5
|
export type RefImageSequence = Instance;
|
|
5
6
|
export declare const ImageSequence: React.ForwardRefExoticComponent<{
|
|
7
|
+
visible?: boolean | undefined;
|
|
6
8
|
renderer?: {
|
|
7
9
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
8
10
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -22,7 +24,6 @@ export declare const ImageSequence: React.ForwardRefExoticComponent<{
|
|
|
22
24
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | Texture | undefined;
|
|
23
25
|
linewidth?: number | undefined;
|
|
24
26
|
opacity?: number | undefined;
|
|
25
|
-
visible?: boolean | undefined;
|
|
26
27
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
27
28
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
28
29
|
miter?: number | undefined;
|
|
@@ -41,10 +42,10 @@ export declare const ImageSequence: React.ForwardRefExoticComponent<{
|
|
|
41
42
|
frameRate?: number | undefined;
|
|
42
43
|
index?: number | undefined;
|
|
43
44
|
} & {
|
|
44
|
-
|
|
45
|
+
src?: string | string[] | Texture | Texture[];
|
|
45
46
|
x?: number;
|
|
46
47
|
y?: number;
|
|
47
48
|
autoPlay?: boolean;
|
|
48
|
-
} & {
|
|
49
|
+
} & Partial<EventHandlers> & {
|
|
49
50
|
children?: React.ReactNode | undefined;
|
|
50
51
|
} & React.RefAttributes<Instance>>;
|
package/dist/Line.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Line as Instance } from 'two.js/src/shapes/line';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefLine = Instance;
|
|
4
5
|
export declare const Line: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const Line: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -41,6 +42,6 @@ export declare const Line: React.ForwardRefExoticComponent<{
|
|
|
41
42
|
y1?: number;
|
|
42
43
|
x2?: number;
|
|
43
44
|
y2?: number;
|
|
44
|
-
} & {
|
|
45
|
+
} & Partial<EventHandlers> & {
|
|
45
46
|
children?: React.ReactNode | undefined;
|
|
46
47
|
} & React.RefAttributes<Instance>>;
|
package/dist/Path.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Path as Instance } from 'two.js/src/path';
|
|
3
|
-
import { ShapeProps } from './Properties';
|
|
3
|
+
import { ShapeProps, type EventHandlers } from './Properties';
|
|
4
4
|
export type PathProps = ShapeProps | 'fill' | 'stroke' | 'linewidth' | 'opacity' | 'visible' | 'cap' | 'join' | 'miter' | 'closed' | 'curved' | 'automatic' | 'beginning' | 'ending' | 'dashes' | 'vertices';
|
|
5
5
|
export type RefPath = Instance;
|
|
6
6
|
export declare const Path: React.ForwardRefExoticComponent<{
|
|
7
|
+
visible?: boolean | 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;
|
|
@@ -23,7 +24,6 @@ export declare const Path: React.ForwardRefExoticComponent<{
|
|
|
23
24
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
24
25
|
linewidth?: number | undefined;
|
|
25
26
|
opacity?: number | undefined;
|
|
26
|
-
visible?: boolean | undefined;
|
|
27
27
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
28
28
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
29
29
|
miter?: number | undefined;
|
|
@@ -40,6 +40,6 @@ export declare const Path: React.ForwardRefExoticComponent<{
|
|
|
40
40
|
manual?: boolean;
|
|
41
41
|
x?: number;
|
|
42
42
|
y?: number;
|
|
43
|
-
} & {
|
|
43
|
+
} & Partial<EventHandlers> & {
|
|
44
44
|
children?: React.ReactNode | undefined;
|
|
45
45
|
} & React.RefAttributes<Instance>>;
|
package/dist/Points.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Points as Instance } from 'two.js/src/shapes/points';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefPoints = Instance;
|
|
4
5
|
export declare const Points: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const Points: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
beginning?: number | undefined;
|
|
26
27
|
ending?: number | undefined;
|
|
27
28
|
dashes?: (number[] & {
|
|
@@ -33,6 +34,6 @@ export declare const Points: React.ForwardRefExoticComponent<{
|
|
|
33
34
|
} & {
|
|
34
35
|
x?: number;
|
|
35
36
|
y?: number;
|
|
36
|
-
} & {
|
|
37
|
+
} & Partial<EventHandlers> & {
|
|
37
38
|
children?: React.ReactNode | undefined;
|
|
38
39
|
} & React.RefAttributes<Instance>>;
|
package/dist/Polygon.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Polygon as Instance } from 'two.js/src/shapes/polygon';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefPolygon = Instance;
|
|
4
5
|
export declare const Polygon: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const Polygon: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -41,6 +42,6 @@ export declare const Polygon: React.ForwardRefExoticComponent<{
|
|
|
41
42
|
x?: number;
|
|
42
43
|
y?: number;
|
|
43
44
|
radius?: number;
|
|
44
|
-
} & {
|
|
45
|
+
} & Partial<EventHandlers> & {
|
|
45
46
|
children?: React.ReactNode | undefined;
|
|
46
47
|
} & React.RefAttributes<Instance>>;
|
package/dist/Properties.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { EventHandlers, EventHandler, TwoEvent } from './Events';
|
|
1
2
|
export type ElementProps = 'renderer' | 'id' | 'className';
|
|
2
3
|
export type ShapeProps = ElementProps | 'position' | 'rotation' | 'scale' | 'skewX' | 'skewY' | 'matrix' | 'worldMatrix';
|
|
3
4
|
export type GradientProps = ElementProps | 'spread' | 'units' | 'stops';
|
package/dist/Provider.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import Two from 'two.js';
|
|
3
3
|
type TwoConstructorProps = ConstructorParameters<typeof Two>[0];
|
|
4
4
|
type TwoConstructorPropsKeys = NonNullable<TwoConstructorProps>;
|
|
5
|
-
type ComponentProps = React.PropsWithChildren<TwoConstructorPropsKeys
|
|
5
|
+
type ComponentProps = React.PropsWithChildren<TwoConstructorPropsKeys & {
|
|
6
|
+
onPointerMissed?: (event: PointerEvent) => void;
|
|
7
|
+
}>;
|
|
6
8
|
export declare const Provider: React.FC<ComponentProps>;
|
|
7
9
|
export {};
|
package/dist/Rectangle.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Rectangle as Instance } from 'two.js/src/shapes/rectangle';
|
|
3
3
|
import { PathProps } from './Path';
|
|
4
|
+
import { type EventHandlers } from './Properties';
|
|
4
5
|
export type RectangleProps = PathProps | 'width' | 'height';
|
|
5
6
|
export type RefRectangle = Instance;
|
|
6
7
|
export declare const Rectangle: React.ForwardRefExoticComponent<{
|
|
8
|
+
visible?: boolean | undefined;
|
|
7
9
|
renderer?: {
|
|
8
10
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
9
11
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -23,7 +25,6 @@ export declare const Rectangle: React.ForwardRefExoticComponent<{
|
|
|
23
25
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
24
26
|
linewidth?: number | undefined;
|
|
25
27
|
opacity?: number | undefined;
|
|
26
|
-
visible?: boolean | undefined;
|
|
27
28
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
28
29
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
29
30
|
miter?: number | undefined;
|
|
@@ -41,6 +42,6 @@ export declare const Rectangle: React.ForwardRefExoticComponent<{
|
|
|
41
42
|
} & {
|
|
42
43
|
x?: number;
|
|
43
44
|
y?: number;
|
|
44
|
-
} & {
|
|
45
|
+
} & Partial<EventHandlers> & {
|
|
45
46
|
children?: React.ReactNode | undefined;
|
|
46
47
|
} & React.RefAttributes<Instance>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { RoundedRectangle as Instance } from 'two.js/src/shapes/rounded-rectangle';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefRoundedRectangle = Instance;
|
|
4
5
|
export declare const RoundedRectangle: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const RoundedRectangle: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -40,6 +41,6 @@ export declare const RoundedRectangle: React.ForwardRefExoticComponent<{
|
|
|
40
41
|
} & {
|
|
41
42
|
x?: number;
|
|
42
43
|
y?: number;
|
|
43
|
-
} & {
|
|
44
|
+
} & Partial<EventHandlers> & {
|
|
44
45
|
children?: React.ReactNode | undefined;
|
|
45
46
|
} & React.RefAttributes<Instance>>;
|
package/dist/SVG.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Group as Instance } from 'two.js/src/group';
|
|
3
|
+
import { ShapeProps, type EventHandlers } from './Properties';
|
|
4
|
+
type GroupProps = ShapeProps | 'fill' | 'stroke' | 'linewidth' | 'cap' | 'join' | 'miter' | 'closed' | 'curved' | 'automatic';
|
|
5
|
+
type ComponentProps = React.PropsWithChildren<{
|
|
6
|
+
[K in Extract<GroupProps, keyof Instance>]?: Instance[K];
|
|
7
|
+
} & ({
|
|
8
|
+
src: string;
|
|
9
|
+
content?: never;
|
|
10
|
+
} | {
|
|
11
|
+
src?: never;
|
|
12
|
+
content: string;
|
|
13
|
+
}) & {
|
|
14
|
+
x?: number;
|
|
15
|
+
y?: number;
|
|
16
|
+
onLoad?: (group: Instance, svg: SVGElement | SVGElement[]) => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
shallow?: boolean;
|
|
19
|
+
} & Partial<EventHandlers>>;
|
|
20
|
+
export type RefSVG = Instance;
|
|
21
|
+
export declare const SVG: React.ForwardRefExoticComponent<ComponentProps & React.RefAttributes<Instance>>;
|
|
22
|
+
export {};
|
package/dist/Sprite.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Sprite as Instance } from 'two.js/src/effects/sprite';
|
|
3
|
+
import { type EventHandlers } from './Properties';
|
|
3
4
|
export type RefSprite = Instance;
|
|
4
5
|
export declare const Sprite: React.ForwardRefExoticComponent<{
|
|
6
|
+
visible?: boolean | undefined;
|
|
5
7
|
renderer?: {
|
|
6
8
|
type: "element" | "group" | "path" | "text" | "points" | string;
|
|
7
9
|
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
|
|
@@ -21,7 +23,6 @@ export declare const Sprite: React.ForwardRefExoticComponent<{
|
|
|
21
23
|
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
24
|
linewidth?: number | undefined;
|
|
23
25
|
opacity?: number | undefined;
|
|
24
|
-
visible?: boolean | undefined;
|
|
25
26
|
cap?: import("two.js/src/path").CapProperties | undefined;
|
|
26
27
|
join?: import("two.js/src/path").JoinProperties | undefined;
|
|
27
28
|
miter?: number | undefined;
|
|
@@ -42,10 +43,10 @@ export declare const Sprite: React.ForwardRefExoticComponent<{
|
|
|
42
43
|
columns?: number | undefined;
|
|
43
44
|
rows?: number | undefined;
|
|
44
45
|
} & {
|
|
45
|
-
|
|
46
|
+
src?: string;
|
|
46
47
|
x?: number;
|
|
47
48
|
y?: number;
|
|
48
49
|
autoPlay?: boolean;
|
|
49
|
-
} & {
|
|
50
|
+
} & Partial<EventHandlers> & {
|
|
50
51
|
children?: React.ReactNode | undefined;
|
|
51
52
|
} & React.RefAttributes<Instance>>;
|