Skip to content

Commit 347ea79

Browse files
drcmdaskratandersonleiteCodyJasonBennettdangrabcad
authored
V8, react 18 beta (#1630)
* react 18 alpha * up use-asset * fix flat * silence disposal errors * support instanced event cancelation * simplify useFrame * Allow partial WebGLRenderer params (#1656) Without the `Partial` the `gl` props is practically unusable as it requires all the params to be present in the prop. * is.test: 'is equal' test to use alredy declared obj and array. (#1643) * refactor into utility functions * refactor * bring over diffprops bug * Merge branch 'master' into v8 * chore: move dpr calc to utils * chore: don't use `is` outside of renderer * fix(core): set null parent in prepare * fix args in createinstance * fix primitve leftovers on switch, add gltf example * chore(web): fix mangled import * make applyprops return the instance * fix merge * spread props over container div, change dpr default, fix createRoot * export createroot * fix cherrypick * [v8] feat: add react-native support (#1699) * chore: add native target from: #1384 Co-authored by @swittk. * fix: set initial render size * refactor: cleanup render API, remove shim * chore: cleanup canvas, TS * chore: map events TODO: bind them * refactor: move expo to Canvas, allow custom renderers * chore: add RN types * refactor: accept constructor args in canvas * chore: bind events * chore: synchronously get handlers from target * chore: remove dependency on expo-three * chore: cleanup Canvas TS * chore: create native entrypoint * chore: cleanup context init * refactor: accept context over canvas * fix: passthrough gl props * chore: remove entrypoint This is created automatically but we'll have to update the CI to skip it. * chore: update canvas props TS * chore: fix native exports * chore: hide __mocks__ from npm output * chore: add TS to native entrypoint * chore: cleanup context TS * chore: update native recipe * chore: add back in bootstrap tip for native TODO: update https://github.com/expo/examples/tree/master/with-react-three-fiber * chore: mirror dpr/size fix from #1707 * feat: add v5 native props * chore: add expo-gl as a dependency * chore: don't use `is` outside of renderer * feat(native): export native useLoader * fix(native/hooks): respect module paths, fix constructor compar * chore(native): streamline loader TS, mirror GLProps from web * chore(native): defer to RenderProps for GL * docs: remove expo-gl dep, use same API * chore: delete RN key in package * chore: bump native deps * chore(native): pin dpr to screen dpr * fix(native): set color management defaults * Merge branch 'v8' into native * chore(Canvas): accept native props * chore(native): export createRoot * fix(Canvas): pass onCreated * [v8] feat: remove vr prop for dynamic render switching (#1702) * fix(Canvas): pass events & size * feat: add `renderVisible` prop to only render while in view * remove zustand sub selector * feat(core): make `frameloop` reactive * chore: `renderVisible` => `include` * chore: add demo for IncludeProp * docs: add `intersect` prop and internal `setFrameloop` * chore: cleanup example with styled-components * chore: revert `intersect` for native * chore: fix peer dep range for native * [v8] refactor(core): use-asset => suspend-react (#1797) * refactor(core): use-asset => suspend-react * fix(native/hooks): use correct import * fix(core): fix shallow equality in useLoader * chore(hooks): fix TS * fix: use correct keys syntax * chore: remove `intersect` prop from web & docs, example * chore: add react-native key for lib interop * update deps * update version * chore: fix native peer dep * chore: update references from github namespace react-spring to pmndrs * fix: tree-shaking * fix: revert removing mergerefs, use pure annotations instead * align both canvases * update usemeasure * Fix missing type for Float32BufferAttribute (#1862) Missing Float32BufferAttriute type causes Typescript error "Property 'float32BufferAttribute' does not exist on type 'JSX.IntrinsicElements'.ts(2339)" Example of use of float32BufferAttribute ```jsx <instancedBufferGeometry attach="geometry" instanceCount={count}> <float32BufferAttribute attachObject={['attributes', 'position']} args={[positionArray, 3]} /> <instancedBufferAttribute attachObject={['attributes', 'offset']} args={[offsetArray, 3]} /> </instancedBufferGeometry> ``` * fix(Canvas): unmount current context * [v8] fix: use new act API & fix extend for tests (#1891) * feat(test-renderer): add RegExp matcher support to `findByProps` and `findAllByProps` (#1890) * chore: apply fix to applyProps * fix: schedule child.dispose() (#1887) * chore: fix eslint * add camera:manual * remove console log * move up to react rc * update examples to react-router 6 * fix three types * unify attach * fix suspense re-attach * chore: update tests * fix(types): use new attach API * switch to createRoot * chore: update test-renderer snapshot * publish new beta * fix(RTTR): use createRoot * chore(tests): use createRoot * fix(web): render when canvas is created * refactor: move createRoot to core (#1915) * chore(native): add expo unimodules as dep (#1916) * clean up example * up version * chore(tests): add native coverage, sort tests (#1917) * fix(native): revert to Pressability (#1923) * fix(native): use relative coords for events * fix(core): safely allocate `now` (#1959) * chore: update new tests to v8 API * fix(native): use expo modules (#1927) * chore: update docs for v8 (#1976) * experiment: unify hooks (#1994) * fix(native): unpin and correctly mark peer deps (#2004) * fix(native): unpin and correctly mark peer deps * chore: add expo-asset as dev dep * feat(core): pass XRFrame to subscribers (#2017) * fix(native): move expo-gl to peer dep, update react-native instructions/example (#2033) * up package * fix: remove unused resize-observer-polyfill dep (#2044) * chore(native): export instance types * docs(changeset): new beta for library testing * RELEASING: Releasing 2 package(s) Releases: @react-three/[email protected] @react-three/[email protected] [skip ci] * v8.0.0-beta.5 * root.configure() * fix(configure): only configure shadowmap if present * fix(native): prefer to resolve external assets * cleanup refactor, extend is.equ * perf adjustments to the renderloop * release new beta * fix(types): add Object3D to IntrinsicElements (#2099) * fix(types): add more bufferAttribute intrinsic elements (#2102) * rc1 * rc * fix test * fix(types): move @types/react-reconciler to dependencies (#2126) * introduce the inject native element, which creates a layered host context * new beta * remove host context, make one up with portals * inject example * use userdata instead of __context * chore: update instance snapshots for new args handling * inject cleanup * example: update `MultiMaterial` example (#2144) * fix(attach): add back `attachArray` * chore: revert code and update example * chore: revert code Co-authored-by: Cody Bennett <[email protected]> * fix: is.equ and attach arrays * remove arrayed attach, prefer function with cleanup * fix: events were broken due to is.equ * enforce attach fn cleanup * refactor portal context * add inject layer for portals, expose it, too * completely revamp portals * cleanup * refactor(core): create an array when indexing with attach (#2145) * refactor(core): create an array when indexing with attach * chore: cleanup attach exp * make 139 peer, remove color correction * update snapshots * fix(Canvas): memoize `onPointerMissed` (#2146) * chore: changes to examples & local linking (#2151) * chore: changes to examples & local linking * . * . * . * minor changes * minor changes * removes bright backgrounds * . * removes unused stuff * removes unused stuff * . * . * . * . * . * . * . * . * work on viewcube * fix colors * chore: fixes vite config (#2152) * fix types * portal inject layers * constrain inject state to a subset, auto increase priority * demo cleanup * new compute api * multi view demo (using skissor) * fix clearcolor * connect events to the canvas parent instead of the canvas itself * cleanup * instead of hijacking the store, make up a new one in createportal * new beta * chore(demos): cleanup render effects Nits from #2153 * chore(tests): de-escalate react-dom/client warnings * fix: tests, add parent property * fix: native canvas registers its parent * chore(tests): fix react-dom silence * chore(tests): remove react-dom/client workaround * chore(tests): move console mock to setuptests * chore(tests): UseStore => UseBoundStore * fix: remove parent * fix: black list for inject layer props * chore(docs): update createRoot signature * chore(docs): add notes on webxr useframe signature * chore(docs): streamline render methods (#2162) * feat(core): default `physicallyCorrectLights` to true (#2148) * feat(core): default `physicallyCorrectLights` to true * chore: streamline gl defaults * chore(docs): note new gl defaults * chore(tests): flip gl prop case, respect lighting preferences * mm as the default example * chore: revert physicallyCorrectLights * deprecate mouse, setevents, more inline docs * forgot partial * update all dependencies * clean up demos * add missing migration parts * add missing migration parts * fix: applyProps was supposed to return the instance * migration * last beta * migration example Co-authored-by: Dušan Maliarik <[email protected]> Co-authored-by: Anderson Leite <[email protected]> Co-authored-by: Cody Bennett <[email protected]> Co-authored-by: Cody Bennett <[email protected]> Co-authored-by: dangrabcad <[email protected]> Co-authored-by: davidblnc <[email protected]> Co-authored-by: Karol Stopyra <[email protected]> Co-authored-by: Egor Blinov <[email protected]> Co-authored-by: Alexander Nanberg <[email protected]> Co-authored-by: Josh <[email protected]> Co-authored-by: Nathan Bierema <[email protected]> Co-authored-by: susiwen8 <[email protected]> Co-authored-by: Gianmarco <[email protected]>
1 parent 836d847 commit 347ea79

File tree

99 files changed

+15091
-8991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+15091
-8991
lines changed

.changeset/pre.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"mode": "pre",
3+
"tag": "beta",
4+
"initialVersions": {
5+
"@react-three/fiber": "8.0.0-beta-05",
6+
"@react-three/test-renderer": "8.0.0-beta-00"
7+
},
8+
"changesets": ["tender-deers-swim"]
9+
}

.changeset/tender-deers-swim.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@react-three/fiber': patch
3+
'@react-three/test-renderer': patch
4+
---
5+
6+
new beta for library testing

.eslintrc.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
"es6": true,
55
"node": true
66
},
7-
"extends": [
8-
"prettier",
9-
"plugin:prettier/recommended",
10-
"plugin:react-hooks/recommended",
11-
"plugin:import/errors",
12-
"plugin:import/warnings"
13-
],
7+
"extends": ["prettier", "plugin:prettier/recommended", "plugin:react-hooks/recommended", "plugin:import/recommended"],
148
"plugins": ["@typescript-eslint", "react", "react-hooks", "import", "jest", "prettier"],
159
"parser": "@typescript-eslint/parser",
1610
"parserOptions": {
@@ -66,5 +60,10 @@
6660
"project": "./tsconfig.json"
6761
}
6862
}
69-
]
63+
],
64+
"rules": {
65+
"import/no-unresolved": "off",
66+
"import/named": "off",
67+
"import/namespace": "off"
68+
}
7069
}

