Skip to main content

Module shapes

Module shapes 

Source
Expand description

The shapes the scene cycles through: their meshes, colliders and textures.

A shape kind decides three things at once โ€” what the render world draws, what physics simulates, and what pattern the material wears โ€” so the three live together and a new kind is one match arm per function.

Re-exportsยง

use glam::Vec3; ๐Ÿ”’
use crate::render::OwnedLitMeshDesc; ๐Ÿ”’
use crate::render::WHITE_COLOR; ๐Ÿ”’
use crate::render::cuboid_mesh; ๐Ÿ”’
use crate::render::uv_sphere; ๐Ÿ”’
use unlit3dx::prelude::*; ๐Ÿ”’

Enumsยง

ShapeKind
One body shape of the scene: the mesh it draws, the collider physics simulates, and the texture pattern its material wears.

Constantsยง

BALL_COLORS
The base colors the balls cycle through, as sRGB bytes.
BALL_RADIUS
Every ballโ€™s radius, in metres.
PATTERN_SIZE
The pattern textures the shape materials draw from, in pixels per side: big enough that a pattern reads across a metre-wide body, small enough that sixteen of them stay cheap.
SHAPE_KINDS
Every shape the scene cycles through, in spawn order.

Functionsยง

into_desc ๐Ÿ”’
Lift a raw meshโ€™s arrays into the owned description the render server takes.
lathe ๐Ÿ”’
A lathe along the y axis: the side wall walks the rings top to bottom, and the caps close whichever ends ask for it, so a cylinder and a cone share one winding story.
pattern_texture
The texture pattern one shape kind wears, tinted with a base color: dots for the ball, a checker for the cube, stripes for the cylinder and rings for the cone. Every pattern puts the accents where the bodyโ€™s silhouette bends, so the tumbling reads as motion.
shape_body
The collider physics simulates for one shape kind, sized to match its mesh.
shape_kind
The shape kind an index draws from the palette.
shape_mesh
The mesh one shape kind draws. Every kind is about BALL_RADIUS across, so every shape shares one visual weight.
tinted ๐Ÿ”’
Scale a colorโ€™s bytes by a factor, for the pattern accents.
uv_cone
A cone pointing up the y axis: an apex ring collapsed to a point on top, a flat base cap below.
uv_cylinder
A cylinder along the y axis: flat caps top and bottom, uvs mapped so a texture wraps the wall and spots the caps.

Type Aliasesยง

RawMesh
A mesh as raw arrays: positions, uvs, colors, indices.