add normal inversion
This commit is contained in:
parent
7d80ed2904
commit
aeaaf0bf0e
4 changed files with 26 additions and 3 deletions
|
|
@ -117,7 +117,7 @@ function restore_space() {
|
|||
let { space, mode } = map;
|
||||
api.grid(space.grid);
|
||||
// restore selected state
|
||||
let selist = space.select;
|
||||
let selist = space.select || [];
|
||||
let smodel = api.model.list().filter(m => selist.contains(m.id));
|
||||
let sgroup = api.group.list().filter(m => selist.contains(m.id));
|
||||
api.selection.set([...smodel, ...sgroup]);
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ let tool = {
|
|||
},
|
||||
|
||||
invert() {
|
||||
for (let m of selection.models(true)) {
|
||||
for (let m of selection.models()) {
|
||||
m.invert(api.mode.get());
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ let materials = mesh.material = {
|
|||
transparent: true,
|
||||
shininess: 100,
|
||||
specular: 0x202020,
|
||||
color: 0xee0000,
|
||||
color: 0x0088ee,
|
||||
opacity: 1
|
||||
}),
|
||||
wireframe: new MeshBasicMaterial({
|
||||
|
|
@ -306,12 +306,34 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
// invert normals for entire mesh or selected faces depending on mod
|
||||
invert(mode) {
|
||||
let { modes } = mesh.api;
|
||||
let geo = this.mesh.geometry;
|
||||
let pos = geo.attributes.position;
|
||||
let arr = pos.array;
|
||||
function swap(i) {
|
||||
let v1x = arr[i ];
|
||||
let v1y = arr[i+1];
|
||||
let v1z = arr[i+2];
|
||||
arr[i ] = arr[i+3];
|
||||
arr[i+1] = arr[i+4];
|
||||
arr[i+2] = arr[i+5];
|
||||
arr[i+3] = v1x;
|
||||
arr[i+4] = v1y;
|
||||
arr[i+5] = v1z;
|
||||
}
|
||||
switch (mode) {
|
||||
case modes.object:
|
||||
for (let i=0, l=arr.length; i<l; i += 9) {
|
||||
swap(i);
|
||||
}
|
||||
break;
|
||||
case modes.face:
|
||||
for (let face of this.sel.faces) {
|
||||
swap(face * 9);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.reload(arr);
|
||||
if (this._norm) this._norm.update();
|
||||
}
|
||||
|
||||
// remove model from group and space
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ button {
|
|||
padding: 2px 3px 2px 3px;
|
||||
border: 1px solid rgba(150,150,150,0.5);
|
||||
background-color: rgba(220,220,220,0.75);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
|
|
|
|||
Loading…
Reference in a new issue