add persistence and defaults to cam animation settings
This commit is contained in:
parent
eb85ab002c
commit
48205cb00f
5 changed files with 42 additions and 14 deletions
|
|
@ -47,7 +47,7 @@ kiri.load(() => {
|
|||
$('layer-animate').innerHTML = '';
|
||||
$('layer-toolpos').innerHTML = '';
|
||||
Object.keys(meshes).forEach(id => deleteMesh(id));
|
||||
toggleStock(undefined,true);
|
||||
toggleStock(undefined,true,false);
|
||||
}
|
||||
|
||||
function animate(api, delay) {
|
||||
|
|
@ -72,6 +72,7 @@ kiri.load(() => {
|
|||
modelButton = UC.newButton(null,toggleModel,{icon:'<i class="fa-solid fa-eye"></i>',title:"show model",class:"padleft"}),
|
||||
shadeButton = UC.newButton(null,toggleStock,{icon:'<i class="fa-solid fa-cube"></i>',title:"stock box"}),
|
||||
]);
|
||||
speedIndex = api.local.getInt('cam.anim.speed') || 0;
|
||||
updateSpeed();
|
||||
setTimeout(step, delay || 0);
|
||||
const toolpos = $('layer-toolpos');
|
||||
|
|
@ -82,8 +83,8 @@ kiri.load(() => {
|
|||
api.event.emit('animate', 'CAM');
|
||||
api.alerts.hide(alert);
|
||||
moto.space.platform.showGridBelow(false);
|
||||
toggleModel();
|
||||
toggleStock();
|
||||
toggleModel(0,api.local.getBoolean('cam.anim.model', false));
|
||||
toggleStock(0,api.local.getBoolean('cam.anim.stock', false));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -174,11 +175,13 @@ kiri.load(() => {
|
|||
delete meshes[id];
|
||||
}
|
||||
|
||||
function toggleModel() {
|
||||
api.widgets.all().forEach(w => w.toggleVisibility());
|
||||
function toggleModel(ev,bool) {
|
||||
api.local.toggle('cam.anim.model', bool);
|
||||
api.widgets.all().forEach(w => w.toggleVisibility(bool));
|
||||
}
|
||||
|
||||
function toggleStock(ev,bool) {
|
||||
function toggleStock(ev,bool,set) {
|
||||
set !== false && api.local.toggle('cam.anim.stock', bool);
|
||||
return api.event.emit('cam.stock.toggle', bool ?? undefined);
|
||||
}
|
||||
|
||||
|
|
@ -232,6 +235,7 @@ kiri.load(() => {
|
|||
} else if (inc > 0) {
|
||||
speedIndex = (speedIndex + inc) % speedValues.length;
|
||||
}
|
||||
api.local.set('cam.anim.speed', speedIndex);
|
||||
speed = speedValues[speedIndex];
|
||||
speedLabel.innerText = speedNames[speedIndex];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,17 @@ const tweak = {
|
|||
gcode_decimals(v) { api.work.config({base:{gcode_decimals: v}}) }
|
||||
};
|
||||
|
||||
function localGet(key) {
|
||||
let sloc = api.conf.get().local;
|
||||
return sloc[key] || api.sdb[key];
|
||||
}
|
||||
|
||||
function localSet(key, val) {
|
||||
let sloc = api.conf.get().local;
|
||||
sloc[key] = api.sdb[key] = val;
|
||||
return val;
|
||||
}
|
||||
|
||||
const api = exports({
|
||||
clip: (text) => {
|
||||
navigator.clipboard
|
||||
|
|
@ -84,6 +95,18 @@ const api = exports({
|
|||
feature,
|
||||
devel,
|
||||
tweak,
|
||||
local: {
|
||||
get: (key) => localGet(key),
|
||||
getInt: (key) => parseInt(localGet(key)),
|
||||
getFloat: (key) => parseFloat(localGet(key)),
|
||||
getBoolean: (key, def = true) => {
|
||||
let val = localGet(key);
|
||||
return val === true || val === 'true' || val === def;
|
||||
},
|
||||
toggle: (key, val, def) => localSet(key, val ?? !api.local.getBoolean(key, def)),
|
||||
put: (key, val) => localSet(key, val),
|
||||
set: (key, val) => localSet(key, val),
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -955,7 +955,11 @@ const conf = exports({
|
|||
// widget extra info for slicing (extruder mapping)
|
||||
widget: {},
|
||||
// legacy localStorage settings (like octo print)
|
||||
local: {},
|
||||
local: {
|
||||
'cam.anim.model': false,
|
||||
'cam.anim.stock': false,
|
||||
'cam.anim.speed': 3
|
||||
},
|
||||
mode: 'FDM',
|
||||
id: genID(),
|
||||
ver: CVER
|
||||
|
|
|
|||
|
|
@ -21,14 +21,11 @@ kiri.export = exportFile;
|
|||
let printSeq = parseInt(local['kiri-print-seq'] || local['print-seq'] || "0") + 1;
|
||||
|
||||
function localGet(key) {
|
||||
let sloc = api.conf.get().local;
|
||||
return sloc[key] || local[key];
|
||||
return api.local.get(key);
|
||||
}
|
||||
|
||||
function localSet(key, val) {
|
||||
let sloc = api.conf.get().local;
|
||||
sloc[key] = local[key] = val;
|
||||
return val;
|
||||
return api.local.set(key, val);
|
||||
}
|
||||
|
||||
function exportFile(options) {
|
||||
|
|
|
|||
|
|
@ -371,9 +371,9 @@ class Widget {
|
|||
}
|
||||
}
|
||||
|
||||
toggleVisibility() {
|
||||
toggleVisibility(bool) {
|
||||
const mat = this.getMaterial();
|
||||
mat.visible = !mat.visible;
|
||||
mat.visible = bool ?? !mat.visible;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue