react-two.js 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +331 -64
- package/dist/ArcSegment.d.ts +5 -5
- package/dist/Circle.d.ts +5 -5
- package/dist/Ellipse.d.ts +4 -4
- package/dist/Group.d.ts +5 -5
- package/dist/Image.d.ts +49 -0
- package/dist/ImageSequence.d.ts +6 -6
- package/dist/Line.d.ts +5 -5
- package/dist/LinearGradient.d.ts +5 -5
- package/dist/Path.d.ts +7 -5
- package/dist/Points.d.ts +7 -4
- package/dist/Polygon.d.ts +5 -5
- package/dist/RadialGradient.d.ts +4 -4
- package/dist/Rectangle.d.ts +7 -5
- package/dist/RoundedRectangle.d.ts +6 -6
- package/dist/Sprite.d.ts +6 -6
- package/dist/Star.d.ts +5 -5
- package/dist/Text.d.ts +8 -8
- package/dist/Texture.d.ts +4 -4
- package/dist/main.d.ts +1 -0
- package/dist/react-two-main.es.js +372 -430
- package/package.json +21 -6
package/README.md
CHANGED
|
@@ -1,95 +1,362 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-two.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
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
|
|
66
|
+
npm install react-two.js react react-dom two.js
|
|
67
|
+
```
|
|
68
|
+
|
|
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:
|
|
81
|
+
|
|
82
|
+
```jsx
|
|
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>
|
|
9
109
|
```
|
|
10
110
|
|
|
11
|
-
|
|
111
|
+
### Animating with useFrame
|
|
112
|
+
|
|
113
|
+
The `useFrame` hook runs on every frame, perfect for animations:
|
|
12
114
|
|
|
13
115
|
```jsx
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
116
|
+
import { useRef } from 'react'
|
|
117
|
+
import { Circle, useFrame } from 'react-two.js'
|
|
16
118
|
|
|
17
119
|
function AnimatedCircle() {
|
|
18
|
-
const
|
|
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 =
|
|
235
|
+
circleRef.current.rotation = Math.PI / 4
|
|
23
236
|
}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
return <Circle ref={circleRef} radius={50}
|
|
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
|
-
<
|
|
33
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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 & Deployment
|
|
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
|
-
|
|
311
|
+
### Publishing to NPM
|
|
85
312
|
|
|
86
|
-
|
|
313
|
+
1. **Increment version** (choose one):
|
|
314
|
+
```bash
|
|
315
|
+
npm run version:patch # Bug fixes (0.1.0 → 0.1.1)
|
|
316
|
+
npm run version:minor # New features (0.1.0 → 0.2.0)
|
|
317
|
+
npm run version:major # Breaking changes (0.1.0 → 1.0.0)
|
|
318
|
+
```
|
|
87
319
|
|
|
88
|
-
|
|
89
|
-
|
|
320
|
+
2. **Create a GitHub release** with the new version tag. This automatically triggers npm publishing via GitHub Actions.
|
|
321
|
+
|
|
322
|
+
Or **publish manually**:
|
|
323
|
+
```bash
|
|
324
|
+
npm run publish:npm
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### GitHub Pages Deployment
|
|
328
|
+
|
|
329
|
+
The documentation site automatically deploys to GitHub Pages on every push to `main`. The site will be available at:
|
|
330
|
+
- **Live URL**: https://jonobr1.github.io/react-two.js
|
|
331
|
+
|
|
332
|
+
#### Manual Setup (if needed):
|
|
333
|
+
|
|
334
|
+
1. **Enable GitHub Pages** in repository settings:
|
|
335
|
+
- Go to Settings → Pages
|
|
336
|
+
- Source: "GitHub Actions"
|
|
337
|
+
|
|
338
|
+
2. **Set up NPM_TOKEN secret** (for npm publishing):
|
|
339
|
+
- Go to Settings → Secrets and variables → Actions
|
|
340
|
+
- Add `NPM_TOKEN` with your npm access token
|
|
90
341
|
|
|
91
|
-
|
|
342
|
+
### Local Development
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Install dependencies
|
|
346
|
+
npm install
|
|
347
|
+
|
|
348
|
+
# Start development server (documentation)
|
|
349
|
+
npm run dev
|
|
350
|
+
|
|
351
|
+
# Run tests
|
|
352
|
+
npm test
|
|
353
|
+
|
|
354
|
+
# Run linting
|
|
355
|
+
npm run lint
|
|
92
356
|
```
|
|
93
357
|
|
|
94
|
-
|
|
95
|
-
|
|
358
|
+
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.
|
|
359
|
+
|
|
360
|
+
## Acknowledgments
|
|
361
|
+
|
|
362
|
+
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).
|
package/dist/ArcSegment.d.ts
CHANGED
|
@@ -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?:
|
|
26
|
-
join?:
|
|
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
|
|
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?:
|
|
26
|
-
join?:
|
|
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
|
|
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?:
|
|
26
|
-
join?:
|
|
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?: "
|
|
24
|
-
join?: "
|
|
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
|
|
34
|
+
} & React.RefAttributes<Instance>>;
|
package/dist/Image.d.ts
ADDED
|
@@ -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>>;
|
package/dist/ImageSequence.d.ts
CHANGED
|
@@ -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?:
|
|
27
|
-
join?:
|
|
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?:
|
|
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
|
|
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?:
|
|
26
|
-
join?:
|
|
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
|
|
46
|
+
} & React.RefAttributes<Instance>>;
|
package/dist/LinearGradient.d.ts
CHANGED
|
@@ -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?: "
|
|
14
|
-
units?: "
|
|
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
|
|
25
|
+
} & React.RefAttributes<Instance>>;
|