Expand description
Compile authored worlds into runnable Worlds, entirely in memory.
Requires the cook feature, which is off by default: the importers this
module needs are build-time weight a shipped application does not carry.
An application declares what it wants – a texture from this file, a room of
that size – and the runtime plays only the finished result. This module is
the step between: it checks the declarations, expands the ones that stand
for several assets, prepares each asset’s data, and then either assembles a
World to run straight away or writes the result to a file for a later
run to play. Prepared payloads are cached under the build root a host
installs – the dev CLI’s is .concinnity/ inside the project – so a
second compile with unchanged sources skips the expensive work. A process
that installed none has nowhere to cache and prepares them every time.
§The authoring vocabulary
This module is also the other half of the asset vocabulary: the types a
world declares and the cook consumes, which never reach a running world as
components. Those are the build-only assets it expands (Prefab,
MainMenu, CharacterSchema, …) and the resources it prepares
(Texture, Mesh, Material, Font, …). The stored half is
components.
Five assets are authored as something other than what they bake into, and
are named here for the asset they declare: cook::AppConfig,
cook::Camera3D, cook::File, cook::Room, and cook::Spawner are the
authored forms of the components of the same name. That makes those five
names ambiguous when both namespaces are glob-imported, so glob
components and path-qualify this module.
§Declaring a world in code
Each asset is declared by its own authored struct, so the type is carried by the value rather than spelled as a string:
use concinnity::App;
use concinnity::components::DirectionalLight;
use concinnity::cook;
fn main() {
let world = cook::world()
.add("sun", DirectionalLight {
color: [1.0, 0.96, 0.86],
direction: [-0.35, 0.85, 0.35],
intensity: 2.2,
})
.add("room", cook::Room {
size: Some([16.0, 20.0, 5.0]),
..Default::default()
})
.compile()
.expect("the declared world compiles");
App::from_world(world).run().expect("the app runs");
}A field that references another asset holds a resolved handle rather than
a name, so the name is given alongside the value with
reference:
cook::world()
.add("stone", cook::Material { roughness: 0.9, ..Default::default() })
.add("pillar", Prop::default())
.reference("material", "stone");Most assets are plain runtime components, so one needing no preparation can
equally be added straight to a World with
add_component. A Room is what this module is
for: its geometry is generated here, and its texture names become the
handles the runtime reads, neither of which exists beforehand.
§Compiling ahead of time
write_blob takes the same declarations and
writes them to a file instead of building a world. That file is a blob:
the compiled form of a world, holding the components and the prepared asset
data together. Producing one moves the preparation to a build tool, off
every launch. The shipped application plays it with
App::from_blob and needs neither this module nor
the importers behind it.
cook::world()
.add("sun", DirectionalLight::default())
.write_blob("data/0")
.expect("the world is written to data/0");Structs§
- AppConfig
- Names, identifies, and sizes the application.
- Audio
Clip - A baked audio clip: the sound an AudioEmitter plays.
- Camera3D
- Authored fields of a
Camera3D; the runtime view matrix and per-frame input intent are not declared. - Camera
Shot - A reusable Camera3D preset: reference it from a
Scene’s
camera_shot, or use it standalone. - Character
Capsule - A kinematic character capsule for a SkinnedMesh, in world
units (after the mesh’s
scale). - Character
Model - A character body that conforms to a CharacterSchema.
- Character
Schema - The contract between a character body and everything that uses it.
- Color
Lut - A 3D colour-grading lookup table applied as a final post-process step. The
build bakes the source into a colour cube; the graded result is blended over
the image by PostProcessConfig’s
lut_strength. - Cubemap
Texture - A six-face HDR cubemap baked from an equirectangular Radiance HDR source.
- Environment
Map - A baked lighting environment built from an equirectangular source (or a built-in generator). It provides the scene’s ambient image-based lighting (soft diffuse fill plus glossy reflections that follow surface roughness) and the on-screen sky.
- File
- Authored fields of a
File. - Font
- Rasterises a TrueType font into a glyph atlas at build time.
- Light
Rig - A named grouping of lights.
- Main
Menu - A ready-made menu declared in a single line.
- Main
Menu Item - One entry in a MainMenu.
- Material
- A Material bundles the surface parameters that control how a Prop is lit and shaded.
- Material
Palette - A named set of Material entries with short aliases.
- Mesh
- Raw geometry. Supply
verticesandindicesdirectly, or import them from a binary glTF file withsource+primitive_index. - Morph
Delta - One morph-target vertex delta: offsets added to the bind-pose position and normal, scaled by the target’s weight at runtime.
- Option
Select - A settings row that cycles through a fixed set of values on click.
- Palette
Entry - One entry in a MaterialPalette. Each carries an
alias(the suffix of the expanded Material name) plus the Material fields the expansion fills in. Names inalbedo/normal_mapare unresolved Texture references, resolved on the expanded Material. - Panel
- A titled background container for grouping UI overlay elements.
- Panel
Section - One panel section: a caption over the rows of the listed regions.
- Prefab
- A reusable template of Props, PointLights, and nested prefabs.
- Prefab
Entry - One entry in a Prefab’s
propslist. The fields consulted depend onkind: apropuses the render / collision / transform fields, apoint_lightuses thelight_*fields, and aprefabusesprefab. Names inmodel/mesh/material/texture/parent/prefabare unresolved references to other assets, resolved when the entry expands. - Proportion
Group - A proportion slider: one value in
[-1, 1]written as a scale and / or length change on every listed joint. - Room
- Authored fields of a
Room; the resolved dimensions and payload locator are runtime state. - Scene
Import - Imports a 3D scene file as a single declaration.
- Schema
Joint - One joint the schema expects in a conforming skeleton.
- Schema
Key - One shape key the schema knows, authored on the source or synthesized.
- Schema
Region - A named group of joints. A vertex belongs to a region by the skin weight it gives the region’s joints.
- Shape
Preset - A named slider vector the panel offers as a button.
- Skeleton
Joint - One joint of a skeleton’s bind pose.
- Skinned
Mesh - A skeletally animated mesh placed directly in the world.
- Skinned
Vertex Data - One vertex of a skinned mesh. Beyond position / colour / uv it carries up
to four joint bindings:
joints[k]indexes the skeleton,weights[k]is its blend weight. Weights are normalised at build time. - Slider
- A settings row that sets a continuous value by dragging a handle along a track.
- Spawner
- Authored fields of a
Spawner; the runtime accumulator is not declared. - Story
Import - Imports a Markdown story file as a single declaration.
- Synth
Params - Generator parameters for a synthesized target. Each generator reads the fields it needs and ignores the rest.
- Synthesized
Target - A morph target the build generates from the mesh instead of reading from the source.
- Texture
- A 2D texture image.
- Vertex
Data - A single vertex as supplied in raw Mesh args.
- World
Builder - A world under construction: typed authored assets, compiled together into
a runnable
Worldor a blob file.
Enums§
- KeyPolarity
- Whether a shape key is one target or a
+/-pair. - Prefab
Kind - Which kind of asset a PrefabEntry expands into.
- Settings
Profile - Which settings screen a MainMenu’s
"settings"item builds.
Traits§
- Authored
- The authored-value trait: the bridge from a typed authoring struct to the
world line that declares it. Implemented for every declarable asset’s args
schema (the
args:override where the authored form diverges from the component, the component itself where it does not) and for every resource asset, so a caller hands the cook a typed value instead of a name/type/args triple assembled by hand.
Functions§
- world
- Start an empty world.