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

@ -4,7 +4,6 @@
* `cnc` * `cnc`
* - tracing (chamfer, engrave) * - tracing (chamfer, engrave)
* - auto feature detection (slicing) * - auto feature detection (slicing)
* - show 1x, 2x, 4x speed in animation
* `laser` * `laser`
* - drag knife support * - drag knife support
* `all` * `all`
@ -20,6 +19,8 @@
# - redo automatic supports using faces instead of deltas # - redo automatic supports using faces instead of deltas
# - bind process to z ranges or boxed regions # - bind process to z ranges or boxed regions
# - non-planar actual # - non-planar actual
# `all`
# - improve device list, selection, management, customization
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix

View file

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

View file

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

View file

@ -888,6 +888,17 @@ th, tr, td, label {
color: #333; color: #333;
font-size: 30px; font-size: 30px;
} }
#layer-animate label {
display: inline-flex;
width: 30px;
border-radius: 3px;
border: 1px solid #aaa;
margin: 1px 2px 2px 4px;
justify-content: center;
align-items: center;
font-weight: bold;
background-color: #ddd;
}
#slider { #slider {
display: none; display: none;