generated from soypat/go-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
414 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"math" | ||
"runtime" | ||
|
||
"github.com/soypat/glgl/math/ms3" | ||
"github.com/soypat/gsdf" | ||
"github.com/soypat/gsdf/forge/threads" | ||
"github.com/soypat/gsdf/glbuild" | ||
"github.com/soypat/gsdf/gsdfaux" | ||
) | ||
|
||
func init() { | ||
runtime.LockOSThread() | ||
} | ||
|
||
// scene generates the 3D object for rendering. | ||
func scene() (glbuild.Shader3D, error) { | ||
const L, shank = 8, 3 | ||
threader := threads.ISO{D: 3, P: 0.5, Ext: true} | ||
M3, err := threads.Bolt(threads.BoltParams{ | ||
Thread: threader, | ||
Style: threads.NutHex, | ||
TotalLength: L + shank, | ||
ShankLength: shank, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
M3, _ = gsdf.Rotate(M3, 2.5*math.Pi/2, ms3.Vec{X: 1, Z: 0.1}) | ||
return M3, nil | ||
} | ||
|
||
func main() { | ||
shape, err := scene() | ||
shape = gsdf.Scale(shape, 0.3) | ||
if err != nil { | ||
log.Fatal("creating scene:", err) | ||
} | ||
err = gsdfaux.UI(shape, gsdfaux.UIConfig{ | ||
Width: 800, | ||
Height: 600, | ||
}) | ||
if err != nil { | ||
log.Fatal("UI:", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build tinygo || !cgo | ||
|
||
package gsdfaux | ||
|
||
import "github.com/soypat/gsdf/glbuild" | ||
|
||
func ui(s glbuild.Shader3D, cfg UIConfig) error { | ||
return errors.new("require cgo for UI rendering") | ||
} |
Oops, something went wrong.