-
Notifications
You must be signed in to change notification settings - Fork 6
/
util.go
53 lines (45 loc) · 1009 Bytes
/
util.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
46
47
48
49
50
51
52
package collada
import (
"regexp"
"strconv"
"strings"
)
func (uri *Uri) Id() (Id, bool) {
idPattern, _ := regexp.Compile("#([\\w-]+)")
matches := idPattern.FindStringSubmatch(string(*uri))
if matches != nil {
return Id(matches[1]), true
}
return Id(""), false
}
func (node *Node) HasGeometry() bool {
return len(node.InstanceGeometry) > 0
}
func (values *Values) Components() []string {
return strings.Split(values.V, " ")
}
func (ints *Ints) I() []int {
ss := ints.Values.Components()
vs := make([]int, len(ss))
for i, value := range ss {
vs[i], _ = strconv.Atoi(value)
}
return vs
}
func (floats *Floats) F() []float64 {
ss := floats.Components()
vs := make([]float64, len(ss))
for i, value := range ss {
vs[i], _ = strconv.ParseFloat(value, 64)
}
return vs
}
func (floats *Floats) F32() []float32 {
ss := floats.Components()
vs := make([]float32, len(ss))
for i, value := range ss {
f, _ := strconv.ParseFloat(value, 32)
vs[i] = float32(f)
}
return vs
}