Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed Jan 3, 2024
2 parents 433efda + 6af72bd commit 4b55f28
Show file tree
Hide file tree
Showing 23 changed files with 627 additions and 407 deletions.
10 changes: 8 additions & 2 deletions css/panels.css
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@

/*Animations*/
#panel_animations #animations_list {
min-height: 126px;
padding-bottom: 12px;
}
.animation {
Expand Down Expand Up @@ -928,6 +927,11 @@
margin-top: 11px;
opacity: 0.5;
}
.keyframe_data_point {
display: flex;
flex-direction: column;
max-height: 250px;
}
#panel_keyframe .bar.flex {
height: auto;
min-height: 30px;
Expand Down Expand Up @@ -1940,7 +1944,8 @@ span.controller_state_section_info {
--color-uv-background: transparent;
--uv-line-width: 1px;
}
#uv_frame.overlay_mode .uv_face {
#uv_frame.overlay_mode .uv_face,
#uv_frame.overlay_mode .uv_face * {
pointer-events: none;
}

Expand Down Expand Up @@ -2044,6 +2049,7 @@ span.controller_state_section_info {
pointer-events: none;
position: relative;
z-index: 1;
margin-top: -1px;
}
#uv_rotate_handle {
width: 21.4px;
Expand Down
6 changes: 3 additions & 3 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ const Blockbench = {
if (icon === undefined) {
//Missing
node = document.createElement('i');
node.classList.add('material-icons', 'icon');
node.classList.add('material-icons', 'notranslate', 'icon');
node.innerText = 'help_outline';
} else if (icon instanceof HTMLElement) {
//Node
node = icon
} else if (icon === true || icon === false) {
//Boolean
node = document.createElement('i');
node.classList.add('material-icons', 'icon');
node.classList.add('material-icons', 'notranslate', 'icon');
node.innerText = icon ? 'check_box' : 'check_box_outline_blank';

} else if (icon === null) {
Expand Down Expand Up @@ -84,7 +84,7 @@ const Blockbench = {
} else {
//Material Icon
node = document.createElement('i');
node.classList.add('material-icons', 'icon');
node.classList.add('material-icons', 'notranslate', 'icon');
node.innerText = icon;
}
if (color) {
Expand Down
88 changes: 82 additions & 6 deletions js/display_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1605,11 +1605,13 @@ function updateDisplaySkin(feedback) {
let {material} = PreviewModel.models.attachable_reference_player;
material.map.image.src = skin;
material.map.needsUpdate = true;
PreviewModel.models.attachable_reference_player.updateArmVariant(slim);
}
if (PreviewModel.models.minecraft_player) {
let {material} = PreviewModel.models.minecraft_player;
material.map.image.src = skin;
material.map.needsUpdate = true;
PreviewModel.models.minecraft_player.updateArmVariant(slim);
}
}
if (!val || typeof val !== 'string') {
Expand Down Expand Up @@ -1649,6 +1651,7 @@ function updateDisplaySkin(feedback) {
setPSkin(val, slim);
}
}
DisplayMode.updateDisplaySkin = updateDisplaySkin;

BARS.defineActions(function() {
new Action('add_display_preset', {
Expand Down Expand Up @@ -1949,7 +1952,7 @@ Interface.definePanels(function() {
// Bedrock Attachables
BARS.defineActions(function() {

let player_preview_model = new PreviewModel('attachable_reference_player', {
let player_attachable_reference_model = new PreviewModel('attachable_reference_player', {
texture: './assets/player_skin.png',
texture_size: [64, 64],
cubes: [
Expand Down Expand Up @@ -2005,12 +2008,15 @@ BARS.defineActions(function() {
"down": {"uv": [36, 32, 28, 36]}
}
},


// ======= Wide Arms
{
// Right Arm
"position": [4, 12, -2],
"size": [4, 12, 4],
"origin": [5, 22, 0],
"rotation": [15, 0, 0],
"rotation": [-1, 0, 3],
"faces": {
"north": {"uv": [44, 20, 48, 32]},
"east": {"uv": [40, 20, 44, 32]},
Expand All @@ -2025,7 +2031,7 @@ BARS.defineActions(function() {
"position": [3.75, 11.75, -2.25],
"size": [4.5, 12.5, 4.5],
"origin": [5, 22, 0],
"rotation": [15, 0, 0],
"rotation": [-1, 0, 3],
"faces": {
"north": {"uv": [44, 36, 48, 48]},
"east": {"uv": [40, 36, 44, 48]},
Expand All @@ -2039,6 +2045,8 @@ BARS.defineActions(function() {
// Left Arm
"position": [-8, 12, -2],
"size": [4, 12, 4],
"origin": [-5, 22, 0],
"rotation": [1, 0, -3],
"faces": {
"north": {"uv": [36, 52, 40, 64]},
"east": {"uv": [32, 52, 36, 64]},
Expand All @@ -2052,6 +2060,8 @@ BARS.defineActions(function() {
// Arm Layer
"position": [-8.25, 11.75, -2.25],
"size": [4.5, 12.5, 4.5],
"origin": [-5, 22, 0],
"rotation": [1, 0, -3],
"faces": {
"north": {"uv": [52, 52, 56, 64]},
"east": {"uv": [48, 52, 52, 64]},
Expand All @@ -2061,6 +2071,71 @@ BARS.defineActions(function() {
"down": {"uv": [60, 48, 56, 52]}
}
},


// ======= Slim Arms
{
// Right Arm
"position": [4, 11.5, -2],
"size": [3, 12, 4],
"origin": [5, 21.5, 0],
"rotation": [-1, 0, 3],
"faces": {
"north": {"uv": [44,20,47,32]},
"east": {"uv": [40,20,44,32]},
"south": {"uv": [51,20,54,32]},
"west": {"uv": [47,20,51,32]},
"up": {"uv": [47,20,44,16]},
"down": {"uv": [50,16,47,20]}
}
},
{
// Arm Layer
"position": [3.75, 11.25, -2.25],
"size": [3.5, 12.5, 4.5],
"origin": [5, 21.5, 0],
"rotation": [-1, 0, 3],
"faces": {
"north": {"uv": [44,36,47,48]},
"east": {"uv": [40,36,44,48]},
"south": {"uv": [51,36,54,48]},
"west": {"uv": [47,36,51,48]},
"up": {"uv": [47,36,44,32]},
"down": {"uv": [50,32,47,36]}
}
},
{
// Left Arm
"position": [-7, 11.5, -2],
"size": [3, 12, 4],
"origin": [-5, 21.5, 0],
"rotation": [1, 0, -3],
"faces": {
"north": {"uv": [36,52,39,64]},
"east": {"uv": [32,52,36,64]},
"south": {"uv": [43,52,46,64]},
"west": {"uv": [39,52,43,64]},
"up": {"uv": [39,52,36,48]},
"down": {"uv": [42,48,39,52]}
}
},
{
// Arm Layer
"position": [-7.25, 11.25, -2.25],
"size": [3.5, 12.5, 4.5],
"origin": [-5, 21.5, 0],
"rotation": [1, 0, -3],
"faces": {
"north": {"uv": [52,52,55,64]},
"east": {"uv": [48,52,52,64]},
"south": {"uv": [59,52,62,64]},
"west": {"uv": [55,52,59,64]},
"up": {"uv": [55,52,52,48]},
"down": {"uv": [58,48,55,52]}
}
},


{
// Right Leg
"position": [-0.1, 0, -2],
Expand Down Expand Up @@ -2116,7 +2191,8 @@ BARS.defineActions(function() {
]
})

window.player_preview_model = player_preview_model;
window.player_attachable_reference_model = player_attachable_reference_model;
player_attachable_reference_model.updateArmVariant = player_preview_model.updateArmVariant;

let camera_preset_1st = {
name: tl('action.bedrock_animation_mode.attachable_first'),
Expand Down Expand Up @@ -2164,14 +2240,14 @@ BARS.defineActions(function() {
Project.model_3d.position.set(5, 22, 0).add(arm_offset);
}
Project.model_3d.rotation.set(angle, 0, 0);
player_preview_model.enable()
player_attachable_reference_model.enable()

if (!player_skin_setup) {
updateDisplaySkin();
player_skin_setup = true;
}
} else {
player_preview_model.disable()
player_attachable_reference_model.disable()
}

if (mode != 'attachable_first' && mode != 'attachable_third' && Format.id == 'bedrock') {
Expand Down
4 changes: 3 additions & 1 deletion js/interface/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@ function setupInterface() {
Interface.work_screen.addEventListener('dblclick', event => {
let reference = ReferenceImage.active.find(reference => reference.projectMouseCursor(event.clientX, event.clientY));
if (!reference) return;
if (document.querySelector('.preview:hover')) {
if (document.querySelector('.preview > canvas:hover')) {
if (Preview.selected.raycast(event)) return;
} else if (document.querySelector('#preview:hover')) {
return;
}
reference.select();
});
Expand Down
3 changes: 2 additions & 1 deletion js/interface/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ class Keybind {

scope.stopRecording()
}
let mac_modifiers = ['Alt', 'Shift', 'Control', 'Meta'];
function onActivateDown(event) {
if (event.metaKey && event.which != 91) {
if (event.metaKey && !mac_modifiers.includes(event.key)) {
onActivate(event)
}
}
Expand Down
22 changes: 17 additions & 5 deletions js/io/formats/bbmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ var codec = new Codec('project', {
let new_elements = [];
let new_textures = [];
let new_animations = [];
let imported_format = Formats[model.meta.model_format];
Undo.initEdit({
elements: new_elements,
textures: new_textures,
Expand Down Expand Up @@ -518,6 +519,7 @@ var codec = new Codec('project', {
if (model.skin_model) {
Codecs.skin_model.rebuild(model.skin_model);
}
let adjust_uv = !Format.per_texture_uv_size || !imported_format?.per_texture_uv_size;
if (model.elements) {
let default_texture = new_textures[0] || Texture.getDefault();
let format = Formats[model.meta.model_format] || Format
Expand All @@ -540,8 +542,12 @@ var codec = new Codec('project', {
} else if (default_texture && copy.faces && copy.faces[face].texture !== null) {
copy.faces[face].texture = default_texture.uuid
}
if (!copy.box_uv) {
if (!copy.box_uv && adjust_uv) {
let tex = copy.faces[face].getTexture();
if (tex && imported_format?.per_texture_uv_size) {
width = tex.uv_width;
height = tex.uv_height;
}
copy.faces[face].uv[0] *= (Project.getUVWidth(tex)) / width;
copy.faces[face].uv[2] *= (Project.getUVWidth(tex)) / width;
copy.faces[face].uv[1] *= (Project.getUVHeight(tex)) / height;
Expand All @@ -558,10 +564,16 @@ var codec = new Codec('project', {
} else if (default_texture && copy.faces && copy.faces[fkey].texture !== null) {
copy.faces[fkey].texture = default_texture.uuid
}
for (let vkey in copy.faces[fkey].uv) {
let tex = copy.faces[fkey].getTexture();
copy.faces[fkey].uv[vkey][0] *= Project.getUVWidth(tex) / width;
copy.faces[fkey].uv[vkey][1] *= Project.getUVHeight(tex) / height;
if (adjust_uv) {
for (let vkey in copy.faces[fkey].uv) {
let tex = copy.faces[fkey].getTexture();
if (tex && imported_format?.per_texture_uv_size) {
width = tex.uv_width;
height = tex.uv_height;
}
copy.faces[fkey].uv[vkey][0] *= Project.getUVWidth(tex) / width;
copy.faces[fkey].uv[vkey][1] *= Project.getUVHeight(tex) / height;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion js/io/formats/gltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,10 @@ function buildSkinnedMesh(root_group, scale) {
let normal = Reusable.vec2;

function addGroup(group, parent_bone) {
if (group.export == false) return;

for (child of group.children) {
if (!child.mesh.geometry) continue;
if (!child.mesh.geometry || child.export == false) continue;
let {geometry} = child.mesh;
let matrix = new THREE.Matrix4().copy(child.mesh.matrixWorld);
matrix.premultiply(root_counter_matrix);
Expand Down
10 changes: 7 additions & 3 deletions js/io/formats/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,15 @@ var codec = new Codec('obj', {

var mtlOutput = '# Made in Blockbench '+appVersion+'\n';;

for (var key in materials) {
for (let key in materials) {
if (materials.hasOwnProperty(key) && materials[key]) {
var tex = materials[key];
let tex = materials[key];
let name = tex.name;
if (name.substr(-4) !== '.png') {
name += '.png';
}
mtlOutput += 'newmtl m_' +key+ '\n'
mtlOutput += `map_Kd ${tex.name}\n`;
mtlOutput += `map_Kd ${name}\n`;
}
}
mtlOutput += 'newmtl none'
Expand Down
9 changes: 6 additions & 3 deletions js/modeling/mesh_editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const ProportionalEdit = {
}

SharedActions.add('delete', {
condition: () => Modes.edit && Mesh.selected[0] && Project.mesh_selection[Mesh.selected[0].uuid],
condition: () => Modes.edit && Prop.active_panel == 'preview' && Mesh.selected[0] && Project.mesh_selection[Mesh.selected[0].uuid],
run() {
let meshes = Mesh.selected.slice();
Undo.initEdit({elements: meshes, outliner: true})
Expand Down Expand Up @@ -785,7 +785,7 @@ BARS.defineActions(function() {
reference_face = face;
reference_face_strength = match_strength;
}
if (face.isSelected(key)) {
if (match_strength == face.vertices.length) {
delete mesh.faces[key];
}
}
Expand Down Expand Up @@ -1167,6 +1167,8 @@ BARS.defineActions(function() {
} else if (match) {
// perpendicular edge, currently unused
direction = match.getNormal(true);
} else {
direction = [0, 1, 0];
}
}

Expand Down Expand Up @@ -2170,7 +2172,8 @@ BARS.defineActions(function() {
vertex_textures: [],
vertex_normals: [],
}
args.forEach(triplet => {
args.forEach((triplet, i) => {
if (i >= 4) return;
let [v, vt, vn] = triplet.split('/').map(v => parseInt(v));
if (!vertex_keys[ v-1 ]) {
vertex_keys[ v-1 ] = mesh.addVertices(vertices[v-1])[0];
Expand Down
2 changes: 1 addition & 1 deletion js/modeling/mirror_modeling.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Blockbench.on('finish_edit', ({aspects}) => {
aspects.elements = aspects.elements.slice();
let static_elements_copy = aspects.elements.slice();
static_elements_copy.forEach((element) => {
if (element.allow_mirror_modeling) {
if (element.allow_mirror_modeling && !element.locked) {
let is_centered = MirrorModeling.isCentered(element);

if (is_centered && element instanceof Mesh) {
Expand Down
Loading

0 comments on commit 4b55f28

Please sign in to comment.