fix split/merge. avoid mirroring cached array
This commit is contained in:
parent
d088512758
commit
f28cd07ba1
4 changed files with 8 additions and 3 deletions
|
|
@ -295,6 +295,7 @@ function space_init(data) {
|
||||||
case 'KeyL':
|
case 'KeyL':
|
||||||
return api.log.toggle();
|
return api.log.toggle();
|
||||||
case 'KeyS':
|
case 'KeyS':
|
||||||
|
if (shiftKey) return call.edit_split();
|
||||||
return selection.visible({toggle:true});
|
return selection.visible({toggle:true});
|
||||||
case 'KeyB':
|
case 'KeyB':
|
||||||
return selection.boundsBox({toggle:true});
|
return selection.boundsBox({toggle:true});
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
// ok, this is confusing, but necessary for now :/
|
// ok, this is confusing, but necessary for now :/
|
||||||
setSelected() {
|
setSelected() {
|
||||||
super.select();
|
super.select();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,10 +143,13 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
opt
|
opt
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
mesh.api.group.new([new mesh.model({
|
let group = mesh.api.group.new([new mesh.model({
|
||||||
file: `${this.file}`,
|
file: `${this.file}`,
|
||||||
mesh: data
|
mesh: data
|
||||||
})]).setSelected();
|
})]).setSelected();
|
||||||
|
if (opt.mirror) {
|
||||||
|
group.move(0, 0, group.bounds.dim.z);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,13 +75,13 @@ let model = {
|
||||||
let { id, matrix, opt } = data;
|
let { id, matrix, opt } = data;
|
||||||
let array = translate_encode(id, matrix);
|
let array = translate_encode(id, matrix);
|
||||||
if (opt.mirror) {
|
if (opt.mirror) {
|
||||||
|
array = array.slice();
|
||||||
// find max z and invert z
|
// find max z and invert z
|
||||||
let maxz = -Infinity;
|
let maxz = -Infinity;
|
||||||
for (let i=2, l=array.length; i<l; i += 3) {
|
for (let i=2, l=array.length; i<l; i += 3) {
|
||||||
maxz = Math.max(maxz, array[i]);
|
maxz = Math.max(maxz, array[i]);
|
||||||
array[i] = -array[i];
|
array[i] = -array[i];
|
||||||
}
|
}
|
||||||
maxz *= 2;
|
|
||||||
for (let i=0, l=array.length; i<l; i += 9) {
|
for (let i=0, l=array.length; i<l; i += 9) {
|
||||||
// swap first two vertices in face to invert normals
|
// swap first two vertices in face to invert normals
|
||||||
let v1 = array.slice(i, i+3);
|
let v1 = array.slice(i, i+3);
|
||||||
|
|
@ -89,7 +89,7 @@ let model = {
|
||||||
array[i+j] = array[i+j+3];
|
array[i+j] = array[i+j+3];
|
||||||
array[i+j+3] = v1[j];
|
array[i+j+3] = v1[j];
|
||||||
}
|
}
|
||||||
// move part up in Z
|
// move part up by maxz to compensate for z inversion
|
||||||
array[i+2] += maxz;
|
array[i+2] += maxz;
|
||||||
array[i+5] += maxz;
|
array[i+5] += maxz;
|
||||||
array[i+8] += maxz;
|
array[i+8] += maxz;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue