Change default FPS to decrease CPU still usage

This commit is contained in:
Ivan Danyliuk 2018-10-20 21:09:30 +02:00
parent be5169c958
commit c7d4a5d014
No known key found for this signature in database
GPG Key ID: 97ED33CE024E1DBF
3 changed files with 20 additions and 13 deletions

View File

@ -12,8 +12,10 @@ const (
// TODO(divan): move this as variables to the frontend
BlinkDecay = 100 * time.Millisecond // time for highlighted node/link to be active
AnimationSlowdown = 1 // slowdown factor for propagation animation
FPS = 20 // default FPS
)
// animate fires up as an requestAnimationFrame handler.
func (w *WebGLScene) animate() {
if w.renderer == nil {
return
@ -21,7 +23,9 @@ func (w *WebGLScene) animate() {
w.controls.Update()
js.Global.Call("requestAnimationFrame", w.animate)
time.AfterFunc((1000/FPS)*time.Millisecond, func() {
js.Global.Call("requestAnimationFrame", w.animate)
})
if w.autoRotate {
pos := w.graphGroup.Object.Get("rotation")

25
whispervis.js generated
View File

@ -162640,23 +162640,26 @@ $packages["github.com/status-im/whispervis"] = (function() {
WebGLScene.ptr.prototype.animate = function() {
var pos, w, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; pos = $f.pos; w = $f.w; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
w = this;
if (w.renderer === ptrType.nil) {
w = [w];
w[0] = this;
if (w[0].renderer === ptrType.nil) {
$s = -1; return;
}
$clone(w.controls, TrackBallControl).Update();
$global.requestAnimationFrame($externalize($methodVal(w, "animate"), funcType));
if (w.autoRotate) {
pos = w.graphGroup.Object.rotation;
$clone(w[0].controls, TrackBallControl).Update();
time.AfterFunc(new time.Duration(0, 50000000), (function(w) { return function() {
$global.requestAnimationFrame($externalize($methodVal(w[0], "animate"), funcType));
}; })(w));
if (w[0].autoRotate) {
pos = w[0].graphGroup.Object.rotation;
pos.y = $parseFloat(pos.y) + 0.001;
}
/* */ if (w.wobble) { $s = 1; continue; }
/* */ if (w[0].wobble) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (w.wobble) { */ case 1:
$r = w.wobbling.Animate(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
w.updatePositions();
/* if (w[0].wobble) { */ case 1:
$r = w[0].wobbling.Animate(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
w[0].updatePositions();
/* } */ case 2:
$clone(w.renderer, three.WebGLRenderer).Render(w.scene, $clone(w.camera, three.PerspectiveCamera));
$clone(w[0].renderer, three.WebGLRenderer).Render(w[0].scene, $clone(w[0].camera, three.PerspectiveCamera));
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: WebGLScene.ptr.prototype.animate }; } $f.pos = pos; $f.w = w; $f.$s = $s; $f.$r = $r; return $f;
};

2
whispervis.js.map generated

File diff suppressed because one or more lines are too long