From 5099784eb3e2ffd34eccf75367eea5a481fc0529 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 25 Aug 2024 12:12:59 +0200 Subject: [PATCH] docs: sandpack basic js/ts demos --- docs/getting-started/introduction.mdx | 80 +++++++++++++++------------ 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/docs/getting-started/introduction.mdx b/docs/getting-started/introduction.mdx index 0544fc6a06..944425f32d 100644 --- a/docs/getting-started/introduction.mdx +++ b/docs/getting-started/introduction.mdx @@ -5,7 +5,7 @@ nav: 0 --- - +
@@ -29,31 +29,25 @@ Yes. It merely expresses Threejs in JSX, `` dynamically turns into `new ## What does it look like? - - - - - - - -
- Let's make a re-usable component that has its own state, reacts to user-input and participates in the - render-loop. (live demo). - - - Two spinning orange cubes that turn purple on mouse over - -
- -```jsx -import { createRoot } from 'react-dom/client' +Let's make a re-usable component that has its own state, reacts to user-input and participates in the render-loop: + + , -) -``` +)`, + }} +/>
Show TypeScript example @@ -96,11 +91,25 @@ createRoot(document.getElementById('root')).render( npm install @types/three ``` -```tsx -import * as THREE from 'three' +(null!) @@ -116,7 +125,7 @@ function Box(props: ThreeElements['mesh']) { onPointerOver={(event) => setHover(true)} onPointerOut={(event) => setHover(false)}> - + ) } @@ -129,10 +138,9 @@ createRoot(document.getElementById('root')).render( , -) -``` - -Live demo: https://codesandbox.io/s/icy-tree-brnsm?file=/src/App.tsx +)`, + }} +/>
@@ -195,7 +203,7 @@ Some helpful material: - [Bruno Simons Threejs Jouney](https://threejs-journey.com), arguably the best learning resource, now includes a full [R3F chapter](https://threejs-journey.com/lessons/what-are-react-and-react-three-fiber) - + ## Eco system @@ -236,7 +244,7 @@ If you like this project, please consider helping out. All contributions are wel Thank you to all our backers! 🙏 - + ## Contributors @@ -244,5 +252,5 @@ Thank you to all our backers! 🙏 This project exists thanks to all the people who contribute. - +