-
Notifications
You must be signed in to change notification settings - Fork 1
/
geometries_basic_geometry.go
43 lines (34 loc) · 1.19 KB
/
geometries_basic_geometry.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
//go:build TODO
package three
//go:generate go run codegen/geometry_method_generator/main.go -typeName BasicGeometry -typeSlug basic_geometry
import "syscall/js"
// BasicGeometry is the basic primitive geometry class. It's a counterpart of three.js' core/Geometry object.
//
// DEPRECATED: Not in documentation at https://threejs.org/docs/index.html.
type BasicGeometry struct {
*js.Object
}
type BasicGeometryParams struct {
}
// NewBasicGeometry creates a new Basic Geometry.
func NewBasicGeometry(params BasicGeometryParams) BasicGeometry {
return BasicGeometry{
Object: three.Get("Geometry").New(),
}
}
// AddVertex adds new vertex to the geometry, specified by its coordinates.
func (bg *BasicGeometry) AddVertex(x, y, z float64) {
vec := NewVector3(x, y, z)
bg.Get("vertices").Call("push", vec)
}
// AddVertices adds new vertices to the geometry.
func (bg *BasicGeometry) AddVertices(v ...Vector3) {
for i := range v {
bg.Get("vertices").Call("push", v[i])
}
}
// AddFace adds new Face3 (triangle) to the geometry, specified by its vertice indicies.
func (bg *BasicGeometry) AddFace(a, b, c int) {
face := NewFace3(float64(a), float64(b), float64(c))
bg.Get("faces").Call("push", face)
}