Written in JS parser and drawer allow to export or embed to web pages 3D graphics from Wolfram notebook.
Unlike other build-in export functions it recreates pure Mathematica's functions like Sphere[], GraphicsComplex[], Polygon[] and etc. See disscussion at https://mathematica.stackexchange.com/a/215025/53728.
Some parts of the code which is responsible for rotation, zoom, dragging objects and lighting system were taken from Mathics project. The home page of Mathics is http://mathics.github.io.
https://jerryi.github.io/Mathematica-ThreeJS-graphics-engine/
- Plot some graphics (used a low-poly mode for smaller code, see
Example.nb)
Graphics3D[{
SphericalPlot3D[
2 SphericalHarmonicY[2, 0, t, p], {t, 0, Pi}, {p, 0, 2 Pi},
PerformanceGoal -> "Speed"][[1]],
Opacity[0.6],
Tetrahedron[{{1, 1, 1}, {-1, -1, 1}, {1, -1, -1}, {-1, 1, -1}}]
}]- Export as a JSON string
ExportString[%//N, "ExpressionJSON"][
"Graphics3D",
[
"List",
[
"GraphicsComplex",
[
"List",
["List",
0.0,
0.0,
1.2615662610100797
]
,
["List",
0.0,
0.0,
1.2615662610100797
]
,...- Copy and paste it to data.js (must be simplified!)
//\data.js
var JSONThree = [...- Run
index.html
Drag - rotate;
Ctrl+Drag - zoom;
Shift+Drag - drag;
Please feel encouraged to contribute and expand features.
There a lot a functions which are not implemented such as Style[], Tube[], Ball[], Cone[], BezierCurve[]...
Currently the minimum necessary set for the functioning of SphericalPlot3D, Plot3D is already done
Graphics3D- supported without styling, themes, custom lightingList- supportedGraphicsGroup- supportedRGBColor- supportedOpacity- supportedRGBColor- supportedTube- renders like arrowsSphere- supportedCenter- supportedTetrahedron- supportedGeometricTransformation- fully supportedGraphicsComplex- supportedPolygon- fully supportedLine- supported
Project is released under the GNU General Public License (GPL).