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