just_dart 0.2.0
just_dart: ^0.2.0 copied to clipboard
Allocation-free math for Flutter games: mutable Vector2, Vector3 and Quaternion, Matrix4 helpers, Aabb3, Ray3, Plane, Frustum culling and a Quadtree.
Changelog #
All notable changes to this package will be documented in this file.
0.2.0 - 2026-10-03 #
The 3-D math the Just engine needs to be ready for 3-D. Everything works in
place, like Vector3, so hot paths never allocate.
Added #
Quaternion— mutable rotation (Hamilton convention): axis-angle, Z turns, products, inverse, slerp, rotating vectors, conversion from a rotation matrix. Euler angles follow one documented convention,q = qY · qX · qZ(Z applied first, then X, then Y — Unity's order), andeulerInto(out, hint:)returns the triple nearest a hint, exactly the hint when it still describes the rotation, so edited angles round-trip.Matrix4— re-exported fromvector_math's 64-bit library. It is the same class Flutter'swidgets/renderinglibraries export, so importing Flutter and a Just package together never makes the name ambiguous, and its column-majorFloat64Listgoes straight toCanvas.transform. TheJustMatrix4extension adds, forVector3/Quaternion:setFromTrs,setFromPlanarTrs(2-D fast path),setProduct,transformPointInto,transformDirectionInto,translationInto, and the engine's clip-space projectionssetOrthographicYDown/setPerspectiveYDown(x right, y down, depth 0..1).Aabb3,Ray3,PlaneandFrustumfor bounds, picking rays and culling.Vector3.crossInto— cross product without allocating.
Changed #
Quadtreestores each item once, in the smallest node that fully contains it; an item on a split line stays in the parent. Queries no longer return an item more than once, and a large item is no longer copied into every leaf (17 world-sized items among 200 small ones used to give 12,227 results for 217 items). Building is about twice as fast; with a few world-sized items, queries return half the hits and run 17% faster.toString()ofVector2,Vector3andQuaternionprints the class name:Vector3(1.0, 2.0, 3.0), notVec3(1.0, 2.0, 3.0).Frustum.planesis a fixed-length list.setOrthographicYDownandsetPerspectiveYDownassert (in debug builds) on inputs with no projection: an empty view box,near <= 0,far <= near,aspect <= 0orfovYoutside (0, π).- Requires Flutter
>=3.41.0. The old>=1.17.0was never reachable withsdk: ^3.11.0.
Fixed #
Quaternion.eulerIntonear x = ±90°: without a matching hint, x snapped to the pole up to 4.5e-4 rad (about 0.026°) early, so 89.98° read back as 90° and the angles no longer described the rotation. x now comes fromatan2, and the gimbal-lock branch only applies within 1e-8 of the pole.- Documented the edge cases:
normalize()leaves a zero vector at zero whilenormalized()returns the unit x axis, equality on mutable values,transformPointIntoon w = 0, and planes with a zero normal.
Dependencies #
vector_math: ^2.1.4(only forMatrix4; Flutter already depends on it).- Tests use
flutter_testinstead oftest, so they resolve against the versions the Flutter SDK pins.