whispervis/simulation.go

27 lines
510 B
Go
Raw Normal View History

2018-09-11 16:23:37 +03:00
package main
import (
"runtime"
"github.com/gopherjs/vecty"
)
2018-09-11 18:33:28 +03:00
// StartSimulation starts graph layout simulation.
2018-09-11 16:23:37 +03:00
func (p *Page) StartSimulation() {
p.loader.Reset()
p.loaded = false
vecty.Rerender(p)
config := p.forceEditor.Config()
2018-09-17 22:11:04 +03:00
p.loader.SetSteps(config.Steps)
for i := 0; i < config.Steps; i++ {
2018-09-11 16:23:37 +03:00
p.layout.UpdatePositions()
p.loader.Inc()
vecty.Rerender(p.loader)
runtime.Gosched()
}
p.loaded = true
2018-09-17 22:11:04 +03:00
p.webgl.CreateObjects(p.layout.Positions(), p.layout.Links())
2018-09-11 16:23:37 +03:00
vecty.Rerender(p)
}