-
Notifications
You must be signed in to change notification settings - Fork 66
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
1 parent
e84d928
commit 64aa010
Showing
14 changed files
with
3,363 additions
and
387 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,97 @@ | ||
import { Box, useTheme } from '@maximeheckel/design-system'; | ||
import Sandpack from '@core/components/Code/Sandpack'; | ||
import useGPUTier from '@core/hooks/useGPUTier'; | ||
import { useInView } from 'react-intersection-observer'; | ||
import normalProjection from './normalProjection'; | ||
import simpleCaustics from './simpleCaustics'; | ||
import beautifulCaustics from './beautifulCaustics'; | ||
import causticsPlane from './causticsPlane'; | ||
import dynamicCaustics from './dynamicCaustics'; | ||
|
||
const SceneCSSDark = ` | ||
html { | ||
background: #20222B; | ||
} | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
canvas { | ||
width: 100vw; | ||
height: 100vh; | ||
}`; | ||
|
||
const SceneCSSLight = ` | ||
html { | ||
background: #F7F7FB; | ||
} | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
canvas { | ||
width: 100vw; | ||
height: 100vh; | ||
}`; | ||
|
||
const CausticsSandpack = (props: any) => { | ||
const { scene } = props; | ||
const [ref, inView] = useInView(); | ||
const { dark } = useTheme(); | ||
const { tier, loading: tierLoading } = useGPUTier(); | ||
|
||
const autorun = tier > 2; | ||
|
||
const SCENES = { | ||
scene1: normalProjection, | ||
scene2: simpleCaustics, | ||
scene3: beautifulCaustics, | ||
scene4: causticsPlane, | ||
scene5: dynamicCaustics, | ||
}; | ||
|
||
return ( | ||
<Box ref={ref}> | ||
{inView && !tierLoading ? ( | ||
<Sandpack | ||
autorun={autorun} | ||
template="react" | ||
dependencies={{ | ||
'@react-three/drei': '9.70.4', | ||
'@react-three/fiber': '8.11.2', | ||
leva: '0.9.31', | ||
three: '0.149.0', | ||
uuid: '^9.0.0', | ||
}} | ||
files={{ | ||
// @ts-ignore | ||
...SCENES[scene], | ||
'/scene.css': { | ||
code: !dark ? SceneCSSLight : SceneCSSDark, | ||
hidden: true, | ||
}, | ||
'/sandbox.config.json': { | ||
code: `{ "infiniteLoopProtection" : false }`, | ||
hidden: true, | ||
}, | ||
}} | ||
/> | ||
) : ( | ||
<Box | ||
css={{ | ||
height: '520px', | ||
'@media(max-width: 750px)': { | ||
height: '1060px', | ||
}, | ||
}} | ||
/> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default CausticsSandpack; |
Oops, something went wrong.
64aa010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog – ./
blog-maximeheckel-com-livid.vercel.app
blog-maximeheckel.vercel.app
blog-git-main-maximeheckel.vercel.app
blog.maximeheckel.com