glodrei
Version:
useful add-ons for react-three-fiber
16 lines (12 loc) • 604 B
text/mdx
title: Preload
sourcecode: src/core/Preload.tsx
The WebGLRenderer will compile materials only when they hit the frustrum, which can cause jank. This component precompiles the scene using [gl.compile](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.compile) which makes sure that your app is responsive from the get go.
By default gl.compile will only preload visible objects, if you supply the `all` prop, it will circumvent that. With the `scene` and `camera` props you could also use it in portals.
```jsx
<Canvas>
<Suspense fallback={null}>
<Model />
<Preload all />
```