Skip to content

Commit 2e13dee

Browse files
committed
Autofocus story wip
1 parent bb1a9e3 commit 2e13dee

File tree

11 files changed

+126
-327
lines changed

11 files changed

+126
-327
lines changed

.storybook/Setup.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as React from 'react'
2+
import { Vector3 } from 'three'
3+
import { Canvas, Props as CanvasProps } from '@react-three/fiber'
4+
5+
// import { OrbitControls } from '../src'
6+
7+
type Props = React.PropsWithChildren<
8+
CanvasProps & {
9+
cameraFov?: number
10+
cameraPosition?: Vector3
11+
controls?: boolean
12+
lights?: boolean
13+
}
14+
>
15+
16+
export const Setup = ({
17+
children,
18+
cameraFov = 75,
19+
cameraPosition = new Vector3(-5, 5, 5),
20+
controls = true,
21+
lights = true,
22+
...restProps
23+
}: Props) => (
24+
<div style={{ height: '100vh' }}>
25+
<Canvas shadows camera={{ position: cameraPosition, fov: cameraFov }} {...restProps}>
26+
{children}
27+
{lights && (
28+
<>
29+
<ambientLight intensity={0.8} />
30+
<pointLight intensity={1} position={[0, 6, 0]} />
31+
</>
32+
)}
33+
{/* {controls && <OrbitControls makeDefault />} */}
34+
</Canvas>
35+
</div>
36+
)

.storybook/preview.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

.storybook/preview.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react'
2+
import type { Preview } from '@storybook/react'
3+
4+
const preview: Preview = {
5+
parameters: {
6+
// actions: { argTypesRegex: '^on[A-Z].*' },
7+
// controls: {
8+
// matchers: {
9+
// color: /(background|color)$/i,
10+
// date: /Date$/,
11+
// },
12+
// },
13+
layout: 'fullscreen',
14+
},
15+
decorators: [
16+
(Story) => (
17+
<React.Suspense fallback={null}>
18+
<Story />
19+
</React.Suspense>
20+
),
21+
],
22+
}
23+
24+
export default preview

src/effects/Autofocus.stories.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import * as THREE from 'three'
2+
import type { Meta, StoryObj } from '@storybook/react'
3+
import { Setup } from '../../.storybook/Setup'
4+
5+
import { EffectComposer } from '../EffectComposer'
6+
7+
import { Autofocus } from '../effects/Autofocus'
8+
9+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
10+
const meta: Meta<typeof Autofocus> = {
11+
title: 'Effect/Autofocus',
12+
component: Autofocus,
13+
decorators: [(Story) => <Setup cameraPosition={new THREE.Vector3(1, 1, 2)}>{Story()}</Setup>],
14+
tags: ['autodocs'],
15+
// argTypes: {
16+
// debug: {
17+
// control: { type: 'range', min: 0, max: 1, step: 0.01 },
18+
// },
19+
// },
20+
}
21+
22+
export default meta
23+
type Story = StoryObj<typeof Autofocus>
24+
25+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
26+
export const Primary: Story = {
27+
render: (args) => (
28+
<>
29+
<mesh castShadow>
30+
<sphereGeometry args={[0.5, 64, 64]} />
31+
<meshStandardMaterial color="#9d4b4b" />
32+
</mesh>
33+
<mesh castShadow position={[1, 0, -5]}>
34+
<boxGeometry args={[1, 1, 1]} />
35+
<meshStandardMaterial color="#9d4b4b" />
36+
</mesh>
37+
38+
<gridHelper />
39+
40+
<EffectComposer>
41+
<Autofocus {...args} focusRange={0.001} bokehScale={18} />
42+
</EffectComposer>
43+
</>
44+
),
45+
args: {
46+
mouse: true,
47+
debug: 0.04,
48+
bokehScale: 8,
49+
},
50+
}

src/stories/Header.stories.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/stories/Header.tsx

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/stories/Introduction.mdx

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Meta } from '@storybook/blocks';
2-
import Code from './assets/code-brackets.svg';
3-
import Colors from './assets/colors.svg';
4-
import Comments from './assets/comments.svg';
5-
import Direction from './assets/direction.svg';
6-
import Flow from './assets/flow.svg';
7-
import Plugin from './assets/plugin.svg';
8-
import Repo from './assets/repo.svg';
9-
import StackAlt from './assets/stackalt.svg';
1+
import { Meta } from '@storybook/blocks'
2+
import Code from './assets/code-brackets.svg'
3+
import Colors from './assets/colors.svg'
4+
import Comments from './assets/comments.svg'
5+
import Direction from './assets/direction.svg'
6+
import Flow from './assets/flow.svg'
7+
import Plugin from './assets/plugin.svg'
8+
import Repo from './assets/repo.svg'
9+
import StackAlt from './assets/stackalt.svg'
1010

1111
<Meta title="Example/Introduction" />
1212

@@ -116,7 +116,9 @@ import StackAlt from './assets/stackalt.svg';
116116
`}
117117
</style>
118118

119-
# Welcome to Storybook
119+
# Welcome to `@react-three/postprocessing`
120+
121+
TODO
120122

121123
Storybook helps you build UI components in isolation from your app's business logic, data, and context.
122124
That makes it easy to develop hard-to-reach states. Save these UI states as **stories** to revisit during development, testing, or QA.
@@ -128,33 +130,21 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
128130
<div className="subheading">Configure</div>
129131

130132
<div className="link-list">
131-
<a
132-
className="link-item"
133-
href="https://storybook.js.org/docs/react/addons/addon-types"
134-
target="_blank"
135-
>
133+
<a className="link-item" href="https://storybook.js.org/docs/react/addons/addon-types" target="_blank">
136134
<img src={Plugin} alt="plugin" />
137135
<span>
138136
<strong>Presets for popular tools</strong>
139137
Easy setup for TypeScript, SCSS and more.
140138
</span>
141139
</a>
142-
<a
143-
className="link-item"
144-
href="https://storybook.js.org/docs/react/configure/webpack"
145-
target="_blank"
146-
>
140+
<a className="link-item" href="https://storybook.js.org/docs/react/configure/webpack" target="_blank">
147141
<img src={StackAlt} alt="Build" />
148142
<span>
149143
<strong>Build configuration</strong>
150144
How to customize webpack and Babel
151145
</span>
152146
</a>
153-
<a
154-
className="link-item"
155-
href="https://storybook.js.org/docs/react/configure/styling-and-css"
156-
target="_blank"
157-
>
147+
<a className="link-item" href="https://storybook.js.org/docs/react/configure/styling-and-css" target="_blank">
158148
<img src={Colors} alt="colors" />
159149
<span>
160150
<strong>Styling</strong>
@@ -208,6 +198,5 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
208198
</div>
209199

210200
<div className="tip-wrapper">
211-
<span className="tip">Tip</span>Edit the Markdown in{' '}
212-
<code>stories/Introduction.stories.mdx</code>
201+
<span className="tip">Tip</span>Edit the Markdown in <code>stories/Introduction.stories.mdx</code>
213202
</div>

src/stories/Page.stories.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/stories/Page.tsx

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)