Skip to main content

Module floor

Module floor 

Source
Expand description

The ground the balls land on: one fixed body in physics, one instance in the render world, wearing a checker so motion reads against it.

The floor is the scene’s only fixed body, and the only instance that never moves, so it is built once and then left alone: the ground is queued before anything can drop on it, and afterwards there is nothing to do. The instance is built by one job in the render world, so the mesh, the checker and the instance that names them need no round trip between them.

Re-exports§

use glam::Vec3; 🔒
use unlit_ecs::World; 🔒
use unlit3d::components::Transform; 🔒
use super::Scene; 🔒
use crate::render::allocate_mesh; 🔒
use crate::render::allocate_rgba_material; 🔒
use crate::render::cuboid_mesh; 🔒
use crate::render::instance_of; 🔒
use crate::render::linear_sampler; 🔒
use unlit3dx::prelude::*; 🔒

Constants§

GROUND_CHECKER_DARK
The checker’s darker square, as sRGB bytes.
GROUND_CHECKER_SIZE
The ground texture’s edge length in pixels; the checker draws eight squares per side, so each square is a block of GROUND_CHECKER_SIZE / 8 pixels.
GROUND_CHECKER_SQUARES 🔒
The checker squares per texture side.
GROUND_COLOR
The ground’s base color, as sRGB bytes.
GROUND_FRICTION 🔒
The friction the ground gives the balls.
GROUND_HALF
The ground box’s half extents, in metres.
GROUND_POSITION
Where the ground box sits; its top face is the y = 0 plane.

Functions§

checker_ground
The ground’s checker texture: GROUND_CHECKER_SQUARES squares per side, the light ones in GROUND_COLOR and the dark ones in GROUND_CHECKER_DARK.
ground_job 🔒
The job that builds the ground’s instance in the render world.
spawn_floor
Put the ground under the scene: one fixed body in physics, one instance in the render world.