Table of Contents
The Canvas object is your portal into Threejs. It renders Threejs elements, not DOM elements! Here is a small hello-world that you can try out:
The canvas stretches to 100% of the next relative/absolute parent-container. Make sure your canvas is given space to show contents!
You can give it additional properties like style and className, which will be added to the container (a div) that holds the dom-canvas element.
Defaults that the canvas component sets up
Canvas will create a translucent WebGL-renderer with the following properties: antialias, alpha, setClearAlpha(0)
A default perspective camera: fov: 75, near: 0.1, far: 1000, z: 5, lookAt: [0,0,0]
A default orthographic camera if Canvas.orthographic is true: near: 0.1, far: 1000, z: 5, lookAt: [0,0,0]
A default shadowMap if Canvas.shadowMap is true: type: PCFSoftShadowMap
A default scene (into which all the JSX is rendered) and a raycaster.
A wrapping container with a resize observer: scroll: true, debounce: { scroll: 50, resize: 0 }
You do not have to use any of these objects, look under "Recipes" down below if you want to bring your own.
Edit this page on GitHub