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§
- Bend
Skin - 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.
- Placed
Light - A light and the transform it shines from.
- Scene
Control - How the example’s runner drives one scene.
- Scene
Def - One selectable scene.
- Scene
Options - 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_viewlooks from. - DEFAULT_
TARGET - The point
camera_viewlooks 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 allruns them.
Functions§
- aim_
camera - Re-aim
entity’s camera attargetfromeyefor a frame ofsize. - allocate_
offset_ cube_ mesh - Allocate the unit cube through the source, its vertices offset by
offsetin 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 abaseline-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
eyelooking attarget, with the same reverse-z infinite perspective ascamera_view. - camera_
view - Camera looking at
DEFAULT_TARGETfromDEFAULT_EYE. - content_
size - The size a scene’s camera should be built for when its content is drawn into
the
baseline-aspect part of atarget-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
entityand its subtree, through the scope that owns it. - grid
- A rectangle centred on
origin,rightwide anduptall, split intosegmentsquads along each of them, wound so its front face is the side the cross product ofrightanduppoints at. - list_
text - A table of every scene, for
--list-scenesand--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
meshthrough the source, releasing its pool ranges. - rest_
pose - A rig of
joint_countjoints, all at rest, returned as joint matrices. - spawn_
in - Spawn
bundleintoscope’s subtree. - spawn_
shared - Spawn
bundleinto the world’s shared subtree. - with_
mesh_ source - Run
fon the world’sMeshSource, which lives on the source entity.