elm-3d-scene
elm-3d-scene copied to clipboard
Add Scene3d.Cache type for WebGL rendering
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 in view
to actually render as WebGL.
This system would have many benefits:
- Can support dynamic levels of detail transparently for analytical shapes like spline curves, extruded/revolved surfaces etc: generate meshes with different levels of accuracy on the fly as needed
- Similarly, can separate construction of a scene from curves/surfaces from the decision of what accuracy to render at
- In some cases, meshing can be avoided entirely: for example, if the scene is actually encoded as JSON or in a particular file format to be rendered on a server and sent back as an image/streaming video etc.
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.
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