Skip to content

struct

Scene

pub struct Scene {
    pub camera: Camera,
    pub light: Light,
    pub point_lights: Vec<PointLight>,
    pub spot_lights: Vec<SpotLight>,
    pub objects: Vec<Object3D>,
    pub particles: Vec<ParticleField>,
    pub background: Color,
    pub fog: f32,
    pub backdrop: Option<String>,
    pub backdrop_colors: Vec<Color>,
    pub backdrop_intensity: f32,
    pub backdrop_speed: f32,
}

A 3D scene: its camera, lights, objects and backdrop.

Fields

camera

pub camera: Camera

The camera.

light

pub light: Light

The key and ambient light.

point_lights

pub point_lights: Vec<PointLight>

Point lights.

spot_lights

pub spot_lights: Vec<SpotLight>

Spot lights.

objects

pub objects: Vec<Object3D>

The objects, in drawing order.

particles

pub particles: Vec<ParticleField>

Particle fields.

background

pub background: Color

The colour behind everything.

fog

pub fog: f32

Exponential fog density (0 = none), fading towards the background.

backdrop

pub backdrop: Option<String>

A shader preset drawn behind the scene.

backdrop_colors

pub backdrop_colors: Vec<Color>

The backdrop preset's colours.

backdrop_intensity

pub backdrop_intensity: f32

The backdrop's brightness (u_intensity) and speed.

backdrop_speed

pub backdrop_speed: f32

See backdrop_intensity.

Methods

has_shadows

pub fn has_shadows(&self) -> bool

Whether any light casts shadows onto anything: some light has shadows on, and some object casts them.

is_animated

pub fn is_animated(&self) -> bool

Whether rendering changes over time (so the host must animate it).

project

pub fn project(&self, point: Vec3, width: f32, height: f32) -> Option<(f32, f32)>

Project a world-space point to viewport pixels (None if behind the camera).

screen_bounds

pub fn screen_bounds(&self, index: usize, width: f32, height: f32) -> Option<Rect>

Screen-space bounding box of object index.

screen_bounds_at

pub fn screen_bounds_at(&self, index: usize, width: f32, height: f32, t: f32) -> Option<Rect>

[Scene::screen_bounds] as drawn at t seconds (spin, float, motion tweens).

hit_test_at

pub fn hit_test_at(&self, x: f32, y: f32, width: f32, height: f32, t: f32) -> Option<usize>

The nearest object under the pixel, as drawn at t seconds.

hit_test

pub fn hit_test(&self, x: f32, y: f32, width: f32, height: f32) -> Option<usize>

The nearest object whose screen bounds contain the pixel.

Trait implementations