19 |
20 | Why?
21 |
22 | Building dynamic scene graphs declaratively with re-usable components
23 | makes dealing with Threejs easier and brings order and sanity to your
24 | codebase. These components react to state changes, are interactive out
25 | of the box and can tap into React's infinite ecosystem.
26 |
27 |
28 |
29 | Does it have limitations?
30 |
31 | None. Everything that works in Threejs will work here. In contrast to
32 | "bindings" where a library ships/maintains dozens of wrapper
33 | components, it just reconciles JSX to Threejs dynamically: <mesh />
34 | simply is another expression for new THREE.Mesh(). It does not know or
35 | target a specific Threejs version nor does it need updates for
36 | modified, added or removed upstream features.
37 |
38 |
39 |
40 | Is it slower than raw Threejs?
41 |
42 | No. Rendering performance is up to Threejs and the GPU. Components may
43 | participate in the renderloop outside of React, without any additional
44 | overhead. React is otherwise very efficient in building and managing
45 | component-trees, it could potentially outperform manual/imperative
46 | apps at scale.
47 |
48 |
49 |
50 | );
51 | };
52 |
53 | export default Why;
54 |
--------------------------------------------------------------------------------
/src/config/sidebar.yml:
--------------------------------------------------------------------------------
1 | - label: "Introduction"
2 | link: "/"
3 | - label: "Getting started"
4 | link: "/getting-started"
5 | - label: First Scene
6 | items:
7 | - label: "First Things on the Screen"
8 | link: "/first-scene/first-render"
9 | - label: "Lights"
10 | link: "/first-scene/lights"
11 | - label: "Animation"
12 | link: "/first-scene/animation"
13 | - label: API
14 | items:
15 | - label: "Canvas"
16 | link: "/api/canvas"
17 | - label: "Objects and properties"
18 | link: "/api/objects-and-properties"
19 | - label: "Automatic disposal"
20 | link: "/api/automatic-disposal"
21 | - label: "Events"
22 | link: "/api/events"
23 | - label: "Hooks"
24 | items:
25 | - label: "Introduction"
26 | link: "/api/hooks/introduction"
27 | - label: "useThree"
28 | link: "/api/hooks/useThree"
29 | - label: "useFrame"
30 | link: "/api/hooks/useFrame"
31 | - label: "useResource"
32 | link: "/api/hooks/useResource"
33 | - label: "useUpdate"
34 | link: "/api/hooks/useUpdate"
35 | - label: "useLoader"
36 | link: "/api/hooks/useLoader"
37 | - label: "Additional exports"
38 | link: "/api/additional"
39 |
40 | - label: Recipes
41 | items:
42 | - label: "Animating with react-spring"
43 | link: "/recipes/animating-with-react-spring"
44 | - label: "Dealing with effects"
45 | link: "/recipes/dealing-with-effects-hijacking-main-render-loop"
46 | - label: "Using your own camera rig"
47 | link: "/recipes/using-your-own-camera-rig"
48 | - label: "Enabling VR"
49 | link: "/recipes/enabling-vr"
50 | - label: "Heads-up display"
51 | link: "/recipes/heads-up-display-rendering-multiple-scenes"
52 | - label: "Managing imperative code"
53 | link: "/recipes/managing-imperative-code"
54 | - label: "Re-parenting"
55 | link: "/recipes/re-parenting"
56 | - label: "Reducing bundle-size"
57 | link: "/recipes/reducing-bundle-size"
58 | - label: "Rendering only when needed"
59 | link: "/recipes/rendering-only-when-needed"
60 | - label: "Shader Materials"
61 | link: "/recipes/shader-materials"
62 | - label: "Switching the default renderer"
63 | link: "/recipes/switching-the-default-renderer"
64 | - label: "Usage with React Native"
65 | link: "/recipes/usage-with-react-native"
66 |
--------------------------------------------------------------------------------
/src/docs/api/events.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Events
3 | ---
4 |
5 | Threejs objects that implement their own `raycast` method (meshes, lines, etc) can be interacted with by declaring events on them. We support pointer events, clicks and wheel-scroll. Events contain the browser event as well as the Threejs event data (object, point, distance, etc). You need to [polyfill](https://github.com/jquery/PEP) them yourself, if that's a concern.
6 |
7 | Additionally, there's a special `onUpdate` that is called every time the object gets fresh props, which is good for things like `self => (self.verticesNeedUpdate = true)`.
8 |
9 | Also notice the `onPointerMissed` on the canvas element, which fires on clicks that haven't hit any meshes.
10 |
11 | ```jsx
12 |