forked from Lngramos/three
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgeometries_circle_geometry.go
More file actions
58 lines (51 loc) · 1.22 KB
/
geometries_circle_geometry.go
File metadata and controls
58 lines (51 loc) · 1.22 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package three
//go:generate go run geometry_method_generator/main.go -geometryType SphereGeometry -geometrySlug sphere_geometry
import (
"math"
"github.com/gopherjs/gopherjs/js"
)
type SphereGeometry struct {
*js.Object
Radius float64 `js:"radius"`
Segments float64 `js:"segments"`
ThetaStart float64 `js:"thetaStart"`
ThetaLength float64 `js:"thetaLength"`
}
type SphereGeometryParameters struct {
Radius float64
WidthSegments float64
HeightSegments float64
ThetaStart float64
ThetaLength float64
PhiStart float64
PhiLength float64
}
// NewSphereGeometry creates a new BoxGeometry.
func NewSphereGeometry(params SphereGeometryParameters) SphereGeometry {
if params.ThetaLength == 0 {
params.ThetaLength = math.Pi
}
if params.PhiLength == 0 {
params.PhiLength = 2 * math.Pi
}
if params.WidthSegments == 0 {
params.WidthSegments = 8
}
if params.HeightSegments == 0 {
params.HeightSegments = 6
}
if params.Radius == 0 {
params.Radius = 1
}
return SphereGeometry{
Object: three.Get("SphereGeometry").New(
params.Radius,
params.WidthSegments,
params.HeightSegments,
params.PhiStart,
params.PhiLength,
params.ThetaStart,
params.ThetaLength,
),
}
}