FIx inflate slider in bedrock block format

This commit is contained in:
JannisX11 2023-03-30 22:10:39 +02:00
parent 4bd1563d22
commit 95d7f5b35a
2 changed files with 5 additions and 3 deletions

View File

@ -1386,6 +1386,7 @@ var block_format = new ModelFormat({
});
return vertices;
},
// Test if it overlaps
test(cube, values = 0) {
let from = values.from || cube.from;
let to = values.to || cube.to;
@ -1394,11 +1395,12 @@ var block_format = new ModelFormat({
let vertices = block_format.cube_size_limiter.getCubeVertexCoordinates(cube, {from, to, inflate});
let center = block_format.cube_size_limiter.getModelCenter([cube]);
return undefined !== vertices.find((v, i) => {
let vertex_outside_bounds = vertices.find((v, i) => {
return (v[0] > center[3]+15 || v[0] < center[0]-15)
|| (v[1] > center[4]+15 || v[1] < center[1]-15)
|| (v[2] > center[5]+15 || v[2] < center[2]-15);
})
return vertex_outside_bounds !== undefined;
},
move(cube, values = 0) {
let from = values.from || cube.from;

View File

@ -1167,13 +1167,13 @@ BARS.defineActions(function() {
obj.inflate = v;
} else {
if (Format.cube_size_limiter.test(obj, {inflate: v})) {
if (Format.cube_size_limiter.test(obj, {inflate: v}) == false) {
obj.inflate = v;
} else {
let step = Math.sign(v - v_before) * 0.1;
let steps = (v - v_before) / step;
for (let i = 0; i < steps; i++) {
if (Format.cube_size_limiter.test(obj, {inflate: v_before + i * (steps+1)})) {
if (Format.cube_size_limiter.test(obj, {inflate: v_before + i * (steps+1)}) == false) {
obj.inflate = v_before + i * steps;
break;
}