Three.js Desert Oasis (Dunes, Palms & Sky)

A desert oasis in Three.js, with ridged-noise sand dunes around a basin, a reflective pool showing a CubeCamera capture of the physically based Sky, palms with Bézier tube trunks and swaying fronds, a mud-brick well house and tents.

Key topics: desert oasis, sand dunes, three.js sky, palm trees, water reflection, environment

What this code does

- Dunes: ridged noise (1 − |n|)² gives sharp crests, fbm adds variation and sine ripples run across the sand; a radial basin holds the pool.
- Sky: the Sky example (Preetham model) with turbidity, Rayleigh and Mie settings, lit by a directional sun at the same angle.
- Water: a custom shader with analytic wave normals, Fresnel reflection of a CubeCamera capture of a fog-free sky copy, and a sharp sun glint.
- Palms: TubeGeometry trunks along quadratic Béziers leaning toward the water, each crowned by eleven bent ShapeGeometry fronds that sway in the wind.
- Ground Colour: vertex colours blend dry sand, wet shoreline and grass by distance from the pool.
- Controls: sun elevation and azimuth (recaptures reflections), palm count, wind and haze.

Continue Learning

JavaScript Implementation

ES6+
// Physically based sky + desert lighting
const sky = new Sky(); sky.scale.setScalar(5000); scene.add(sky)
const sun = new THREE.Vector3().setFromSphericalCoords(1, THREE.MathUtils.degToRad(90 - elevation), THREE.MathUtils.degToRad(azimuth))
sky.material.uniforms.sunPosition.value.copy(sun)
sunLight.position.copy(sun).multiplyScalar(200)
// Palm: trunk = TubeGeometry along a Bézier leaning toward the water; fronds = bent ShapeGeometry
const trunk = new THREE.QuadraticBezierCurve3(base, base.clone().setY(base.y + h * 0.6), top)
scene.add(new THREE.Mesh(new THREE.TubeGeometry(trunk, 16, 0.32, 8), bark))