Skip to content

Commit 4c99393

Browse files
committed
Merge branch 'master' into gh-pages
2 parents 1aec46f + 774ef18 commit 4c99393

File tree

16 files changed

+1387
-1333
lines changed

16 files changed

+1387
-1333
lines changed

js/animations/animation.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class Animation extends AnimationItem {
133133
copy.animators = {}
134134
for (var uuid in this.animators) {
135135
let ba = this.animators[uuid]
136-
var kfs = ba.keyframes
137-
if ((kfs && kfs.length) || ba.rotation_global) {
136+
let kfs = ba.keyframes
137+
if ((kfs && kfs.length) || ba.rotation_global || !save) {
138138
let ba_copy = copy.animators[uuid] = {
139139
name: ba.name,
140140
type: ba.type,
@@ -160,10 +160,10 @@ class Animation extends AnimationItem {
160160

161161
if (this.length) ani_tag.animation_length = Math.roundTo(this.length, 4);
162162
if (this.override) ani_tag.override_previous_animation = true;
163-
if (this.anim_time_update) ani_tag.anim_time_update = this.anim_time_update.replace(/\n/g, '');
164-
if (this.blend_weight) ani_tag.blend_weight = this.blend_weight.replace(/\n/g, '');
165-
if (this.start_delay) ani_tag.start_delay = this.start_delay.replace(/\n/g, '');
166-
if (this.loop_delay && ani_tag.loop) ani_tag.loop_delay = this.loop_delay.replace(/\n/g, '');
163+
if (this.anim_time_update) ani_tag.anim_time_update = exportMolang(this.anim_time_update);
164+
if (this.blend_weight) ani_tag.blend_weight = exportMolang(this.blend_weight);
165+
if (this.start_delay) ani_tag.start_delay = exportMolang(this.start_delay);
166+
if (this.loop_delay && ani_tag.loop) ani_tag.loop_delay = exportMolang(this.loop_delay);
167167
ani_tag.bones = {};
168168

169169
for (var uuid in this.animators) {
@@ -1769,12 +1769,17 @@ BARS.defineActions(function() {
17691769
temp_animators[target_uuid] = new animator.constructor(target_uuid, animation);
17701770
copyAnimator(temp_animators[target_uuid], target_animator);
17711771
}
1772+
1773+
let tempsave_current_animator = !temp_animators[animator.uuid];
1774+
if (tempsave_current_animator) {
1775+
temp_animators[animator.uuid] = new animator.constructor(animator.uuid, animation);
1776+
copyAnimator(temp_animators[animator.uuid], animator);
1777+
}
1778+
17721779
copyAnimator(target_animator, temp_animators[animator.uuid] ?? animator);
17731780

17741781
// Reset animator
1775-
if (!temp_animators[animator.uuid]) {
1776-
temp_animators[animator.uuid] = new animator.constructor(animator.uuid, animation);
1777-
copyAnimator(temp_animators[animator.uuid], animator);
1782+
if (tempsave_current_animator) {
17781783
resetAnimator(animator)
17791784
}
17801785
}

js/animations/keyframe.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ class Keyframe {
9494
data_point = this.data_points[data_point];
9595
if (!data_point || !data_point[axis]) {
9696
return this.transform ? 0 : '';
97-
} else if (!isNaN(data_point[axis])) {
98-
let num = parseFloat(data_point[axis]);
99-
return isNaN(num) ? 0 : num;
10097
} else {
101-
return data_point[axis]
98+
return exportMolang(data_point[axis])
10299
}
103100
}
104101
calc(axis, data_point = 0) {
@@ -113,6 +110,7 @@ class Keyframe {
113110
}
114111
set(axis, value, data_point = 0) {
115112
if (data_point) data_point = Math.clamp(data_point, 0, this.data_points.length-1);
113+
if (typeof value == 'number') value = Math.roundTo(value, 10).toString();
116114
if (this.data_points[data_point]) {
117115
if (this.uniform) {
118116
this.data_points[data_point].x = value;

js/interface/start_screen.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,23 +573,39 @@ ModelLoader.loaders = {};
573573
});
574574
documentReady.then(() => {
575575

576-
//Twitter
577-
let twitter_ad;
578-
if (!settings.classroom_mode.value && Blockbench.startup_count < 20 && Blockbench.startup_count % 5 === 4) {
579-
twitter_ad = true;
580-
addStartScreenSection('twitter_link', {
581-
color: '#1da1f2',
576+
//Bluesky
577+
let bsky_ad;
578+
Blockbench.onUpdateTo('4.12.2', () => {
579+
//Bluesky
580+
if (!settings.classroom_mode.value) {
581+
bsky_ad = true;
582+
addStartScreenSection('bluesky_link', {
583+
color: 'rgb(32, 139, 254);',
584+
text_color: '#ffffff',
585+
graphic: {type: 'icon', icon: 'fab.fa-bluesky'},
586+
text: [
587+
{type: 'h3', text: 'Blockbench on Bluesky'},
588+
{text: 'Follow Blockbench on Bluesky for the latest news & cool models from the community! [@blockbench.net](https://bsky.app/profile/blockbench.net)'}
589+
],
590+
last: true
591+
})
592+
}
593+
})
594+
if (!settings.classroom_mode.value && !bsky_ad && Blockbench.startup_count < 20 && Blockbench.startup_count % 5 === 4) {
595+
bsky_ad = true;
596+
addStartScreenSection('bluesky_link', {
597+
color: 'rgb(32, 139, 254);',
582598
text_color: '#ffffff',
583-
graphic: {type: 'icon', icon: 'fab.fa-twitter'},
599+
graphic: {type: 'icon', icon: 'fab.fa-bluesky'},
584600
text: [
585-
{type: 'h2', text: 'Blockbench on Twitter'},
586-
{text: 'Follow Blockbench on Twitter for the latest news as well as cool models from the community! [twitter.com/blockbench](https://twitter.com/blockbench/)'}
601+
{type: 'h3', text: 'Blockbench on Bluesky'},
602+
{text: 'Follow Blockbench on Bluesky for the latest news & cool models from the community! [@blockbench.net](https://bsky.app/profile/blockbench.net)'}
587603
],
588604
last: true
589605
})
590606
}
591607
//Discord
592-
if (!settings.classroom_mode.value && Blockbench.startup_count < 6 && !twitter_ad) {
608+
if (!settings.classroom_mode.value && Blockbench.startup_count < 6 && !bsky_ad) {
593609
addStartScreenSection('discord_link', {
594610
color: '#5865F2',
595611
text_color: '#ffffff',

js/modeling/mesh_editing.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,6 @@ BARS.defineActions(function() {
24532453
}},
24542454
even_extend: {type: 'checkbox', value: false, label: 'edit.extrude_mesh_selection.even_extend'},
24552455
}, form => {
2456-
console.log(form)
24572456
runEdit(true, form.extend, form.direction_mode, form.even_extend);
24582457
})
24592458
}

js/modeling/mirror_modeling.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ const MirrorModeling = {
284284
} else {
285285
// change
286286
let original_vkey = pre_part_connections.vertices[vkey];
287-
new_face.uv[new_vkey] = original_face.uv[original_vkey].slice();
287+
if (original_face.uv[original_vkey]) {
288+
new_face.uv[new_vkey] = original_face.uv[original_vkey].slice();
289+
}
288290
}
289291
})
290292
new_face.invert();

js/modeling/transform_gizmo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@
11521152
}
11531153
})
11541154
}
1155-
_has_groups = Format.bone_rig && Group.first_selected && Group.first_selected.matchesSelection() && Toolbox.selected.transformerMode == 'translate';
1155+
_has_groups = Format.bone_rig && Group.first_selected && Toolbox.selected.transformerMode == 'translate';
11561156
var rotate_group = Format.bone_rig && Group.first_selected && (Toolbox.selected.transformerMode == 'rotate');
11571157

11581158
if (Toolbox.selected.id == 'move_tool') {

js/outliner/group.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ class Group extends OutlinerNode {
399399
obj.locked = this.locked;
400400
obj.visibility = this.visibility;
401401
obj.autouv = this.autouv;
402+
obj.selected = Group.multi_selected.includes(this);
402403
}
403404

404405
if (this.rotation.allEqual(0)) {

js/outliner/outliner.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ function parseGroups(array, import_reference, startIndex) {
800800
OutlinerNode.uuids[array[i].uuid].removeFromParent();
801801
delete OutlinerNode.uuids[array[i].uuid];
802802
}
803-
var obj = new Group(array[i], array[i].uuid)
803+
// todo: Update old groups instead of rebuilding all
804+
let obj = new Group(array[i], array[i].uuid)
804805
obj.parent = addGroup
805806
obj.isOpen = !!array[i].isOpen
806807
if (array[i].uuid) {
@@ -814,6 +815,9 @@ function parseGroups(array, import_reference, startIndex) {
814815
if (array[i].content && array[i].content.length > 0) {
815816
iterate(array[i].content, obj.children, obj)
816817
}
818+
if (array[i].selected) {
819+
obj.multiSelect();
820+
}
817821
}
818822
i++;
819823
}
@@ -1129,14 +1133,15 @@ SharedActions.add('select_all', {
11291133
Undo.initSelection();
11301134
let selectable_elements = Outliner.elements.filter(element => !element.locked);
11311135
if (Outliner.selected.length < selectable_elements.length) {
1132-
if (Outliner.root.length == 1 && !Outliner.root[0].locked) {
1133-
Outliner.root[0].select();
1134-
} else {
1135-
selectable_elements.forEach(obj => {
1136-
obj.selectLow()
1137-
})
1138-
TickUpdates.selection = true;
1136+
for (let node of Outliner.root) {
1137+
if (node instanceof Group) {
1138+
node.multiSelect();
1139+
}
11391140
}
1141+
selectable_elements.forEach(obj => {
1142+
obj.selectLow()
1143+
})
1144+
TickUpdates.selection = true;
11401145
Undo.finishSelection('Select all elements');
11411146
} else {
11421147
unselectAllElements()

js/preview/preview.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,11 +1153,11 @@ class Preview {
11531153

11541154
let z_offset = world_normal.clone().multiplyScalar(z_fight_offset);
11551155
let matrix_offset = new THREE.Matrix4().makeTranslation(z_offset.x, z_offset.y, z_offset.z);
1156-
if (!Format.centered_grid) {
1157-
matrix_offset.makeTranslation(-Canvas.scene.position.x, -Canvas.scene.position.y, -Canvas.scene.position.z);
1158-
}
11591156
brush_matrix.multiplyMatrices(matrix_offset, brush_matrix);
11601157

1158+
// Since we're setting the brush matrix, we need to multiply in its parents matrix as well in case there are any.
1159+
if (Canvas.brush_outline.parent)
1160+
brush_matrix.multiplyMatrices(Canvas.brush_outline.parent.matrixWorld.clone().invert(), brush_matrix);
11611161
Canvas.brush_outline.matrix = brush_matrix;
11621162
}
11631163

js/undo.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ class UndoSystem {
1515
}
1616
}
1717
initEdit(aspects, amended = false) {
18+
// todo: selecting all groups, moving, then undoing, unselects all multi-selected groups
1819
if (aspects && aspects.cubes) {
1920
console.warn('Aspect "cubes" is deprecated. Please use "elements" instead.');
2021
aspects.elements = aspects.cubes;
2122
}
2223
this.startChange(amended);
23-
this.current_save = new UndoSystem.save(aspects)
24+
this.current_save = new UndoSystem.save(aspects);
25+
if (aspects.selection) {
26+
this.current_selection_save = new UndoSystem.selectionSave(typeof aspects.selection == 'object' ? typeof aspects.selection : 0);
27+
}
2428
Blockbench.dispatchEvent('init_edit', {aspects, amended, save: this.current_save})
2529
return this.current_save;
2630
}
@@ -40,7 +44,18 @@ class UndoSystem {
4044
type: 'edit',
4145
time: Date.now()
4246
}
43-
this.current_save = entry.post
47+
48+
if (aspects.selection && this.current_selection_save) {
49+
let selection_aspects = typeof aspects.selection == 'object' ? aspects.selection : this.current_selection_save.aspects;
50+
let selection_before = this.current_selection_save;
51+
let selection_post = new UndoSystem.selectionSave(selection_aspects);
52+
if (!selection_before.matches(selection_post)) {
53+
entry.selection_before = selection_before;
54+
entry.selection_post = selection_post;
55+
}
56+
}
57+
58+
4459
if (this.history.length > this.index) {
4560
this.history.length = this.index;
4661
}
@@ -89,7 +104,6 @@ class UndoSystem {
89104
type: 'selection',
90105
time: Date.now()
91106
}
92-
this.current_selection_save = entry.selection_post
93107
if (this.history.length > this.index) {
94108
this.history.length = this.index;
95109
}
@@ -239,7 +253,7 @@ UndoSystem.save = class {
239253

240254
this.mode = Modes.selected.id;
241255

242-
if (aspects.selection) {
256+
/*if (aspects.selection) {
243257
this.selection = [];
244258
this.mesh_selection = {};
245259
selected.forEach(obj => {
@@ -251,8 +265,7 @@ UndoSystem.save = class {
251265
if (Group.multi_selected.length) {
252266
this.selected_groups = Group.multi_selected.map(g => g.uuid);
253267
}
254-
255-
}
268+
}*/
256269

257270
if (aspects.elements) {
258271
this.elements = {}
@@ -440,7 +453,7 @@ UndoSystem.save = class {
440453
}
441454
}
442455

443-
if (this.selection && !is_session) {
456+
/*if (this.selection && !is_session) {
444457
selected.length = 0;
445458
Outliner.elements.forEach((obj) => {
446459
if (this.selection.includes(obj.uuid)) {
@@ -450,7 +463,7 @@ UndoSystem.save = class {
450463
}
451464
}
452465
})
453-
}
466+
}*/
454467

455468
if (this.groups) {
456469
for (let saved_group of this.groups) {
@@ -619,7 +632,7 @@ UndoSystem.save = class {
619632
if (this.animations) {
620633
for (var uuid in this.animations) {
621634

622-
var animation = (reference.animations && reference.animations[uuid]) ? this.getItemByUUID(Animator.animations, uuid) : null;
635+
var animation = (reference.animations && reference.animations[uuid]) ? Undo.getItemByUUID(Animator.animations, uuid) : null;
623636
if (!animation) {
624637
animation = new Animation()
625638
animation.uuid = uuid
@@ -631,7 +644,7 @@ UndoSystem.save = class {
631644
}
632645
for (var uuid in reference.animations) {
633646
if (!this.animations[uuid]) {
634-
var animation = this.getItemByUUID(Animator.animations, uuid)
647+
var animation = Undo.getItemByUUID(Animator.animations, uuid)
635648
if (animation) {
636649
animation.remove(false)
637650
}
@@ -641,7 +654,7 @@ UndoSystem.save = class {
641654
if (this.animation_controllers) {
642655
for (var uuid in this.animation_controllers) {
643656

644-
var controller = (reference.animation_controllers && reference.animation_controllers[uuid]) ? this.getItemByUUID(AnimationController.all, uuid) : null;
657+
var controller = (reference.animation_controllers && reference.animation_controllers[uuid]) ? Undo.getItemByUUID(AnimationController.all, uuid) : null;
645658
if (!controller) {
646659
controller = new AnimationController();
647660
controller.uuid = uuid;
@@ -653,7 +666,7 @@ UndoSystem.save = class {
653666
}
654667
for (var uuid in reference.animation_controllers) {
655668
if (!this.animation_controllers[uuid]) {
656-
var controller = this.getItemByUUID(AnimationController.all, uuid);
669+
var controller = Undo.getItemByUUID(AnimationController.all, uuid);
657670
if (controller) {
658671
controller.remove(false);
659672
}

0 commit comments

Comments
 (0)