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 May 29, 2024
2 parents 299cf71 + e1805d5 commit c8dbd0b
Show file tree
Hide file tree
Showing 26 changed files with 529 additions and 759 deletions.
2 changes: 1 addition & 1 deletion content/news.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"layout": "vertical",
"insert_after": "splash_screen",
"text": [
{"text": "Welcome to Blockbench 4.10", "type": "h2"},
{"text": "Welcome to Blockbench 4.10", "type": "h3"},
{"text": "The Knife Tool Update!", "type": "h1"},
{"text": "Check out the [full changelog](https://github.com/JannisX11/blockbench/releases/tag/v4.10.0)!"}
],
Expand Down
2 changes: 2 additions & 0 deletions css/dialogs.css
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,12 @@
li.validator_dialog_problem.validator_warning > i {
color: var(--color-warning);
margin: 3px 4px;
flex-shrink: 0;
}
li.validator_dialog_problem.validator_error > i {
color: var(--color-error);
margin: 3px 4px;
flex-shrink: 0;
}
li.validator_dialog_problem span {
flex-grow: 1;
Expand Down
1 change: 1 addition & 0 deletions css/setup.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
overflow: hidden;
flex-shrink: 0;
}
i.fa_big {
font-size: 18px;
Expand Down
8 changes: 6 additions & 2 deletions css/start_screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}
#start_screen button {
margin-right: 4px;
margin-top: 4px;
}
#start_screen .recent_project {
margin: 2px 0;
Expand Down Expand Up @@ -183,6 +184,7 @@
div.start_screen_right > ul {
max-height: 470px;
padding-right: 5px;
overflow-x: hidden;
overflow-y: auto;
grid-template-columns: repeat(auto-fit, minmax(170px ,1fr));
grid-gap: 5px;
Expand All @@ -207,8 +209,10 @@
}
#start_screen div.graphic.graphic_icon i {
font-size: 40px;
width: 12px;
margin-top: 6px;
width: 42px;
max-width: unset;
margin-top: 4px;
margin-right: -20px;
}
#start_screen .start_screen_graphic_description {
bottom: 15px;
Expand Down
39 changes: 30 additions & 9 deletions js/animations/keyframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ class Keyframe {
function updateKeyframeValue(axis, value, data_point) {
Timeline.selected.forEach(function(kf) {
if (axis == 'uniform' && kf.channel == 'scale') kf.uniform = true;
if (data_point && !kf.data_points[data_point]) return;
kf.set(axis, value, data_point);
})
if (!['effect', 'locator', 'script'].includes(axis)) {
Expand All @@ -603,8 +604,8 @@ function updateKeyframeSelection() {
}
let has_expressions = false;
if (kf.transform) {
has_expressions = !!kf.data_points.find(point => {
return !isStringNumber(point.x) || !isStringNumber(point.y) ||! isStringNumber(point.z);
has_expressions = !!kf.data_points.find((point, i) => {
return kf.getArray(i).find(v => typeof v == 'string');
})
}
if (has_expressions != kf.has_expressions) {
Expand Down Expand Up @@ -1200,6 +1201,15 @@ BARS.defineActions(function() {
time = (time + Animation.selected.length/2) % (Animation.selected.length + 0.001);
}
time = Timeline.snapTime(time);
if (Math.epsilon(time, Animation.selected.length, 0.004) && formResult.offset && !occupied_times.includes(0)) {
// Copy keyframe to start
occupied_times.push(0);
let new_kf = opposite_animator.createKeyframe(old_kf, 0, channel, false, false)
if (new_kf) {
new_kf.flip(0);
new_keyframes.push(new_kf);
}
}
if (occupied_times.includes(time)) return;
occupied_times.push(time);
let new_kf = opposite_animator.createKeyframe(old_kf, time, channel, false, false)
Expand Down Expand Up @@ -1454,6 +1464,17 @@ Interface.definePanels(function() {
}
}
return channel;
},
firstKeyframe() {
let data_point_length = 0;
let keyframe;
for (let kf of this.keyframes) {
if (kf.data_points.length > data_point_length) {
keyframe = kf;
data_point_length = kf.data_points.length;
}
}
return keyframe;
}
},
template: `
Expand All @@ -1466,27 +1487,27 @@ Interface.definePanels(function() {
<label>{{ tl('panel.keyframe.type', [getKeyframeInfos()]) }}</label>
<div
class="in_list_button"
v-if="keyframes[0].animator.channels[channel] && keyframes[0].data_points.length < keyframes[0].animator.channels[channel].max_data_points && keyframes[0].interpolation !== 'catmullrom'"
v-if="firstKeyframe.animator.channels[channel] && firstKeyframe.data_points.length < firstKeyframe.animator.channels[channel].max_data_points && firstKeyframe.interpolation !== 'catmullrom'"
v-on:click.stop="addDataPoint()"
title="${ tl('panel.keyframe.change_effect_file') }"
>
<i class="material-icons">add</i>
</div>
</div>
<ul class="list" :style="{overflow: keyframes[0].data_points.length > 1 ? 'auto' : 'visible'}">
<ul class="list" :style="{overflow: firstKeyframe.data_points.length > 1 ? 'auto' : 'visible'}">
<div v-for="(data_point, data_point_i) of keyframes[0].data_points" class="keyframe_data_point">
<div v-for="(data_point, data_point_i) of firstKeyframe.data_points" class="keyframe_data_point">
<div class="keyframe_data_point_header" v-if="keyframes[0].data_points.length > 1">
<label>{{ keyframes[0].transform ? tl('panel.keyframe.' + (data_point_i ? 'post' : 'pre')) : (data_point_i + 1) }}</label>
<div class="keyframe_data_point_header" v-if="firstKeyframe.data_points.length > 1">
<label>{{ firstKeyframe.transform ? tl('panel.keyframe.' + (data_point_i ? 'post' : 'pre')) : (data_point_i + 1) }}</label>
<div class="flex_fill_line"></div>
<div class="in_list_button" v-on:click.stop="removeDataPoint(data_point_i)" title="${ tl('panel.keyframe.remove_data_point') }">
<i class="material-icons">clear</i>
</div>
</div>
<template v-if="channel == 'scale' && keyframes[0].uniform && data_point.x_string == data_point.y_string && data_point.y_string == data_point.z_string">
<template v-if="channel == 'scale' && firstKeyframe.uniform && data_point.x_string == data_point.y_string && data_point.y_string == data_point.z_string">
<div
class="bar flex"
id="keyframe_bar_uniform_scale"
Expand Down Expand Up @@ -1533,7 +1554,7 @@ Interface.definePanels(function() {
@focus="key == 'locator' && updateLocatorSuggestionList()"
@input="updateInput(key, $event.target.value, data_point_i)"
/>
<div class="tool" v-if="key == 'effect'" :title="tl(channel == 'sound' ? 'timeline.select_sound_file' : 'timeline.select_particle_file')" @click="changeKeyframeFile(data_point, keyframes[0])">
<div class="tool" v-if="key == 'effect'" :title="tl(channel == 'sound' ? 'timeline.select_sound_file' : 'timeline.select_particle_file')" @click="changeKeyframeFile(data_point, firstKeyframe)">
<i class="material-icons">upload_file</i>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions js/boot_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ onVueSetup.funcs.forEach((func) => {
}
})

AutoBackup.initialize();

if (isApp) {
initializeDesktopApp();
} else {
Expand Down
4 changes: 2 additions & 2 deletions js/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function initializeDesktopApp() {
} else {
$('#windows_window_menu').show()
}
if (Blockbench.platform == 'linux' && (Blockbench.hasFlag('after_update') || Blockbench.hasFlag('after_patch_update'))) {
if (Blockbench.platform == 'linux') {
// Clear GPU cache: https://github.com/JannisX11/blockbench/issues/1964
let gpu_cache_path = PathModule.join(app.getPath('userData'), 'GPUCache');
try {
Expand Down Expand Up @@ -732,7 +732,7 @@ ipcRenderer.on('update-available', (event, arg) => {
color: 'var(--color-back)',
graphic: {type: 'icon', icon: 'update'},
text: [
{type: 'h2', text: tl('message.update_notification.title')},
{type: 'h3', text: tl('message.update_notification.title')},
{text: tl('message.update_notification.message')},
{type: 'button', text: tl('generic.enable'), click: (e) => {
settings.automatic_updates.set(true);
Expand Down
2 changes: 1 addition & 1 deletion js/interface/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function buildForm(dialog) {
let bar = $(`<div class="dialog_bar bar form_bar form_bar_${form_id}"></div>`)
let label;
if (typeof data.label == 'string') {
label = Interface.createElement('label', {class: 'name_space_left', for: form_id}, tl(data.label)+(data.nocolon?'':':'))
label = Interface.createElement('label', {class: 'name_space_left', for: form_id}, tl(data.label)+((data.nocolon || !data.label)?'':':'))
bar.append(label);
if (!data.full_width && data.condition !== false) {
dialog.max_label_width = Math.max(getStringWidth(label.textContent), dialog.max_label_width)
Expand Down
2 changes: 1 addition & 1 deletion js/interface/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ function updateStreamerModeNotification() {
color: 'var(--color-stream)',
text_color: 'var(--color-light)',
text: [
{type: 'h1', text: tl('interface.streamer_mode_on'), click() {
{type: 'h2', text: tl('interface.streamer_mode_on'), click() {
Settings.openDialog({search_term: tl('settings.streamer_mode')})
}}
]
Expand Down
29 changes: 3 additions & 26 deletions js/interface/start_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ function addStartScreenSection(id, data) {
var content = line.text ? pureMarked(tl(line.text)) : '';
switch (line.type) {
case 'h1': var tag = 'h1'; break;
case 'h2': var tag = 'h3'; break;
case 'h3': var tag = 'h4'; break;
case 'h2': var tag = 'h2'; break;
case 'h3': var tag = 'h3'; break;
case 'h4': var tag = 'h4'; break;
case 'list':
var tag = 'ul class="list_style"';
line.list.forEach(string => {
Expand Down Expand Up @@ -527,30 +528,6 @@ onVueSetup(async function() {
if (settings.streamer_mode.value) {
updateStreamerModeNotification()
}

//Backup Model
let has_backups = await AutoBackup.hasBackups();
if (has_backups && (!isApp || !currentwindow.webContents.second_instance)) {

let section = addStartScreenSection({
color: 'var(--color-back)',
graphic: {type: 'icon', icon: 'fa-archive'},
insert_before: 'start_files',
text: [
{type: 'h2', text: tl('message.recover_backup.title')},
{text: tl('message.recover_backup.message')},
{type: 'button', text: tl('message.recover_backup.recover'), click: (e) => {
AutoBackup.recoverAllBackups().then(() => {
section.delete();
});
}},
{type: 'button', text: tl('dialog.discard'), click: (e) => {
AutoBackup.removeAllBackups();
section.delete();
}}
]
})
}
});


Expand Down
5 changes: 2 additions & 3 deletions js/io/formats/gltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ function buildSkinnedMesh(root_group, scale) {
let bone = new THREE.Bone();
bone.name = group.name;
bone.uuid = group.mesh.uuid;
let parent_offset = THREE.fastWorldPosition(group.mesh.parent, Reusable.vec3);
THREE.fastWorldPosition(group.mesh, bone.position).sub(parent_offset);
bone.position.copy(group.mesh.position);
bone.rotation.copy(group.mesh.rotation)
if (group == root_group) {
bone.position.set(0, 0, 0);
}
Expand Down Expand Up @@ -334,7 +334,6 @@ var codec = new Codec('gltf', {
Outliner.root.forEach(node => {
if (node instanceof Group) {
let armature = buildSkinnedMesh(node, options.scale);
console.log(armature)
gl_scene.add(armature);
} else {
gl_scene.add(node.mesh);
Expand Down
2 changes: 1 addition & 1 deletion js/io/formats/modded_entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ var codec = new Codec('modded_entity', {
let group_snippets = [];
for (var group of all_groups) {
if ((group instanceof Group === false && !group.is_catch_bone) || !group.export) continue;
if (group.is_rotation_subgroup) continue;
if (group.is_rotation_subgroup && Templates.get('model_part')) continue;
//if (usesLayerDef && group.parent instanceof Group) continue;
let snippet = Templates.get('field')
.replace(R('bone'), group.name)
Expand Down
27 changes: 25 additions & 2 deletions js/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,32 @@ const AutoBackup = {
console.log(`Upgraded ${Object.keys(parsed_backup_models).length} project back-ups to indexedDB`);
}
}
request.onsuccess = function() {
request.onsuccess = async function() {
AutoBackup.db = request.result;

// Start Screen Message
let has_backups = await AutoBackup.hasBackups();
if (has_backups && (!isApp || !currentwindow.webContents.second_instance)) {

let section = addStartScreenSection({
color: 'var(--color-back)',
graphic: {type: 'icon', icon: 'fa-archive'},
insert_before: 'start_files',
text: [
{type: 'h3', text: tl('message.recover_backup.title')},
{text: tl('message.recover_backup.message')},
{type: 'button', text: tl('message.recover_backup.recover'), click: (e) => {
AutoBackup.recoverAllBackups().then(() => {
section.delete();
});
}},
{type: 'button', text: tl('dialog.discard'), click: (e) => {
AutoBackup.removeAllBackups();
section.delete();
}}
]
})
}
}
},
async backupOpenProject() {
Expand Down Expand Up @@ -347,7 +371,6 @@ const AutoBackup = {
});
}
}
AutoBackup.initialize();


setInterval(function() {
Expand Down
2 changes: 1 addition & 1 deletion js/modeling/scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ModelScaler = {
pivot_options: {label: ' ', nocolon: true, type: 'buttons', buttons: ['dialog.scale.element_pivot', 'dialog.scale.selection_center'], click(index) {
ModelScaler.setPivot(['pivot', 'selection'][index]);
}},
scale: {label: '', type: 'range', min: 0, max: 4, step: 0.01, value: 1, full_width: true, editable_range_label: true},
scale: {type: 'range', min: 0, max: 4, step: 0.01, value: 1, full_width: true, editable_range_label: true},
overflow_info: {
condition: () => ModelScaler.overflow,
type: 'info',
Expand Down
33 changes: 17 additions & 16 deletions js/outliner/cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,55 +684,56 @@ class Cube extends OutlinerElement {
if (scope.autouv === 2) {
//Relative UV
var all_faces = ['north', 'south', 'west', 'east', 'up', 'down']
let offset = Format.centered_grid ? 8 : 0;
all_faces.forEach(function(side) {
var uv = scope.faces[side].uv.slice()
switch (side) {
case 'north':
uv = [
pw - scope.to[0],
pw - (scope.to[0]+offset),
ph - scope.to[1],
pw - scope.from[0],
pw - (scope.from[0]+offset),
ph - scope.from[1],
];
break;
case 'south':
uv = [
scope.from[0],
(scope.from[0]+offset),
ph - scope.to[1],
scope.to[0],
(scope.to[0]+offset),
ph - scope.from[1],
];
break;
case 'west':
uv = [
scope.from[2],
(scope.from[2]+offset),
ph - scope.to[1],
scope.to[2],
(scope.to[2]+offset),
ph - scope.from[1],
];
break;
case 'east':
uv = [
pw - scope.to[2],
pw - (scope.to[2]+offset),
ph - scope.to[1],
pw - scope.from[2],
pw - (scope.from[2]+offset),
ph - scope.from[1],
];
break;
case 'up':
uv = [
scope.from[0],
scope.from[2],
scope.to[0],
scope.to[2],
(scope.from[0]+offset),
(scope.from[2]+offset),
(scope.to[0]+offset),
(scope.to[2]+offset),
];
break;
case 'down':
uv = [
scope.from[0],
ph - scope.to[2],
scope.to[0],
ph - scope.from[2],
(scope.from[0]+offset),
ph - (scope.to[2]+offset),
(scope.to[0]+offset),
ph - (scope.from[2]+offset),
];
break;
}
Expand Down
Loading

0 comments on commit c8dbd0b

Please sign in to comment.