Fix #1120 glTF export issue

Fix #1125 The Java Block/Item rotation limit is not enforced when pasting elements
Remove menu option to set texture to transparent on mesh
Face selection now validates face existance when selecting different elements
This commit is contained in:
JannisX11 2021-10-23 12:45:06 +02:00
parent 9df1fa10ca
commit def95852b5
4 changed files with 84 additions and 12 deletions

View File

@ -137,6 +137,11 @@ function updateSelection(options = {}) {
}
}
if (Outliner.selected.length || (Format.single_texture && Modes.paint)) {
UVEditor.selected_faces.forEachReverse((fkey, i) => {
if (!UVEditor.getMappableElements().find(el => el.faces[fkey])) {
UVEditor.selected_faces.splice(i, 1);
}
})
UVEditor.loadData()
}
if (Modes.animate) {

View File

@ -307,6 +307,62 @@ const Clipbench = {
})
Canvas.updateView({elements});
}
//Rotate Cubes
if (!Format.rotate_cubes) {
elements.forEach(cube => {
if (cube instanceof Cube == false) return;
cube.rotation.V3_set(0, 0, 0)
})
Canvas.updateView({elements, element_aspects: {transform: true}});
}
//Canvas Limit
if (Format.canvas_limit && !settings.deactivate_size_limit.value) {
elements.forEach(s => {
if (s instanceof Cube == false) return;
//Push elements into 3x3 block box
[0, 1, 2].forEach(function(ax) {
var overlap = s.to[ax] + s.inflate - 32
if (overlap > 0) {
//If positive site overlaps
s.from[ax] -= overlap
s.to[ax] -= overlap
if (16 + s.from[ax] - s.inflate < 0) {
s.from[ax] = -16 + s.inflate
}
} else {
overlap = s.from[ax] - s.inflate + 16
if (overlap < 0) {
s.from[ax] -= overlap
s.to[ax] -= overlap
if (s.to[ax] + s.inflate > 32) {
s.to[ax] = 32 - s.inflate
}
}
}
})
})
Canvas.updateView({elements, element_aspects: {transform: true, geometry: true}});
}
//Rotation Limit
if (Format.rotation_limit && Format.rotate_cubes) {
elements.forEach(cube => {
if (cube instanceof Cube == false) return;
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 );
cube.rotation.V3_set(0, 0, 0);
cube.rotation[axis] = angle;
}
})
Canvas.updateView({elements, element_aspects: {transform: true}});
}
Undo.finishEdit('Paste Elements', {outliner: true, elements: selected, selection: true});
}
}

View File

@ -1351,7 +1351,7 @@ const UVEditor = {
UVEditor.message('uv_editor.reset')
Undo.initEdit('texture blank')
}},
{icon: 'clear', name: 'menu.cube.texture.transparent', click: function() {UVEditor.clear(event)}},
{icon: 'clear', name: 'menu.cube.texture.transparent', condition: () => UVEditor.getReferenceFace() instanceof CubeFace, click: function() {UVEditor.clear(event)}},
]
Texture.all.forEach(function(t) {
arr.push({

View File

@ -1302,18 +1302,29 @@ GLTFExporter.prototype = {
modifiedAttribute = new BufferAttribute( new Float32Array( array ), attribute.itemSize, attribute.normalized );
modifiedAttribute.array.forEach((v, i) => {
if (mesh.geometry) {
var map = mesh.material instanceof Array
? mesh.material[mesh.geometry.faces[Math.floor(i / 6)].materialIndex].map
: mesh.material.map;
if (!mesh.geometry) return;
let material;
if (mesh.material instanceof Array) {
let group = mesh.geometry.groups.find(group => Math.floor(i/2) >= group.start && Math.floor(i/2) < (group.start + group.count));
console.log(group, mesh.geometry)
if (group) material = mesh.material[group.materialIndex];
} else {
material = mesh.material;
}
if (map && map.image) {
if (i%2 == 0) {
modifiedAttribute.array[i] = v * (map.image.width / THREE.Math.ceilPowerOfTwo(map.image.width));
} else {
modifiedAttribute.array[i] = 1-(1-v) * (map.image.height / THREE.Math.ceilPowerOfTwo(map.image.height));
}
if (!material) return;
let map = material.map;
if (!map && material.uniforms.t0) map = material.uniforms.t0.value;
if (!map && material.uniforms.map) map = material.uniforms.map.value;
if (!map || !map.image) return;
if (i%2 == 0) {
modifiedAttribute.array[i] = v * (map.image.width / THREE.Math.ceilPowerOfTwo(map.image.width));
} else {
modifiedAttribute.array[i] = 1-(1-v) * (map.image.height / THREE.Math.ceilPowerOfTwo(map.image.height));
}
})
}