Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
/examples/**/*.js.map
!/examples/_vendor/*.js
examples/basic/basic

# Jetbrains
*.idea
113 changes: 113 additions & 0 deletions gen_geometry_ring_geometry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions geometries_ring_geometry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package three

//go:generate go run geometry_method_generator/main.go -geometryType RingGeometry -geometrySlug ring_geometry

import (
"github.com/gopherjs/gopherjs/js"
"math"
)

// RingGeometry is the two-dimensional primitive ring geometry class. It is typically
// used for creating a ring of the dimensions provided with the 'innerRadius', 'outerRadius',
// 'thetaSegments', 'phiSegments', 'thetaStart', and 'thetaLength' constructor arguments.
type RingGeometry struct {
*js.Object

InnerRadius float64 `js:"innerRadius"`
OuterRadius float64 `js:"outerRadius"`
ThetaSegments float64 `js:"thetaSegments"`
PhiSegments float64 `js:"phiSegments"`
ThetaStart float64 `js:"thetaStart"`
ThetaLength float64 `js:"thetaLength"`
}

// RingGeometryParameters .
type RingGeometryParameters struct {
InnerRadius float64
OuterRadius float64
ThetaSegments float64
PhiSegments float64
ThetaStart float64
ThetaLength float64
}

// NewRingGeometry creates a new RingGeometry.
func NewRingGeometry(params *RingGeometryParameters) RingGeometry {
if params.InnerRadius == 0 {
params.ThetaLength = 0.5
}
if params.OuterRadius == 0 {
params.OuterRadius = 1
}
if params.ThetaSegments < 3 {
params.ThetaSegments = 3
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimum is 3, but default is 8 in three.js, so I settled on a default of 3 here, this can be changed, but I didn't think it made a lot of sense to check for less than 3 and then default to 8 after that.

}
if params.PhiSegments < 1 {
params.PhiSegments = 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above for ThetaSegments, the three.js default is 8 with a minimum of 1, so I settled on default of 1 because it didn't make a lot of sense to check for less than 1 and then roll up to a default of 8.

}
if params.ThetaLength == 0 {
params.ThetaLength = 2 * math.Pi
}
return RingGeometry{
Object: three.Get("RingGeometry").New(
params.InnerRadius,
params.OuterRadius,
params.ThetaSegments,
params.PhiSegments,
params.ThetaStart,
params.ThetaLength,
),
}
}