Change local rotation behavior

Closes #899
This commit is contained in:
JannisX11 2021-06-12 00:07:23 +02:00
parent ca97a592fc
commit b46895fd7f
4 changed files with 30 additions and 17 deletions

View File

@ -307,7 +307,6 @@ function uploadSketchfabModel() {
title: tl('message.sketchfab.success'),
message:
`[${formResult.name} on Sketchfab](https://sketchfab.com/models/${response.uid})`, //\n\n \n\n`+
//tl('message.sketchfab.setup_guide', '[Sketchfab Setup and Common Issues](https://blockbench.net/2020/01/22/sketchfab-setup-and-common-issues/)'),
icon: 'icon-sketchfab',
})
},

View File

@ -1400,7 +1400,23 @@
scope.keyframes[0].offset('x', Math.trimDeg( (-Math.radToDeg(e.x - mesh.fix_rotation.x)) - scope.keyframes[0].calc('x') ));
scope.keyframes[0].offset('y', Math.trimDeg( (-Math.radToDeg(e.y - mesh.fix_rotation.y)) - scope.keyframes[0].calc('y') ));
scope.keyframes[0].offset('z', Math.trimDeg( ( Math.radToDeg(e.z - mesh.fix_rotation.z)) - scope.keyframes[0].calc('z') ));
/*
} else if (Toolbox.selected.id === 'rotate_tool' && Transformer.getTransformSpace() == 2) {
if (axisNumber != 2) difference *= -1;
let old_order = mesh.rotation.order;
mesh.rotation.reorder(axisNumber == 0 ? 'ZYX' : (axis == 1 ? 'ZXY' : 'XYZ'))
var obj_val = Math.trimDeg(Math.radToDeg(mesh.rotation[axis]) + difference);
mesh.rotation[axis] = Math.degToRad(obj_val);
mesh.rotation.reorder(old_order);
scope.keyframes[0].offset('x', Math.trimDeg( (-Math.radToDeg(mesh.rotation.x - mesh.fix_rotation.x)) - scope.keyframes[0].calc('x') ));
scope.keyframes[0].offset('y', Math.trimDeg( (-Math.radToDeg(mesh.rotation.y - mesh.fix_rotation.y)) - scope.keyframes[0].calc('y') ));
scope.keyframes[0].offset('z', Math.trimDeg( ( Math.radToDeg(mesh.rotation.z - mesh.fix_rotation.z)) - scope.keyframes[0].calc('z') ));
*/
} else if (Toolbox.selected.id === 'move_tool' && BarItems.transform_space.value === 'global') {
let offset_vec = new THREE.Vector3();

View File

@ -755,7 +755,7 @@ function rotateOnAxis(modify, axis, slider) {
}
}
if (slider || space == 2) {
if (slider || (space == 2 && Format.rotation_limit)) {
var obj_val = modify(obj.rotation[axis]);
obj_val = Math.trimDeg(obj_val)
if (Format.rotation_limit) {
@ -779,6 +779,18 @@ function rotateOnAxis(modify, axis, slider) {
if (obj instanceof Cube) {
obj.rotation_axis = axis_letter
}
} else if (space == 2) {
let old_order = mesh.rotation.order;
mesh.rotation.reorder(axis == 0 ? 'ZYX' : (axis == 1 ? 'ZXY' : 'XYZ'))
var obj_val = modify(Math.radToDeg(mesh.rotation[axis_letter]));
obj_val = Math.trimDeg(obj_val)
mesh.rotation[axis_letter] = Math.degToRad(obj_val);
mesh.rotation.reorder(old_order);
obj.rotation[0] = Math.radToDeg(mesh.rotation.x);
obj.rotation[1] = Math.radToDeg(mesh.rotation.y);
obj.rotation[2] = Math.radToDeg(mesh.rotation.z);
} else if (space instanceof Group) {
let normal = axis == 0 ? THREE.NormalX : (axis == 1 ? THREE.NormalY : THREE.NormalZ)

View File

@ -21,21 +21,7 @@ function loadInfoFromURL() {
EditSession.dialog()
$('#edit_session_token').val(location.hash.substr(9))
}
if (location.hash.substr(1, 5) == 'load=') {
$.getJSON('https://blockbench.net/api/rawtext.php?url='+location.hash.substr(6), (model) => {
if (showSaveDialog()) {
resetProject();
Codecs.project.load(model, {path: ''});
}
})
} else if (location.hash.substr(1, 5) == 'pbin=') {
$.getJSON('https://blockbench.net/api/rawtext.php?url='+'https://pastebin.com/raw/'+location.hash.substr(6), (model) => {
if (showSaveDialog()) {
resetProject();
Codecs.project.load(model, {path: ''});
}
})
} else if (location.hash.substr(1, 2) == 'm=') {
if (location.hash.substr(1, 2) == 'm=') {
$.getJSON(`https://blckbn.ch/api/models/${location.hash.substr(3)}`, (model) => {
if (showSaveDialog()) {
resetProject();