Fix mesh and cube rotation issues

Fix issue when copying cube+mesh UV faces
This commit is contained in:
JannisX11 2022-01-14 19:25:27 +01:00
parent 30474e23a6
commit 769b54b471
5 changed files with 47 additions and 29 deletions

View File

@ -289,6 +289,23 @@ class Cube extends OutlinerElement {
}
}
//Rotations
var i = 0;
var temp_rot = undefined;
var temp_i = undefined;
while (i < 3) {
if (i !== axis) {
if (temp_rot === undefined) {
temp_rot = this.rotation[i]
temp_i = i
} else {
this.rotation[temp_i] = -this.rotation[i]
this.rotation[i] = temp_rot
}
}
i++;
}
function rotateUVFace(number, iterations) {
if (!number) number = 0;
number += iterations * 90;
@ -347,24 +364,6 @@ class Cube extends OutlinerElement {
this.faces.west.extend(this.faces.up)
this.faces.up.extend(temp)
}
//Fine Rotations
var i = 0;
var temp_rot = undefined;
var temp_i = undefined;
while (i < 3) {
if (i !== axis) {
if (temp_rot === undefined) {
temp_rot = this.rotation[i]
temp_i = i
} else {
this.rotation[temp_i] = -this.rotation[i]
this.rotation[i] = temp_rot
}
}
i++;
}
}
}
this.preview_controller.updateTransform(this);

View File

@ -420,6 +420,22 @@ class Mesh extends OutlinerElement {
this.origin.V3_set(rotateCoord(this.origin))
}
}
//Rotations
var i = 0;
var temp_rot = undefined;
var temp_i = undefined;
while (i < 3) {
if (i !== axis) {
if (temp_rot === undefined) {
temp_rot = this.rotation[i]
temp_i = i
} else {
this.rotation[temp_i] = -this.rotation[i]
this.rotation[i] = temp_rot
}
}
i++;
}
this.preview_controller.updateTransform(this);
this.preview_controller.updateGeometry(this);
return this;

View File

@ -734,9 +734,10 @@ const Canvas = {
if (Group.selected.visibility) {
Group.selected.mesh.add(rot_origin)
}
} else if (Cube.selected.length && Format.rotate_cubes) {
if (Cube.selected.length === 1 && Cube.selected.length == 1) {
let mesh = Cube.selected[0].mesh
} else if ((Cube.selected.length && Format.rotate_cubes) || Mesh.selected.length) {
let selected_elements = [...Cube.selected, ...Mesh.selected];
if (selected_elements.length === 1) {
let mesh = selected_elements[0].mesh
if (mesh) {
mesh.add(rot_origin)
}
@ -744,15 +745,15 @@ const Canvas = {
var origin = null;
var first_visible = null;
var i = 0;
while (i < Cube.selected.length) {
if (Cube.selected[i].visibility) {
while (i < selected_elements.length) {
if (selected_elements[i].visibility) {
if (first_visible === null) {
first_visible = Cube.selected[i]
first_visible = selected_elements[i]
}
if (origin === null) {
origin = Cube.selected[i].origin
} else if (!origin.equals(Cube.selected[i].origin)) {
origin = selected_elements[i].origin
} else if (!origin.equals(selected_elements[i].origin)) {
origin = false;
i = Infinity;
}

View File

@ -838,7 +838,7 @@
break;
}
}
return bone;
return bone instanceof Group ? bone : 0;
}
// Global Space
return 0;

View File

@ -1080,9 +1080,11 @@ const UVEditor = {
}
function addToClipboard(key) {
var tag = elements[0].faces[key];
let element = elements.find(el => el.faces[key]);
if (!element) return;
var tag = element.faces[key];
var new_face;
if (elements[0] instanceof Mesh) {
if (element instanceof Mesh) {
new_face = new MeshFace(null, tag);
new_face.vertices = tag.getSortedVertices();
new_face.direction = key;