From 5cedf21fcafa57393afc0f758aae33eec39445b7 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Wed, 11 Sep 2024 22:57:09 +0200 Subject: [PATCH] Prepare cullfaces for bedrock support Fix java block format scenes being shifted down 8 pixels --- css/panels.css | 1 + js/display_mode.js | 6 ++---- js/io/format.js | 3 ++- js/io/formats/java_block.js | 1 + js/modeling/transform.js | 7 ++++--- js/outliner/cube.js | 2 +- js/preview/preview.js | 1 - js/texturing/uv.js | 20 ++++++++++++++------ 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/css/panels.css b/css/panels.css index f9a4425a..98f2b4a4 100644 --- a/css/panels.css +++ b/css/panels.css @@ -2279,6 +2279,7 @@ span.controller_state_section_info { flex-grow: 1; flex-shrink: 1; width: 50px; + overflow: hidden; } .uv_face_properties_labels label > i { vertical-align: top; diff --git a/js/display_mode.js b/js/display_mode.js index 390bb150..11868cfd 100644 --- a/js/display_mode.js +++ b/js/display_mode.js @@ -1312,9 +1312,7 @@ enterDisplaySettings = function() { //Enterung Display Setting Mode, changes th scene.add(display_area); if (Project.model_3d) { Project.model_3d.position.copy(Canvas.scene.position); - if (Format.id == 'bedrock_block') { - Project.model_3d.position.y = -8; - } + Project.model_3d.position.y = -8; } scene.position.set(0, 0, 0); @@ -1336,7 +1334,7 @@ exitDisplaySettings = function() { //Enterung Display Setting Mode, changes the Canvas.global_light_side = 0; Canvas.updateShading(); scene.remove(display_area) - if (!Format.centered_grid) scene.position.set(-8, -8, -8); + if (!Format.centered_grid) scene.position.set(-8, 0, -8); display_base.children.forEachReverse(child => { display_base.remove(child); child.position.set(0, 0, 0); diff --git a/js/io/format.js b/js/io/format.js index 9e835e67..5586464d 100644 --- a/js/io/format.js +++ b/js/io/format.js @@ -65,7 +65,7 @@ class ModelFormat { scene.position.set(0, 0, 0); Canvas.ground_plane.position.x = Canvas.ground_plane.position.z = 8; } else { - scene.position.set(-8, -8, -8); + scene.position.set(-8, 0, -8); Canvas.ground_plane.position.x = Canvas.ground_plane.position.z = 0; } PreviewModel.getActiveModels().forEach(model => { @@ -281,6 +281,7 @@ new Property(ModelFormat, 'boolean', 'rotation_snap'); new Property(ModelFormat, 'boolean', 'uv_rotation'); new Property(ModelFormat, 'boolean', 'java_cube_shading_properties'); new Property(ModelFormat, 'boolean', 'java_face_properties'); +new Property(ModelFormat, 'boolean', 'cullfaces'); new Property(ModelFormat, 'boolean', 'select_texture_for_particles'); new Property(ModelFormat, 'boolean', 'texture_mcmeta'); new Property(ModelFormat, 'boolean', 'bone_binding_expression'); diff --git a/js/io/formats/java_block.js b/js/io/formats/java_block.js index 3277dfcb..ddb836ff 100644 --- a/js/io/formats/java_block.js +++ b/js/io/formats/java_block.js @@ -532,6 +532,7 @@ var format = new ModelFormat({ uv_rotation: true, java_cube_shading_properties: true, java_face_properties: true, + cullfaces: true, animated_textures: true, select_texture_for_particles: true, texture_mcmeta: true, diff --git a/js/modeling/transform.js b/js/modeling/transform.js index 2e6eeef7..ff928c1a 100644 --- a/js/modeling/transform.js +++ b/js/modeling/transform.js @@ -19,7 +19,7 @@ function getSelectionCenter(all = false) { let center = (min[0] == Infinity) ? [0, 0, 0] : max.V3_add(min).V3_divide(2); if (!Format.centered_grid) { - center.V3_add(8, 8, 8) + center.V3_add(8, 0, 8) } return center; } @@ -1950,7 +1950,7 @@ BARS.defineActions(function() { }) new Action('auto_set_cullfaces', { icon: 'smart_button', - condition: () => Modes.edit && Format.java_face_properties, + condition: () => Modes.edit && Format.cullfaces, click() { if (!Cube.selected.length) { BarItems.select_all.click(); @@ -1977,7 +1977,8 @@ BARS.defineActions(function() { }); }) - Undo.finishEdit('Automatically set cullfaces') + updateSelection(); + Undo.finishEdit('Automatically set cullfaces'); } }) }) diff --git a/js/outliner/cube.js b/js/outliner/cube.js index 45afc746..cc7719f3 100644 --- a/js/outliner/cube.js +++ b/js/outliner/cube.js @@ -619,7 +619,7 @@ class Cube extends OutlinerElement { vec.set(...coords.V3_subtract(this.origin)); vec.applyMatrix4( this.mesh.matrixWorld ); let arr = vec.toArray(); - arr.V3_add(8, 8, 8); + arr.V3_add(8, 0, 8); return arr; }) } diff --git a/js/preview/preview.js b/js/preview/preview.js index 3da210f6..0440bc03 100644 --- a/js/preview/preview.js +++ b/js/preview/preview.js @@ -1098,7 +1098,6 @@ class Preview { intersect.object.localToWorld(brush_coord); if (!Format.centered_grid) { brush_coord.x += 8; - brush_coord.y += 8; brush_coord.z += 8; } Canvas.brush_outline.position.copy(brush_coord); diff --git a/js/texturing/uv.js b/js/texturing/uv.js index 37581613..7a981890 100644 --- a/js/texturing/uv.js +++ b/js/texturing/uv.js @@ -602,8 +602,10 @@ const UVEditor = { let face = UVEditor.getReferenceFace(); if (face instanceof CubeFace) { BarItems.uv_rotation.set((face && face.rotation)||0); - if (Format.java_face_properties) { + if (Format.cullfaces) { BarItems.cullface.set(face.cullface||'off') + } + if (Format.java_face_properties) { BarItems.face_tint.setIcon(face.tint !== -1 ? 'check_box' : 'check_box_outline_blank') BarItems.slider_face_tint.update() } @@ -1495,7 +1497,7 @@ const UVEditor = { }, new MenuSeparator('face_options'), 'face_tint', - {icon: 'flip_to_back', condition: () => (Format.java_face_properties && Cube.selected.length && UVEditor.getReferenceFace()), name: 'action.cullface' , children: function() { + {icon: 'flip_to_back', condition: () => (Format.cullfaces && Cube.selected.length && UVEditor.getReferenceFace()), name: 'action.cullface' , children: function() { let off = 'far.fa-circle'; let on = 'far.fa-dot-circle'; function setCullface(cullface) { @@ -1881,7 +1883,7 @@ BARS.defineActions(function() { }) new BarSelect('cullface', { category: 'uv', - condition: () => UVEditor.isFaceUV() && Format.java_face_properties && Cube.selected.length && UVEditor.getReferenceFace(), + condition: () => UVEditor.isFaceUV() && Format.cullfaces && Cube.selected.length && UVEditor.getReferenceFace(), label: true, options: { off: tl('uv_editor.no_faces'), @@ -1901,7 +1903,7 @@ BARS.defineActions(function() { new Action('auto_cullface', { icon: 'block', category: 'uv', - condition: () => UVEditor.isFaceUV() && Format.java_face_properties && Cube.selected.length && UVEditor.getReferenceFace(), + condition: () => UVEditor.isFaceUV() && Format.cullfaces && Cube.selected.length && UVEditor.getReferenceFace(), keybind: new Keybind({}, { all_faces: 'shift' }), @@ -2425,8 +2427,10 @@ Interface.definePanels(function() { UVEditor.updateSelectionOutline(false); }, centerView() { - this.$refs.viewport.scrollLeft = this.width/2; - this.$refs.viewport.scrollTop = this.height/2; + if (this.$refs.viewport) { + this.$refs.viewport.scrollLeft = this.width/2; + this.$refs.viewport.scrollTop = this.height/2; + } this.centered_view = true; }, setMode(mode) { @@ -4041,7 +4045,9 @@ Interface.definePanels(function() { ${tl('action.face_tint')} info + + +