1
1
import * as React from 'react'
2
2
import { Vector3 } from 'three'
3
3
import { GeometryUtils } from 'three-stdlib'
4
- import { withKnobs , number , color , boolean , select } from '@storybook/addon-knobs'
5
4
6
5
import { Setup } from '../Setup'
7
6
@@ -20,77 +19,88 @@ const colors = new Array(points.length).fill(0).map(() => [Math.random(), Math.r
20
19
number
21
20
] [ ]
22
21
23
- export function BasicLine ( ) {
22
+ export function BasicLine ( args ) {
24
23
return (
25
24
< >
26
- < Line
27
- points = { points }
28
- color = { color ( 'color' , 'red' ) }
29
- lineWidth = { number ( 'lineWidth' , 3 ) }
30
- dashed = { boolean ( 'dashed' , false ) }
31
- />
25
+ < Line points = { points } { ...args } />
32
26
< OrbitControls zoomSpeed = { 0.5 } />
33
27
</ >
34
28
)
35
29
}
36
30
BasicLine . storyName = 'Basic'
31
+ BasicLine . args = {
32
+ color : 'red' ,
33
+ lineWidth : 3 ,
34
+ dashed : false ,
35
+ }
36
+ BasicLine . argTypes = {
37
+ color : { control : 'color' } ,
38
+ }
37
39
38
40
BasicLine . decorators = [
39
- withKnobs ,
40
41
( storyFn ) => (
41
42
< Setup controls = { false } cameraPosition = { new Vector3 ( 0 , 0 , 17 ) } >
42
43
{ storyFn ( ) }
43
44
</ Setup >
44
45
) ,
45
46
]
46
47
47
- export function QuadraticBezier ( ) {
48
+ export function QuadraticBezier ( args ) {
48
49
return (
49
50
< >
50
- < QuadraticBezierLine
51
- start = { [ number ( 'startX' , 0 ) , number ( 'startY' , 0 ) , number ( 'startZ' , 0 ) ] }
52
- end = { [ number ( 'endX' , 4 ) , number ( 'endY' , 7 ) , number ( 'endZ' , 5 ) ] }
53
- segments = { number ( 'segments' , 10 ) }
54
- color = { color ( 'color' , 'red' ) }
55
- lineWidth = { number ( 'lineWidth' , 2 ) }
56
- dashed = { boolean ( 'dashed' , true ) }
57
- />
51
+ < QuadraticBezierLine { ...args } />
58
52
< OrbitControls zoomSpeed = { 0.5 } />
59
53
</ >
60
54
)
61
55
}
62
56
QuadraticBezier . storyName = 'QuadraticBezier'
57
+ QuadraticBezier . args = {
58
+ start : [ 0 , 0 , 0 ] ,
59
+ end : [ 4 , 7 , 5 ] ,
60
+ segments : 10 ,
61
+ color : 'red' ,
62
+ lineWidth : 2 ,
63
+ dashed : true ,
64
+ foo : 3 ,
65
+ }
66
+ QuadraticBezier . argTypes = {
67
+ segments : { control : { type : 'range' , min : 1 , max : 20 , step : 1 } } ,
68
+ color : { control : 'color' } ,
69
+ }
63
70
64
71
QuadraticBezier . decorators = [
65
- withKnobs ,
66
72
( storyFn ) => (
67
73
< Setup controls = { false } cameraPosition = { new Vector3 ( 0 , 0 , 17 ) } >
68
74
{ storyFn ( ) }
69
75
</ Setup >
70
76
) ,
71
77
]
72
78
73
- export function CubicBezier ( ) {
79
+ export function CubicBezier ( args ) {
74
80
return (
75
81
< >
76
- < CubicBezierLine
77
- start = { [ number ( 'startX' , 0 ) , number ( 'startY' , 0 ) , number ( 'startZ' , 0 ) ] }
78
- end = { [ number ( 'endX' , 10 ) , number ( 'endY' , 0 ) , number ( 'endZ' , 10 ) ] }
79
- midA = { [ number ( 'midAX' , 5 ) , number ( 'midAY' , 4 ) , number ( 'midAZ' , 0 ) ] }
80
- midB = { [ number ( 'midBX' , 0 ) , number ( 'midBY' , 0 ) , number ( 'midBZ' , 5 ) ] }
81
- segments = { number ( 'segments' , 10 ) }
82
- color = { color ( 'color' , 'red' ) }
83
- lineWidth = { number ( 'lineWidth' , 2 ) }
84
- dashed = { boolean ( 'dashed' , true ) }
85
- />
82
+ < CubicBezierLine { ...args } />
86
83
< OrbitControls zoomSpeed = { 0.5 } />
87
84
</ >
88
85
)
89
86
}
90
87
CubicBezier . storyName = 'CubicBezier'
88
+ CubicBezier . args = {
89
+ start : [ 0 , 0 , 0 ] ,
90
+ end : [ 10 , 0 , 10 ] ,
91
+ midA : [ 5 , 4 , 0 ] ,
92
+ midB : [ 0 , 0 , 5 ] ,
93
+ segments : 10 ,
94
+ color : 'red' ,
95
+ lineWidth : 2 ,
96
+ dashed : true ,
97
+ }
98
+ CubicBezier . argTypes = {
99
+ segments : { control : { type : 'range' , min : 1 , max : 20 , step : 1 } } ,
100
+ color : { control : 'color' } ,
101
+ }
91
102
92
103
CubicBezier . decorators = [
93
- withKnobs ,
94
104
( storyFn ) => (
95
105
< Setup controls = { false } cameraPosition = { new Vector3 ( 0 , 0 , 17 ) } >
96
106
{ storyFn ( ) }
@@ -106,52 +116,58 @@ const catPoints = [
106
116
[ 0.5 , 8 , - 1 ] as [ number , number , number ] ,
107
117
]
108
118
109
- export function CatmullRom ( ) {
119
+ export function CatmullRom ( args ) {
110
120
return (
111
121
< >
112
- < CatmullRomLine
113
- points = { catPoints }
114
- closed = { boolean ( 'closed' , false ) }
115
- curveType = { select ( 'curveType' , [ 'centripetal' , 'chordal' , 'catmullrom' ] , 'centripetal' ) }
116
- tension = { number ( 'tension' , 0.5 , { range : true , min : 0 , max : 1 , step : 0.01 } ) }
117
- segments = { number ( 'segments' , 20 ) }
118
- color = { color ( 'color' , 'red' ) }
119
- lineWidth = { number ( 'lineWidth' , 3 ) }
120
- dashed = { boolean ( 'dashed' , true ) }
121
- />
122
+ < CatmullRomLine points = { catPoints } { ...args } segments = { 20 } />
122
123
< OrbitControls zoomSpeed = { 0.5 } />
123
124
</ >
124
125
)
125
126
}
126
127
CatmullRom . storyName = 'CatmullRom'
128
+ CatmullRom . args = {
129
+ closed : false ,
130
+ curveType : 'centripetal' ,
131
+ tension : 0.5 ,
132
+ segments : 20 ,
133
+ color : 'red' ,
134
+ lineWidth : 3 ,
135
+ dashed : true ,
136
+ }
137
+ CatmullRom . argTypes = {
138
+ curveType : { control : 'select' , options : [ 'centripetal' , 'chordal' , 'catmullrom' ] } ,
139
+ tension : { control : { type : 'range' , min : 0 , max : 1 , step : 0.01 } } ,
140
+ segments : { control : { type : 'range' , min : 1 , max : 20 , step : 1 } } ,
141
+ color : { control : 'color' } ,
142
+ }
127
143
128
144
CatmullRom . decorators = [
129
- withKnobs ,
130
145
( storyFn ) => (
131
146
< Setup controls = { false } cameraPosition = { new Vector3 ( 0 , 0 , 17 ) } >
132
147
{ storyFn ( ) }
133
148
</ Setup >
134
149
) ,
135
150
]
136
151
137
- export function VertexColorsLine ( ) {
152
+ export function VertexColorsLine ( args ) {
138
153
return (
139
154
< >
140
- < Line
141
- points = { points }
142
- color = { color ( 'color' , 'white' ) }
143
- vertexColors = { colors }
144
- lineWidth = { number ( 'lineWidth' , 3 ) }
145
- dashed = { boolean ( 'dashed' , false ) }
146
- />
155
+ < Line points = { points } vertexColors = { colors } { ...args } />
147
156
< OrbitControls zoomSpeed = { 0.5 } />
148
157
</ >
149
158
)
150
159
}
151
160
VertexColorsLine . storyName = 'VertexColors'
161
+ VertexColorsLine . args = {
162
+ color : 'white' ,
163
+ lineWidth : 3 ,
164
+ dashed : false ,
165
+ }
166
+ VertexColorsLine . argTypes = {
167
+ color : { control : 'color' } ,
168
+ }
152
169
153
170
VertexColorsLine . decorators = [
154
- withKnobs ,
155
171
( storyFn ) => (
156
172
< Setup controls = { false } cameraPosition = { new Vector3 ( 0 , 0 , 17 ) } >
157
173
{ storyFn ( ) }
0 commit comments