-
Notifications
You must be signed in to change notification settings - Fork 5
/
geom_ethereum.go
45 lines (38 loc) · 883 Bytes
/
geom_ethereum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import "github.com/divan/three"
// NewEthereumGeometry creates a geometry for representing Ethereum node (non-regular 3D octahedron).
// It scales object according to the given scale.
func NewEthereumGeometry(scale float64) three.Geometry {
var geom = three.NewBasicGeometry(three.BasicGeometryParams{})
vertices := []struct {
x, y, z float64
}{
{scale * 1.0, 0.0, 0.0},
{scale * -1.0, 0.0, 0.0},
{0.0, scale * 1.5, 0.0},
{0.0, scale * -1.5, 0.0},
{0.0, 0.0, scale * 1.0},
{0.0, 0.0, scale * -1.0},
}
for _, v := range vertices {
geom.AddVertice(v.x, v.y, v.z)
}
faces := []struct {
a, b, c int
}{
{0, 2, 4},
{0, 4, 3},
{0, 3, 5},
{0, 5, 2},
{1, 2, 5},
{1, 5, 3},
{1, 3, 4},
{1, 4, 2},
}
for _, f := range faces {
geom.AddFace(f.a, f.b, f.c)
}
geom.ComputeBoundingSphere()
geom.ComputeFaceNormals()
return geom
}