mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
Merge pull request #1610 from MrCrayfish/rotation_snapping
Model formats can now disable cube rotation snapping
This commit is contained in:
commit
ea24c06e21
@ -365,7 +365,8 @@ const Clipbench = {
|
||||
if (cube instanceof Cube == false) return;
|
||||
if (!cube.rotation.allEqual(0)) {
|
||||
var axis = getAxisNumber(cube.rotationAxis()) || 0;
|
||||
var angle = limitNumber( Math.round(cube.rotation[axis]/22.5)*22.5, -45, 45 );
|
||||
var cube_rotation = Format.rotation_snap ? Math.round(cube.rotation[axis]/22.5)*22.5 : cube.rotation[axis];
|
||||
var angle = limitNumber( cube_rotation, -45, 45 );
|
||||
cube.rotation.V3_set(0, 0, 0);
|
||||
cube.rotation[axis] = angle;
|
||||
}
|
||||
|
@ -190,7 +190,8 @@ class ModelFormat {
|
||||
Cube.all.forEach(cube => {
|
||||
if (!cube.rotation.allEqual(0)) {
|
||||
var axis = (cube.rotation_axis && getAxisNumber(cube.rotation_axis)) || 0;
|
||||
var angle = limitNumber( Math.round(cube.rotation[axis]/22.5)*22.5, -45, 45 );
|
||||
var cube_rotation = Format.rotation_snap ? Math.round(cube.rotation[axis]/22.5)*22.5 : cube.rotation[axis];
|
||||
var angle = limitNumber( cube_rotation, -45, 45 );
|
||||
cube.rotation.V3_set(0, 0, 0)
|
||||
cube.rotation[axis] = angle;
|
||||
}
|
||||
@ -238,6 +239,7 @@ new Property(ModelFormat, 'boolean', 'meshes');
|
||||
new Property(ModelFormat, 'boolean', 'texture_meshes');
|
||||
new Property(ModelFormat, 'boolean', 'locators');
|
||||
new Property(ModelFormat, 'boolean', 'rotation_limit');
|
||||
new Property(ModelFormat, 'boolean', 'rotation_snap');
|
||||
new Property(ModelFormat, 'boolean', 'uv_rotation');
|
||||
new Property(ModelFormat, 'boolean', 'java_face_properties');
|
||||
new Property(ModelFormat, 'boolean', 'select_texture_for_particles');
|
||||
|
@ -524,6 +524,7 @@ var format = new ModelFormat({
|
||||
vertex_color_ambient_occlusion: true,
|
||||
rotate_cubes: true,
|
||||
rotation_limit: true,
|
||||
rotation_snap: true,
|
||||
optional_box_uv: true,
|
||||
uv_rotation: true,
|
||||
java_face_properties: true,
|
||||
|
@ -838,7 +838,7 @@ function getSpatialInterval(event = 0) {
|
||||
}
|
||||
//Rotate
|
||||
function getRotationInterval(event) {
|
||||
if (Format.rotation_limit) {
|
||||
if (Format.rotation_snap) {
|
||||
return 22.5;
|
||||
} else if ((event.shiftKey || Pressing.overrides.shift) && (event.ctrlOrCmd || Pressing.overrides.ctrl)) {
|
||||
return 0.25;
|
||||
@ -986,13 +986,16 @@ function rotateOnAxis(modify, axis, slider) {
|
||||
obj.rotation[(axis+1)%3] = 0
|
||||
obj.rotation[(axis+2)%3] = 0
|
||||
//Limit Angle
|
||||
obj_val = Math.round(obj_val/22.5)*22.5
|
||||
if (Format.rotation_snap) {
|
||||
obj_val = Math.round(obj_val/22.5)*22.5
|
||||
}
|
||||
if (obj_val > 45 || obj_val < -45) {
|
||||
|
||||
let f = obj_val > 45
|
||||
let can_roll = obj.roll(axis, f!=(axis==1) ? 1 : 3);
|
||||
if (can_roll) {
|
||||
obj_val = f ? -22.5 : 22.5;
|
||||
let roll_angle = Format.rotation_snap ? 22.5 : 90 - Math.abs(obj_val)
|
||||
obj_val = f ? -roll_angle : roll_angle;
|
||||
} else {
|
||||
obj_val = Math.clamp(obj_val, -45, 45);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user