Skip to main content

Module scenes

Module scenes 

Source
Expand description

The example’s selectable scenes.

A scene is a SceneDef: the fixed size and frame count its snapshots were captured at, what offscreen target it draws into, and a build that populates an ECS world. The world it builds is the ordinary one every frame loop drives — the frame’s context and Renderer are already in it — so the windowed run and the snapshot tests differ only in what they bind they do with the result.

A scene’s SceneControl carries the per-frame behaviour (an animated sequence, the orbit of the camera) and the snapshot each frame verifies against in the snapshot tests. Scenes without snapshots — the windowed example’s own — report none.

Every scene here is ported from a GPU snapshot test that used to live in crates/unlit3d/tests, which is why its size, frame count and content are exactly what that test froze: the stored snapshots in the unlit3d_asset_files submodule still verify them.

Re-exports§

use unlit_ecs::Bundle; 🔒
use unlit_ecs::DynamicBundle; 🔒
use unlit_ecs::bundle; 🔒
use unlit_wgpu::pipeline::DepthStencilPolicy; 🔒
use unlit_wgpu::pipeline::LitOptions; 🔒
use unlit_wgpu::scene::ViewportRect; 🔒
use unlit3d::prelude::*; 🔒

Modules§

animated
The animated-grid scene: meshes allocated, recycled and moved across eight frames.
custom_pipeline
A caller-owned pipeline: a procedural sky and an animated particle cloud.
gltf
The glTF scene: a skinned fox and a morph-target cube, animated from the documents they were loaded from.
instanced_skinned_morph
The instanced skin-and-morph scene: three entities sharing one deformed mesh.
lit
The lit scene: Lambert shading under every kind of built-in light.
lit_clusters
The cluster debug scene: the grid a lit frame looks its lights up in.
mesh_and_ui
The mesh-and-UI scene: a cube and a rich egui panel in one pass.
mesh_topologies
The mesh-topology scene: every primitive topology, drawn indexed and non-indexed.
morphed
The morphed-cube scene: a cube blended by two morph targets across six frames.
outline
The outline scene: one picture drawn by both ways of drawing an outline.
skinned
The skinned-cube scene: a mesh bent by two joints across six frames.
spin_cube
The example’s own scene: a spinning, textured cube with two egui panels.
transparent
The transparent, z-sorted scene: overlapping translucent panes composite in draw order.
ui_only
The UI-only scene: egui drawn into a frame with no mesh source and no camera.

Structs§

BendSkin
A two-joint skin that bends a mesh about its own base.
Grid
A rectangle as the mesh allocator takes it.
LitSurface
One surface of the scene: the mesh and the pipeline it is drawn with.
PlacedLight
A light and the transform it shines from.
SceneControl
How the example’s runner drives one scene.
SceneDef
One selectable scene.
SceneOptions
What a scene is built with.

Constants§

BASELINE_SIZE
The aspect the windowed example keeps its 3D content to, as a reference resolution.
DEFAULT_EYE
The eye camera_view looks from.
DEFAULT_TARGET
The point camera_view looks at.
SEQUENCE_STEP
Seconds each frame of a fixed-sequence scene stays on screen in the windowed loop.
TEST_FORMAT
The format the test scenes render into: sRGB, like the example’s window.
TEST_SIZE
The size the ported test scenes draw at, matching their snapshots.

Statics§

SCENES
Every selectable scene, in the order the GUI lists and --scene all runs them.

Functions§

aim_camera
Re-aim entity’s camera at target from eye for a frame of size.
allocate_offset_cube_mesh
Allocate the unit cube through the source, its vertices offset by offset in mesh space.
allocate_surface
Upload a rectangle and return its mesh.
aspect_of
The aspect ratio of a size-pixel render target.
baseline_viewport
The region of a target-pixel render target a baseline-aspect scene draws into: the largest rectangle of that aspect that fits, centred.
by_id
The scene whose id is id, if any.
camera_looking_at
A camera at eye looking at target, with the same reverse-z infinite perspective as camera_view.
camera_view
Camera looking at DEFAULT_TARGET from DEFAULT_EYE.
content_size
The size a scene’s camera should be built for when its content is drawn into the baseline-aspect part of a target-pixel render target.
cube
A unit cube centred at the origin, returned as (positions, uvs, colors, indices).
cube_with_normals
The same cube, beside one outward normal per vertex.
default
The scene the example runs when none is asked for.
default_options
Default options for the ported ECS scenes: per-instance transform and tint, no texture, no MSAA, with reverse-z depth.
despawn_in
Despawn entity and its subtree, through the scope that owns it.
grid
A rectangle centred on origin, right wide and up tall, split into segments quads along each of them, wound so its front face is the side the cross product of right and up points at.
list_text
A table of every scene, for --list-scenes and --help.
morph_deltas
The displacement of the two morph targets the deformed scenes use, packed the way a mesh stores it: per vertex, one target after the other, three components each.
remove_mesh
Free mesh through the source, releasing its pool ranges.
rest_pose
A rig of joint_count joints, all at rest, returned as joint matrices.
spawn_in
Spawn bundle into scope’s subtree.
spawn_shared
Spawn bundle into the world’s shared subtree.
with_mesh_source
Run f on the world’s MeshSource, which lives on the source entity.

Type Aliases§

Advance
Advances a scene’s behaviour by one frame.
Build
Builds a scene’s world content and returns its per-frame behaviour.
RawMesh
The raw channels of one mesh: (positions, uvs, colors, indices).
Snapshot
Names the snapshot a frame verifies against, if it has one.