Skip to main content

Crate unlit3dx_examples

Crate unlit3dx_examples 

Source
Expand description

The multi-world demo’s library half: the scene the windowed binary shows, the thread-free headless run the –headless mode and the snapshot tests drive, and the entry point the Android activity calls.

A multi-world demo: one scene where rendering, physics and audio each run in their own world, joined by jobs and snapshots.

The host world owns the window and drives the frame. A render sub-world sits on the main thread as a nested world and serves the others: it allocates meshes, materials and instances when the scene asks, and the entity bits it answers with are the handles the rest of the show uses. The scene’s other worlds — physics, audio and gameplay — are spawned through one runner, so the host carries the same entities and components whether they run on threads of their own or are stepped by the host’s frames. The gameplay world holds the scene’s objects: one entity each for the scene’s assets, the floor, the balls and the music, every one of them ticking itself. The panel is the fifth object, and lives in the gameplay world with the rest: it lays its frames out there and sends them to the render world, which holds and draws them.

Space drops a body. The render world’s control panel drives two music tracks — a looping background piece and a one-shot MIDI sequence — each of which pauses, resumes and rewinds on its own, and it drops the next ball or puts every live ball away. Bodies fall, bounce off the ground and each other while the music plays. The soundfont is embedded at build time: build.rs reads the FluidR3Mono_GM.sf3 file the repository keeps out of version control under assets, and the demo runs silent when it is missing.

The –headless switch runs the same scene without a window or threads: the worlds are stepped at fixed rates, the run keeps its last frame and audio mix, and writes them into –out. A browser build steps the worlds the same way, because the target has no threads to put them on, and –stepped asks a windowed run to take that same path.

Re-exports§

pub(crate) use argh::FromArgs; 🔒
pub(crate) use argh::FromArgs; 🔒
pub(crate) use std::process::ExitCode; 🔒
pub(crate) use std::sync::atomic::Ordering; 🔒
pub(crate) use unlit_ecs::bundle; 🔒
pub(crate) use image::ImageEncoder; 🔒
pub(crate) use unlit3d::input::winit::WinitInput; 🔒
pub(crate) use ExitOn; 🔒
pub(crate) use ExitRequest; 🔒
pub(crate) use ExitTrigger; 🔒
pub(crate) use WindowSetup; 🔒
pub(crate) use request_redraw_while_foreground; 🔒
pub(crate) use window; 🔒
pub(crate) use winit_input_behaviour; 🔒
pub(crate) use unlit3d::winit::event::WinitHost; 🔒
pub(crate) use draw_presented; 🔒
pub(crate) use pump_presented; 🔒
pub(crate) use setup_presenter; 🔒
pub(crate) use ControlFlow; 🔒
pub(crate) use EventLoop; 🔒
pub(crate) use winit::window::Window; 🔒
pub(crate) use crate::scene::*; 🔒
pub(crate) use unlit3d::prelude::*; 🔒
pub(crate) use unlit3dx::prelude::*; 🔒

Modules§

headless
The headless run: the whole scene, stepped inline without a window, threads or audio output.
interactive
The interactive run, stepped inline: the wasm page drives this module. The interactive run: the whole scene, stepped inline and driven by input.
mcp
The interactive headless host: MCP drives the same scene without a window.
render
The demo’s render bridge: an asset server over entities in the render sub-world.
scene
The demo’s scene: its constants, its objects, and the worlds that run them.

Structs§

Args
The example’s command line: switches for the Model Context Protocol, the headless render and the stepped runner.

Functions§

init_logging
Install the logger backend this target writes through.
parse_args 🔒
Read the command line into Args.
run
Run the example the binary was started as.
run_headless 🔒
Render the scene headless and write the run’s outputs.
stepped_audio 🔒
The audio setup a windowed run takes when the host steps the worlds.
stepped_frame 🔒
Step the scene’s worlds once per frame, before the draw.
windowed
Run the whole show: five worlds, one window.