Skip to content

Commit ff607ec

Browse files
Update README.md
1 parent d062807 commit ff607ec

File tree

1 file changed

+65
-20
lines changed

1 file changed

+65
-20
lines changed

README.md

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,75 @@ This can be used in Mathics front ends like [Mathics-Django](https://pypi.org/pr
88
```js
99
import drawGraphics3D from '@mathicsorg/mathics-threejs-backend';
1010

11-
drawGraphics3D(
12-
document.getElementById('main'),
11+
drawGraphics3D(document.getElementById('main'), {
12+
elements: [
1313
{
14-
elements: [
15-
{
16-
type: 'sphere',
17-
color: [1, 1, 1],
18-
coords: [
19-
[[0, 0, 0]]
20-
]
21-
}
22-
],
23-
lighting: [
24-
{
25-
type: 'ambient',
26-
color: [1, 1, 1]
27-
}
28-
],
29-
viewpoint: [2.6, -4.8, 4.0]
14+
type: 'tube',
15+
color: [0.2, 0.2, 0.2],
16+
coords: [
17+
[null, [0, 0, 0]],
18+
[null, [1, 0, 0]],
19+
[null, [1, 1, 0]],
20+
[null, [1, 1, 1]],
21+
[null, [1, 0, 1]],
22+
[null, [0, 0, 1]],
23+
[null, [0, 1, 1]],
24+
[null, [0, 1, 0]]
25+
],
26+
radius: 0.1
27+
},
28+
{
29+
type: 'uniformPolyhedron',
30+
color: [1, 0.5, 0.5],
31+
coords: [
32+
[[0, 0, 0]],
33+
[[2, 2, 2]]
34+
],
35+
edgeForm: { showEdges: false },
36+
opacity: 0.5, // 50% of opacity
37+
subType: 'dodecahedron'
38+
},
39+
{
40+
type: 'sphere',
41+
color: [0.5, 0.5, 1],
42+
coords: [
43+
[[0, 0, 0]],
44+
[[1, 1, 1]],
45+
[[2, 2, 2]]
46+
],
47+
edgeForm: { showEdges: false },
48+
opacity: 0.7, // 70% of opacity
49+
radius: 0.5,
50+
subType: 'dodecahedron'
51+
}
52+
],
53+
lighting: [
54+
{
55+
type: 'ambient',
56+
color: [0.5, 0.5, 0.5]
57+
},
58+
{
59+
type: 'directional',
60+
color: [0.8, 0, 0],
61+
coords: [null, [2, 0, 2]]
62+
},
63+
{
64+
type: 'directional',
65+
color: [0, 0.8, 0],
66+
coords: [null, [2, 2, 2]]
67+
},
68+
{
69+
type: 'directional',
70+
color: [0, 0, 0.8],
71+
coords: [null, [0, 2, 2]]
3072
}
31-
);
73+
],
74+
viewpoint: [2, -4, 4]
75+
});
3276
```
77+
<p align="center"><a href="https://mathics3.github.io/mathics-threejs-backend/examples/tube-dodecahedrons-and-spheres"><img alt="demonstration" src="https://user-images.githubusercontent.com/62714153/155851002-13b0200b-7835-40f9-8780-97aefb12bac5.gif" /></a></p>
3378

34-
Lots of other examples can be found in the [examples](https://github.com/Mathics3/mathics-threejs-backend/tree/master/examples) directory of this repository.
79+
Lots of other examples can be found in the [examples](https://github.com/Mathics3/mathics-threejs-backend/tree/master/examples) folder of this repository and in the [documentation](https://mathics3.github.io/mathics-threejs-backend/examples).
3580

3681
## Displaying Examples
3782
Install an HTTP server and run it:

0 commit comments

Comments
 (0)