Showcases
The four examples the gallery lists under Showcases. Each block is what the gallery’s code panel shows beside that example, copied from the example itself: the lines that do it rather than the whole file, so it isn’t compiled here the way the guides’ code is. The file it came from is linked under each one.
Blocks
Section titled “Blocks”A landscape of sixty thousand cubes, generated and sent once.
// The world is a grid of bytes, not a list of what to draw. The moment// somebody can dig, "what is at this point" is asked constantly — by the// body falling, by every step, by every ray under the crosshair — and a// grid answers it in one lookup instead of sixty thousand.Uint8List blocks; // side * side * tall, nought is air
// Only what can be seen is drawn. A block with six solid neighbours is// invisible from everywhere, and in a world of hills that is most of them.if (!buriedOnAllSides) { transforms.addAll(placed(x, y, z)); colours.addAll(colourOf(kind));}
// Moved one axis at a time, which is the whole reason it works: move in// one step and test afterwards and you are inside a wall with no way to// know which way to come back out. One at a time, a corner stops you// sideways and lets you keep walking forwards — which is what sliding// along a wall is.for (final step in [(dx, 0.0), (0.0, dz)]) { ... }
// And digging is a ray walked a fraction of a block at a time. A proper// grid traversal is faster; this is called once per click, on a ray six// blocks long, and being obviously correct is worth more here.From voxels.dart. To open the gallery on it:
ORBLIT_EXAMPLE='blocks' flutter run -d macosRunner
Section titled “Runner”A runner you can play: dodge, jump, slide and pick up coins.
// Every model is made in code, written out as a glb, and handed to the// renderer by name — the same path a downloaded file takes.final art = RunnerArt.build();for (final file in art.files.entries) { await OrblitResources.provide(file.key, file.value);}
// The world is laid in chunks as the runner reaches them. A chunk that// falls behind hands its keys to the one being laid ahead, so the// renderer reuses what it made rather than making more.final key = 1000 + type * 100 + slot * cap + index;
// Grass is one population per chunk, sent when the chunk is laid and never// again: the revision only changes when the blades do.OrblitPopulation( key: 1 + slot, transforms: blades, colours: shades, minimum: low, maximum: high, revision: revisions[slot], range: 60,);
// A hurdle is cleared by being above it when you reach it, a bar by being// below it, a container by not being in its lane.final blocked = switch (hazard.kind) { Kind.hurdle => y < 0.92, Kind.bar => y + (sliding ? 0.8 : 1.3) > 1.05, Kind.container => true,};From runner.dart. To open the gallery on it:
ORBLIT_EXAMPLE='runner' flutter run -d macosBistro exterior
Section titled “Bistro exterior”Somebody else’s street, lit by this engine. A hundred lights at night.
// The fixtures come out of the scene's own emissive geometry, so the lights// stand where the artist put the lamps.for (final fixture in fixtures) OrblitLight( kind: OrblitLightKind.point, position: fixture.at, intensity: 2400, // lumens — a street lamp falloffRadius: 14, // metres castShadows: false, // a hundred shadow casters is not a thing ),
// And the sky is still a light, even at night.OrblitSky(zenith: Color(0xFF0B1224), horizon: Color(0xFF243046), ambient: 120)From bistro.dart. To open the gallery on it:
ORBLIT_EXAMPLE='bistro exterior' flutter run -d macosBistro interior
Section titled “Bistro interior”The room, and the one place the absence of bounced light shows.
// Indoors, the ambient is doing the job bounced light would do. Drag it to// nothing and the shadows go black, which is exactly what a renderer without// global illumination looks like when nothing stands in for it.OrblitSky( zenith: linearOf(const Color(0xFF2A1D18)), ambient: 400, // lux drawn: false, // lighting only; there is no sky to see from in here)
// And occlusion, the cheapest approximation of contact darkening.OrblitPostProcess(occlusion: OrblitOcclusion(enabled: true))From bistro.dart. To open the gallery on it:
ORBLIT_EXAMPLE='bistro interior' flutter run -d macos