Skip to content

Commit e129e19

Browse files
committed
fix: Implement mesh transform updates via helper function for CI/CD compatibility
The previous fix directly edited the generated app_gen.go file, which would be lost when CI/CD regenerates the code. This commit implements a proper solution that survives code regeneration. Changes: - Created helpers.go with updateMeshTransform() function - Updated app.gx to call helper from renderUpdate callback - Regenerated app_gen.go now calls the helper function - Helper contains the mesh transform update logic The helper function: - Casts rendererInterface to *SceneRenderer - Creates a Transform with current rotation values - Calls UpdateMeshTransform to apply the rotation on every frame This approach works because: 1. helpers.go is not generated, so it won't be overwritten 2. The simple function call in app.gx is supported by the Guix DSL parser 3. Code regeneration preserves the helper function call 4. Both auto-rotation and manual controls now work correctly
1 parent f60fe3f commit e129e19

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

examples/webgpu-cube/app.gx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func App() (Component) {
5353
rotationY = rotationY + (delta * speed)
5454
rotationX = rotationX + (delta * speed * 0.5)
5555
}
56+
updateMeshTransform(rendererInterface, rotationX, rotationY)
5657
}
5758

5859
Div(

examples/webgpu-cube/app_gen.go

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/webgpu-cube/helpers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build js && wasm
2+
3+
package main
4+
5+
import (
6+
"github.com/gaarutyunov/guix/pkg/runtime"
7+
)
8+
9+
// updateMeshTransform updates the mesh transform with the given rotation values
10+
func updateMeshTransform(rendererInterface interface{}, rotationX, rotationY float64) {
11+
if renderer, ok := rendererInterface.(*runtime.SceneRenderer); ok && len(renderer.Meshes) > 0 {
12+
transform := runtime.NewTransform()
13+
transform.Position = runtime.Vec3{X: 0, Y: 0, Z: 0}
14+
transform.Rotation = runtime.Vec3{X: float32(rotationX), Y: float32(rotationY), Z: 0}
15+
transform.Scale = runtime.Vec3{X: 1, Y: 1, Z: 1}
16+
renderer.UpdateMeshTransform(0, transform)
17+
}
18+
}

0 commit comments

Comments
 (0)