diff --git a/.gitignore b/.gitignore index 595ab3c..0ff1f73 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ /examples/**/*.js.map !/examples/_vendor/*.js examples/basic/basic + +# Jetbrains +*.idea diff --git a/gen_geometry_ring_geometry.go b/gen_geometry_ring_geometry.go new file mode 100644 index 0000000..65d574a --- /dev/null +++ b/gen_geometry_ring_geometry.go @@ -0,0 +1,113 @@ +package three +// Code generated by go generate; DO NOT EDIT. +// +// using the following cmd: +// geometry_method_generator -geometryType RingGeometry -geometrySlug ring_geometry + +import "github.com/gopherjs/gopherjs/js" + +func (g RingGeometry) ApplyMatrix(matrix *Matrix4) { + g.Object.Call("applyMatrix", matrix) +} + +func (g RingGeometry) RotateX() { + g.Object.Call("rotateX") +} + +func (g RingGeometry) RotateY() { + g.Object.Call("rotateY") +} + +func (g RingGeometry) RotateZ() { + g.Object.Call("rotateZ") +} + +func (g RingGeometry) Translate() { + g.Object.Call("translate") +} + +func (g RingGeometry) Scale() { + g.Object.Call("scale") +} + +func (g RingGeometry) LookAt() { + g.Object.Call("lookAt") +} + +func (g RingGeometry) FromBufferGeometry(geometry Geometry) { + g.Object.Call("fromBufferGeometry") +} + +func (g RingGeometry) Center() { + g.Object.Call("center") +} + +func (g RingGeometry) Normalize() RingGeometry { + g.Object.Call("normalize") + return g +} + +func (g RingGeometry) ComputeFaceNormals() { + g.Object.Call("computeFaceNormals") +} + +func (g RingGeometry) ComputeVertexNormals(areaWeighted bool) { + g.Object.Call("computeVertexNormals", areaWeighted) +} + +func (g RingGeometry) ComputeFlatVertexNormals() { + g.Object.Call("computeFlatVertexNormals") +} + +func (g RingGeometry) ComputeMorphNormals() { + g.Object.Call("computeMorphNormals") +} + +func (g RingGeometry) ComputeLineDistances() { + g.Object.Call("computeLineDistances") +} + +func (g RingGeometry) ComputeBoundingBox() { + g.Object.Call("computeBoundingBox") +} + +func (g RingGeometry) ComputeBoundingSphere() { + g.Object.Call("computeBoundingSphere") +} + +func (g RingGeometry) Merge(geometry Geometry, matrix Matrix4, materialIndexOffset float64) { + g.Object.Call("merge", geometry, matrix, materialIndexOffset) +} + +func (g RingGeometry) MergeMesh(mesh Mesh) { + g.Object.Call("mergeMesh", mesh.getInternalObject()) +} + +func (g RingGeometry) MergeVertices() { + g.Object.Call("mergeVertices") +} + +func (g RingGeometry) SortFacesByMaterialIndex() { + g.Object.Call("sortFacesByMaterialIndex") +} + +func (g RingGeometry) ToJSON() interface{} { + return g.Object.Call("toJSON") +} + +// func (g RingGeometry) Clone() RingGeometry { +// return g.Object.Call("clone") +// } + +func (g RingGeometry) Copy(source Object3D, recursive bool) *RingGeometry { + return &RingGeometry{Object: g.getInternalObject().Call("copy", source.getInternalObject(), recursive)} +} + +func (g RingGeometry) Dispose() { + g.Object.Call("dispose") +} + +func (g RingGeometry) getInternalObject() *js.Object { + return g.Object +} + diff --git a/geometries_ring_geometry.go b/geometries_ring_geometry.go new file mode 100644 index 0000000..5c85c1b --- /dev/null +++ b/geometries_ring_geometry.go @@ -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 + } + 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, + ), + } +}