@@ -20,14 +20,22 @@ type SceneRenderer struct {
2020 AmbientLight * Light
2121}
2222
23+ // ReactiveBinding holds pointers to values that should be synced to transform
24+ type ReactiveBinding struct {
25+ RotationX * float64
26+ RotationY * float64
27+ RotationZ * float64
28+ }
29+
2330// MeshInstance represents an instantiated mesh with buffers
2431type MeshInstance struct {
25- Transform Transform
26- Geometry Geometry
27- Material * Material
28- VertexBuffer * GPUBuffer
29- IndexBuffer * GPUBuffer
30- IndexCount int
32+ Transform Transform
33+ Geometry Geometry
34+ Material * Material
35+ VertexBuffer * GPUBuffer
36+ IndexBuffer * GPUBuffer
37+ IndexCount int
38+ ReactiveBinding * ReactiveBinding // Reactive binding for auto-updates
3139}
3240
3341// NewSceneRenderer creates a new scene renderer
@@ -160,13 +168,22 @@ func (sr *SceneRenderer) createMeshInstance(node *GPUNode) (*MeshInstance, error
160168 }
161169 }
162170
171+ // Check for reactive binding
172+ var binding * ReactiveBinding
173+ if node .Properties != nil {
174+ if b , ok := node .Properties ["bindRotation" ].(* ReactiveBinding ); ok {
175+ binding = b
176+ }
177+ }
178+
163179 return & MeshInstance {
164- Transform : node .Transform ,
165- Geometry : node .Geometry ,
166- Material : material ,
167- VertexBuffer : vertexBuffer ,
168- IndexBuffer : indexBuffer ,
169- IndexCount : len (indices ),
180+ Transform : node .Transform ,
181+ Geometry : node .Geometry ,
182+ Material : material ,
183+ VertexBuffer : vertexBuffer ,
184+ IndexBuffer : indexBuffer ,
185+ IndexCount : len (indices ),
186+ ReactiveBinding : binding ,
170187 }, nil
171188}
172189
@@ -227,8 +244,28 @@ func (sr *SceneRenderer) createPipeline() error {
227244 return nil
228245}
229246
247+ // syncReactiveBindings updates mesh transforms from reactive bindings
248+ func (sr * SceneRenderer ) syncReactiveBindings () {
249+ for _ , mesh := range sr .Meshes {
250+ if binding := mesh .ReactiveBinding ; binding != nil {
251+ if binding .RotationX != nil {
252+ mesh .Transform .Rotation .X = float32 (* binding .RotationX )
253+ }
254+ if binding .RotationY != nil {
255+ mesh .Transform .Rotation .Y = float32 (* binding .RotationY )
256+ }
257+ if binding .RotationZ != nil {
258+ mesh .Transform .Rotation .Z = float32 (* binding .RotationZ )
259+ }
260+ }
261+ }
262+ }
263+
230264// Render renders the scene
231265func (sr * SceneRenderer ) Render () {
266+ // Sync reactive bindings before rendering
267+ sr .syncReactiveBindings ()
268+
232269 if sr .ActiveCamera == nil {
233270 logError ("No active camera in scene" )
234271 return
0 commit comments