stevenpetryk / mafs

React components for interactive math
https://mafs.dev
MIT License
3.23k stars 87 forks source link

WebGL component #64

Open stevenpetryk opened 1 year ago

stevenpetryk commented 1 year ago

I think it'd be nice to add some sort of API for easily integrating webgl/threejs/react-three-fiber if someone wants to embed some really performance-intensive stuff into Mafs.

Much like the Mafs SVG stuff, this would really just be a matter of making sure that a WebGL canvas "has its bearings" and knows how to map things from coordinate space to pixel space.

An interesting idea would be to move Function and VectorField to WebGL to improve performance. VectorField would especially benefit. We do, however, lose server side rendering with that approach.

Side-note: I would never want Mafs to be pure WebGL, because it's really difficult to make that accessible. I enjoy how Mafs is keyboard accessible by default at the moment.

debater-coder commented 1 year ago

Possible WebGPU support?

stevenpetryk commented 1 year ago

Possible WebGPU support?

Something in particular you had in mind?

debater-coder commented 1 year ago

Either through three.js or a raw implementation (WebGPU makes this actually feasible as it is less painful to work with directly). Not sure if there is much computation to GPU accelerate, but the graphics could definitely benefit.

stevenpetryk commented 1 year ago

The only computation worth GPU accelerating would be function plotting/sampling, but doing that on the GPU would require Mafs users to write their function in shader code.