flutter3d_physics 0.5.1
flutter3d_physics: ^0.5.1 copied to clipboard
Collision shapes, a broadphase, queries and a character controller. No Flutter, no renderer, no game.
flutter3d_physics #
Collision shapes, a broadphase grid, ray and overlap queries, rigid bodies and a character controller.
No Flutter and no renderer in it. That is the boundary this package exists
to keep: it runs under dart test, and the day it needs a widget is the day
something has been put in the wrong package.
final world = CollisionWorld();
world.add(Collider(shape: CollisionBox(Vector3(2, 1, 2))));
final body = CharacterController(world: world, position: Vector3(0, 2, 0));
body.step(dt, wishDirection: forward, sprint: false);
What the character controller is for #
Walking, which is harder than falling. Slopes it can climb and slopes it slides off, steps it can walk up without a jump, ramps whose surface it follows, a coyote window after walking off an edge and a buffered jump pressed just before landing. Every one of those is a decision with a test beside it saying which way it went and why.
Ground, and the joins in it #
CollisionHeightfield is a field of samples a body can walk on: the fifth
shape, and the first that is not one convex solid. A query names the box it
cares about, the shape hands back the convex pieces near it, and the plane walk
every other query already used runs once per piece.
The part worth knowing about is the joins. Where two triangles meet, each piece
ends in a vertical face the other continues through — and a sweep that reports
one stops the body dead against a wall nobody drew. The shape names those faces
and the world refuses to contact them; heightfield_test.dart holds the two
measurements that catch it going wrong, and tool/ground_cost.dart holds what
the whole thing costs.
Tolerances #
Nearly names the four magnitudes this package compares against, because the
number was never the interesting part: a distance nobody can perceive, the slack
on two numbers computed different ways, and a denominator guard on a squared
quantity are different questions that used to look identical.
Part of flutter3d, an independent
implementation of a 3D engine for Flutter — not a fork or a binding of
another engine, and not affiliated with the Flutter team. Three switchable
rendering backends: Impeller via Flutter GPU, WebGL2, and a software
rasteriser. glTF, OBJ and .f3d loading, six lighting models, shadows, bloom,
skinning, animation, BVH culling and picking; a deterministic fixed-step game
layer with collision, navigation, positional audio, and gamepad and touch
input. Three example games — shooter, platformer, racing — each built on its
genre package: flutter3d_game_shooter,
flutter3d_game_platformer,
flutter3d_game_racing. A new game starts from the
editor's scaffold, which writes one from a template: https://flutter3d.pleion.dev/first-project/.
Documentation: https://flutter3d.pleion.dev.