forked from Lngramos/three
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuffer_attrbiute.go
More file actions
31 lines (25 loc) · 1.01 KB
/
buffer_attrbiute.go
File metadata and controls
31 lines (25 loc) · 1.01 KB
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
package three
import "github.com/gopherjs/gopherjs/js"
// BufferAttribute stores data for an attribute (such as vertex positions, face indices, normals, colors, UVs, and any custom attributes) associated with a BufferGeometry, which allows for more efficient passing of data to the GPU.
type BufferAttribute struct {
*js.Object
Array []int `js:"array"`
Count int `js:"count"`
IsDynamic bool `js:"dynamic"`
ItemSize int `js:"itemSize"`
NeedsUpdate bool `js:"needsUpdate"`
Normalized bool `js:"normalized"`
}
// NewBufferAttribute creates a new BufferAttribute
func NewBufferAttribute(data []float32, itemSize int) *BufferAttribute {
return &BufferAttribute{
Object: three.Get("BufferAttribute").New(data, itemSize),
}
}
// SetXYZ sets the x, y and z components of the vector at the given index.
func (b BufferAttribute) SetXYZ(i int, x, y, z float64) {
b.Call("setXYZ", i, float32(x), float32(y), float32(z))
}
func (b BufferAttribute) GetX(i int) float64 {
return b.Call("getX", i).Float()
}