-
Notifications
You must be signed in to change notification settings - Fork 703
/
GizmoHelper.stories.tsx
86 lines (73 loc) · 1.86 KB
/
GizmoHelper.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import * as React from 'react'
import { Vector3 } from 'three'
import { Meta, StoryObj } from '@storybook/react'
import { GizmoHelper, OrbitControls, useGLTF, GizmoViewcube, TrackballControls, GizmoViewport } from '../../src'
import { Setup } from '../Setup'
import { ComponentProps } from 'react'
const alignments = [
'top-left',
'top-right',
'bottom-right',
'bottom-left',
'bottom-center',
'center-right',
'center-left',
'center-center',
'top-center',
] as const
export default {
title: 'Gizmos/GizmoHelper',
component: GizmoHelper,
decorators: [
(Story) => (
<Setup controls={false} cameraPosition={new Vector3(0, 0, 10)}>
<Story />
</Setup>
),
],
args: {
alignment: alignments[2],
margin: [80, 80],
},
argTypes: {
alignment: {
control: { type: 'select' },
options: alignments,
},
},
} satisfies Meta<typeof GizmoHelper>
type Story = StoryObj<typeof GizmoHelper>
function Tokyo() {
const { scene } = useGLTF('LittlestTokyo.glb')
return <primitive object={scene} scale={0.01} />
}
const GizmoHelperScene1 = (props: ComponentProps<typeof GizmoHelper>) => {
return (
<React.Suspense fallback={null}>
<Tokyo />
<GizmoHelper {...props}>
<GizmoViewcube />
</GizmoHelper>
<OrbitControls makeDefault />
</React.Suspense>
)
}
export const GizmoHelperSt1: Story = {
name: 'Cube',
render: (args) => <GizmoHelperScene1 {...args} />,
} satisfies Story
const GizmoHelperScene2 = (props: ComponentProps<typeof GizmoHelper>) => {
return (
<React.Suspense fallback={null}>
<Tokyo />
<GizmoHelper {...props}>
<GizmoViewport />
</GizmoHelper>
<OrbitControls makeDefault />
</React.Suspense>
)
}
export const GizmoHelperSt2: Story = {
name: 'Viewport',
render: (args) => <GizmoHelperScene2 {...args} />,
} satisfies Story