Skip to content

struct

Object3D

pub struct Object3D {
    pub geometry: Geometry,
    pub transform: Transform,
    pub color: Color,
    pub material: Material,
    pub motion: Motion,
    pub transition_ms: f32,
    pub label: Option<String>,
    pub parent: Mat4,
    pub animation: Option<Tween>,
    pub bounds: Option<(Vec3, Vec3)>,
    pub cast_shadow: bool,
    pub receive_shadow: bool,
}

An object in a scene: its geometry, transform, colour and material, motion and animation, label and shadows.

Fields

geometry

pub geometry: Geometry

Its shape.

transform

pub transform: Transform

Where it is, how it's turned, and its size.

color

pub color: Color

Its colour.

material

pub material: Material

What its surface looks like.

motion

pub motion: Motion

How it moves on its own.

transition_ms

pub transition_ms: f32

Animate changes to transform/color over this many milliseconds.

label

pub label: Option<String>

Its accessible name.

parent

pub parent: Mat4

The combined transform of enclosing groups.

animation

pub animation: Option<Tween>

A GSAP-style tween over x y z rotation-x/y/z scale opacity (start values already resolved), timed from scene start.

bounds

pub bounds: Option<(Vec3, Vec3)>

Local bounds of what it loaded (a model, text), once known.

cast_shadow

pub cast_shadow: bool

Draws into the shadow maps of lights that cast shadows.

receive_shadow

pub receive_shadow: bool

Darkened where shadow-casting objects block a light.

Methods

new

pub fn new(primitive: Primitive) -> Object3D

An object of a built-in shape, with the default material and no transform.

of

pub fn of(geometry: Geometry) -> Object3D

An object of geometry, with the default material and no transform.

local_bounds

pub fn local_bounds(&self) -> (Vec3, Vec3)

Its local bounding box: the mesh's, what loaded, or a unit box until then.

pose

pub fn pose(&self, t: f32) -> (Transform, Color, f32)

The transform, colour and opacity at time t (seconds): the base transform with the tween and continuous motion applied.

pose_from

pub fn pose_from(&self, base: &Transform, color: Color, t: f32) -> (Transform, Color, f32)

[Object3D::pose] starting from another base (e.g. mid-transition).

world_matrix

pub fn world_matrix(&self, t: f32) -> Mat4

World matrix at time t (enclosing groups, tween and motion).

Trait implementations