Skip to content

NgtsEnvironment

NgtsEnvironment is a port of Drei’s Environment which sets up a global cubemap affecting the default scene.environment and optionally scene.background.

Available Presets

Presets link to common HDRI Haven assets hosted on GitHub CDN:

PresetHDRI File
apartmentlebombo_1k.hdr
citypotsdamer_platz_1k.hdr
dawnkiara_1_dawn_1k.hdr
forestforest_slope_1k.hdr
lobbyst_fagans_interior_1k.hdr
nightdikhololo_night_1k.hdr
parkrooitou_park_1k.hdr
studiostudio_small_03_1k.hdr
sunsetvenice_sunset_1k.hdr
warehouseempty_warehouse_01_1k.hdr

Note: Presets are not meant for production environments as they rely on CDNs.

Usage

Using a Preset

<ngts-environment [options]="{ preset: 'city' }" />

With Background

<ngts-environment [options]="{ preset: 'sunset', background: true }" />

Blurred Background

<ngts-environment
[options]="{
preset: 'forest',
background: true,
backgroundBlurriness: 0.5,
backgroundIntensity: 0.8
}"
/>

Custom Environment File

<ngts-environment
[options]="{
files: 'path/to/environment.hdr',
background: true
}"
/>

Custom Rendered Environment

Render custom content into an environment map using a cube camera:

<ngts-environment [options]="{ background: true }">
<ng-template>
<ngt-mesh>
<ngt-sphere-geometry *args="[10]" />
<ngt-mesh-basic-material [side]="BackSide" color="skyblue" />
</ngt-mesh>
</ng-template>
</ngts-environment>

Ground Projection

Project the environment map onto the ground for more realistic scene integration:

<ngts-environment [options]="{ preset: 'park', ground: true }" />

With custom ground options:

<ngts-environment
[options]="{
preset: 'warehouse',
ground: {
height: 15,
radius: 60,
scale: 1000
}
}"
/>

Adjusted Lighting Intensity

<ngts-environment
[options]="{
preset: 'studio',
environmentIntensity: 0.5,
environmentRotation: [0, Math.PI / 2, 0]
}"
/>

Options

Properties

name type description
background boolean Whether to use the environment map as the scene background. Default: false
files string | string[] Array of cubemap files OR single equirectangular file path.
path string Base path to the cubemap files OR single equirectangular file.
preset string One of the available presets: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'.
scene THREE.Scene Custom scene to apply the environment map to.
map THREE.Texture Pre-loaded texture to use as environment map.
blur number Background blur amount (deprecated, use backgroundBlurriness). Default: 0
backgroundBlurriness number Background blur amount (0 to 1). Default: 0
backgroundIntensity number Intensity of the background. Default: 1
backgroundRotation [number, number, number] Rotation of the background as Euler angles. Default: [0, 0, 0]
environmentIntensity number Intensity of the environment lighting. Default: 1
environmentRotation [number, number, number] Rotation of the environment lighting as Euler angles. Default: [0, 0, 0]
ground boolean | { height?: number; radius?: number; scale?: number } Configuration for ground-projected environment.
frames number Number of frames to render the environment cube camera. Default: 1
near number Near clipping plane for the cube camera. Default: 1
far number Far clipping plane for the cube camera. Default: 1000
resolution number Resolution of the cube render target. Default: 256