mathics-threejs-backend
mathics-threejs-backend copied to clipboard
Add support for `ExpressionJSON`
As @rocky said we should add support to ExpressionJSON.
I just need some examples to see how ExpressionJSON is with Graphics3D, maybe @mmatera could help here?
Something like this:
In[4]:= ExportString[Graphics3D[{Sphere[]}],"ExpressionJSON"]
Out[4]= [
"Graphics3D",
[
"List",
[
"Sphere",
[
"List",
0,
0,
0
]
]
]
]
In[4]:=ExportString[Plot3D[x*y,{x,0,2},{y,0,2}],"ExpressionJSON"]
Out[4]=
[
"Graphics3D",
[
"GraphicsComplex",
[
"List",
["List",
1.4285714285714285e-7,
1.4285714285714285e-7,
2.040816326530612e-14
]
,...
],
[
"List",
[
"List",
[
"List",
[
"EdgeForm"
],
[
"Directive",
[
"Specularity",
[
"GrayLevel",
1
],
3
],
[
"RGBColor",
0.880722,
0.611041,
0.142051
],
[
"Rule",
"Lighting",
[
"List",
[
"List",
"'Ambient'",
[
"RGBColor",
0.30100577,
0.22414668499999998,
9.0484535e-2
]
],
[
"List",
"'Directional'",
[
"RGBColor",
0.2642166,
0.18331229999999998,
4.261530000000001e-2
],
[
"ImageScaled",
[
"List",
0,
2,
2
]
]
],
[
"List",
"'Directional'",
[
"RGBColor",
0.2642166,
0.18331229999999998,
4.261530000000001e-2
],
[
"ImageScaled",
[
"List",
2,
2,
2
]
]
],
[
"List",
"'Directional'",
[
"RGBColor",
0.2642166,
0.18331229999999998,
4.261530000000001e-2
],
[
"ImageScaled",
[
"List",
2,
0,
2
]
]
]
]
]
],
[
"GraphicsGroup",
[
"Annotation",
[
"List",
[
"Polygon",
[
"List",
["List",
689,
17,
473
]
,
["List",
561,
89,
338
]
,...
]
],
[
"Polygon",
[
"List",
["List",
831,
144,
600,
1271
]
,...
]
],
[
"Polygon",
[
"List",
["List",
960,
570,
1260,
794,
795
]
,...
]
]
],
"'Charting`Private`Tag$855#1'"
]
]
],
[
"List"
],
[
"List"
],
[
"List"
],
[
"List"
]
],
[
"List",
[
"List",
[
"GrayLevel",
0
],
[
"Line",
[
"List",
246,
1,...
]
]
],...
[
"List"
],
[
"List"
]
]
],
[
"Rule",
"VertexNormals",
[
"List",
["List",
-1.428571428571399e-7,
-1.428571428571399e-7,
0.9999999999999796
]
, ...
]
]
],
[
"List",
[
"Rule",
"DisplayFunction",
"Identity"
],
[
"Rule",
"Ticks",
[
"List",
"Automatic",
"Automatic",
"Automatic"
]
],
[
"Rule",
"FaceGrids",
"None"
],
[
"Rule",
"DisplayFunction",
"Identity"
],
[
"Rule",
"Axes",
true
],
[
"Rule",
"AxesLabel",
[
"List",
"None",
"None",
"None"
]
],
[
"Rule",
"AxesOrigin",
[
"List",
"Automatic",
"Automatic",
"Automatic"
]
],
[
"Rule",
"BoxRatios",
[
"List",
1,
1,
0.4
]
],
[
"RuleDelayed",
"DisplayFunction",
"Identity"
],
[
"Rule",
"FaceGridsStyle",
"Automatic"
],
[
"Rule",
"Method",
[
"List",
[
"Rule",
"'DefaultBoundaryStyle'",
[
"Directive",
[
"GrayLevel",
0.3
]
]
],
[
"Rule",
"'RotationControl'",
"'Globe'"
]
]
],
[
"Rule",
"PlotRange",
[
"List",
[
"List",
0,
2
],
[
"List",
0,
2
],
[
"List",
0.0,
3.9999994285714493
]
]
],
[
"Rule",
"PlotRangePadding",
[
"List",
[
"Scaled",
2.0e-2
],
[
"Scaled",
2.0e-2
],
[
"Scaled",
2.0e-2
]
]
],
[
"Rule",
"Ticks",
[
"List",
"Automatic",
"Automatic",
"Automatic"
]
]
]
]
Essentially, is just as any ExpressionJSON: first takes the FullForm of the expression, and then builds a javascript nested list.
@mmatera thanks!
Essentially, is just as any ExpressionJSON: first takes the FullForm of the expression, and then builds a javascript nested list.
Yes, it looks like just a list of the element name and its leaves.
See:
- https://mathematica.stackexchange.com/a/215025/21734