savoiardi/scene

Scene creation and scene-level rendering configuration.

This module wraps Three.js scenes together with typed helpers for backgrounds, environment maps, and fog settings.

Types

Scene background sources supported by Savoiardi.

pub type Background {
  ColorBackground(Int)
  TextureBackground(texture.Texture)
  CubeTextureBackground(texture.CubeTexture)
}

Constructors

Scene environment map sources supported by Savoiardi.

pub type Environment {
  EnvironmentTexture(texture.Texture)
  EnvironmentCubeTexture(texture.CubeTexture)
}

Constructors

Fog settings for a scene.

pub type Fog {
  LinearFog(color: Int, near: Float, far: Float)
  ExponentialFog(color: Int, density: Float)
}

Constructors

  • LinearFog(color: Int, near: Float, far: Float)
  • ExponentialFog(color: Int, density: Float)

A Three.js scene.

pub type Scene

Values

pub fn background_color(value: Int) -> Background

Builds a solid-color background value.

pub fn background_cube_texture(
  cube_texture: texture.CubeTexture,
) -> Background

Builds a cube texture background value.

pub fn background_texture(texture: texture.Texture) -> Background

Builds a 2D texture background value.

pub fn clear_background(scene: Scene) -> Scene

Removes the current scene background.

pub fn clear_environment(scene: Scene) -> Scene

Removes the current environment map.

pub fn clear_fog(scene: Scene) -> Scene

Removes fog from a scene.

pub fn environment_cube_texture(
  cube_texture: texture.CubeTexture,
) -> Environment

Builds an environment map from a cube texture.

pub fn environment_texture(
  texture: texture.Texture,
) -> Environment

Builds an environment map from a 2D texture.

pub fn fog(
  color color: Int,
  near near: Float,
  far far: Float,
) -> Fog

Builds linear fog settings.

pub fn fog_exp2(color color: Int, density density: Float) -> Fog

Builds exponential fog settings.

pub fn new() -> Scene

Creates an empty scene.

pub fn set_background(
  scene: Scene,
  background: Background,
) -> Scene

Applies a background to a scene.

pub fn set_background_blurriness(
  scene: Scene,
  blurriness: Float,
) -> Scene

Sets the blur amount used for texture-based backgrounds.

pub fn set_background_intensity(
  scene: Scene,
  intensity: Float,
) -> Scene

Sets the intensity used for texture-based backgrounds.

pub fn set_environment(
  scene: Scene,
  environment: Environment,
) -> Scene

Applies an environment map to a scene.

pub fn set_environment_intensity(
  scene: Scene,
  intensity: Float,
) -> Scene

Sets the environment lighting intensity.

pub fn set_fog(scene: Scene, fog: Fog) -> Scene

Applies fog settings to a scene.

pub fn to_object3d(scene: Scene) -> object.Object3D

Views a scene as an object so it can be used with object APIs.

Search Document