0

I am trying to write a few math equations in 3D with react-three/fiber, and have been looking for a way to get it working with latex.

Currently I have been using the Text3D component in @react-three/drei, have been googling and looking for ways to allow latex, though no luck.

I'm guessing I will be able to do it if I write an equation, export the SVG, then make it into a 3D object. Though it would be nice, if there was a faster way.

Any help is appreciated!

1 Answers1

2

Try this npm package https://www.npmjs.com/package/mathmesh

works for both babylon and three

its not perfect but its something.

Example to use in three js with react fiber:

import {mathmesh} from "mathmesh";
const vertices = mathmesh("\\int_{a}^{b}x^2 \\,dx").vertices;
...
<bufferGeometry >
  <bufferAttribute
        attach='attributes-position'
        array={vertices}
        count={vertices.length / 3}
        itemSize={3}
    /> 
</bufferGeometry>

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158