|
| 1 | +import React, { memo } from 'react' |
| 2 | +import * as THREE from 'three' |
| 3 | +import type { Meta, StoryObj } from '@storybook/react' |
| 4 | +import { BackSide } from 'three' |
| 5 | +import { Box, useTexture } from '@react-three/drei' |
| 6 | + |
| 7 | +import { Setup } from '../Setup' |
| 8 | +import { EffectComposer, LensFlare, Vignette, Bloom } from '../../src' |
| 9 | + |
| 10 | +function SkyBox() { |
| 11 | + const texture = useTexture('/digital_painting_golden_hour_sunset.jpg') |
| 12 | + |
| 13 | + return ( |
| 14 | + <mesh userData={{ lensflare: 'no-occlusion' }} scale={[-1, 1, 1]} castShadow={false} receiveShadow={false}> |
| 15 | + <sphereGeometry args={[50, 32, 32]} /> |
| 16 | + <meshBasicMaterial toneMapped={false} map={texture} side={BackSide} /> |
| 17 | + </mesh> |
| 18 | + ) |
| 19 | +} |
| 20 | + |
| 21 | +// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction |
| 22 | +const meta = { |
| 23 | + title: 'Effect/LensFlare', |
| 24 | + component: LensFlare, |
| 25 | + decorators: [ |
| 26 | + (Story) => ( |
| 27 | + <Setup cameraPosition={new THREE.Vector3(8, 1, 10)} cameraFov={50}> |
| 28 | + {Story()} |
| 29 | + </Setup> |
| 30 | + ), |
| 31 | + ], |
| 32 | + tags: ['autodocs'], |
| 33 | + // argTypes: { |
| 34 | + // debug: { |
| 35 | + // control: { type: 'range', min: 0, max: 1, step: 0.01 }, |
| 36 | + // }, |
| 37 | + // }, |
| 38 | +} satisfies Meta<typeof LensFlare> |
| 39 | + |
| 40 | +export default meta |
| 41 | +type Story = StoryObj<typeof meta> |
| 42 | + |
| 43 | +// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args |
| 44 | +export const Primary: Story = { |
| 45 | + render: (args) => ( |
| 46 | + <> |
| 47 | + <color attach="background" args={['#303035']} /> |
| 48 | + |
| 49 | + <directionalLight intensity={3} position={[-25, 60, -60]} /> |
| 50 | + |
| 51 | + <Box /> |
| 52 | + |
| 53 | + <SkyBox /> |
| 54 | + |
| 55 | + <EffectComposer multisampling={0} disableNormalPass> |
| 56 | + <LensFlare {...args} /> |
| 57 | + </EffectComposer> |
| 58 | + </> |
| 59 | + ), |
| 60 | + args: {}, |
| 61 | +} |
| 62 | + |
| 63 | +function DirtLensFlare(props) { |
| 64 | + const texture = useTexture('/lensDirtTexture.png') |
| 65 | + |
| 66 | + return <LensFlare {...props} lensDirtTexture={texture} /> |
| 67 | +} |
| 68 | + |
| 69 | +export const Secondary: Story = { |
| 70 | + render: (args) => ( |
| 71 | + <> |
| 72 | + <color attach="background" args={['#303035']} /> |
| 73 | + |
| 74 | + <directionalLight intensity={3} position={[-25, 60, -60]} /> |
| 75 | + |
| 76 | + <Box /> |
| 77 | + |
| 78 | + <SkyBox /> |
| 79 | + |
| 80 | + <EffectComposer multisampling={0} disableNormalPass> |
| 81 | + <DirtLensFlare {...args} /> |
| 82 | + </EffectComposer> |
| 83 | + </> |
| 84 | + ), |
| 85 | + args: { starBurst: true }, |
| 86 | +} |
0 commit comments