Skip to content

Commit 2c38242

Browse files
joshuaellisgsimoneCode47XmattrossmanRenaudRohlinger
authored
BREAKING CHANGE: v3.0.0
* [Feature] move stories to TS (#223) (#231) * feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <[email protected]> Co-authored-by: Josh <[email protected]> * 2.2.16 * chore: add templates (#232) * chore: add react-dom as optional peer depency if you're using react-native you don't need it. * docs: update readme * fix: fix storybook imports that should have been done before * BREAKING CHANGE: refactor internal to solve react-native imports my bad. Co-authored-by: Gianmarco <[email protected]> * 2.3.0-beta.0 * fix: edit transformOutputPath to remove .ts from files * 2.3.0-beta.1 * fix: useAnimations ref type & chore: add storybook entry for useAnimations * Added THREE.Group to useAnimations types * Small refactor * Added useAnimations story * Clean up storybook * Fix null ref typing on useAnimations * Forgot to change typing on useAnimations api * chore: add storybook entry to README Co-authored-by: Josh Ellis <[email protected]> * [fix] Blob is undefined when using SSR (#239) * fix: #233 Blob is undefined in SSR * refactor: it appears Billboard is fixed Looks like Typescript does not suck. * 2.3.0-beta.2 * fix: create polyfill for atob * 2.3.0-beta.3 * chore: update readme in response to #240 * fix: #242 Frustum has incorrect spelling in softshadows (#243) * fix: suggestion for fixing #242 * refactor: default should be other way round * chore: update readme with correct spelling * 2.3.0-beta.4 * feat: Add MeshoptDecoder support to useGLTF (#246) * Add MeshoptDecoder support to useGLTF * chore: move center Co-authored-by: Josh Ellis <[email protected]> * 2.3.0-beta.5 * feat: #181 – adding points to line (#247) * feat: re-create geometry on new points * refactor: useMemo the geometry instead of useEffect * 2.3.0-beta.6 * 3.0.0-beta.1 * 3.0.0-beta.2 * feat: update troika with new features (#255) * 3.0.0-beta.3 * feat: add ability to add custom scene as prop (#256) * feat: add ability to add custom scene as prop * docs: update Environment with new feats * 3.0.0-beta.4 * refactor: shuffle imports for beta * 3.0.0-beta.5 * docs: clearly specify name of package & old has been deprecated * BREAKING CHANGE: Upgrade Three.js to r125 (#262) * chore: update Three.js dependency * refactor: remove subdivision modifier * fix: remove use of FaceNormalsHelper as it no longer exists in Three * fix: update typings for THREE * fix: update modifiers to work without THREE.Geometry * docs: update README * chore: add Three.js peer dependency * fix: change install instructions to use yarn instead of npm (#265) * repurpose reflector, make it capable to blur (#260) * repurpose reflector, make it capable to blur * refactor: move materials out to reduce noise & fix types * refactor: merge beta * fix: add child propType * refactor: update reflector story & fix children type * changes * fix: shuffle types so reflectorProps come from what the material expects * docs Co-authored-by: Josh Ellis <[email protected]> * chore: add workflows to beta release * BREAKING CHANGE force build * 3.0.0-beta.6 Co-authored-by: Gianmarco Simone <[email protected]> Co-authored-by: Tanner Hartwig <[email protected]> Co-authored-by: Matt Rossman <[email protected]> Co-authored-by: Renaud Rohlinger <[email protected]> Co-authored-by: Jure Triglav <[email protected]> Co-authored-by: Jason Bixon <[email protected]> Co-authored-by: Paul Henschel <[email protected]>
1 parent 413bce8 commit 2c38242

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+819
-310
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: release
22
on:
33
push:
44
branches:
5+
- 'master'
56
- 'beta'
67
- 'alpha'
78
pull_request: {}
@@ -27,7 +28,7 @@ jobs:
2728
release:
2829
needs: main
2930
runs-on: ubuntu-latest
30-
if: ${{ github.repository == 'pmndrs/drei' && contains('refs/heads/beta,refs/heads/alpha',github.ref) && github.event_name == 'push' }}
31+
if: ${{ github.repository == 'pmndrs/drei' && contains('refs/heads/master,refs/heads/beta,refs/heads/alpha',github.ref) && github.event_name == 'push' }}
3132
steps:
3233
- name: Cancel Previous Runs
3334
uses: styfle/[email protected]

.storybook/Setup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import * as THREE from 'three'
33
import { Canvas } from 'react-three-fiber'
44

5-
import { OrbitControls } from '../src/OrbitControls'
5+
import { OrbitControls } from '../src'
66

77
export function Setup({ children, cameraPosition = new THREE.Vector3(-5, 5, 5), controls = true, ...restProps }) {
88
return (

.storybook/public/ybot.glb

2.35 MB
Binary file not shown.

.storybook/stories/ContactShadows.stories.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ function ContactShadowScene() {
2323
<Icosahedron ref={mesh} args={[1, 2]} position-y={2}>
2424
<meshBasicMaterial attach="material" color="lightblue" />
2525
</Icosahedron>
26-
27-
<ContactShadows width={10} height={10} far={20} rotation={[Math.PI / 2, 0, 0]} />
28-
26+
<ContactShadows position={[0, 0, 0]} width={10} height={10} far={20} rotation={[Math.PI / 2, 0, 0]} />
2927
<Plane args={[10, 10]} position={[0, -0.01, 0]} rotation={[-Math.PI / 2, 0, 0]}>
3028
<meshBasicMaterial attach="material" color="white" />
3129
</Plane>

.storybook/stories/PositionalAudio.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as React from 'react'
22
import { Vector3 } from 'three'
33

44
import { Setup } from '../Setup'
5-
import { OrbitControls } from '../../src/OrbitControls'
6-
import { PositionalAudio } from '../../src/PositionalAudio'
5+
import { OrbitControls, PositionalAudio } from '../../src'
76

87
export default {
98
title: 'Abstractions/PositionalAudio',

.storybook/stories/Reflector.stories.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22
import { useFrame } from 'react-three-fiber'
3-
import { Color, Vector3, Mesh } from 'three'
3+
import { Vector3, Mesh } from 'three'
44

55
import { Setup } from '../Setup'
66

@@ -12,8 +12,6 @@ export default {
1212
decorators: [(storyFn) => <Setup cameraPosition={new Vector3(-2, 2, 6)}> {storyFn()}</Setup>],
1313
}
1414

15-
const reflectorCol = new Color('#333')
16-
1715
function ReflectorScene() {
1816
const $box = React.useRef<Mesh>(null!)
1917
useFrame(({ clock }) => {
@@ -24,13 +22,14 @@ function ReflectorScene() {
2422
return (
2523
<>
2624
<Reflector
27-
clipBias={0.1}
28-
textureWidth={1024}
29-
textureHeight={1024}
30-
rotation={[-Math.PI / 2, 0, 0]}
31-
color={reflectorCol}
25+
position={[0, 0, 0]}
26+
resolution={512}
27+
args={[10, 10]}
28+
mirror={0.5}
29+
rotation={[-Math.PI / 2, 0, Math.PI / 2]}
30+
blur={[400, 100]}
3231
>
33-
<planeBufferGeometry args={[10, 10]} attach="geometry" />
32+
{(Material, props) => <Material color="#a0a0a0" metalness={0.5} normalScale={[1, 1]} {...props} />}
3433
</Reflector>
3534

3635
<Box position={[-2, 1, -1]} material-color="hotpink" material-wireframe />

.storybook/stories/Shapes.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Mesh } from 'three'
44

55
import { Setup } from '../Setup'
66

7-
import * as shapes from '../../src/shapes'
7+
import * as shapes from '../../src/core/shapes'
88

99
export default {
1010
title: 'Shapes',

.storybook/stories/Text.stories.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,60 @@ function TextOutlineScene() {
6666
)
6767
}
6868

69+
function TextStrokeScene() {
70+
const ref = useTurntable()
71+
72+
return (
73+
<Text
74+
ref={ref}
75+
fontSize={12}
76+
maxWidth={200}
77+
lineHeight={1}
78+
letterSpacing={0.02}
79+
textAlign={'left'}
80+
font="https://fonts.gstatic.com/s/raleway/v14/1Ptrg8zYS_SKggPNwK4vaqI.woff"
81+
anchorX="center"
82+
anchorY="middle"
83+
fillOpacity={0}
84+
strokeWidth={'2.5%'}
85+
strokeColor="#ffffff"
86+
>
87+
LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT, SED DO EIUSMOD TEMPOR INCIDIDUNT UT LABORE ET DOLORE
88+
MAGNA ALIQUA. UT ENIM AD MINIM VENIAM, QUIS NOSTRUD EXERCITATION ULLAMCO LABORIS NISI UT ALIQUIP EX EA COMMODO
89+
CONSEQUAT. DUIS AUTE IRURE DOLOR IN REPREHENDERIT IN VOLUPTATE VELIT ESSE CILLUM DOLORE EU FUGIAT NULLA PARIATUR.
90+
EXCEPTEUR SINT OCCAECAT CUPIDATAT NON PROIDENT, SUNT IN CULPA QUI OFFICIA DESERUNT MOLLIT ANIM ID EST LABORUM.
91+
</Text>
92+
)
93+
}
94+
95+
function TextShadowScene() {
96+
const ref = useTurntable()
97+
98+
return (
99+
<Text
100+
ref={ref}
101+
color={'#EC2D2D'}
102+
fontSize={12}
103+
maxWidth={200}
104+
lineHeight={1}
105+
letterSpacing={0.02}
106+
textAlign={'left'}
107+
font="https://fonts.gstatic.com/s/raleway/v14/1Ptrg8zYS_SKggPNwK4vaqI.woff"
108+
anchorX="center"
109+
anchorY="middle"
110+
outlineOffsetX={'10%'}
111+
outlineOffsetY={'10%'}
112+
outlineBlur={'30%'}
113+
outlineOpacity={0.3}
114+
outlineColor="#EC2D2D"
115+
>
116+
LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT, SED DO EIUSMOD TEMPOR INCIDIDUNT UT LABORE ET DOLORE
117+
MAGNA ALIQUA. UT ENIM AD MINIM VENIAM, QUIS NOSTRUD EXERCITATION ULLAMCO LABORIS NISI UT ALIQUIP EX EA COMMODO
118+
CONSEQUAT. DUIS AUTE IRURE DOLOR IN REPREHENDERIT IN VOLUPTATE VELIT ESSE CILLUM DOLORE EU FUGIAT NULLA PARIATUR.
119+
EXCEPTEUR SINT OCCAECAT CUPIDATAT NON PROIDENT, SUNT IN CULPA QUI OFFICIA DESERUNT MOLLIT ANIM ID EST LABORUM.
120+
</Text>
121+
)
122+
}
69123
function CustomMaterialTextScene() {
70124
const ref = useTurntable()
71125
const defaultColor = '#EC2D2D'
@@ -100,5 +154,11 @@ function CustomMaterialTextScene() {
100154
export const TextOutlineSt = () => <TextOutlineScene />
101155
TextOutlineSt.storyName = 'Outline'
102156

157+
export const TextStrokeSt = () => <TextStrokeScene />
158+
TextStrokeSt.storyName = 'Transparent with stroke'
159+
160+
export const TextShadowSt = () => <TextShadowScene />
161+
TextShadowSt.storyName = 'Text Shadow'
162+
103163
export const CustomMaterialTextSt = () => <CustomMaterialTextScene />
104164
CustomMaterialTextSt.storyName = 'Custom Material'
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import * as React from 'react'
2+
import { Vector3 } from 'three'
3+
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'
4+
import { withKnobs, select, number } from '@storybook/addon-knobs'
5+
6+
import { Setup } from '../Setup'
7+
8+
import { useAnimations, useGLTF, useMatcapTexture } from '../../src'
9+
10+
export default {
11+
title: 'Abstractions/useAnimations',
12+
component: useAnimations,
13+
decorators: [(storyFn) => <Setup cameraPosition={new Vector3(0, 0, 3)}>{storyFn()}</Setup>, withKnobs],
14+
}
15+
16+
type GLTFResult = GLTF & {
17+
nodes: {
18+
YB_Body: THREE.SkinnedMesh
19+
YB_Joints: THREE.SkinnedMesh
20+
mixamorigHips: THREE.Bone
21+
}
22+
materials: {
23+
YB_Body: THREE.MeshStandardMaterial
24+
YB_Joints: THREE.MeshStandardMaterial
25+
}
26+
}
27+
28+
type AnimationControllerProps = {
29+
ybotRef: React.MutableRefObject<THREE.Group | undefined | null>
30+
animations: THREE.AnimationClip[]
31+
}
32+
33+
function AnimationController(props: AnimationControllerProps) {
34+
const { actions } = useAnimations(props.animations, props.ybotRef)
35+
36+
// Storybook Knobs
37+
const actionOptions = Object.keys(actions)
38+
const selectedAction = select('Animation', actionOptions, actionOptions[2])
39+
const blendDuration = number('Blend duration', 0.5, {
40+
range: true,
41+
min: 0,
42+
max: 2,
43+
step: 0.1,
44+
})
45+
46+
React.useEffect(() => {
47+
actions[selectedAction].reset().fadeIn(blendDuration).play()
48+
return () => void actions[selectedAction].fadeOut(blendDuration)
49+
}, [actions, selectedAction, blendDuration])
50+
51+
return null
52+
}
53+
54+
function YBotModel(props: JSX.IntrinsicElements['group']) {
55+
const ybotRef = React.useRef<THREE.Group>(null)
56+
const { nodes, animations } = useGLTF('ybot.glb') as GLTFResult
57+
const [matcapBody] = useMatcapTexture('293534_B2BFC5_738289_8A9AA7', 1024)
58+
const [matcapJoints] = useMatcapTexture('3A2412_A78B5F_705434_836C47', 1024)
59+
60+
return (
61+
<>
62+
<group ref={ybotRef} {...props} dispose={null}>
63+
<group rotation={[Math.PI / 2, 0, 0]} scale={[0.01, 0.01, 0.01]}>
64+
<primitive object={nodes.mixamorigHips} />
65+
<skinnedMesh geometry={nodes.YB_Body.geometry} skeleton={nodes.YB_Body.skeleton}>
66+
<meshMatcapMaterial attach="material" matcap={matcapBody} skinning={true} />
67+
</skinnedMesh>
68+
<skinnedMesh geometry={nodes.YB_Joints.geometry} skeleton={nodes.YB_Joints.skeleton}>
69+
<meshMatcapMaterial attach="material" matcap={matcapJoints} skinning={true} />
70+
</skinnedMesh>
71+
</group>
72+
</group>
73+
74+
<AnimationController ybotRef={ybotRef} animations={animations} />
75+
</>
76+
)
77+
}
78+
79+
useGLTF.preload('ybot.glb')
80+
81+
function UseAnimationsScene() {
82+
return (
83+
<React.Suspense fallback={null}>
84+
<YBotModel position={[0, -1, 0]} />
85+
</React.Suspense>
86+
)
87+
}
88+
89+
export const UseAnimationsSt = () => <UseAnimationsScene />
90+
UseAnimationsSt.storyName = 'Default'

.storybook/stories/useContextBridge.stories.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import * as React from 'react'
22
import { Canvas } from 'react-three-fiber'
33
import { withKnobs } from '@storybook/addon-knobs'
44

5-
import { OrbitControls } from '../../src/OrbitControls'
6-
import { Box } from '../../src/shapes'
7-
import { useContextBridge } from '../../src/useContextBridge'
8-
import { Text } from '../../src/Text'
5+
import { OrbitControls, Box, useContextBridge, Text } from '../../src'
96

107
export default {
118
title: 'Misc/useContextBridge',

0 commit comments

Comments
 (0)