.gitignore

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
node_modules/
2-
coverage/
3-
dist/
4-
build/
5-
types/
6-
# commit types in src
7-
!packages/*/src/types/
8-
Thumbs.db
9-
ehthumbs.db
10-
Desktop.ini
11-
$RECYCLE.BIN/
12-
.DS_Store
13-
.vscode
14-
.docz/
15-
package-lock.json
16-
coverage/
17-
.idea
18-
yarn-error.log
19-
.size-snapshot.json
20-
__tests__/__image_snapshots__/__diff_output__
1+
node_modules/
2+
coverage/
3+
dist/
4+
build/
5+
types/
6+
# commit types in src
7+
!packages/*/src/types/
8+
Thumbs.db
9+
ehthumbs.db
10+
Desktop.ini
11+
$RECYCLE.BIN/
12+
.DS_Store
13+
.vscode
14+
.docz/
15+
package-lock.json
16+
coverage/
17+
.idea
18+
yarn-error.log
19+
.size-snapshot.json
20+
__tests__/__image_snapshots__/__diff_output__

docs/API/additional-exports.mdx

+14-15
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ title: Additional Exports
33
nav: 9
44
---
55

6-
| export | usage |
7-
| ---------------------- | -------------------------------------------------------------- |
8-
| addEffect | Adds a global render callback which is called each frame |
9-
| addAfterEffect | Adds a global after-render callback which is called each frame |
10-
| addTail | Adds a global callback which is called when rendering stops |
11-
| invalidate | Forces view global invalidation |
12-
| advance | Advances the frameloop (given that it's set to 'never') |
13-
| extend | Extends the native-object catalogue |
14-
| createPortal | Creates a portal (it's a React feature for re-parenting) |
15-
| render | Renders three JSX into a canvas |
16-
| unmountComponentAtNode | Unmounts root scene |
17-
| events | Dom pointer-event system |
18-
| applyProps | `applyProps(element, props)` sets element properties, |
19-
| act | usage with react-testing |
20-
| | |
6+
| export | usage |
7+
| -------------- | -------------------------------------------------------------- |
8+
| addEffect | Adds a global render callback which is called each frame |
9+
| addAfterEffect | Adds a global after-render callback which is called each frame |
10+
| addTail | Adds a global callback which is called when rendering stops |
11+
| invalidate | Forces view global invalidation |
12+
| advance | Advances the frameloop (given that it's set to 'never') |
13+
| extend | Extends the native-object catalogue |
14+
| createPortal | Creates a portal (it's a React feature for re-parenting) |
15+
| createRoot | Creates a root that can render three JSX into a canvas |
16+
| events | Dom pointer-event system |
17+
| applyProps | `applyProps(element, props)` sets element properties, |
18+
| act | usage with react-testing |
19+
| | |

docs/API/canvas.mdx

+95-18
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const App = () => (
2121
)
2222
```
2323

24-
### Render Props
24+
## Render Props
2525

2626
| Prop | Description | Default |
2727
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
@@ -30,20 +30,18 @@ const App = () => (
3030
| camera | Props that go into the default camera, or your own `THREE.Camera` | `{ fov: 75, near: 0.1, far: 1000, position: [0, 0, 5] }` |
3131
| shadows | Props that go into `gl.shadowMap`, can also be set true for `PCFsoft` | `false` |
3232
| raycaster | Props that go into the default raycaster | `{}` |
33-
| vr | Switches renderer to VR mode, then uses `gl.setAnimationLoop` | `false` |
34-
| mode | React mode: legacy, blocking, concurrent | `blocking` |
3533
| frameloop | Render mode: always, demand, never | `always` |
3634
| resize | Resize config, see react-use-measure's options | `{ scroll: true, debounce: { scroll: 50, resize: 0 } }` |
3735
| orthographic | Creates an orthographic camera | `false` |
38-
| dpr | Pixel-ratio, use `window.devicePixelRatio`, or automatic: [min, max] | `undefined` |
36+
| dpr | Pixel-ratio, use `window.devicePixelRatio`, or automatic: [min, max] | `[1, 2]` |
3937
| linear | Switch off automatic sRGB encoding and gamma correction | `false` |
4038
| flat | Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` | `false` |
4139
| onCreated | Callback after the canvas has rendered (but not yet committed) | `(state) => {}` |
4240
| onPointerMissed | Response for pointer clicks that have missed any target | `(event) => {}` |
4341

44-
### Render defaults
42+
## Render defaults
4543

46-
Canvas uses the [render function](/react-three-fiber/api/render-function) which will create a translucent `THREE.WebGLRenderer` with the following constructor args:
44+
Canvas uses [createRoot](#createroot) which will create a translucent `THREE.WebGLRenderer` with the following constructor args:
4745

4846
- antialias=true
4947
- alpha=true
@@ -61,21 +59,100 @@ It will also create the following scene internals:
6159
- A `THREE.PCFSoftShadowMap` if `shadows` is true
6260
- A `THREE.Scene` (into which all the JSX is rendered) and a `THREE.Raycaster`
6361

64-
<Hint>
62+
In recent versions of threejs, `THREE.ColorManagement.legacy` will be set to false to enable automatic conversion of colors according to the renderer's configured color space. R3F will handle texture encoding conversion. For more on this topic, see [https://threejs.org/docs/#manual/en/introduction/Color-management](https://threejs.org/docs/#manual/en/introduction/Color-management).
6563

66-
The colorspace will be set to sRGB (unless "linear" is true), all colors and textures will be
67-
auto-converted. Consult [donmccurdy.com: Color Management in
68-
three.js](https://www.donmccurdy.com/2020/06/17/color-management-in-threejs) for more information
69-
about this. Unless "flat" is true it will set up `THREE.ACESFilmicToneMapping` for slightly more
70-
contrast.
64+
## Custom Canvas
7165

72-
</Hint>
66+
R3F can render to a root, similar to how `react-dom` and all the other React renderers work. This allows you to shave off `react-dom` (~40kb), `react-use-measure` (~3kb) and, if you don't need them, `pointer-events` (~7kb) (you need to explicitly import `events` and add them to the config otherwise).
7367

74-
<Hint>
68+
Roots have the same options and properties as `Canvas`, but you are responsible for resizing it. It requires an existing DOM `<canvas>` object into which it renders.
7569

76-
Canvas creates a [resize observer](https://github.com/pmndrs/react-use-measure) to update the canvas size.
70+
### CreateRoot
7771

78-
Consider Resize-Observer polyfills for older Safari browsers. We recommend
79-
[juggle/resize-observer](https://github.com/juggle/resize-observer).
72+
Creates a root targeting a canvas, rendering JSX.
8073

81-
</Hint>
74+
```jsx
75+
import { createRoot, events } from '@react-three/fiber'
76+
77+
let root
78+
79+
const handleResize = () => {
80+
const size = { width: window.innerWidth, height: window.innerHeight }
81+
82+
// Create root with a size, events
83+
root = createRoot(document.querySelector('canvas'), {
84+
events,
85+
size,
86+
})
87+
88+
// Render JSX
89+
root.render(<mesh />)
90+
91+
// Can also tweak root root options after creation:
92+
root.configure({ size })
93+
94+
// Or to unmount and dispose of memory:
95+
root.unmount()
96+
}
97+
handleResize()
98+
99+
window.addEventListener('resize', handleResize)
100+
101+
// to unmount
102+
root.unmount()
103+
```
104+
105+
## Tree-shaking
106+
107+
New with v8, the underlying reconciler no longer pulls in the THREE namespace automatically.
108+
109+
This enables a granular catalogue which also enables tree-shaking via the `extend` API:
110+
111+
```jsx
112+
import { extend, createRoot } from '@react-three/fiber'
113+
import { Mesh, BoxGeometry, MeshStandardMaterial } from 'three'
114+
115+
extend({ Mesh, BoxGeometry, MeshStandardMaterial })
116+
117+
createRoot(canvas).render(
118+
<>
119+
<mesh>
120+
<boxGeometry />
121+
<meshStandardMaterial />
122+
</mesh>
123+
</>,
124+
)
125+
```
126+
127+
There's an [official babel plugin](https://github.com/pmndrs/react-three-babel) which will do this for you automatically:
128+
129+
```jsx
130+
// In:
131+
132+
import { createRoot } from '@react-three/fiber'
133+
134+
createRoot(canvasNode).render(
135+
<mesh>
136+
<boxGeometry />
137+
<meshStandardMaterial />
138+
</mesh>,
139+
)
140+
141+
// Out:
142+
143+
import { createRoot, extend } from '@react-three/fiber'
144+
import { Mesh as _Mesh, BoxGeometry as _BoxGeometry, MeshStandardMaterial as _MeshStandardMaterial } from 'three'
145+
146+
extend({
147+
Mesh: _Mesh,
148+
BoxGeometry: _BoxGeometry,
149+
MeshStandardMaterial: _MeshStandardMaterial,
150+
})
151+
152+
createRoot(canvasNode).render(
153+
<mesh>
154+
<boxGeometry />
155+
<meshStandardMaterial />
156+
</mesh>,
157+
)
158+
```

docs/API/hooks.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ The hook is reactive, if you resize the browser for instance, you get fresh meas
5454
| camera | Camera | `THREE.PerspectiveCamera` |
5555
| mouse | Contains updated, normalized, centric pointer coordinates | `THREE.Vector2` |
5656
| clock | Running system clock | `THREE.Clock` |
57-
| vr | True when the system is in VR mode | `boolean` |
5857
| linear | True when the colorspace is linear | `boolean` |
5958
| flat | True when no tonemapping is used | `boolean` |
6059
| frameloop | React render-mode | `always`, `demand`, `never` |
@@ -111,7 +110,7 @@ This hook allows you to execute code on every rendered frame, like running effec
111110
import { useFrame } from '@react-three/fiber'
112111

113112
function Foo() {
114-
useFrame((state, delta) => {
113+
useFrame((state, delta, xrFrame) => {
115114
// This function runs at the native refresh rate inside of a shared render-loop
116115
})
117116
```

docs/API/objects.mdx

+19-53
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ Properties that have a `setScalar` method (for instance `Vector3`) can be set li
6565
<mesh scale={1} />
6666
```
6767

68+
## Piercing into nested properties
69+
70+
If you want to reach into nested attributes (for instance: `mesh.rotation.x`), just use dash-case.
71+
72+
```jsx
73+
<mesh rotation-x={1} material-uniforms-resolution-value={[512, 512]} />
74+
```
75+
6876
## Dealing with non-scene objects
6977

7078
You can put non-Object3D primitives (geometries, materials, etc) into the render tree as well. They take the same properties and constructor arguments they normally would.
@@ -94,44 +102,20 @@ The following attaches a material to the `material` property of a mesh and a geo
94102
<boxGeometry />
95103
```
96104

97-
### Nesting
98-
99-
You can nest primitive objects, too:
100-
101-
```jsx
102-
<mesh>
103-
<meshBasicMaterial attach="material">
104-
<texture attach="map" image={img} onUpdate={self => (self.needsUpdate = true)} />
105-
```
106-
107-
### AttachArray
108-
109-
Sometimes attaching isn't enough. The following example attaches effects to an array called "passes" of the parent `effectComposer`. `attachArray` adds the object to the target array and takes it out on unmount:
110-
111-
```jsx
112-
<effectComposer>
113-
<renderPass attachArray="passes" scene={scene} camera={camera} />
114-
<glitchPass attachArray="passes" renderToScreen />
115-
```
116-
117-
### AttachObject
118-
119-
You can also attach to named parent properties using `attachObject={[target, name]}`, which adds the object and takes it out on unmount. The following adds a buffer-attribute to `parent.attributes.position`.
105+
You can also deeply nest attach through piercing. The following adds a buffer-attribute to `parent.attributes.position`.
120106

121107
```jsx
122108
<bufferGeometry attach="geometry">
123-
<bufferAttribute attachObject={['attributes', 'position']} count={v.length / 3} array={v} itemSize={3} />
109+
<bufferAttribute attach="attributes-position" count={v.length / 3} array={v} itemSize={3} />
124110
```
125111

126-
### AttachFns
127-
128-
Some objects have special add/remove function, you can't easily attach objects. In that case `attachFns` gives you full control.
112+
Some objects have special add/remove function, you can't easily attach objects. In that case `attach` gives you full control.
129113

130114
The following uses the effect composer from the [vanruesc/postprocessing](https://github.com/vanruesc/postprocessing) library, which works differently than three/examples/jsm. You need to call `Composer.addPass` to add an effect and `Composer.removePass` to remove it.
131115

132116
```jsx
133117
<effectComposer>
134-
<renderPass attachFns={["addPass", "removePass"]} args={[scene, camera]} />
118+
<renderPass args={[scene, camera]} attach={["addPass", "removePass"]} />
135119
```
136120

137121
And in the case the add/remove functions are more complex:
@@ -140,18 +124,20 @@ And in the case the add/remove functions are more complex:
140124
<effectComposer>
141125
<renderPass
142126
args={[scene, camera]}
143-
attachFns={[
127+
attach={[
144128
(parent, self) => parent.addPass(self),
145129
(parent, self) => parent.removePass(self)
146130
]} />
147131
```
148132

149-
## Piercing into nested properties
133+
### Nesting
150134

151-
If you want to reach into nested attributes (for instance: `mesh.rotation.x`), just use dash-case.
135+
You can nest primitive objects, too:
152136

153137
```jsx
154-
<mesh rotation-x={1} material-uniforms-resolution-value={[512, 512]} />
138+
<mesh>
139+
<meshBasicMaterial attach="material">
140+
<texture attach="map" image={img} onUpdate={self => (self.needsUpdate = true)} />
155141
```
156142

157143
## Putting already existing objects into the scene-graph
@@ -181,27 +167,7 @@ return (
181167
<transformControls />
182168
```
183169
184-
If you are using Typescript, it is important to let Typescript be aware of the new elements.
185-
186-
```tsx
187-
import { extend, ReactThreeFiber } from '@react-three/fiber'
188-
import { OrbitControls } from 'three-stdlib'
189-
190-
extend({ OrbitControls })
191-
192-
declare global {
193-
namespace JSX {
194-
interface IntrinsicElements {
195-
orbitControls: ReactThreeFiber.Object3DNode<
196-
OrbitControls,
197-
typeof OrbitControls
198-
>
199-
}
200-
}
201-
}
202-
```
203-
204-
170+
If you're using TypeScript, you'll also need to [extend the JSX namespace](/react-three-fiber/tutorials/typescript#extending-jsx-intrinsic-elements).
205171
206172
## Disposal
207173

0 commit comments

Comments
 (0)