工程造价信息价在什么网站查,泗阳网站建设公司,wordpress无刷新,河南建设安全监督网站目录 说在前面安装测试 说在前面 操作系统#xff1a;win 11go version#xff1a;go1.21.5 windows/amd64g3n版本#xff1a;github.com/g3n/engine v0.2.0其他#xff1a;找了下golang 3d相关的库#xff0c;目前好像就这个比较活跃 安装
按照官方教程所说#xff0c;… 目录 说在前面安装测试 说在前面 操作系统win 11go versiongo1.21.5 windows/amd64g3n版本github.com/g3n/engine v0.2.0其他找了下golang 3d相关的库目前好像就这个比较活跃 安装
按照官方教程所说需要mingw环境首先按照教程去下载 We tested the Windows build using the mingw-w64 toolchain (you can download this file in particular). 下载后将文件解压并添加环境变量(主要是bin、include、lib) 然后下载g3n源代码git clone https://github.com/g3n/engine g3n-engine同样添加下环境变量 重启然后可以开始install了cd g3n-engine
go install ./...测试
创建一个空文件加创建一个main.go 文件package mainimport (timegithub.com/g3n/engine/appgithub.com/g3n/engine/cameragithub.com/g3n/engine/coregithub.com/g3n/engine/geometrygithub.com/g3n/engine/glsgithub.com/g3n/engine/graphicgithub.com/g3n/engine/guigithub.com/g3n/engine/lightgithub.com/g3n/engine/materialgithub.com/g3n/engine/math32github.com/g3n/engine/renderergithub.com/g3n/engine/util/helpergithub.com/g3n/engine/window
)func main() {// 创建appa : app.App()// 创建scenescene : core.NewNode()// 设置gui控制器gui.Manager().Set(scene)// 创建相机cam : camera.New(1)cam.SetPosition(0, 0, 3)scene.Add(cam)// 初始化相机控制器camera.NewOrbitControl(cam)// 设置窗口回调onResize : func(evname string, ev interface{}) {// Get framebuffer size and update viewport accordinglywidth, height : a.GetSize()a.Gls().Viewport(0, 0, int32(width), int32(height))// Update the cameras aspect ratiocam.SetAspect(float32(width) / float32(height))}a.Subscribe(window.OnWindowSize, onResize)onResize(, nil)// 添加一个蓝色甜甜圈geom : geometry.NewTorus(1, .4, 12, 32, math32.Pi*2)mat : material.NewStandard(math32.NewColor(DarkBlue))mesh : graphic.NewMesh(geom, mat)scene.Add(mesh)// 添加一个改变甜甜圈颜色的按钮btn : gui.NewButton(Make Red)btn.SetPosition(100, 40)btn.SetSize(40, 40)btn.Subscribe(gui.OnClick, func(name string, ev interface{}) {mat.SetColor(math32.NewColor(DarkRed))})scene.Add(btn)// 添加光照scene.Add(light.NewAmbient(math32.Color{1.0, 1.0, 1.0}, 0.8))pointLight : light.NewPoint(math32.Color{1, 1, 1}, 5.0)pointLight.SetPosition(1, 0, 2)scene.Add(pointLight)// 添加坐标系显示scene.Add(helper.NewAxes(0.5))// 设置灰色背景色a.Gls().ClearColor(0.5, 0.5, 0.5, 1.0)// 运行应用a.Run(func(renderer *renderer.Renderer, deltaTime time.Duration) {a.Gls().Clear(gls.DEPTH_BUFFER_BIT | gls.STENCIL_BUFFER_BIT | gls.COLOR_BUFFER_BIT)renderer.Render(scene, cam)})
}初始化go mod init test
go mod tidy运行go run main.go内存和cpu