Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8, react 18 beta #1630

Merged
merged 214 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
728cb8a
react 18 alpha
drcmda Sep 3, 2021
6357294
up use-asset
drcmda Sep 8, 2021
1085d9c
fix flat
drcmda Sep 14, 2021
72b576d
silence disposal errors
drcmda Sep 14, 2021
6882197
support instanced event cancelation
drcmda Sep 15, 2021
dd4d00c
simplify useFrame
drcmda Sep 16, 2021
0d7b4b0
Allow partial WebGLRenderer params (#1656)
skrat Sep 16, 2021
af65d19
is.test: 'is equal' test to use alredy declared obj and array. (#1643)
andersonleite Sep 16, 2021
629b210
pull master
drcmda Sep 28, 2021
5bba18a
refactor into utility functions
drcmda Sep 29, 2021
028854f
refactor
drcmda Oct 1, 2021
2818784
bring over diffprops bug
drcmda Oct 2, 2021
91a768a
Merge branch 'master' into v8
CodyJasonBennett Oct 6, 2021
2be4c1e
Merge branch 'master' into v8
CodyJasonBennett Oct 6, 2021
6e6f2d1
Merge branch 'master' into v8
CodyJasonBennett Oct 7, 2021
1338145
chore: move dpr calc to utils
CodyJasonBennett Oct 7, 2021
2abc958
Merge branch 'master' into v8
CodyJasonBennett Oct 9, 2021
d0e6a1b
chore: don't use `is` outside of renderer
CodyJasonBennett Oct 9, 2021
3b2c181
fix(core): set null parent in prepare
CodyJasonBennett Oct 9, 2021
89ce5bd
fix args in createinstance
drcmda Oct 10, 2021
abfa7b0
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Oct 10, 2021
d73f39e
fix primitve leftovers on switch, add gltf example
drcmda Oct 10, 2021
453792c
Merge branch 'master' into v8
CodyJasonBennett Oct 12, 2021
63d4aa5
Merge branch 'master' into v8
CodyJasonBennett Oct 12, 2021
9622b86
chore(web): fix mangled import
CodyJasonBennett Oct 12, 2021
5ebb4e8
make applyprops return the instance
drcmda Oct 14, 2021
a7061e1
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Oct 14, 2021
29bfb96
Merge branch 'master' into v8
CodyJasonBennett Oct 15, 2021
3f228ac
fix merge
drcmda Oct 18, 2021
a6a98a3
Merge branch 'master' into v8
CodyJasonBennett Oct 26, 2021
6fe22ba
spread props over container div, change dpr default, fix createRoot
drcmda Nov 1, 2021
0309b59
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Nov 1, 2021
c545c3d
export createroot
drcmda Nov 1, 2021
d65de10
fix cherrypick
dangrabcad Nov 2, 2021
ea4fa85
[v8] feat: add react-native support (#1699)
CodyJasonBennett Nov 4, 2021
e55027b
fix(Canvas): pass onCreated
CodyJasonBennett Nov 4, 2021
c8916ae
[v8] feat: remove vr prop for dynamic render switching (#1702)
CodyJasonBennett Nov 4, 2021
d737660
fix(Canvas): pass events & size
CodyJasonBennett Nov 4, 2021
7037402
feat: add `renderVisible` prop to only render while in view
CodyJasonBennett Nov 4, 2021
f1cc700
remove zustand sub selector
drcmda Nov 10, 2021
8fbd672
feat(core): make `frameloop` reactive
CodyJasonBennett Nov 11, 2021
c12b063
chore: `renderVisible` => `include`
CodyJasonBennett Nov 11, 2021
5c565ab
chore: add demo for IncludeProp
CodyJasonBennett Nov 11, 2021
40f0eaf
docs: add `intersect` prop and internal `setFrameloop`
CodyJasonBennett Nov 11, 2021
2058043
chore: cleanup example with styled-components
CodyJasonBennett Nov 11, 2021
32ba68c
chore: revert `intersect` for native
CodyJasonBennett Nov 15, 2021
d354879
chore: fix peer dep range for native
CodyJasonBennett Nov 15, 2021
ef03dc4
[v8] refactor(core): use-asset => suspend-react (#1797)
CodyJasonBennett Nov 16, 2021
bec93fb
chore: remove `intersect` prop from web & docs, example
CodyJasonBennett Nov 16, 2021
67c8990
chore: add react-native key for lib interop
CodyJasonBennett Nov 16, 2021
2090b08
update deps
drcmda Nov 16, 2021
746481c
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Nov 16, 2021
34fb944
update version
drcmda Nov 16, 2021
7db8b4d
chore: fix native peer dep
CodyJasonBennett Nov 18, 2021
6e306a6
chore: update references from github namespace react-spring to pmndrs
Nov 21, 2021
193e5e1
Merge pull request #1842 from davidblnc/v8
CodyJasonBennett Nov 22, 2021
6aeb5bb
fix: tree-shaking
drcmda Nov 22, 2021
acbcca9
fix: revert removing mergerefs, use pure annotations instead
drcmda Nov 22, 2021
ea0485a
Merge branch 'master' into v8
CodyJasonBennett Nov 25, 2021
f2c3075
align both canvases
drcmda Nov 26, 2021
bbcbaba
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Nov 26, 2021
5e89c5e
update usemeasure
drcmda Nov 26, 2021
52fb269
Fix missing type for Float32BufferAttribute (#1862)
stopyransky Nov 27, 2021
2fc41b6
fix(Canvas): unmount current context
CodyJasonBennett Nov 29, 2021
b17fe4b
Merge pull request #1798 from pmndrs/feat/render-visible
CodyJasonBennett Nov 29, 2021
647bf46
Merge pull request #1869 from pmndrs/fix/native-unmount
CodyJasonBennett Nov 29, 2021
ccdf95e
Merge branch 'master' into v8
CodyJasonBennett Nov 29, 2021
87d52d8
Merge branch 'master' into v8
CodyJasonBennett Nov 29, 2021
fc4df79
Merge branch 'master' into v8
CodyJasonBennett Dec 2, 2021
da5854f
[v8] fix: use new act API & fix extend for tests (#1891)
CodyJasonBennett Dec 6, 2021
ef8e5de
feat(test-renderer): add RegExp matcher support to `findByProps` and …
CodyJasonBennett Dec 6, 2021
343778c
Merge branch 'master' into v8
CodyJasonBennett Dec 8, 2021
196f077
chore: apply fix to applyProps
CodyJasonBennett Dec 8, 2021
8e4b10e
Merge branch 'master' into v8
CodyJasonBennett Dec 8, 2021
54aa783
fix: schedule child.dispose() (#1887)
escaton Dec 9, 2021
375208a
chore: fix eslint
CodyJasonBennett Dec 9, 2021
26d14fc
Merge branch 'master' into v8
CodyJasonBennett Dec 10, 2021
dfbc264
add camera:manual
drcmda Dec 10, 2021
1279027
remove console log
drcmda Dec 10, 2021
7e9229f
Merge branch 'master' into v8
CodyJasonBennett Dec 11, 2021
8e45128
move up to react rc
drcmda Dec 11, 2021
e791210
update examples to react-router 6
drcmda Dec 11, 2021
9e645a8
fix three types
drcmda Dec 11, 2021
f4a0ecc
unify attach
drcmda Dec 11, 2021
5eafc6a
fix suspense re-attach
drcmda Dec 11, 2021
aba9cb1
Merge branch 'master' into v8
CodyJasonBennett Dec 11, 2021
af33f2f
chore: update tests
CodyJasonBennett Dec 11, 2021
8d54e96
fix(types): use new attach API
CodyJasonBennett Dec 11, 2021
19e9e31
switch to createRoot
drcmda Dec 11, 2021
de05f5c
chore: update test-renderer snapshot
CodyJasonBennett Dec 11, 2021
576eae9
publish new beta
drcmda Dec 11, 2021
4f4c44b
fix(RTTR): use createRoot
CodyJasonBennett Dec 11, 2021
b46481b
chore(tests): use createRoot
CodyJasonBennett Dec 11, 2021
ef743f0
fix(web): render when canvas is created
CodyJasonBennett Dec 11, 2021
9e6b65c
refactor: move createRoot to core (#1915)
CodyJasonBennett Dec 11, 2021
b3982b4
chore(native): add expo unimodules as dep (#1916)
CodyJasonBennett Dec 11, 2021
b70cde7
clean up example
drcmda Dec 11, 2021
af1095c
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Dec 11, 2021
5e0637d
up version
drcmda Dec 11, 2021
8fb268d
chore(tests): add native coverage, sort tests (#1917)
CodyJasonBennett Dec 12, 2021
f3f9173
fix(native): revert to Pressability (#1923)
CodyJasonBennett Dec 13, 2021
f51bc97
fix(native): use relative coords for events
CodyJasonBennett Dec 28, 2021
25b121d
fix(core): safely allocate `now` (#1959)
CodyJasonBennett Jan 1, 2022
a29c62a
Merge branch 'master' into v8
CodyJasonBennett Jan 5, 2022
e8156f8
chore: update new tests to v8 API
CodyJasonBennett Jan 5, 2022
5395985
Merge branch 'master' into v8
CodyJasonBennett Jan 7, 2022
325a9cf
Merge branch 'master' into v8
CodyJasonBennett Jan 8, 2022
4e8b7a0
fix(native): use expo modules (#1927)
CodyJasonBennett Jan 9, 2022
5819078
Merge branch 'master' into v8
CodyJasonBennett Jan 9, 2022
4193295
Merge branch 'master' into v8
CodyJasonBennett Jan 12, 2022
4b2dd2c
Merge branch 'master' into v8
CodyJasonBennett Jan 14, 2022
1e0f32a
chore: update docs for v8 (#1976)
CodyJasonBennett Jan 16, 2022
8a61981
experiment: unify hooks (#1994)
CodyJasonBennett Jan 16, 2022
504e04d
fix(native): unpin and correctly mark peer deps (#2004)
CodyJasonBennett Jan 19, 2022
c35dd4b
Merge branch 'master' into v8
CodyJasonBennett Jan 23, 2022
6f3a301
feat(core): pass XRFrame to subscribers (#2017)
CodyJasonBennett Jan 25, 2022
302828e
Merge branch 'master' into v8
CodyJasonBennett Jan 27, 2022
7326df1
fix(native): move expo-gl to peer dep, update react-native instructio…
CodyJasonBennett Jan 28, 2022
e6f83a5
Merge branch 'master' into v8
CodyJasonBennett Jan 28, 2022
9106d41
up package
drcmda Jan 28, 2022
912ec66
fix: remove unused resize-observer-polyfill dep (#2044)
alexandernanberg Feb 3, 2022
f9dac71
Merge branch 'master' into v8
CodyJasonBennett Feb 10, 2022
67b86f4
Merge branch 'master' into v8
CodyJasonBennett Feb 11, 2022
71eee46
chore(native): export instance types
CodyJasonBennett Feb 11, 2022
cf6316c
docs(changeset): new beta for library testing
joshuaellis Feb 11, 2022
d597be8
RELEASING: Releasing 2 package(s)
joshuaellis Feb 11, 2022
5d50209
v8.0.0-beta.5
joshuaellis Feb 11, 2022
bf88ba9
Merge branch 'master' into v8
CodyJasonBennett Feb 17, 2022
7be3956
Merge branch 'master' into v8
CodyJasonBennett Feb 17, 2022
01b187c
Merge branch 'master' into v8
CodyJasonBennett Feb 21, 2022
ce57538
root.configure()
drcmda Feb 21, 2022
6b09862
fix(configure): only configure shadowmap if present
CodyJasonBennett Feb 21, 2022
a9f2981
fix(native): prefer to resolve external assets
CodyJasonBennett Feb 22, 2022
9dfff30
cleanup refactor, extend is.equ
drcmda Feb 23, 2022
b73544a
perf adjustments to the renderloop
drcmda Feb 23, 2022
c6a93bb
release new beta
drcmda Feb 23, 2022
df92c26
fix(types): add Object3D to IntrinsicElements (#2099)
alexandernanberg Feb 25, 2022
958f007
fix(types): add more bufferAttribute intrinsic elements (#2102)
alexandernanberg Feb 26, 2022
7ee9e43
rc1
drcmda Mar 8, 2022
fff49b0
rc
drcmda Mar 8, 2022
2c84a49
fix test
drcmda Mar 8, 2022
d5f8075
fix(types): move @types/react-reconciler to dependencies (#2126)
Methuselah96 Mar 16, 2022
7f898d9
Merge branch 'master' into v8
CodyJasonBennett Mar 16, 2022
0d96f4e
Merge branch 'master' into v8
CodyJasonBennett Mar 19, 2022
305190d
introduce the inject native element, which creates a layered host con…
drcmda Mar 21, 2022
e5f666a
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 21, 2022
159c7bf
new beta
drcmda Mar 21, 2022
6d50fe9
remove host context, make one up with portals
drcmda Mar 22, 2022
d57c55e
inject example
drcmda Mar 22, 2022
f4326c0
use userdata instead of __context
drcmda Mar 22, 2022
14fb8de
chore: update instance snapshots for new args handling
CodyJasonBennett Mar 23, 2022
d10c28c
inject cleanup
drcmda Mar 23, 2022
1bbce40
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 23, 2022
4b69c5d
example: update `MultiMaterial` example (#2144)
susiwen8 Mar 23, 2022
9f8377c
fix: is.equ and attach arrays
drcmda Mar 23, 2022
2412f91
remove arrayed attach, prefer function with cleanup
drcmda Mar 23, 2022
3a8d928
fix: events were broken due to is.equ
drcmda Mar 23, 2022
cf65a93
enforce attach fn cleanup
drcmda Mar 23, 2022
2a0a0ff
refactor portal context
drcmda Mar 23, 2022
4602dbd
add inject layer for portals, expose it, too
drcmda Mar 23, 2022
994124f
completely revamp portals
drcmda Mar 24, 2022
d094fcc
cleanup
drcmda Mar 24, 2022
7f7d31c
refactor(core): create an array when indexing with attach (#2145)
CodyJasonBennett Mar 24, 2022
1efeb32
make 139 peer, remove color correction
drcmda Mar 24, 2022
6191687
update snapshots
drcmda Mar 24, 2022
483304a
fix(Canvas): memoize `onPointerMissed` (#2146)
susiwen8 Mar 24, 2022
a12d5e5
Merge branch 'master' into v8
CodyJasonBennett Mar 25, 2022
a4c60a4
Merge branch 'master' into v8
CodyJasonBennett Mar 25, 2022
12f0a3a
chore: changes to examples & local linking (#2151)
gsimone Mar 25, 2022
f8b51dd
work on viewcube
drcmda Mar 25, 2022
df673a6
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 25, 2022
9ed4862
fix colors
drcmda Mar 25, 2022
3e9f709
chore: fixes vite config (#2152)
gsimone Mar 25, 2022
73e3b64
fix types
drcmda Mar 25, 2022
23237d8
portal inject layers
drcmda Mar 25, 2022
3614c7e
constrain inject state to a subset, auto increase priority
drcmda Mar 26, 2022
f38f988
demo cleanup
drcmda Mar 26, 2022
a10af73
new compute api
drcmda Mar 26, 2022
476ce7b
multi view demo (using skissor)
drcmda Mar 26, 2022
f0573df
fix clearcolor
drcmda Mar 26, 2022
ecbbfca
connect events to the canvas parent instead of the canvas itself
drcmda Mar 27, 2022
53612ff
cleanup
drcmda Mar 27, 2022
fd122e5
instead of hijacking the store, make up a new one in createportal
drcmda Mar 27, 2022
5d9c6b6
new beta
drcmda Mar 27, 2022
9c10f62
chore(demos): cleanup render effects
CodyJasonBennett Mar 27, 2022
642f8f8
chore(tests): de-escalate react-dom/client warnings
CodyJasonBennett Mar 27, 2022
6613205
fix: tests, add parent property
drcmda Mar 27, 2022
76b728b
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 27, 2022
1923fc2
fix: native canvas registers its parent
drcmda Mar 27, 2022
b57bb49
chore(tests): fix react-dom silence
CodyJasonBennett Mar 27, 2022
e224ed2
chore(tests): remove react-dom/client workaround
CodyJasonBennett Mar 27, 2022
69eacb2
chore(tests): move console mock to setuptests
CodyJasonBennett Mar 27, 2022
29de31d
chore(tests): UseStore => UseBoundStore
CodyJasonBennett Mar 27, 2022
2d704fd
fix: remove parent
drcmda Mar 27, 2022
257a9c8
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 27, 2022
f756cbb
fix: black list for inject layer props
drcmda Mar 27, 2022
ed0b235
chore(docs): update createRoot signature
CodyJasonBennett Mar 29, 2022
c3be809
chore(docs): add notes on webxr useframe signature
CodyJasonBennett Mar 29, 2022
acfdb6a
chore(docs): streamline render methods (#2162)
CodyJasonBennett Mar 29, 2022
3e96b79
feat(core): default `physicallyCorrectLights` to true (#2148)
CodyJasonBennett Mar 29, 2022
1da7e45
mm as the default example
drcmda Mar 29, 2022
7f41149
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 29, 2022
b346e06
chore: revert physicallyCorrectLights
CodyJasonBennett Mar 29, 2022
4b87ecb
Merge branch 'v8' of https://github.com/pmndrs/react-three-fiber into v8
drcmda Mar 29, 2022
bf89107
deprecate mouse, setevents, more inline docs
drcmda Mar 29, 2022
2f2c6b2
forgot partial
drcmda Mar 29, 2022
20816d2
update all dependencies
drcmda Mar 29, 2022
aab2386
clean up demos
drcmda Mar 29, 2022
aaad43b
add missing migration parts
drcmda Mar 30, 2022
091de13
add missing migration parts
drcmda Mar 30, 2022
c60b909
fix: applyProps was supposed to return the instance
drcmda Mar 30, 2022
41b6aa1
migration
drcmda Mar 30, 2022
7d02e90
last beta
drcmda Mar 30, 2022
0bf5e42
migration example
drcmda Mar 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mode": "pre",
"tag": "beta",
"initialVersions": {
"@react-three/fiber": "8.0.0-beta-05",
"@react-three/test-renderer": "8.0.0-beta-00"
},
"changesets": ["tender-deers-swim"]
}
6 changes: 6 additions & 0 deletions .changeset/tender-deers-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@react-three/fiber': patch
'@react-three/test-renderer': patch
---

new beta for library testing
15 changes: 7 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
"es6": true,
"node": true
},
"extends": [
"prettier",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"extends": ["prettier", "plugin:prettier/recommended", "plugin:react-hooks/recommended", "plugin:import/recommended"],
"plugins": ["@typescript-eslint", "react", "react-hooks", "import", "jest", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down Expand Up @@ -66,5 +60,10 @@
"project": "./tsconfig.json"
}
}
]
],
"rules": {
"import/no-unresolved": "off",
"import/named": "off",
"import/namespace": "off"
}
}
40 changes: 20 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
node_modules/
coverage/
dist/
build/
types/
# commit types in src
!packages/*/src/types/
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.DS_Store
.vscode
.docz/
package-lock.json
coverage/
.idea
yarn-error.log
.size-snapshot.json
__tests__/__image_snapshots__/__diff_output__
node_modules/
coverage/
dist/
build/
types/
# commit types in src
!packages/*/src/types/
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.DS_Store
.vscode
.docz/
package-lock.json
coverage/
.idea
yarn-error.log
.size-snapshot.json
__tests__/__image_snapshots__/__diff_output__
29 changes: 14 additions & 15 deletions docs/API/additional-exports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ title: Additional Exports
nav: 9
---

| export | usage |
| ---------------------- | -------------------------------------------------------------- |
| addEffect | Adds a global render callback which is called each frame |
| addAfterEffect | Adds a global after-render callback which is called each frame |
| addTail | Adds a global callback which is called when rendering stops |
| invalidate | Forces view global invalidation |
| advance | Advances the frameloop (given that it's set to 'never') |
| extend | Extends the native-object catalogue |
| createPortal | Creates a portal (it's a React feature for re-parenting) |
| render | Renders three JSX into a canvas |
| unmountComponentAtNode | Unmounts root scene |
| events | Dom pointer-event system |
| applyProps | `applyProps(element, props)` sets element properties, |
| act | usage with react-testing |
| | |
| export | usage |
| -------------- | -------------------------------------------------------------- |
| addEffect | Adds a global render callback which is called each frame |
| addAfterEffect | Adds a global after-render callback which is called each frame |
| addTail | Adds a global callback which is called when rendering stops |
| invalidate | Forces view global invalidation |
| advance | Advances the frameloop (given that it's set to 'never') |
| extend | Extends the native-object catalogue |
| createPortal | Creates a portal (it's a React feature for re-parenting) |
| createRoot | Creates a root that can render three JSX into a canvas |
| events | Dom pointer-event system |
| applyProps | `applyProps(element, props)` sets element properties, |
| act | usage with react-testing |
| | |
113 changes: 95 additions & 18 deletions docs/API/canvas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const App = () => (
)
```

### Render Props
## Render Props

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

### Render defaults
## Render defaults

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

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

<Hint>
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).

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

</Hint>
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).

<Hint>
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.

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

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

</Hint>
```jsx
import { createRoot, events } from '@react-three/fiber'

let root

const handleResize = () => {
const size = { width: window.innerWidth, height: window.innerHeight }

// Create root with a size, events
root = createRoot(document.querySelector('canvas'), {
events,
size,
})

// Render JSX
root.render(<mesh />)

// Can also tweak root root options after creation:
root.configure({ size })

// Or to unmount and dispose of memory:
root.unmount()
}
handleResize()

window.addEventListener('resize', handleResize)

// to unmount
root.unmount()
```

## Tree-shaking

New with v8, the underlying reconciler no longer pulls in the THREE namespace automatically.

This enables a granular catalogue which also enables tree-shaking via the `extend` API:

```jsx
import { extend, createRoot } from '@react-three/fiber'
import { Mesh, BoxGeometry, MeshStandardMaterial } from 'three'

extend({ Mesh, BoxGeometry, MeshStandardMaterial })

createRoot(canvas).render(
<>
<mesh>
<boxGeometry />
<meshStandardMaterial />
</mesh>
</>,
)
```

There's an [official babel plugin](https://github.com/pmndrs/react-three-babel) which will do this for you automatically:

```jsx
// In:

import { createRoot } from '@react-three/fiber'

createRoot(canvasNode).render(
<mesh>
<boxGeometry />
<meshStandardMaterial />
</mesh>,
)

// Out:

import { createRoot, extend } from '@react-three/fiber'
import { Mesh as _Mesh, BoxGeometry as _BoxGeometry, MeshStandardMaterial as _MeshStandardMaterial } from 'three'

extend({
Mesh: _Mesh,
BoxGeometry: _BoxGeometry,
MeshStandardMaterial: _MeshStandardMaterial,
})

createRoot(canvasNode).render(
<mesh>
<boxGeometry />
<meshStandardMaterial />
</mesh>,
)
```
3 changes: 1 addition & 2 deletions docs/API/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ The hook is reactive, if you resize the browser for instance, you get fresh meas
| camera | Camera | `THREE.PerspectiveCamera` |
| mouse | Contains updated, normalized, centric pointer coordinates | `THREE.Vector2` |
| clock | Running system clock | `THREE.Clock` |
| vr | True when the system is in VR mode | `boolean` |
| linear | True when the colorspace is linear | `boolean` |
| flat | True when no tonemapping is used | `boolean` |
| frameloop | React render-mode | `always`, `demand`, `never` |
Expand Down Expand Up @@ -111,7 +110,7 @@ This hook allows you to execute code on every rendered frame, like running effec
import { useFrame } from '@react-three/fiber'

function Foo() {
useFrame((state, delta) => {
useFrame((state, delta, xrFrame) => {
// This function runs at the native refresh rate inside of a shared render-loop
})
```
Expand Down
72 changes: 19 additions & 53 deletions docs/API/objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Properties that have a `setScalar` method (for instance `Vector3`) can be set li
<mesh scale={1} />
```

## Piercing into nested properties

If you want to reach into nested attributes (for instance: `mesh.rotation.x`), just use dash-case.

```jsx
<mesh rotation-x={1} material-uniforms-resolution-value={[512, 512]} />
```

## Dealing with non-scene objects

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.
Expand Down Expand Up @@ -94,44 +102,20 @@ The following attaches a material to the `material` property of a mesh and a geo
<boxGeometry />
```

### Nesting

You can nest primitive objects, too:

```jsx
<mesh>
<meshBasicMaterial attach="material">
<texture attach="map" image={img} onUpdate={self => (self.needsUpdate = true)} />
```

### AttachArray

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:

```jsx
<effectComposer>
<renderPass attachArray="passes" scene={scene} camera={camera} />
<glitchPass attachArray="passes" renderToScreen />
```

### AttachObject

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`.
You can also deeply nest attach through piercing. The following adds a buffer-attribute to `parent.attributes.position`.

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

### AttachFns

Some objects have special add/remove function, you can't easily attach objects. In that case `attachFns` gives you full control.
Some objects have special add/remove function, you can't easily attach objects. In that case `attach` gives you full control.

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.

```jsx
<effectComposer>
<renderPass attachFns={["addPass", "removePass"]} args={[scene, camera]} />
<renderPass args={[scene, camera]} attach={["addPass", "removePass"]} />
```

And in the case the add/remove functions are more complex:
Expand All @@ -140,18 +124,20 @@ And in the case the add/remove functions are more complex:
<effectComposer>
<renderPass
args={[scene, camera]}
attachFns={[
attach={[
(parent, self) => parent.addPass(self),
(parent, self) => parent.removePass(self)
]} />
```

## Piercing into nested properties
### Nesting

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

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

## Putting already existing objects into the scene-graph
Expand Down Expand Up @@ -181,27 +167,7 @@ return (
<transformControls />
```

If you are using Typescript, it is important to let Typescript be aware of the new elements.

```tsx
import { extend, ReactThreeFiber } from '@react-three/fiber'
import { OrbitControls } from 'three-stdlib'

extend({ OrbitControls })

declare global {
namespace JSX {
interface IntrinsicElements {
orbitControls: ReactThreeFiber.Object3DNode<
OrbitControls,
typeof OrbitControls
>
}
}
}
```


If you're using TypeScript, you'll also need to [extend the JSX namespace](/react-three-fiber/tutorials/typescript#extending-jsx-intrinsic-elements).

## Disposal

Expand Down