Currently Drawables must be constructed with a specific color/material, but it is possible to vary color dynamically without reloading the mesh data. This might be done by adding functions like
Drawable.trianglesWithDynamicColor : List Triangle3d -> Vec3 -> Drawable
which are designed to be partially applied, resulting in a Vec3 -> Drawable function where every call with a different color ends up reusing the same underlying mesh.
This could also be done by changing the argument order of existing functions to always pass color/material last, but that could interfere with some optimizations - for example, if a simple flat color is passed as the material for some mesh, the implementation can choose to store positions only and discard normal vectors. If the implementation had to always assume that materials will be changed dynamically (potentially to one where normals are required), then such optimizations would become harder or impossible.
Currently
Drawable
s must be constructed with a specific color/material, but it is possible to vary color dynamically without reloading the mesh data. This might be done by adding functions likewhich are designed to be partially applied, resulting in a
Vec3 -> Drawable
function where every call with a different color ends up reusing the same underlying mesh.This could also be done by changing the argument order of existing functions to always pass color/material last, but that could interfere with some optimizations - for example, if a simple flat color is passed as the material for some mesh, the implementation can choose to store positions only and discard normal vectors. If the implementation had to always assume that materials will be changed dynamically (potentially to one where normals are required), then such optimizations would become harder or impossible.