-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peeke Kuepers
committed
Jun 10, 2022
1 parent
626eaad
commit be09b19
Showing
6 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
"author": "Peeke Kuepers <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@kaliber/build": "^0.0.126" | ||
"@kaliber/build": "^0.0.126", | ||
"react-spring": "^9.4.5", | ||
"three": "^0.141.0" | ||
}, | ||
"scripts": { | ||
"start": "npm-run-all --parallel watch serve.dev", | ||
|
@@ -18,4 +20,4 @@ | |
"lint.javascript": "eslint -c .eslintrc --ignore-path .gitignore './**/*.js'", | ||
"lint.styles": "stylelint --config .stylelintrc --ignore-path .gitignore './**/*.css'" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.app { | ||
isolation: isolate; | ||
} | ||
|
||
.object { | ||
width: 50px !important; | ||
height: 50px !important; | ||
background: hotpink; | ||
border-radius: 50%; | ||
will-change: transform; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
|
||
// import { Vector2 } from 'three' | ||
import { useSpring, animated } from 'react-spring' | ||
import { useAnimationFrame } from '/machinery/useAnimationFrame' | ||
import styles from './App.css' | ||
|
||
export function App() { | ||
useAnimationFrame({ onFrame: console.log }) | ||
const [spring, api] = useSpring(() => ({ x: 0 })) | ||
const stateRef = React.useRef({ | ||
position: 0, | ||
velocity: 0, | ||
acceleration: 0, | ||
}) | ||
|
||
useAnimationFrame({ onFrame(dt) { | ||
stateRef.current.position += stateRef.current.velocity * dt | ||
stateRef.current.velocity += stateRef.current.position * dt | ||
api.set({ x: stateRef.current.position }) | ||
} }) | ||
|
||
return ( | ||
<div /> | ||
<div className={styles.app}> | ||
<animated.div className={styles.object} style={spring} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,9 @@ body { | |
font-weight: var(--font-weight-base-400); | ||
line-height: 1.7; | ||
} | ||
|
||
html, | ||
body, | ||
body > * { | ||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters