You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/fiber/readme.md
+114-66
Original file line number
Diff line number
Diff line change
@@ -10,25 +10,23 @@
10
10
11
11
react-three-fiber is a <ahref="https://reactjs.org/docs/codebase-overview.html#renderers">React renderer</a> for threejs.
12
12
13
+
Build your scene declaratively with re-usable, self-contained components that react to state, are readily interactive and can participate in React's ecosystem.
14
+
13
15
```bash
14
16
npm install three @react-three/fiber
15
17
```
16
18
17
-
### Why?
18
-
19
-
Build your scene declaratively with re-usable, self-contained components that react to state, are readily interactive and can tap into React's ecosystem.
20
-
21
19
#### Does it have limitations?
22
20
23
-
None. Everything that works in threejs will work here without exception.
21
+
None. Everything that works in Threejs will work here without exception.
24
22
25
-
#### Can it keep up with frequent updates to threejs?
23
+
#### Is it slower than plain Threejs?
26
24
27
-
Yes, because it merely expresses threejs in JSX: `<mesh />` becomes `new THREE.Mesh()`, and that happens dynamically. There is no hard dependency on a particular threejs version, it does not wrap or duplicate a single threejs class.
25
+
No. There is no overhead. Components render outside of React. It outperforms Threejs in scale due to Reacts scheduling abilities.
28
26
29
-
#### Is it slower than plain threejs?
27
+
#### Can it keep up with frequent feature updates to Threejs?
30
28
31
-
There is no additional overhead. Components participate in the renderloop outside of React.
29
+
Yes. It merely expresses Threejs in JSX: `<mesh />` becomes `new THREE.Mesh()`, and that happens dynamically. If a new Threejs version adds, removes or changes features, it will be available to you instantly without depending on updates to this library.
32
30
33
31
### What does it look like?
34
32
@@ -45,80 +43,127 @@ There is no additional overhead. Components participate in the renderloop outsid
Either use `Canvas`, which you can think of as a portal to threejs inside your regular dom graph. Everything within it is a [native threejs element](https://threejs.org/docs). If you want to mix Webgl and Html (react-dom) this is what you should use.
Or use react-three-fibers own `render` function, which is a little more low-level but could save you the extra cost of carrying react-dom. It renders into a dom `canvas` element. Use this for Webgl-only apps.
126
+
Live demo: https://codesandbox.io/s/icy-tree-brnsm?file=/src/App.tsx
100
127
101
-
```jsx
102
-
import { render } from'@react-three/fiber'
128
+
</details>
129
+
130
+
<details>
131
+
<summary>Show React Native example</summary>
132
+
133
+
This example relies on react 18 and uses `expo-cli`, but you can create a bare project with their template or with the `react-native` CLI.
npm install three @react-three/fiber@beta react@rc
143
+
# Start
144
+
expo start
105
145
```
106
146
107
-
<details>
108
-
<summary>Show TypeScript example</summary>
147
+
Some configuration may be required to tell the Metro bundler about your assets if you use `useLoader` or Drei abstractions like `useGLTF` and `useTexture`:
@@ -161,13 +206,14 @@ You need to be versed in both React and Threejs before rushing into this. If you
161
206
1. Make sure you have a [basic grasp of Threejs](https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene). Keep that site open.
162
207
2. When you know what a scene is, a camera, mesh, geometry, material, fork the [demo above](https://github.com/pmndrs/react-three-fiber#what-does-it-look-like).
163
208
3.[Look up](https://threejs.org/docs/index.html#api/en/objects/Mesh) the JSX elements that you see (mesh, ambientLight, etc), _all_ threejs exports are native to three-fiber.
164
-
4. Try changing some values, scroll though our [Api](/markdown/api.md) to see what the various settings and hooks do.
209
+
4. Try changing some values, scroll through our [API](https://docs.pmnd.rs/react-three-fiber/API) to see what the various settings and hooks do.
0 commit comments