Skip to content

Commit 542c76c

Browse files
committed
.
1 parent 2f8f08e commit 542c76c

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

.storybook/stories/Fbo.stories.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ type Story = StoryObj<typeof Fbo>
2424
function SpinningThing() {
2525
const mesh = React.useRef<React.ComponentRef<typeof TorusKnot>>(null!)
2626

27-
useFrame(() => {
28-
mesh.current.rotation.x = mesh.current.rotation.y = mesh.current.rotation.z += 0.01
27+
useFrame((state) => {
28+
const t = state.clock.getElapsedTime()
29+
mesh.current.rotation.x = mesh.current.rotation.y = mesh.current.rotation.z = t
2930
})
3031

3132
return (

.storybook/stories/HTML.stories.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,14 @@ export const HTMLTransformSt = {
9595

9696
function HTMLOrthographicScene(props: HtmlProps) {
9797
const camera = useThree((state) => state.camera)
98-
const [zoomIn, setZoomIn] = React.useState(true)
9998

10099
const initialCamera = {
101100
position: new THREE.Vector3(0, 0, -10),
102101
}
103102

104-
useFrame(() => {
105-
zoomIn ? (camera.zoom += 0.01) : (camera.zoom -= 0.01)
103+
useFrame((state) => {
104+
camera.zoom = 2 + Math.sin(state.clock.getElapsedTime()) * 1
106105
camera.updateProjectionMatrix()
107-
108-
if (camera.zoom > 3) {
109-
setZoomIn(false)
110-
} else if (camera.zoom < 1) {
111-
setZoomIn(true)
112-
}
113106
})
114107

115108
return (

0 commit comments

Comments
 (0)