mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-04-06 17:31:09 +08:00
Fix cube face rotation not always restricted to format
This commit is contained in:
parent
91869e39c8
commit
2e575e9a96
@ -84,6 +84,7 @@ class ModelFormat {
|
||||
}
|
||||
Interface.Panels.animations.inside_vue._data.animation_files_enabled = this.animation_files;
|
||||
Interface.status_bar.vue.Format = this;
|
||||
UVEditor.vue.cube_uv_rotation = this.uv_rotation;
|
||||
Modes.vue.$forceUpdate()
|
||||
updateInterfacePanels()
|
||||
Canvas.updateShading();
|
||||
|
@ -328,6 +328,7 @@ class Cube extends OutlinerElement {
|
||||
}
|
||||
|
||||
function rotateUVFace(number, iterations) {
|
||||
if (!Format.uv_rotation) return 0;
|
||||
if (!number) number = 0;
|
||||
number += iterations * 90;
|
||||
return number % 360;
|
||||
|
@ -1236,14 +1236,16 @@ const Canvas = {
|
||||
arr[2][1] += offset
|
||||
arr[3][1] += offset
|
||||
}
|
||||
var rot = (face.rotation+0)
|
||||
while (rot > 0) {
|
||||
let a = arr[0];
|
||||
arr[0] = arr[2];
|
||||
arr[2] = arr[3];
|
||||
arr[3] = arr[1];
|
||||
arr[1] = a;
|
||||
rot = rot-90;
|
||||
if (Format.uv_rotation) {
|
||||
var rot = (face.rotation+0)
|
||||
while (rot > 0) {
|
||||
let a = arr[0];
|
||||
arr[0] = arr[2];
|
||||
arr[2] = arr[3];
|
||||
arr[3] = arr[1];
|
||||
arr[1] = a;
|
||||
rot = rot-90;
|
||||
}
|
||||
}
|
||||
vertex_uvs.array.set(arr[0], index*8 + 0); //0,1
|
||||
vertex_uvs.array.set(arr[1], index*8 + 2); //1,1
|
||||
|
@ -1111,12 +1111,14 @@ const UVEditor = {
|
||||
if (Cube.selected[0] && Cube.selected[0].faces[this.selected_faces] && Math.abs(Cube.selected[0].faces[this.selected_faces].rotation - value) % 180 == 90) {
|
||||
UVEditor.turnMapping();
|
||||
}
|
||||
this.forCubes(obj => {
|
||||
this.selected_faces.forEach(face => {
|
||||
obj.faces[face].rotation = value;
|
||||
if (Format.uv_rotation) {
|
||||
this.forCubes(obj => {
|
||||
this.selected_faces.forEach(face => {
|
||||
obj.faces[face].rotation = value;
|
||||
})
|
||||
Canvas.updateUV(obj);
|
||||
})
|
||||
Canvas.updateUV(obj);
|
||||
})
|
||||
}
|
||||
let rect = this.vue.getSelectedUVBoundingBox();
|
||||
let center = [(rect[0] + rect[2]) / 2, (rect[1] + rect[3]) / 2];
|
||||
Mesh.selected.forEach(mesh => {
|
||||
@ -1936,6 +1938,7 @@ Interface.definePanels(function() {
|
||||
mode: 'uv',
|
||||
hidden: false,
|
||||
box_uv: false,
|
||||
cube_uv_rotation: true,
|
||||
width: 320,
|
||||
height: 320,
|
||||
zoom: 1,
|
||||
@ -3361,16 +3364,16 @@ Interface.definePanels(function() {
|
||||
<div class="uv_resize_side vertical" @mousedown="resizeFace(key, $event, -1, 0)" @touchstart.prevent="resizeFace(key, $event, -1, 0)" style="height: var(--height)"></div>
|
||||
<div class="uv_resize_side vertical" @mousedown="resizeFace(key, $event, 1, 0)" @touchstart.prevent="resizeFace(key, $event, 1, 0)" style="left: var(--width); height: var(--height)"></div>
|
||||
<div class="uv_resize_corner uv_c_nw" :class="{main_corner: !face.rotation}" @mousedown="resizeFace(key, $event, -1, -1)" @touchstart.prevent="resizeFace(key, $event, -1, -1)" style="left: 0; top: 0">
|
||||
<div class="uv_rotate_field" v-if="!face.rotation" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
<div class="uv_rotate_field" v-if="cube_uv_rotation && face.rotation == 0" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
</div>
|
||||
<div class="uv_resize_corner uv_c_ne" :class="{main_corner: face.rotation == 270}" @mousedown="resizeFace(key, $event, 1, -1)" @touchstart.prevent="resizeFace(key, $event, 1, -1)" style="left: var(--width); top: 0">
|
||||
<div class="uv_rotate_field" v-if="face.rotation == 270" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
<div class="uv_rotate_field" v-if="cube_uv_rotation && face.rotation == 270" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
</div>
|
||||
<div class="uv_resize_corner uv_c_sw" :class="{main_corner: face.rotation == 90}" @mousedown="resizeFace(key, $event, -1, 1)" @touchstart.prevent="resizeFace(key, $event, -1, 1)" style="left: 0; top: var(--height)">
|
||||
<div class="uv_rotate_field" v-if="face.rotation == 90" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
<div class="uv_rotate_field" v-if="cube_uv_rotation && face.rotation == 90" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
</div>
|
||||
<div class="uv_resize_corner uv_c_se" :class="{main_corner: face.rotation == 180}" @mousedown="resizeFace(key, $event, 1, 1)" @touchstart.prevent="resizeFace(key, $event, 1, 1)" style="left: var(--width); top: var(--height)">
|
||||
<div class="uv_rotate_field" v-if="face.rotation == 180" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
<div class="uv_rotate_field" v-if="cube_uv_rotation && face.rotation == 180" @mousedown.stop="rotateFace($event)" @touchstart.prevent.stop="rotateFace($event)"></div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user