Skip to content

Environment ​

The Environment class is used to create and manage environment maps in Three.js scenes. It generates dynamic environment maps using THREE.CubeCamera and applies them to the scene, typically used for reflection effects and global ambient lighting.

This class inherits from BaseThree and is initialized through a ThreeInstance instance. Environment maps are generated through a cube camera (THREE.CubeCamera) that renders six faces of the scene to create the environment map.

Note

Environment map images can be used as backgrounds and directly on objects for reflections and lighting. They illuminate the entire scene in a very realistic way.

Note

Click the image to jump to the example! ⬆️

Constructor ​

typescript
Environment(instance: ThreeInstance)

This constructor creates a new Environment.

Parameters ​

  • instance (ThreeInstance): A ThreeInstance object containing basic Three.js renderer, scene, and other settings.

Methods ​

update() :void ​

Updates the cube camera to re-render the environment texture. This method should be called every frame to maintain real-time environment mapping.

typescript
instance.time.on("tick", () => {
    animation.update()
});

Properties ​

cubeCamera ​

THREE.CubeCamera instance used to render six faces of the scene and generate environment maps. Access the current cubeCamera camera.

typescript
const env = new AUTO.Environment(instance)
console.log(env.cubeCamera);

Released under the MIT License