The Canvas object is your portal into three.js.

The Canvas object is where you start to define your React Three Fiber Scene.

import React from 'react'
import { Canvas } from '@react-three/fiber'

const App = () => (
    <pointLight position={[10, 10, 10]} />
      <sphereBufferGeometry />
      <meshStandardMaterial color="hotpink" />

Render Props

childrenthree.js JSX elements or regular components
glProps that go into the default renderer, or your own renderer. Also accepts a synchronous callback like gl={canvas => new Renderer({ canvas })}{}
cameraProps that go into the default camera, or your own THREE.Camera{ fov: 75, near: 0.1, far: 1000, position: [0, 0, 5] }
shadowsProps that go into gl.shadowMap, can also be set true for PCFsoftfalse
raycasterProps that go into the default raycaster{}
vrSwitches renderer to VR mode, then uses gl.setAnimationLoopfalse
modeReact mode: legacy, blocking, concurrentblocking
frameloopRender mode: always, demand, neveralways
resizeResize config, see react-use-measure's options{ scroll: true, debounce: { scroll: 50, resize: 0 } }
orthographicCreates an orthographic camerafalse
dprPixel-ratio, use window.devicePixelRatio, or automatic: [min, max]undefined
linearSwitch off automatic sRGB encoding and gamma correctionfalse
flatUse THREE.NoToneMapping instead of THREE.ACESFilmicToneMappingfalse
onCreatedCallback after the canvas has rendered (but not yet committed)(state) => {}
onPointerMissedResponse for pointer clicks that have missed any target(event) => {}

Render defaults

Canvas uses the render function which will create a translucent THREE.WebGLRenderer with the following constructor args:

  • antialias=true
  • alpha=true
  • powerPreference="high-performance"

and with the following properties:

  • outputEncoding = THREE.sRGBEncoding
  • toneMapping = THREE.ACESFilmicToneMapping

It will also create the following scene internals:

  • A THREE.Perspective camera
  • A THREE.Orthographic cam if orthographic is true
  • A THREE.PCFSoftShadowMap if shadows is true
  • A THREE.Scene (into which all the JSX is rendered) and a THREE.Raycaster

The colorspace will be set to sRGB (unless "linear" is true), all colors and textures will be auto-converted. Consult Color Management in three.js for more information about this. Unless "flat" is true it will set up THREE.ACESFilmicToneMapping for slightly more contrast.

Canvas creates a resize observer to update the canvas size.

Consider Resize-Observer polyfills for older Safari browsers. We recommend juggle/resize-observer.