remove decimation on save. fix showGrid persistence

This commit is contained in:
Stewart Allen 2023-01-07 14:28:29 -05:00
commit b4321197c7
5 changed files with 11 additions and 62 deletions

View file

@ -738,7 +738,6 @@ const conf = exports({
exportLocal: false,
exportThumb: false,
exportPreview: false,
decimate: true,
detail: "50",
animesh: "800",
healMesh: false,

View file

@ -9,22 +9,16 @@ gapp.register("kiri.files", [], (root, exports) => {
const { kiri } = self;
class Files {
constructor(indexdb, options) {
constructor(indexdb) {
let store = this;
this.db = indexdb;
this.files = {};
this.listeners = [];
this.options = options || {};
this.deferredHandler = null;
this.concurrent = 0;
this.refresh();
}
setOptions(options) {
this.options = options;
return this;
}
get index() {
return this.db;
}
@ -61,16 +55,6 @@ class Files {
this.listeners.remove(listener);
};
decimate(vertices, callback) {
let options = this.options;
if (vertices.length < (options.threshold || 500000)) {
return callback(vertices);
}
kiri.client.decimate(vertices, this.options, function(reply) {
callback(reply);
});
};
setDeferredHandler(handler) {
this.deferredHandler = handler;
};
@ -109,14 +93,6 @@ class Files {
};
return pdb.put('files', store.files);
})
.then(() => {
return new Promise((resolve,reject) => {
store.decimate(vertices, resolve);
});
})
.then(decimated => {
return pdb.put(`fdec-${name}`, decimated)
})
.then(ondone)
.catch(ondone);
};
@ -133,15 +109,10 @@ class Files {
store.files[newname] = store.files[name];
delete store.files[name];
saveFileList(store);
store.db.remove(`fdec-${name}`);
store.db.remove(`file-${name}`);
callback(error.length ? {error} : {});
}
}
store.db.get(`fdec-${name}`, (vertices) => {
if (!vertices) return complete(false, 'no decimation');
store.db.put(`fdec-${newname}`, vertices, complete);
});
store.db.get(`file-${name}`, (vertices) => {
if (!vertices) return complete(false, 'no raw file');
store.db.put(`file-${newname}`, vertices, complete);
@ -159,21 +130,8 @@ class Files {
if (store.deferredHandler) return store.deferredHandler(rec.deferred, name, callback);
return callback();
}
this.db.get('fdec-'+name, function(vertices) {
if (vertices) {
this.db.get('file-'+name, function(vertices) {
callback(vertices);
} else {
store.db.get('file-'+name, function(vertices) {
if (vertices) {
store.decimate(vertices, function(decimated) {
store.db.put('fdec-'+name, decimated);
callback(vertices);
});
} else {
return callback();
}
});
}
});
};
@ -185,7 +143,6 @@ class Files {
let store = this;
if (store.files[name]) {
delete store.files[name];
store.db.remove('fdec-'+name);
store.db.remove('file-'+name, function(ok) {
saveFileList(store);
if (callback) callback(ok);
@ -217,8 +174,8 @@ function notifyFileListeners(store) {
}
}
kiri.openFiles = function(indexdb, options) {
return new Files(indexdb, options);
kiri.openFiles = function(indexdb) {
return new Files(indexdb);
};
});

View file

@ -194,7 +194,6 @@ gapp.register("kiri.init", [], (root, exports) => {
control.exportLocal = ui.exportLocal.checked;
control.exportThumb = ui.exportThumb.checked;
control.exportPreview = ui.exportPreview.checked;
control.decimate = ui.decimate.checked;
control.healMesh = ui.healMesh.checked;
control.threaded = setThreaded(ui.threaded.checked);
control.assembly = ui.assembly.checked;
@ -204,9 +203,6 @@ gapp.register("kiri.init", [], (root, exports) => {
// platform.layout();
api.conf.save();
api.platform.update_size();
api.catalog.setOptions({
maxpass: control.decimate ? 10 : 0
});
uc.setHoverPop(false);
updateStats();
if (control.decals && !control.dark) {
@ -1803,7 +1799,6 @@ gapp.register("kiri.init", [], (root, exports) => {
parts: uc.newGroup(LANG.pt_menu, $('prefs-prt'), {inline: true}),
detail: uc.newSelect(LANG.pt_qual_s, {title: LANG.pt_qual_l, action: detailSave}, "detail"),
decimate: uc.newBoolean(LANG.pt_deci_s, booleanSave, {title: LANG.pt_deci_l}),
healMesh: uc.newBoolean(LANG.pt_heal_s, booleanSave, {title: LANG.pt_heal_l}),
threaded: uc.newBoolean(LANG.pt_thrd_s, booleanSave, {title: LANG.pt_thrd_l, modes:FDM_SLA}),
assembly: uc.newBoolean(LANG.pt_assy_s, booleanSave, {title: LANG.pt_assy_l, modes:FDM_SLA}),
@ -2679,7 +2674,6 @@ gapp.register("kiri.init", [], (root, exports) => {
ui.antiAlias.checked = control.antiAlias;
ui.reverseZoom.checked = control.reverseZoom;
ui.autoSave.checked = control.autoSave;
ui.decimate.checked = control.decimate;
ui.healMesh.checked = control.healMesh;
ui.threaded.checked = setThreaded(control.threaded);
ui.assembly.checked = control.assembly;

View file

@ -104,13 +104,11 @@ class Widget {
}
const widget = this;
const mark = time();
const vertices = this.getGeoVertices(true);
widget.meta.file = filename;
widget.meta.save = mark;
catalog().putFile(filename, this.getGeoVertices(true), vertices => {
if (vertices && vertices.length) {
console.log("saving decimated mesh ["+vertices.length+"] time ["+(time()-mark)+"]");
widget.loadVertices(vertices);
}
catalog().putFile(filename, vertices, () => {
console.log("saved mesh ["+(vertices.length/3)+"] time ["+(time()-mark)+"]");
});
return this;
}

View file

@ -42,6 +42,7 @@ gapp.register("moto.space", [], (root, exports) => {
showPlatform = true,
hidePlatformBelow = true,
hideGridBelow = false,
showGrid = true,
showGridLines = true,
showFocus = 0,
focalPoint = undefined,
@ -1186,7 +1187,7 @@ gapp.register("moto.space", [], (root, exports) => {
showAxes,
showVolume,
showGridBelow: (b) => { hideGridBelow = !b },
showGrid: (b) => { grid.view.visible = b },
showGrid: (b) => { showGrid = grid.view.visible = b },
showGrid2: (b) => { showGridLines = grid.lines.visible = b },
setMaxZ: (z) => { panY = z / 2 },
setCenter: (x,y,z) => { panX = x; panY = z, panZ = y },
@ -1355,7 +1356,7 @@ gapp.register("moto.space", [], (root, exports) => {
volume.visible = showVolume && platform.visible;
}
if (grid.view) {
grid.view.visible = hideGridBelow ? platform.visible : true;
grid.view.visible = hideGridBelow ? platform.visible : showGrid;
}
if (cameraLight) {
cameraLight.position.copy(camera.position);