remove zlist() in mesh, test structuredClone for object.clone

This commit is contained in:
Stewart Allen 2022-05-15 14:48:22 -04:00
commit 38f5399573
4 changed files with 5 additions and 23 deletions

View file

@ -2,6 +2,9 @@
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
* `F` experiment with structuredClone(), SharedArrayBuffer, createImageBitmap()
* `F` test #private fields, array.at() for negative indices
# Kiri:Moto
* `B` origin (and bed size) bug (Onshape?) when switching device modes

View file

@ -218,7 +218,8 @@ String.prototype.reverse = function() {
};
Object.clone = function(o) {
return o ? JSON.parse(JSON.stringify(o)) : o;
return structuredClone(o);
// return o ? JSON.parse(JSON.stringify(o)) : o;
};
Object.toArray = function(o) {

View file

@ -449,15 +449,6 @@ mesh.model = class MeshModel extends mesh.object {
});
}
zlist(round = 2) {
return new Promise((resolve,reject) => {
let { id, matrix } = this;
worker.model_zlist({id, matrix, round}).then(data => {
resolve(data);
});
});
}
// release from a group but remain in memory and storage
// so it can be re-assigned to another group
ungroup() {

View file

@ -172,19 +172,6 @@ let model = {
return subs.toFloat32();
},
// used to generate a list for split snapping
zlist(data) {
let { id, matrix, round } = data;
let zlist = {};
let pos = translate_encode(id, matrix);
for (let i=0, l=pos.length; i<l; ) {
let v1 = new Vector3(pos[i++], pos[i++], pos[i++]);
let z = v1.z.round(round || 2);
zlist[z] = '';
}
return Object.keys(zlist).map(v => parseFloat(v));
},
// split a model along an axis at a given point
// return two arrays of vertices for each resulting object
split(data) {