show animation speed

This commit is contained in:
Stewart Allen 2020-11-29 10:04:13 -05:00
commit b1c8feb319
4 changed files with 34 additions and 10 deletions

View file

@ -1278,7 +1278,7 @@
tracker = $('tracker'),
controller = settings().controller;
// UC.setHoverPop(controller.hoverPop);
UC.setHoverPop(false);
WIN.addEventListener("resize", () => {
API.event.emit('resize');

View file

@ -8,7 +8,10 @@ self.kiri.loader.push(function() {
CAM = KIRI.driver.CAM,
API, WORLD, SPACE,
meshes = {},
speedDef = 20,
speedValues = [ 25, 12, 6, 3 ],
speedNames = [ "1x", "2x", "4x", "8x" ],
speedIndex = 0,
speedLabel,
speed;
// ---( CLIENT FUNCTIONS )---
@ -36,19 +39,28 @@ self.kiri.loader.push(function() {
layer.innerHTML = '';
UC.setGroup(layer);
UC.newRow([
UC.newButton(null,replay,{icon:'<i class="fas fa-step-backward"></i>'}),
UC.newButton(null,replay,{icon:'<i class="fas fa-fast-backward"></i>'}),
UC.newButton(null,play,{icon:'<i class="fas fa-play"></i>'}),
UC.newButton(null,step,{icon:'<i class="fas fa-step-forward"></i>'}),
UC.newButton(null,fast,{icon:'<i class="fas fa-forward"></i>'}),
UC.newButton(null,pause,{icon:'<i class="fas fa-pause"></i>'})
UC.newButton(null,fast,{icon:'<i class="fas fa-fast-forward"></i>'}),
UC.newButton(null,pause,{icon:'<i class="fas fa-pause"></i>'}),
speedLabel = UC.newLabel("speed")
]);
speed = speedDef;
updateSpeed();
setTimeout(() => {
play({steps: 1});
}, delay || 0);
});
};
function updateSpeed(inc = 0) {
if (inc > 0) {
speedIndex = (speedIndex + inc) % speedValues.length;
}
speed = speedValues[speedIndex];
speedLabel.innerText = speedNames[speedIndex];
}
function replay() {
CAM.animate_clear(API);
setTimeout(() => {
@ -118,19 +130,19 @@ self.kiri.loader.push(function() {
function step(opts) {
const { steps } = opts;
updateSpeed();
KIRI.client.animate({speed, steps: 1}, handleGridUpdate);
}
function play(opts) {
const { steps } = opts;
speed = speedDef;
updateSpeed();
KIRI.client.animate({speed, steps: steps || Infinity}, handleGridUpdate);
}
function fast(opts) {
const { steps } = opts;
speed = speed / 2;
if (speed < 5) speed = speedDef;
updateSpeed(1);
KIRI.client.animate({speed, steps: steps || Infinity}, handleGridUpdate);
}