2018-09-05 16:53:09 +03:00
|
|
|
package main
|
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
import (
|
2018-09-20 15:41:24 +03:00
|
|
|
"fmt"
|
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
"github.com/gopherjs/gopherjs/js"
|
2018-09-20 15:41:24 +03:00
|
|
|
"github.com/status-im/simulation/propagation"
|
2018-09-17 22:11:04 +03:00
|
|
|
)
|
2018-09-05 16:53:09 +03:00
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
func (w *WebGLScene) animate() {
|
|
|
|
if w.renderer == nil {
|
2018-09-05 16:53:09 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
w.controls.Update()
|
2018-09-05 16:53:09 +03:00
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
js.Global.Call("requestAnimationFrame", w.animate)
|
2018-09-05 16:53:09 +03:00
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
if w.autoRotate {
|
2018-09-20 20:38:43 +03:00
|
|
|
pos := w.graphGroup.Object.Get("rotation")
|
2018-09-17 22:11:04 +03:00
|
|
|
pos.Set("y", pos.Get("y").Float()+float64(0.001))
|
2018-09-05 16:53:09 +03:00
|
|
|
}
|
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
w.renderer.Render(w.scene, w.camera)
|
2018-09-05 16:53:09 +03:00
|
|
|
}
|
|
|
|
|
2018-09-17 22:11:04 +03:00
|
|
|
// ToggleAutoRotation switches auto rotation option.
|
|
|
|
func (w *WebGLScene) ToggleAutoRotation() {
|
|
|
|
w.autoRotate = !w.autoRotate
|
2018-09-05 16:53:09 +03:00
|
|
|
}
|
2018-09-20 15:41:24 +03:00
|
|
|
|
|
|
|
// AnimatePropagation visualizes propagation of message based on plog.
|
|
|
|
func (w *WebGLScene) AnimatePropagation(plog *propagation.Log) {
|
|
|
|
fmt.Println("Animating plog")
|
|
|
|
}
|