react-two.js 0.1.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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/ArcSegment.d.ts +47 -0
- package/dist/Circle.d.ts +44 -0
- package/dist/Context.d.ts +15 -0
- package/dist/Ellipse.d.ts +45 -0
- package/dist/Group.d.ts +34 -0
- package/dist/ImageSequence.d.ts +50 -0
- package/dist/Line.d.ts +46 -0
- package/dist/LinearGradient.d.ts +25 -0
- package/dist/Path.d.ts +43 -0
- package/dist/Points.d.ts +35 -0
- package/dist/Polygon.d.ts +46 -0
- package/dist/Properties.d.ts +3 -0
- package/dist/Provider.d.ts +7 -0
- package/dist/RadialGradient.d.ts +26 -0
- package/dist/Rectangle.d.ts +44 -0
- package/dist/RoundedRectangle.d.ts +45 -0
- package/dist/Sprite.d.ts +51 -0
- package/dist/Star.d.ts +45 -0
- package/dist/Text.d.ts +43 -0
- package/dist/Texture.d.ts +24 -0
- package/dist/main.d.ts +19 -0
- package/dist/react-two-main.es.js +508 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 @jonobr1 / http://jono.fyi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @react/two.js
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @react/two.js react react-dom two.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Canvas, Circle, Rectangle, useFrame } from '@react/two.js';
|
|
15
|
+
import { useRef } from 'react';
|
|
16
|
+
|
|
17
|
+
function AnimatedCircle() {
|
|
18
|
+
const circleRef = useRef();
|
|
19
|
+
|
|
20
|
+
useFrame((elapsed) => {
|
|
21
|
+
if (circleRef.current) {
|
|
22
|
+
circleRef.current.rotation = elapsed * 0.5;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return <Circle ref={circleRef} radius={50} fill="red" />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<Canvas width={800} height={600}>
|
|
32
|
+
<Rectangle width={100} height={100} fill="blue" x={100} y={100} />
|
|
33
|
+
<AnimatedCircle />
|
|
34
|
+
</Canvas>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
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
|
+
```
|
|
72
|
+
|
|
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
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## TypeScript Support
|
|
85
|
+
|
|
86
|
+
Full TypeScript support with proper types for all components and refs:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { RefCircle } from '@react/two.js';
|
|
90
|
+
|
|
91
|
+
const circleRef = useRef<RefCircle>(null);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Roadmap
|
|
95
|
+
- [ ] Add helpers (aka gizmos)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ArcSegment as Instance } from 'two.js/src/shapes/arc-segment';
|
|
3
|
+
export type RefArcSegment = Instance;
|
|
4
|
+
export declare const ArcSegment: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
cap?: string | undefined;
|
|
26
|
+
join?: string | undefined;
|
|
27
|
+
miter?: number | undefined;
|
|
28
|
+
closed?: boolean | undefined;
|
|
29
|
+
curved?: boolean | undefined;
|
|
30
|
+
automatic?: boolean | undefined;
|
|
31
|
+
beginning?: number | undefined;
|
|
32
|
+
ending?: number | undefined;
|
|
33
|
+
dashes?: (number[] & {
|
|
34
|
+
offset?: number;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
37
|
+
startAngle?: number | undefined;
|
|
38
|
+
endAngle?: number | undefined;
|
|
39
|
+
innerRadius?: number | undefined;
|
|
40
|
+
outerRadius?: number | undefined;
|
|
41
|
+
} & {
|
|
42
|
+
x?: number;
|
|
43
|
+
y?: number;
|
|
44
|
+
resolution?: number;
|
|
45
|
+
} & {
|
|
46
|
+
children?: React.ReactNode | undefined;
|
|
47
|
+
} & React.RefAttributes<Instance | null>>;
|
package/dist/Circle.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Circle as Instance } from 'two.js/src/shapes/circle';
|
|
3
|
+
export type RefCircle = Instance;
|
|
4
|
+
export declare const Circle: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
cap?: string | undefined;
|
|
26
|
+
join?: string | undefined;
|
|
27
|
+
miter?: number | undefined;
|
|
28
|
+
closed?: boolean | undefined;
|
|
29
|
+
curved?: boolean | undefined;
|
|
30
|
+
automatic?: boolean | undefined;
|
|
31
|
+
beginning?: number | undefined;
|
|
32
|
+
ending?: number | undefined;
|
|
33
|
+
dashes?: (number[] & {
|
|
34
|
+
offset?: number;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
37
|
+
radius?: number | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
x?: number;
|
|
40
|
+
y?: number;
|
|
41
|
+
resolution?: number;
|
|
42
|
+
} & {
|
|
43
|
+
children?: React.ReactNode | undefined;
|
|
44
|
+
} & React.RefAttributes<Instance | null>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Two from 'two.js';
|
|
2
|
+
import type { Group } from 'two.js/src/group';
|
|
3
|
+
export declare const Context: import("react").Context<{
|
|
4
|
+
two: Two | null;
|
|
5
|
+
parent: Group | null;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const useTwo: () => {
|
|
10
|
+
two: Two | null;
|
|
11
|
+
parent: Group | null;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const useFrame: (callback: (elapsed: number, frameDelta: number) => void, deps?: unknown[]) => void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Ellipse as Instance } from 'two.js/src/shapes/ellipse';
|
|
3
|
+
export type RefEllipse = Instance;
|
|
4
|
+
export declare const Ellipse: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
cap?: string | undefined;
|
|
26
|
+
join?: string | undefined;
|
|
27
|
+
miter?: number | undefined;
|
|
28
|
+
closed?: boolean | undefined;
|
|
29
|
+
curved?: boolean | undefined;
|
|
30
|
+
automatic?: boolean | undefined;
|
|
31
|
+
beginning?: number | undefined;
|
|
32
|
+
ending?: number | undefined;
|
|
33
|
+
dashes?: (number[] & {
|
|
34
|
+
offset?: number;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
37
|
+
width?: number | undefined;
|
|
38
|
+
height?: number | undefined;
|
|
39
|
+
} & {
|
|
40
|
+
x?: number;
|
|
41
|
+
y?: number;
|
|
42
|
+
resolution?: number;
|
|
43
|
+
} & {
|
|
44
|
+
children?: React.ReactNode | undefined;
|
|
45
|
+
} & React.RefAttributes<Instance | null>>;
|
package/dist/Group.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Group as Instance } from 'two.js/src/group';
|
|
3
|
+
export type RefGroup = Instance;
|
|
4
|
+
export declare const Group: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
cap?: "butt" | "round" | "square" | undefined;
|
|
24
|
+
join?: "butt" | "round" | "square" | undefined;
|
|
25
|
+
miter?: number | undefined;
|
|
26
|
+
closed?: boolean | undefined;
|
|
27
|
+
curved?: boolean | undefined;
|
|
28
|
+
automatic?: boolean | undefined;
|
|
29
|
+
} & {
|
|
30
|
+
x?: number;
|
|
31
|
+
y?: number;
|
|
32
|
+
} & {
|
|
33
|
+
children?: React.ReactNode | undefined;
|
|
34
|
+
} & React.RefAttributes<Instance | null>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ImageSequence as Instance } from 'two.js/src/effects/image-sequence';
|
|
3
|
+
import type { Texture } from 'two.js/src/effects/texture';
|
|
4
|
+
export type RefImageSequence = Instance;
|
|
5
|
+
export declare const ImageSequence: React.ForwardRefExoticComponent<{
|
|
6
|
+
renderer?: {
|
|
7
|
+
type: "element" | string;
|
|
8
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
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?: string | undefined;
|
|
27
|
+
join?: string | 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
|
+
textures?: any[] | undefined;
|
|
41
|
+
frameRate?: number | undefined;
|
|
42
|
+
index?: number | undefined;
|
|
43
|
+
} & {
|
|
44
|
+
paths?: string | string[] | Texture | Texture[];
|
|
45
|
+
x?: number;
|
|
46
|
+
y?: number;
|
|
47
|
+
autoPlay?: boolean;
|
|
48
|
+
} & {
|
|
49
|
+
children?: React.ReactNode | undefined;
|
|
50
|
+
} & React.RefAttributes<Instance | null>>;
|
package/dist/Line.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Line as Instance } from 'two.js/src/shapes/line';
|
|
3
|
+
export type RefLine = Instance;
|
|
4
|
+
export declare const Line: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
cap?: string | undefined;
|
|
26
|
+
join?: string | undefined;
|
|
27
|
+
miter?: number | undefined;
|
|
28
|
+
closed?: boolean | undefined;
|
|
29
|
+
curved?: boolean | undefined;
|
|
30
|
+
automatic?: boolean | undefined;
|
|
31
|
+
beginning?: number | undefined;
|
|
32
|
+
ending?: number | undefined;
|
|
33
|
+
dashes?: (number[] & {
|
|
34
|
+
offset?: number;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
37
|
+
left?: import("two.js/src/anchor").Anchor | undefined;
|
|
38
|
+
right?: import("two.js/src/anchor").Anchor | undefined;
|
|
39
|
+
} & {
|
|
40
|
+
x1?: number;
|
|
41
|
+
y1?: number;
|
|
42
|
+
x2?: number;
|
|
43
|
+
y2?: number;
|
|
44
|
+
} & {
|
|
45
|
+
children?: React.ReactNode | undefined;
|
|
46
|
+
} & React.RefAttributes<Instance | null>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LinearGradient as Instance } from 'two.js/src/effects/linear-gradient';
|
|
3
|
+
export type RefLinearGradient = Instance;
|
|
4
|
+
export declare const LinearGradient: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
spread?: "repeat" | "pad" | "reflect" | undefined;
|
|
14
|
+
units?: "userSpaceOnUse" | "objectBoundingBox" | undefined;
|
|
15
|
+
stops?: import("two.js/src/effects/stop").Stop[] | undefined;
|
|
16
|
+
left?: import("two.js/src/vector").Vector | undefined;
|
|
17
|
+
right?: import("two.js/src/vector").Vector | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
x1?: number;
|
|
20
|
+
y1?: number;
|
|
21
|
+
x2?: number;
|
|
22
|
+
y2?: number;
|
|
23
|
+
} & {
|
|
24
|
+
children?: React.ReactNode | undefined;
|
|
25
|
+
} & React.RefAttributes<Instance | null>>;
|
package/dist/Path.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Path as Instance } from 'two.js/src/path';
|
|
3
|
+
import { ShapeProps } from './Properties';
|
|
4
|
+
export type PathProps = ShapeProps | 'fill' | 'stroke' | 'linewidth' | 'opacity' | 'visible' | 'cap' | 'join' | 'miter' | 'closed' | 'curved' | 'automatic' | 'beginning' | 'ending' | 'dashes' | 'vertices';
|
|
5
|
+
export type RefPath = Instance;
|
|
6
|
+
export declare const Path: React.ForwardRefExoticComponent<{
|
|
7
|
+
renderer?: {
|
|
8
|
+
type: "element" | string;
|
|
9
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
10
|
+
onBeforeRender?: () => void;
|
|
11
|
+
onAfterRender?: () => void;
|
|
12
|
+
} | undefined;
|
|
13
|
+
id?: string | undefined;
|
|
14
|
+
className?: string | undefined;
|
|
15
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
rotation?: number | undefined;
|
|
17
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
18
|
+
skewX?: number | undefined;
|
|
19
|
+
skewY?: number | undefined;
|
|
20
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
21
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
22
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
23
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
24
|
+
linewidth?: number | undefined;
|
|
25
|
+
opacity?: number | undefined;
|
|
26
|
+
visible?: boolean | undefined;
|
|
27
|
+
cap?: string | undefined;
|
|
28
|
+
join?: string | undefined;
|
|
29
|
+
miter?: number | undefined;
|
|
30
|
+
closed?: boolean | undefined;
|
|
31
|
+
curved?: boolean | undefined;
|
|
32
|
+
automatic?: boolean | undefined;
|
|
33
|
+
beginning?: number | undefined;
|
|
34
|
+
ending?: number | undefined;
|
|
35
|
+
dashes?: (number[] & {
|
|
36
|
+
offset?: number;
|
|
37
|
+
}) | undefined;
|
|
38
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
39
|
+
} & {
|
|
40
|
+
manual?: boolean;
|
|
41
|
+
} & {
|
|
42
|
+
children?: React.ReactNode | undefined;
|
|
43
|
+
} & React.RefAttributes<Instance | null>>;
|
package/dist/Points.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Points as Instance } from 'two.js/src/shapes/points';
|
|
3
|
+
export type RefPoints = Instance;
|
|
4
|
+
export declare const Points: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
beginning?: number | undefined;
|
|
26
|
+
ending?: number | undefined;
|
|
27
|
+
dashes?: (number[] & {
|
|
28
|
+
offset?: number;
|
|
29
|
+
}) | undefined;
|
|
30
|
+
vertices?: (import("two.js/src/vector").Vector | import("two.js/src/anchor").Anchor)[] | undefined;
|
|
31
|
+
size?: number | undefined;
|
|
32
|
+
sizeAttenuation?: boolean | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
children?: React.ReactNode | undefined;
|
|
35
|
+
} & React.RefAttributes<Instance | null>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Polygon as Instance } from 'two.js/src/shapes/polygon';
|
|
3
|
+
export type RefPolygon = Instance;
|
|
4
|
+
export declare const Polygon: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
cap?: string | undefined;
|
|
26
|
+
join?: string | undefined;
|
|
27
|
+
miter?: number | undefined;
|
|
28
|
+
closed?: boolean | undefined;
|
|
29
|
+
curved?: boolean | undefined;
|
|
30
|
+
automatic?: boolean | undefined;
|
|
31
|
+
beginning?: number | undefined;
|
|
32
|
+
ending?: number | undefined;
|
|
33
|
+
dashes?: (number[] & {
|
|
34
|
+
offset?: number;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
37
|
+
width?: number | undefined;
|
|
38
|
+
height?: number | undefined;
|
|
39
|
+
sides?: number | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
x?: number;
|
|
42
|
+
y?: number;
|
|
43
|
+
radius?: number;
|
|
44
|
+
} & {
|
|
45
|
+
children?: React.ReactNode | undefined;
|
|
46
|
+
} & React.RefAttributes<Instance | null>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Two from 'two.js';
|
|
3
|
+
type TwoConstructorProps = ConstructorParameters<typeof Two>[0];
|
|
4
|
+
type TwoConstructorPropsKeys = NonNullable<TwoConstructorProps>;
|
|
5
|
+
type ComponentProps = React.PropsWithChildren<TwoConstructorPropsKeys>;
|
|
6
|
+
export declare const Provider: React.FC<ComponentProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RadialGradient as Instance } from 'two.js/src/effects/radial-gradient';
|
|
3
|
+
export type RefRadialGradient = Instance;
|
|
4
|
+
export declare const RadialGradient: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
spread?: "repeat" | "pad" | "reflect" | undefined;
|
|
14
|
+
units?: "userSpaceOnUse" | "objectBoundingBox" | undefined;
|
|
15
|
+
stops?: import("two.js/src/effects/stop").Stop[] | undefined;
|
|
16
|
+
center?: import("two.js/src/vector").Vector | undefined;
|
|
17
|
+
radius?: number | undefined;
|
|
18
|
+
focal?: import("two.js/src/vector").Vector | undefined;
|
|
19
|
+
} & {
|
|
20
|
+
x?: number;
|
|
21
|
+
y?: number;
|
|
22
|
+
focalX?: number;
|
|
23
|
+
focalY?: number;
|
|
24
|
+
} & {
|
|
25
|
+
children?: React.ReactNode | undefined;
|
|
26
|
+
} & React.RefAttributes<Instance | null>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Rectangle as Instance } from 'two.js/src/shapes/rectangle';
|
|
3
|
+
export type RefRectangle = Instance;
|
|
4
|
+
export declare const Rectangle: React.ForwardRefExoticComponent<{
|
|
5
|
+
renderer?: {
|
|
6
|
+
type: "element" | string;
|
|
7
|
+
elem?: SVGGElement | SVGPathElement | SVGTextElement | SVGPatternElement | SVGDefsElement | SVGGradientElement | SVGLinearGradientElement | SVGRadialGradientElement | SVGImageElement | SVGClipPathElement | SVGStopElement;
|
|
8
|
+
onBeforeRender?: () => void;
|
|
9
|
+
onAfterRender?: () => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
position?: import("two.js/src/vector").Vector | undefined;
|
|
14
|
+
rotation?: number | undefined;
|
|
15
|
+
scale?: number | import("two.js/src/vector").Vector | undefined;
|
|
16
|
+
skewX?: number | undefined;
|
|
17
|
+
skewY?: number | undefined;
|
|
18
|
+
matrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
19
|
+
worldMatrix?: import("two.js/src/matrix").Matrix | undefined;
|
|
20
|
+
fill?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
21
|
+
stroke?: string | import("two.js/src/effects/gradient").Gradient | import("two.js/src/effects/texture").Texture | undefined;
|
|
22
|
+
linewidth?: number | undefined;
|
|
23
|
+
opacity?: number | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
cap?: string | undefined;
|
|
26
|
+
join?: string | undefined;
|
|
27
|
+
miter?: number | undefined;
|
|
28
|
+
closed?: boolean | undefined;
|
|
29
|
+
curved?: boolean | undefined;
|
|
30
|
+
automatic?: boolean | undefined;
|
|
31
|
+
beginning?: number | undefined;
|
|
32
|
+
ending?: number | undefined;
|
|
33
|
+
dashes?: (number[] & {
|
|
34
|
+
offset?: number;
|
|
35
|
+
}) | undefined;
|
|
36
|
+
vertices?: import("two.js/src/anchor").Anchor[] | undefined;
|
|
37
|
+
width?: number | undefined;
|
|
38
|
+
height?: number | undefined;
|
|
39
|
+
} & {
|
|
40
|
+
x?: number;
|
|
41
|
+
y?: number;
|
|
42
|
+
} & {
|
|
43
|
+
children?: React.ReactNode | undefined;
|
|
44
|
+
} & React.RefAttributes<Instance | null>>;
|