react-two.js 0.1.0 → 0.2.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 CHANGED
@@ -1,95 +1,331 @@
1
- # @react/two.js
1
+ # react-two.js
2
2
 
3
- A React virtual DOM for Two.js — a renderer agnostic two-dimensional drawing API for the web. Supports SVG, Canvas, and WebGL rendering. Declaratively describe your Two.js scene within your React application.
3
+ ![Version](https://img.shields.io/npm/v/react-two.js?style=flat&colorA=000000&colorB=000000)
4
+ ![License](https://img.shields.io/npm/l/react-two.js?style=flat&colorA=000000&colorB=000000)
5
+
6
+ A React renderer for [Two.js](https://two.js.org) — bringing declarative, component-based 2D graphics to React. Build interactive SVG, Canvas, or WebGL scenes using familiar React patterns.
7
+
8
+ ```bash
9
+ npm install react-two.js react react-dom two.js
10
+ ```
11
+
12
+ ```jsx
13
+ import { Canvas, Circle, useFrame } from 'react-two.js'
14
+
15
+ function RotatingCircle() {
16
+ const ref = useRef()
17
+ useFrame((t) => ref.current.rotation = t * 0.5)
18
+ return <Circle ref={ref} radius={50} fill="#00AEFF" />
19
+ }
20
+
21
+ <Canvas width={800} height={600}>
22
+ <RotatingCircle />
23
+ </Canvas>
24
+ ```
25
+
26
+ ## Why react-two.js?
27
+
28
+ - 🎨 **Declarative 2D Graphics** — Describe your Two.js scene using React components
29
+ - ⚡ **Renderer Agnostic** — Switch between SVG, Canvas, and WebGL without changing code
30
+ - 🪝 **React Hooks** — Built-in `useFrame` for smooth animations and `useTwo` for instance access
31
+ - 📦 **Fully Typed** — Complete TypeScript support with proper types for all components
32
+ - 🎯 **Zero Overhead** — Direct mapping to Two.js primitives with no performance penalty
33
+ - 🔄 **Everything Works** — All Two.js features work seamlessly in React
34
+
35
+ ## What does it look like?
36
+
37
+ Create complex 2D scenes using React components:
38
+
39
+ ```jsx
40
+ import { Canvas, Group, Rectangle, Circle, Star, useFrame } from 'react-two.js'
41
+
42
+ function Scene() {
43
+ const groupRef = useRef()
44
+
45
+ useFrame((elapsed) => {
46
+ groupRef.current.rotation = Math.sin(elapsed) * 0.5
47
+ })
48
+
49
+ return (
50
+ <Group ref={groupRef} x={400} y={300}>
51
+ <Rectangle width={100} height={100} fill="#FF6B6B" />
52
+ <Circle radius={40} fill="#4ECDC4" x={60} />
53
+ <Star innerRadius={20} outerRadius={40} sides={5} fill="#FFE66D" x={-60} />
54
+ </Group>
55
+ )
56
+ }
57
+
58
+ <Canvas width={800} height={600} type="webgl">
59
+ <Scene />
60
+ </Canvas>
61
+ ```
4
62
 
5
63
  ## Installation
6
64
 
7
65
  ```bash
8
- npm install @react/two.js react react-dom two.js
66
+ npm install react-two.js react react-dom two.js
9
67
  ```
10
68
 
11
- ## Quick Start
69
+ **Requirements** as peer dependencies:
70
+ - React 18.3+
71
+ - Two.js v0.8.21+
72
+
73
+ > [!IMPORTANT]
74
+ > react-two.js is a React renderer, it must pair with a major version of React, just like react-dom, react-native, etc.
75
+
76
+ ## First Steps
77
+
78
+ ### Creating a Canvas
79
+
80
+ The `<Canvas>` component is your entry point. It creates a Two.js instance and manages the rendering context:
12
81
 
13
82
  ```jsx
14
- import { Canvas, Circle, Rectangle, useFrame } from '@react/two.js';
15
- import { useRef } from 'react';
83
+ import { Canvas } from 'react-two.js'
84
+
85
+ function App() {
86
+ return (
87
+ <Canvas
88
+ width={800}
89
+ height={600}
90
+ type="svg" // 'svg' | 'canvas' | 'webgl'
91
+ autostart={true}
92
+ >
93
+ {/* Your scene goes here */}
94
+ </Canvas>
95
+ )
96
+ }
97
+ ```
98
+
99
+ ### Adding Shapes
100
+
101
+ All Two.js primitives are available as React components:
102
+
103
+ ```jsx
104
+ <Canvas width={800} height={600}>
105
+ <Circle radius={50} fill="#00AEFF" x={400} y={300} />
106
+ <Rectangle width={100} height={60} stroke="#FF0000" linewidth={3} />
107
+ <Polygon sides={6} radius={40} fill="#00FF00" />
108
+ </Canvas>
109
+ ```
110
+
111
+ ### Animating with useFrame
112
+
113
+ The `useFrame` hook runs on every frame, perfect for animations:
114
+
115
+ ```jsx
116
+ import { useRef } from 'react'
117
+ import { Circle, useFrame } from 'react-two.js'
16
118
 
17
119
  function AnimatedCircle() {
18
- const circleRef = useRef();
19
-
120
+ const ref = useRef()
121
+
20
122
  useFrame((elapsed) => {
123
+ ref.current.rotation = elapsed * 0.5
124
+ ref.current.scale = 1 + Math.sin(elapsed) * 0.2
125
+ })
126
+
127
+ return <Circle ref={ref} radius={50} fill="#00AEFF" />
128
+ }
129
+ ```
130
+
131
+ ### Accessing Two.js Instance
132
+
133
+ Use `useTwo` to access the underlying Two.js instance:
134
+
135
+ ```jsx
136
+ import { useTwo } from 'react-two.js'
137
+
138
+ function Component() {
139
+ const { instance, width, height } = useTwo()
140
+
141
+ useEffect(() => {
142
+ console.log('Canvas size:', width, height)
143
+ console.log('Two.js instance:', instance)
144
+ }, [])
145
+ }
146
+ ```
147
+
148
+ ## API
149
+
150
+ ### Components
151
+
152
+ #### Core
153
+ - **`<Canvas>`** — Main container that creates Two.js instance
154
+ - **`<Group>`** — Container for organizing and transforming multiple shapes
155
+
156
+ #### Primitives
157
+ - **`<Circle>`** — Circle with radius
158
+ - **`<Rectangle>`** — Rectangle with width and height
159
+ - **`<RoundedRectangle>`** — Rectangle with rounded corners
160
+ - **`<Ellipse>`** — Ellipse with width and height
161
+ - **`<Line>`** — Straight line between two points
162
+ - **`<Polygon>`** — Regular polygon with specified sides
163
+ - **`<Star>`** — Star shape with inner and outer radius
164
+ - **`<ArcSegment>`** — Arc segment with start and end angles
165
+
166
+ #### Paths & Text
167
+ - **`<Path>`** — Custom path with vertices
168
+ - **`<Points>`** — Collection of points rendered in one draw call
169
+ - **`<Text>`** — Text rendering
170
+
171
+ #### Advanced
172
+ - **`<Image>`** - Basic image class inspired by Figma
173
+ - **`<Sprite>`** — Animated sprite sheets
174
+ - **`<ImageSequence>`** — Animated image sequence
175
+ - **`<LinearGradient>`** — Linear gradient fill
176
+ - **`<RadialGradient>`** — Radial gradient fill
177
+ - **`<Texture>`** — Texture mapping
178
+
179
+ ### Hooks
180
+
181
+ #### `useTwo()`
182
+
183
+ Access the Two.js instance and canvas properties:
184
+
185
+ ```jsx
186
+ const { two, width, height } = useTwo()
187
+ ```
188
+
189
+ Returns:
190
+ - `two` — The Two.js instance
191
+ - `width` — Canvas width
192
+ - `height` — Canvas height
193
+
194
+ #### `useFrame(callback)`
195
+
196
+ Register a callback that runs on every animation frame:
197
+
198
+ ```jsx
199
+ useFrame((elapsed: number) => {
200
+ // elapsed is time in seconds since animation started
201
+ })
202
+ ```
203
+
204
+ ### Props
205
+
206
+ All Two.js properties work as React props:
207
+
208
+ ```jsx
209
+ <Circle
210
+ radius={50}
211
+ fill="#00AEFF"
212
+ stroke="#000000"
213
+ linewidth={2}
214
+ opacity={0.8}
215
+ x={400}
216
+ y={300}
217
+ rotation={Math.PI / 4}
218
+ scale={1.5}
219
+ />
220
+ ```
221
+
222
+ ## TypeScript
223
+
224
+ Full TypeScript support with ref types for all components:
225
+
226
+ ```tsx
227
+ import { useRef } from 'react'
228
+ import { Circle, RefCircle } from 'react-two.js'
229
+
230
+ function Component() {
231
+ const circleRef = useRef<RefCircle>(null)
232
+
233
+ useEffect(() => {
21
234
  if (circleRef.current) {
22
- circleRef.current.rotation = elapsed * 0.5;
235
+ circleRef.current.rotation = Math.PI / 4
23
236
  }
24
- });
25
-
26
- return <Circle ref={circleRef} radius={50} fill="red" />;
237
+ }, [])
238
+
239
+ return <Circle ref={circleRef} radius={50} />
27
240
  }
241
+ ```
242
+
243
+ ## Examples
244
+
245
+ ### Rotating Group
246
+
247
+ ```jsx
248
+ function RotatingGroup() {
249
+ const ref = useRef()
250
+ useFrame((t) => ref.current.rotation = t)
251
+
252
+ return (
253
+ <Group ref={ref}>
254
+ <Rectangle width={100} height={100} fill="#FF6B6B" />
255
+ <Circle radius={50} fill="#4ECDC4" x={120} />
256
+ </Group>
257
+ )
258
+ }
259
+ ```
260
+
261
+ ### Gradient Fill
262
+
263
+ ```jsx
264
+ function () {
265
+ const [gradient, setGradient] = useState(null);
266
+
267
+ const updateRef = useMemo((ref) => {
268
+ if (ref) {
269
+ setGradient(ref);
270
+ }
271
+ }, [setGradient]);
28
272
 
29
- function App() {
30
273
  return (
31
274
  <Canvas width={800} height={600}>
32
- <Rectangle width={100} height={100} fill="blue" x={100} y={100} />
33
- <AnimatedCircle />
275
+ <LinearGradient
276
+ ref={updateRef}
277
+ x1={0} y1={0}
278
+ x2={100} y2={100}
279
+ stops={[
280
+ { offset: 0, color: '#FF6B6B' },
281
+ { offset: 1, color: '#4ECDC4' }
282
+ ]}
283
+ />
284
+ <Rectangle width={200} height={200} fill={gradient} />
34
285
  </Canvas>
35
286
  );
36
287
  }
37
288
  ```
38
289
 
39
- ## Available Components
40
-
41
- ### Core Components
42
- - `<Canvas>` - Main container component
43
- - `<Group>` - Container for organizing components
44
-
45
- ### Shape Components
46
- - `<Circle>` - Basic circle with radius
47
- - `<Rectangle>` - Rectangle with width/height
48
- - `<RoundedRectangle>` - Rectangle with corner radius
49
- - `<Ellipse>` - Oval shape with width/height
50
- - `<Line>` - Straight line between two points
51
- - `<Path>` - Custom path with vertices
52
- - `<Points>` - Collection of points
53
- - `<Polygon>` - Regular polygon with sides
54
- - `<Star>` - Star shape with inner/outer radius
55
- - `<ArcSegment>` - Arc segment with angles
56
- - `<Text>` - Text rendering component
57
-
58
- ### Advanced Components
59
- - `<Sprite>` - Image sprite component
60
- - `<ImageSequence>` - Animated image sequence
61
- - `<LinearGradient>` - Linear gradient fill
62
- - `<RadialGradient>` - Radial gradient fill
63
- - `<Texture>` - Texture mapping component
64
-
65
- ## Hooks
66
-
67
- ### `useTwo()`
68
- Access the Two.js instance and canvas dimensions:
69
- ```jsx
70
- const { width, height, instance } = useTwo();
71
- ```
290
+ ## Learn More
72
291
 
73
- ### `useFrame()`
74
- Create smooth animations with frame-based updates:
75
- ```jsx
76
- useFrame((elapsed) => {
77
- // Animation logic runs on every frame
78
- if (ref.current) {
79
- ref.current.rotation = elapsed * 0.5;
80
- }
81
- });
292
+ - **[Two.js Documentation](https://two.js.org/docs/)** — Complete Two.js API reference
293
+ - **[Two.js Examples](https://two.js.org/examples/)** Interactive examples and demos
294
+ - **[Two.js Repository](https://github.com/jonobr1/two.js)** — Source code and issues
295
+
296
+ ## Development
297
+
298
+ ### Building the Library
299
+
300
+ ```bash
301
+ # Build the library for npm distribution
302
+ npm run build:lib
303
+
304
+ # Build the documentation site
305
+ npm run build:docs
306
+
307
+ # Preview the documentation locally
308
+ npm run preview:docs
82
309
  ```
83
310
 
84
- ## TypeScript Support
311
+ ### Local Development
85
312
 
86
- Full TypeScript support with proper types for all components and refs:
313
+ ```bash
314
+ # Install dependencies
315
+ npm install
87
316
 
88
- ```tsx
89
- import { RefCircle } from '@react/two.js';
317
+ # Start development server (documentation)
318
+ npm run dev
90
319
 
91
- const circleRef = useRef<RefCircle>(null);
320
+ # Run tests
321
+ npm test
322
+
323
+ # Run linting
324
+ npm run lint
92
325
  ```
93
326
 
94
- ## Roadmap
95
- - [ ] Add helpers (aka gizmos)
327
+ The development server runs the documentation site which imports the library components directly from the `lib/` directory, allowing you to see changes in real-time.
328
+
329
+ ## Acknowledgments
330
+
331
+ Built on top of [Two.js](https://github.com/jonobr1/two.js) by [Jono Brandel](https://jono.fyi). Inspired by [Three.js](https://threejs.org/) and [react-three-fiber](https://github.com/pmndrs/react-three-fiber).
@@ -3,8 +3,8 @@ import type { ArcSegment as Instance } from 'two.js/src/shapes/arc-segment';
3
3
  export type RefArcSegment = Instance;
4
4
  export declare const ArcSegment: React.ForwardRefExoticComponent<{
5
5
  renderer?: {
6
- type: "element" | string;
7
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
6
+ type: "element" | "group" | "path" | "text" | "points" | string;
7
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
8
8
  onBeforeRender?: () => void;
9
9
  onAfterRender?: () => void;
10
10
  } | undefined;
@@ -22,8 +22,8 @@ export declare const ArcSegment: React.ForwardRefExoticComponent<{
22
22
  linewidth?: number | undefined;
23
23
  opacity?: number | undefined;
24
24
  visible?: boolean | undefined;
25
- cap?: string | undefined;
26
- join?: string | undefined;
25
+ cap?: import("two.js/src/path").CapProperties | undefined;
26
+ join?: import("two.js/src/path").JoinProperties | undefined;
27
27
  miter?: number | undefined;
28
28
  closed?: boolean | undefined;
29
29
  curved?: boolean | undefined;
@@ -44,4 +44,4 @@ export declare const ArcSegment: React.ForwardRefExoticComponent<{
44
44
  resolution?: number;
45
45
  } & {
46
46
  children?: React.ReactNode | undefined;
47
- } & React.RefAttributes<Instance | null>>;
47
+ } & React.RefAttributes<Instance>>;
package/dist/Circle.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { Circle as Instance } from 'two.js/src/shapes/circle';
3
3
  export type RefCircle = Instance;
4
4
  export declare const Circle: React.ForwardRefExoticComponent<{
5
5
  renderer?: {
6
- type: "element" | string;
7
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
6
+ type: "element" | "group" | "path" | "text" | "points" | string;
7
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
8
8
  onBeforeRender?: () => void;
9
9
  onAfterRender?: () => void;
10
10
  } | undefined;
@@ -22,8 +22,8 @@ export declare const Circle: React.ForwardRefExoticComponent<{
22
22
  linewidth?: number | undefined;
23
23
  opacity?: number | undefined;
24
24
  visible?: boolean | undefined;
25
- cap?: string | undefined;
26
- join?: string | undefined;
25
+ cap?: import("two.js/src/path").CapProperties | undefined;
26
+ join?: import("two.js/src/path").JoinProperties | undefined;
27
27
  miter?: number | undefined;
28
28
  closed?: boolean | undefined;
29
29
  curved?: boolean | undefined;
@@ -41,4 +41,4 @@ export declare const Circle: React.ForwardRefExoticComponent<{
41
41
  resolution?: number;
42
42
  } & {
43
43
  children?: React.ReactNode | undefined;
44
- } & React.RefAttributes<Instance | null>>;
44
+ } & React.RefAttributes<Instance>>;
package/dist/Ellipse.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { Ellipse as Instance } from 'two.js/src/shapes/ellipse';
3
3
  export type RefEllipse = Instance;
4
4
  export declare const Ellipse: React.ForwardRefExoticComponent<{
5
5
  renderer?: {
6
- type: "element" | string;
7
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
6
+ type: "element" | "group" | "path" | "text" | "points" | string;
7
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
8
8
  onBeforeRender?: () => void;
9
9
  onAfterRender?: () => void;
10
10
  } | undefined;
@@ -22,8 +22,8 @@ export declare const Ellipse: React.ForwardRefExoticComponent<{
22
22
  linewidth?: number | undefined;
23
23
  opacity?: number | undefined;
24
24
  visible?: boolean | undefined;
25
- cap?: string | undefined;
26
- join?: string | undefined;
25
+ cap?: import("two.js/src/path").CapProperties | undefined;
26
+ join?: import("two.js/src/path").JoinProperties | undefined;
27
27
  miter?: number | undefined;
28
28
  closed?: boolean | undefined;
29
29
  curved?: boolean | undefined;
package/dist/Group.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { Group as Instance } from 'two.js/src/group';
3
3
  export type RefGroup = Instance;
4
4
  export declare const Group: React.ForwardRefExoticComponent<{
5
5
  renderer?: {
6
- type: "element" | string;
7
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
6
+ type: "element" | "group" | "path" | "text" | "points" | string;
7
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
8
8
  onBeforeRender?: () => void;
9
9
  onAfterRender?: () => void;
10
10
  } | undefined;
@@ -20,8 +20,8 @@ export declare const Group: React.ForwardRefExoticComponent<{
20
20
  fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
21
21
  stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
22
22
  linewidth?: number | undefined;
23
- cap?: "butt" | "round" | "square" | undefined;
24
- join?: "butt" | "round" | "square" | undefined;
23
+ cap?: import("two.js/src/path").CapProperties | undefined;
24
+ join?: import("two.js/src/path").JoinProperties | undefined;
25
25
  miter?: number | undefined;
26
26
  closed?: boolean | undefined;
27
27
  curved?: boolean | undefined;
@@ -31,4 +31,4 @@ export declare const Group: React.ForwardRefExoticComponent<{
31
31
  y?: number;
32
32
  } & {
33
33
  children?: React.ReactNode | undefined;
34
- } & React.RefAttributes<Instance | null>>;
34
+ } & React.RefAttributes<Instance>>;
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import type { Image as Instance } from 'two.js/src/effects/image';
3
+ import type { Texture } from 'two.js/src/effects/texture';
4
+ export type RefImage = Instance;
5
+ export declare const Image: React.ForwardRefExoticComponent<{
6
+ renderer?: {
7
+ type: "element" | "group" | "path" | "text" | "points" | string;
8
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
9
+ onBeforeRender?: () => void;
10
+ onAfterRender?: () => void;
11
+ } | undefined;
12
+ id?: string | undefined;
13
+ className?: string | undefined;
14
+ position?: import("two.js/src/vector").Vector | undefined;
15
+ rotation?: number | undefined;
16
+ scale?: number | import("two.js/src/vector").Vector | undefined;
17
+ skewX?: number | undefined;
18
+ skewY?: number | undefined;
19
+ matrix?: import("two.js/src/matrix").Matrix | undefined;
20
+ worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
21
+ fill?: string | import("two.js/src/effects/gradient").Gradient | Texture | undefined;
22
+ stroke?: string | import("two.js/src/effects/gradient").Gradient | Texture | undefined;
23
+ linewidth?: number | undefined;
24
+ opacity?: number | undefined;
25
+ visible?: boolean | undefined;
26
+ cap?: import("two.js/src/path").CapProperties | undefined;
27
+ join?: import("two.js/src/path").JoinProperties | undefined;
28
+ miter?: number | undefined;
29
+ closed?: boolean | undefined;
30
+ curved?: boolean | undefined;
31
+ automatic?: boolean | undefined;
32
+ beginning?: number | undefined;
33
+ ending?: number | undefined;
34
+ dashes?: (number[] & {
35
+ offset?: number;
36
+ }) | undefined;
37
+ vertices?: import("two.js/src/anchor").Anchor[] | undefined;
38
+ width?: number | undefined;
39
+ height?: number | undefined;
40
+ mode?: import("two.js/src/effects/image").ModeProperties | undefined;
41
+ texture?: Texture | undefined;
42
+ } & {
43
+ x?: number;
44
+ y?: number;
45
+ mode?: string;
46
+ texture?: Texture;
47
+ } & {
48
+ children?: React.ReactNode | undefined;
49
+ } & React.RefAttributes<Instance>>;
@@ -4,8 +4,8 @@ import type { Texture } from 'two.js/src/effects/texture';
4
4
  export type RefImageSequence = Instance;
5
5
  export declare const ImageSequence: React.ForwardRefExoticComponent<{
6
6
  renderer?: {
7
- type: "element" | string;
8
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
7
+ type: "element" | "group" | "path" | "text" | "points" | string;
8
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
9
9
  onBeforeRender?: () => void;
10
10
  onAfterRender?: () => void;
11
11
  } | undefined;
@@ -23,8 +23,8 @@ export declare const ImageSequence: React.ForwardRefExoticComponent<{
23
23
  linewidth?: number | undefined;
24
24
  opacity?: number | undefined;
25
25
  visible?: boolean | undefined;
26
- cap?: string | undefined;
27
- join?: string | undefined;
26
+ cap?: import("two.js/src/path").CapProperties | undefined;
27
+ join?: import("two.js/src/path").JoinProperties | undefined;
28
28
  miter?: number | undefined;
29
29
  closed?: boolean | undefined;
30
30
  curved?: boolean | undefined;
@@ -37,7 +37,7 @@ export declare const ImageSequence: React.ForwardRefExoticComponent<{
37
37
  vertices?: import("two.js/src/anchor").Anchor[] | undefined;
38
38
  width?: number | undefined;
39
39
  height?: number | undefined;
40
- textures?: any[] | undefined;
40
+ textures?: Texture[] | undefined;
41
41
  frameRate?: number | undefined;
42
42
  index?: number | undefined;
43
43
  } & {
@@ -47,4 +47,4 @@ export declare const ImageSequence: React.ForwardRefExoticComponent<{
47
47
  autoPlay?: boolean;
48
48
  } & {
49
49
  children?: React.ReactNode | undefined;
50
- } & React.RefAttributes<Instance | null>>;
50
+ } & React.RefAttributes<Instance>>;
package/dist/Line.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { Line as Instance } from 'two.js/src/shapes/line';
3
3
  export type RefLine = Instance;
4
4
  export declare const Line: React.ForwardRefExoticComponent<{
5
5
  renderer?: {
6
- type: "element" | string;
7
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
6
+ type: "element" | "group" | "path" | "text" | "points" | string;
7
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
8
8
  onBeforeRender?: () => void;
9
9
  onAfterRender?: () => void;
10
10
  } | undefined;
@@ -22,8 +22,8 @@ export declare const Line: React.ForwardRefExoticComponent<{
22
22
  linewidth?: number | undefined;
23
23
  opacity?: number | undefined;
24
24
  visible?: boolean | undefined;
25
- cap?: string | undefined;
26
- join?: string | undefined;
25
+ cap?: import("two.js/src/path").CapProperties | undefined;
26
+ join?: import("two.js/src/path").JoinProperties | undefined;
27
27
  miter?: number | undefined;
28
28
  closed?: boolean | undefined;
29
29
  curved?: boolean | undefined;
@@ -43,4 +43,4 @@ export declare const Line: React.ForwardRefExoticComponent<{
43
43
  y2?: number;
44
44
  } & {
45
45
  children?: React.ReactNode | undefined;
46
- } & React.RefAttributes<Instance | null>>;
46
+ } & React.RefAttributes<Instance>>;
@@ -3,15 +3,15 @@ import type { LinearGradient as Instance } from 'two.js/src/effects/linear-gradi
3
3
  export type RefLinearGradient = Instance;
4
4
  export declare const LinearGradient: React.ForwardRefExoticComponent<{
5
5
  renderer?: {
6
- type: "element" | string;
7
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
6
+ type: "element" | "group" | "path" | "text" | "points" | string;
7
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
8
8
  onBeforeRender?: () => void;
9
9
  onAfterRender?: () => void;
10
10
  } | undefined;
11
11
  id?: string | undefined;
12
12
  className?: string | undefined;
13
- spread?: "repeat" | "pad" | "reflect" | undefined;
14
- units?: "userSpaceOnUse" | "objectBoundingBox" | undefined;
13
+ spread?: import("two.js/src/effects/gradient").SpreadProperties | undefined;
14
+ units?: import("two.js/src/effects/gradient").UnitsProperties | undefined;
15
15
  stops?: import("two.js/src/effects/stop").Stop[] | undefined;
16
16
  left?: import("two.js/src/vector").Vector | undefined;
17
17
  right?: import("two.js/src/vector").Vector | undefined;
@@ -22,4 +22,4 @@ export declare const LinearGradient: React.ForwardRefExoticComponent<{
22
22
  y2?: number;
23
23
  } & {
24
24
  children?: React.ReactNode | undefined;
25
- } & React.RefAttributes<Instance | null>>;
25
+ } & React.RefAttributes<Instance>>;
package/dist/Path.d.ts CHANGED
@@ -5,8 +5,8 @@ export type PathProps = ShapeProps | 'fill' | 'stroke' | 'linewidth' | 'opacity'
5
5
  export type RefPath = Instance;
6
6
  export declare const Path: React.ForwardRefExoticComponent<{
7
7
  renderer?: {
8
- type: "element" | string;
9
- elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
8
+ type: "element" | "group" | "path" | "text" | "points" | string;
9
+ elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement | SVGPatternElement;
10
10
  onBeforeRender?: () => void;
11
11
  onAfterRender?: () => void;
12
12
  } | undefined;
@@ -24,8 +24,8 @@ export declare const Path: React.ForwardRefExoticComponent<{
24
24
  linewidth?: number | undefined;
25
25
  opacity?: number | undefined;
26
26
  visible?: boolean | undefined;
27
- cap?: string | undefined;
28
- join?: string | undefined;
27
+ cap?: import("two.js/src/path").CapProperties | undefined;
28
+ join?: import("two.js/src/path").JoinProperties | undefined;
29
29
  miter?: number | undefined;
30
30
  closed?: boolean | undefined;
31
31
  curved?: boolean | undefined;
@@ -38,6 +38,8 @@ export declare const Path: React.ForwardRefExoticComponent<{
38
38
  vertices?: import("two.js/src/anchor").Anchor[] | undefined;
39
39
  } & {
40
40
  manual?: boolean;
41
+ x?: number;
42
+ y?: number;
41
43
  } & {
42
44
  children?: React.ReactNode | undefined;
43
- } & React.RefAttributes<Instance | null>>;
45
+ } & React.RefAttributes<Instance>>;