Skip to main content

Module spin_cube

Module spin_cube 

Source
Expand description

The exampleโ€™s own scene: a spinning, textured cube with two egui panels.

This is the scene the windowed example always showed. Its snapshot test is the workspaceโ€™s CI check against spin_cube.webp: 30 frames at the default window size, so a rendering regression fails the build.

Re-exportsยง

use super::BASELINE_SIZE; ๐Ÿ”’
use super::SceneControl; ๐Ÿ”’
use super::SceneDef; ๐Ÿ”’
use super::SceneOptions; ๐Ÿ”’
use unlit_ecs::Bundle; ๐Ÿ”’
use unlit_ecs::DynamicBundle; ๐Ÿ”’
use unlit_ecs::bundle; ๐Ÿ”’
use unlit_wgpu::pipeline::LitOptions; ๐Ÿ”’
use unlit3d::ui::UiSource; ๐Ÿ”’
use unlit3d::ui::egui; ๐Ÿ”’
use unlit3d::prelude::*; ๐Ÿ”’

Structsยง

CameraOrbit ๐Ÿ”’
How far the camera has been dragged around the cube, in radians.
DragFrom ๐Ÿ”’
The pointer the drag is following, and where it was at the previous move.
FrameCount ๐Ÿ”’
Counts the frames drawn, for the panelโ€™s readout.
Spin ๐Ÿ”’
A behaviour component: the cube turns by radians_per_second.
SpinReset ๐Ÿ”’
Set by the panelโ€™s button, read once by the frame loop.
SpinState ๐Ÿ”’
The state of the spin, shared between the panel, the pointer behaviour and the frame loop.
TexturedCube ๐Ÿ”’
The sceneโ€™s one visible object: a textured cube turned by the frame loop.

Constantsยง

ORBIT_ELEVATION ๐Ÿ”’
How high above the horizon the camera starts, in radians.
ORBIT_RADIUS ๐Ÿ”’
How far from the target the camera orbits, in world units.
ORBIT_TARGET ๐Ÿ”’
The point the camera looks at, in world units.
SAMPLE_COUNT
The number of samples every frame is rendered with.
SPIN ๐Ÿ”’
How fast the cube spins, in radians per second.

Staticsยง

SCENE
The scene: a spinning cube at the exampleโ€™s default window size, whose snapshot test verifies spin_cube.webp.

Functionsยง

build ๐Ÿ”’
Build the cube sceneโ€™s world content.
checkerboard ๐Ÿ”’
A size x size checkerboard base-color texture.
orbit_camera ๐Ÿ”’
A camera orbiting ORBIT_TARGET at azimuth and elevation, in radians.