nicschumann / many-rivers

Home base for work related to simulation and rendering for Many Rivers
https://todoslosriosposibles.com
1 stars 0 forks source link

Refactor #1

Closed nicschumann closed 1 year ago

nicschumann commented 1 year ago

@whoisbma I know we said no documentation needed, but I thought I'd leave a few notes and a few references here, just in case.

Notes

Note: preserveDrawingBuffer

I enabled preserveDrawingBuffer: true in regl. You should now be able to get the contents of the current canvas output as a Uint8Array by calling

// essentially a thin wrapper around gl.readPixels()
let pixels = regl.read();
// pixels is now a Uint8Array instance.

at any point. If you're interested in the contents of a particular framebuffer associated with a simulation variable, you can now get at by:

/** Let's say you want to read the DoubleFramebuffer containing
 * the height map of the simulation, which (in a rendering class like View2d)
 * lives in this.parent.H
 **/
this.parent.H.front.use(async () => {
    let pixels = await regl.read();
   // pixels is now a Float32Array instance
});