Skip to main content

Scene

Type

Component

Default Usage

import { Scene } from 'react-three-lite'

function App() {
return (
<Scene style={{ marginTop: '10px', width: '100%', height: '300px' }} />
)
}

Color As Background

import { Scene } from 'react-three-lite'

function App() {
return (
<Scene
style={{ marginTop: '10px', width: '100%', height: '400px' }}
bgColor="#98F5F9"
/>
)
}

Image As Background

import { Scene } from 'react-three-lite'

function App() {
return (
<Scene
style={{ marginTop: '10px', width: '100%', height: '300px' }}
bgImage="/images/examples/bg.jpg"
/>
)
}

Props

NameTypeDefaultDescription
modelValueTHREE.SceneTHREE.Sceneoptional The value will be the THREE.Scene instance from undefined after the components mounted.
rendererTHREE.WebGLRendererTHREE.WebGLRendereroptional
bgColorStringoptional The background color of the scene.
bgImageStringoptional The background image of the scene.
cameraTHREE.CameraTHREE.PerspectiveCameraoptional Defaults to a PerspectiveCamera.
lightTHREE.LightTHREE.HemisphereLightoptional Defaults to a HemisphereLight.
axesHelperTHREE.AxesHelper | booleanTHREE.AxesHelperoptional Defaults to a AxesHelper, false to hide it.
gridHelperTHREE.GridHelper | booleanTHREE.GridHelperoptional Defaults to a GridHelper, false to hide it.
controlsOrbitControls | booleanOrbitControlsoptional Defaults to a OrbitControls, false to disable it.

Events

NameParametersDescription
onCreated(scene, {camera, light, axesHelper, controls}) => voidCalled when the component is mounted and the scene is created.
onBeforeFrame(renderer: THREE.WebGLRenderer, scene: THREE.Scene, components: {camera, light, axesHelper, controls}) => voidCalled before each frame is rendered.
onFrame(renderer: THREE.WebGLRenderer, scene: THREE.Scene, components: {camera, light, axesHelper, controls}) => voidCalled during each frame render loop.
onAfterFrame(renderer: THREE.WebGLRenderer, scene: THREE.Scene, components: {camera, light, axesHelper, controls}) => voidCalled after each frame is rendered.