Open ianmackenzie opened 5 years ago
Could probably just call the cache type Scene3d
, with an API like
-- Create an empty scene
Scene3d.init : Scene3d
-- Update a scene to include the given scene graph (drawable), reusing
-- cached meshes or generating new meshes as needed
Scene3d.update : List Light -> Camera -> Drawable -> Scene3d -> Scene3d
-- Render the cached meshes using WebGL
Scene3d.view : Scene3d -> Html msg
-- Could then also have export-to-file functions like
Scene3d.toCollada : Scene3d -> String
This would contain generated WebGL meshes at varying levels of detail, and would be updated in an app's
update
function based on a 3D scene, a camera position, a desired rendering accuracy (in pixels), and possibly a caching strategy (to determine when generated meshes should be discarded). The cache would then be used inview
to actually render as WebGL.This system would have many benefits:
Having a cache system would likely mean that individual drawables should have a pre-computed hash of their content, to be used as an ID for looking up corresponding meshes in the cache.