Skip to main content

Sky Dome

Type​

Class

A gradient sky sphere that replaces the scene background: four color bands rising from the horizon to the zenith, plus a wide halo and a bright disc around a configurable sun direction. The dome is rendered from the inside with BackSide and no depth write, so it always reads as an infinitely distant sky.

Default Usage​

Every example below can be viewed with either the WebGPU (default) or the WebGL renderer — switch tabs to compare.

import { useRef, useEffect } from 'react'
import * as THREE from 'three'
import { Scene, SkyDome } from 'react-three-lite'
import type { SceneComponents } from 'react-three-lite'

export default function App() {
const skyRef = useRef<SkyDome | null>(null)

const handleCreated = (scene: THREE.Scene, components: SceneComponents) => {
const { camera } = components

camera.position.set(0, 0.8, 7)
camera.lookAt(0, 0.8, 0)

skyRef.current = new SkyDome()
scene.add(skyRef.current)
}

// Cleanup on unmount
useEffect(() => {
return () => {
skyRef.current?.dispose()
skyRef.current = null
}
}, [])

return (
<Scene
bgColor="rgb(40, 42, 54)"
onCreated={handleCreated}
style={{ marginTop: '10px', width: '100%', height: '300px' }}
/>
)
}

Options​

PropertyTypeDefaultDescription
radiusnumber420Radius of the dome sphere. Keep it larger than any scene content
horizonColornumber0xf27536Color of the band lying on the horizon
lowerSkyColornumber0x803624Color just above the horizon
upperSkyColornumber0x260f13Color of the intermediate band
zenithColornumber0x060409Color at the top of the dome
sunDirection[number, number, number][-0.78, 0.2, -0.6]Direction of the sun, normalized internally
glowColornumber0xff9947Color of the wide halo around the sun
sunColornumber0xffe0b8Color of the sun disc
sunIntensitynumber2.4Brightness multiplier of the sun disc
sunSizenumber10Angular diameter of the sun disc in degrees. The disc is drawn in screen space, so it stays round wherever the sun sits in the view
segmentsnumber48Horizontal segment count of the dome sphere

Methods​

NameParametersDescription
constructor(options?: SkyDomeOptions)Create the dome. It extends THREE.Mesh, so add it to the scene with scene.add(sky)
dispose() => voidDispose the geometry and material and remove the dome from the scene. Should be called on component unmount to prevent memory leaks