go-three
go-three provides a simple API to create and display animated 3D computer graphics.
Prerequisites
NOTE: Check out the scripts
directory on how to install dependencies.
Installation
Once you have installed the prerequisites you can install the package via go get
:
go get github.com/tobscher/go-three
Usage
package main
import (
"log"
three "github.com/tobscher/go-three"
"github.com/tobscher/go-three/geometries"
)
const (
fov = 75.0
width = 640
height = 480
near = 1
far = 10000
)
func main() {
window, err := three.NewWindow(width, height, "Example")
if err != nil {
log.Fatal(err)
}
renderer, err := three.NewRenderer(window)
if err != nil {
log.Fatal(err)
}
scene := three.NewScene()
camera := three.NewPerspectiveCamera(fov, width/height, near, far)
camera.Transform.TranslateZ(1000)
box := geometries.NewCube(200)
red := three.NewBasicMaterial()
red.SetColor(three.NewColor(1.0, 0.0, 0.0))
mesh := three.NewMesh(box, red)
scene.Add(mesh)
for !window.ShouldClose() {
mesh.Transform.RotateX(0.01)
mesh.Transform.RotateY(0.02)
renderer.Render(scene, camera)
}
renderer.Unload(scene)
renderer.OpenGLSentinel()
}
Documentation
Documentation can be found on godoc.org.
Examples
Examples can be found in the examples/
subdirectory.
Contributing
If you encounter any issues please file an issue.
Pull requests are welcome.