-
Notifications
You must be signed in to change notification settings - Fork 7
Added Ring Geometry #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,6 @@ | |
| /examples/**/*.js.map | ||
| !/examples/_vendor/*.js | ||
| examples/basic/basic | ||
|
|
||
| # Jetbrains | ||
| *.idea | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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 | ||
| } | ||
| if params.PhiSegments < 1 { | ||
| params.PhiSegments = 1 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
| ), | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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.