Currently it is quite hard to operate with the Mesh class, because the list of surfaces is kept private.
I understand the concern with immutability, and the fact that the aabb must be recalculated when anything change.
Sadly I don't think Dart provides us with patterns to fully automate updating the aabb.
We need a way to update the meshes, so this is a compromise:
add a getter to an unmodifiable list
if the user updates the surfaces within, they are responsible for calling updateBounds
add methods to update or remove elements from the list, which automatically call updateBounds
this allow us to remove the silly "updateMaterial" methods that are used by Defend the Donut
This also adds an add method that takes a Surface object witch is extremely handy (even though it allows for post-modifications).
If we prefer to go a truly fully immutable route, we instead need helper methods to copy and recreate meshes with given set of changes. I am happy to take a stab at that option too.
Description
Currently it is quite hard to operate with the
Mesh
class, because the list of surfaces is kept private.I understand the concern with immutability, and the fact that the
aabb
must be recalculated when anything change. Sadly I don't think Dart provides us with patterns to fully automate updating theaabb
. We need a way to update the meshes, so this is a compromise:updateBounds
updateBounds
This also adds an
add
method that takes aSurface
object witch is extremely handy (even though it allows for post-modifications).If we prefer to go a truly fully immutable route, we instead need helper methods to copy and recreate meshes with given set of changes. I am happy to take a stab at that option too.
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?