tiramisu/scene
Structural scene root for Tiramisu.
A scene lives inside a tiramisu.renderer and owns the scene-node subtree
that will be parsed and reconciled into Three.js objects.
Scene roots are structural rather than imperative: application code declares the scene subtree, and Tiramisu reconciles it into the runtime.
Types
Context provided on each animation frame tick.
Contains timing and input information useful for smooth animations and responsive game controls.
pub type Tick {
Tick(
delta_time: duration.Duration,
timestamp: timestamp.Timestamp,
)
}
Constructors
-
Tick( delta_time: duration.Duration, timestamp: timestamp.Timestamp, )Arguments
- delta_time
-
Time elapsed since the last frame (typically ~16ms at 60fps). Use
duration.to_seconds()to convert to a Float for animation math. - timestamp
-
The timestamp when this frame was rendered. Useful for time-based effects or synchronized animations.
Values
pub fn background_color(hex: Int) -> attribute.Attribute(msg)
Set the background color for the scene (as hex int).
pub fn background_color_space_linear() -> attribute.Attribute(msg)
Set the color space used for loaded scene background textures.
pub fn background_color_space_srgb() -> attribute.Attribute(msg)
Set the color space used for loaded scene background textures to sRGB.
pub fn background_cube(
positive_x px: String,
negative_x nx: String,
positive_y py: String,
negative_y ny: String,
positive_z pz: String,
negative_z nz: String,
) -> attribute.Attribute(msg)
Set the background to a cubemap skybox.
pub fn background_equirectangular(
url: String,
) -> attribute.Attribute(msg)
Set the background to an equirectangular panorama.
pub fn background_texture(
url: String,
) -> attribute.Attribute(msg)
Set the background to a flat 2D texture.
pub fn clear_background() -> attribute.Attribute(msg)
Clear any scene background.
pub fn fog(
color color: Int,
near near: Float,
far far: Float,
) -> attribute.Attribute(msg)
Set linear fog on the scene.
pub fn fog_exp2(
color color: Int,
density density: Float,
) -> attribute.Attribute(msg)
Set exponential fog on the scene.
pub fn on_tick(
to_msg: fn(Tick) -> msg,
) -> attribute.Attribute(msg)
Listen for per-frame tick events emitted by the renderer.
This is the main entry point for animation and simulation work in a scene.
The callback receives a Tick containing the frame delta and
timestamp.