Skip to content

Commit

Permalink
v3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed Jul 21, 2019
1 parent 43a4799 commit ae6a261
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 90 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#181a1f">
<meta name="robots" content="noindex">
<link rel="manifest" href="manifest.json">
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
<link rel="stylesheet" href="css/w3.css">
<link rel="stylesheet" href="css/jquery-ui.min.css">
Expand All @@ -26,7 +27,7 @@
<script>
if (typeof module === 'object') {window.module = module; module = undefined;}//jQuery Fix
const isApp = typeof require !== 'undefined';
const appVersion = '3.0.2';
const appVersion = '3.0.3';
</script>
<script src="lib/vue.min.js"></script>
<script src="lib/vue_sortable.js"></script>
Expand Down
30 changes: 23 additions & 7 deletions js/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Animation {
constructor(data) {
this.name = '';
this.uuid = guid()
this.loop = true;
this.loop = false;
this.playing = false;
this.override = false;
this.selected = false;
Expand Down Expand Up @@ -37,6 +37,12 @@ class Animation {
}
}
}
if (data.particle_effects) {
this.particle_effects = data.particle_effects;
}
if (data.sound_effects) {
this.sound_effects = data.sound_effects;
}
return this;
}
undoCopy(options) {
Expand All @@ -49,14 +55,17 @@ class Animation {
anim_time_update: this.anim_time_update,
length: this.length,
selected: this.selected,
particle_effects: this.particle_effects,
sound_effects: this.sound_effects,
}
if (Object.keys(this.bones).length) {
copy.bones = {}
for (var uuid in this.bones) {
var kfs = this.bones[uuid].keyframes
if (kfs && kfs.length) {
if (options && options.bone_names) {
uuid = this.bones[uuid].getGroup().name
var group = this.bones[uuid].getGroup();
uuid = group ? group.name : ''
}
var kfs_copy = copy.bones[uuid] = []
kfs.forEach(kf => {
Expand Down Expand Up @@ -134,11 +143,10 @@ class Animation {
}
var uuid = group.uuid
if (!this.bones[uuid]) {
this.bones[uuid] = new BoneAnimator(uuid);
this.bones[uuid] = new BoneAnimator(uuid, this);
}
return this.bones[uuid];
}

add(undo) {
if (undo) {
Undo.initEdit({animations: []})
Expand Down Expand Up @@ -206,14 +214,18 @@ class Animation {
*/
])
class BoneAnimator {
constructor(uuid) {
constructor(uuid, animation) {
this.keyframes = [];
this.uuid = uuid;
this.animation = animation;
}
getGroup() {
this.group = Outliner.root.findRecursive('uuid', this.uuid)
if (!this.group) {
console.log('no group found for '+this.uuid)
if (this.animation && this.animation.bones[this.uuid]) {
delete this.animation.bones[this.uuid];
}
}
return this.group
}
Expand Down Expand Up @@ -841,14 +853,16 @@ const Animator = {
override: a.override_previous_animation,
anim_time_update: a.anim_time_update,
length: a.animation_length,
blend_weight: a.blend_weight
blend_weight: a.blend_weight,
particle_effects: a.particle_effects,
sound_effects: a.sound_effects,
}).add()
//Bones
for (var bone_name in a.bones) {
var b = a.bones[bone_name]
var group = Outliner.root.findRecursive('name', bone_name)
if (group) {
var ba = new BoneAnimator(group.uuid);
var ba = new BoneAnimator(group.uuid, animation);
animation.bones[group.uuid] = ba;
//Channels
for (var channel in b) {
Expand Down Expand Up @@ -885,6 +899,8 @@ const Animator = {
if (a.override) ani_tag.override_previous_animation = true
if (a.anim_time_update) ani_tag.anim_time_update = a.anim_time_update
ani_tag.bones = {}
if (a.particle_effects) ani_tag.particle_effects = a.particle_effects;
if (a.sound_effects) ani_tag.sound_effects = a.sound_effects;
for (var uuid in a.bones) {
var group = a.bones[uuid].getGroup()
if (group && a.bones[uuid].keyframes.length) {
Expand Down
5 changes: 5 additions & 0 deletions js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ const Blockbench = {
},
read(paths, options, cb) {
if (!isApp || paths == undefined) return false;
if (typeof paths == 'string') paths = [paths];

var results = [];
var result_count = 0;
Expand Down Expand Up @@ -427,6 +428,10 @@ const Blockbench = {
? options.startpath.replace(/\.\w+$/, '')
: options.name
}, function (file_path) {
var extension = pathToExtension(file_path);
if (!extension && options.extensions && options.extensions[0]) {
file_path += '.'+options.extensions[0]
}
Blockbench.writeFile(file_path, options, cb)
})
}
Expand Down
18 changes: 9 additions & 9 deletions js/blockbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ function onVueSetup(func) {
}
function canvasGridSize(shift, ctrl) {
if (!shift && !ctrl) {
return 16 / limitNumber(settings.edit_size.value, 1, 1024)
return 16 / limitNumber(settings.edit_size.value, 1, 512)
} else if (ctrl && shift) {
var basic = 16 / limitNumber(settings.edit_size.value, 1, 1024)
var control = 16 / limitNumber(settings.ctrl_size.value, 1, 1024)
var shift = 16 / limitNumber(settings.shift_size.value, 1, 1024)
var basic = 16 / limitNumber(settings.edit_size.value, 1, 512)
var control = 16 / limitNumber(settings.ctrl_size.value, 1, 4096)
var shift = 16 / limitNumber(settings.shift_size.value, 1, 4096)
control = basic / control
return shift / control
} else if (ctrl) {
return 16 / limitNumber(settings.ctrl_size.value, 1, 1024)
return 16 / limitNumber(settings.ctrl_size.value, 1, 4096)
} else {
return 16 / limitNumber(settings.shift_size.value, 1, 1024)
return 16 / limitNumber(settings.shift_size.value, 1, 4096)
}
}
function updateNslideValues() {
Expand Down Expand Up @@ -730,15 +730,15 @@ const Clipbench = {
if (Clipbench.group) {
function iterate(obj, parent) {
if (obj.children) {
var copy = new Group(obj)
var copy = new Group(obj).addTo(parent).init()
if (obj.children && obj.children.length) {
obj.children.forEach((child) => {
iterate(child, copy)
})
}
copy.addTo(parent)
} else {
NonGroup.fromSave(obj).addTo(parent).selectLow()
var el = NonGroup.fromSave(obj).addTo(parent).selectLow();
Canvas.adaptObjectPosition(el);
}
}
iterate(Clipbench.group, target)
Expand Down
28 changes: 5 additions & 23 deletions js/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ $(document).ready(function() {

//Load Model
if (electron.process.argv.length >= 2) {
var extension = pathToExtension(electron.process.argv[1])

var extension = pathToExtension(electron.process.argv.last())
if (['json', 'bbmodel', 'jem'].includes(extension)) {
Blockbench.read([electron.process.argv[1]], {}, (files) => {
Blockbench.read([electron.process.argv.last()], {}, (files) => {
loadModelFile(files[0])
})
}
Expand All @@ -62,7 +61,6 @@ $(document).ready(function() {
});
(function() {
console.log('Electron '+process.versions.electron+', Node '+process.versions.node)
getLatestVersion(true)
})()

//Recent Projects
Expand Down Expand Up @@ -103,28 +101,12 @@ function addRecentProject(data) {

//Updates
//Called on start to show message
function getLatestVersion(init) {
function getLatestVersion() {
if (process.platform == 'linux') return;
$.getJSON('https://raw.githubusercontent.com/JannisX11/blockbench/master/package.json', (data) => {
if (data.version) {
latest_version = data.version
if (compareVersions(latest_version, appVersion) && init === true && !open_dialog) {

Blockbench.showMessageBox({
translateKey: 'update_notification',
message: tl('message.update_notification.message', [latest_version]),
icon: 'update',
buttons: ['message.update_notification.install', 'message.update_notification.later'],
confirm: 0, cancel: 1
}, (result) => {
if (result === 0) {
checkForUpdates(true)
}
})

} else if (init === false) {
checkForUpdates()
}
checkForUpdates()
}
}).fail(function() {
latest_version = false
Expand Down Expand Up @@ -172,7 +154,7 @@ function refreshUpdateDialog() {
currentwindow.webContents.session.clearCache(function() {
data = '<div class="dialog_bar narrow"><i class="material-icons blue_icon spinning">refresh</i>'+tl('dialog.update.connecting')+'</div>'
$('#updater_content').html(data)
getLatestVersion(false)
getLatestVersion()
})
}
function installUpdate() {
Expand Down
28 changes: 8 additions & 20 deletions js/interface/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,27 +1031,12 @@ const BARS = {
id: 'swap_tools',
icon: 'swap_horiz',
category: 'tools',
condition: () => Modes.edit || Modes.display,
condition: () => !Modes.animate,
keybind: new Keybind({key: 32}),
click: function () {
var index = Toolbox.children.indexOf(Toolbox.selected)+1;
var overflow = 0;
while ((
Toolbox.children[index] instanceof Tool == false ||
Toolbox.children[index] == Toolbox.selected ||
!Condition(Toolbox.children[index])
) && overflow < 64) {
index++;
if (index >= Toolbox.children.length) index = 0;
overflow++;
if (BarItems[Toolbox.selected.alt_tool]) {
BarItems[Toolbox.selected.alt_tool].select()
}
Toolbox.children[index].select()
/*
if (Toolbox.selected.id === 'move_tool') {
BarItems.resize_tool.select()
} else if (Toolbox.selected.id === 'resize_tool') {
BarItems.move_tool.select()
}*/
}
})

Expand Down Expand Up @@ -1389,10 +1374,14 @@ const BARS = {
'slider_size_x',
'slider_size_y',
'slider_size_z',
'scale'
'slider_inflate'
],
default_place: !Blockbench.isMobile
})
//3.0.3 update
if (Toolbars.element_size.children.includes(BarItems.slider_inflate)) {
Toolbars.element_size.add(BarItems.slider_inflate, -1);
}
Toolbars.element_origin = new Toolbar({
id: 'element_origin',
children: [
Expand Down Expand Up @@ -1580,7 +1569,6 @@ const BARS = {
item.id.toUpperCase().includes(name)
) {
if (
BARS.condition(item.condition) &&
!this.currentBar.includes(item)
) {
list.push(item)
Expand Down
2 changes: 1 addition & 1 deletion js/interface/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ var documentReady = new Promise((resolve, reject) => {
Promise.all([version_call, documentReady]).then((data) => {
if (data[0] && data[0].version) {
latest_version = data[0].version;
if (compareVersions(latest_version, appVersion)) {
if (isApp && compareVersions(latest_version, appVersion)) {

addStartScreenSection({
color: 'var(--color-back)',
Expand Down
2 changes: 1 addition & 1 deletion js/io/bbmodel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {

var codec = new Codec('project', {
name: 'Blockbench Save',
name: 'Blockbench Project',
extension: 'bbmodel',
remember: true,
load(model, file) {
Expand Down
4 changes: 3 additions & 1 deletion js/io/bedrock.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,13 @@ var codec = new Codec('bedrock', {
if (obj.export) {
if (obj instanceof Cube) {
var cube = {
name: obj.name == g.name ? undefined : obj.name,
origin: obj.from.slice(),
size: obj.size(),
inflate: obj.inflate||undefined,
}
if (Project.box_uv) {
cube = new oneLiner(cube);
}
cube.origin[0] = -(cube.origin[0] + cube.size[0])


Expand Down
5 changes: 2 additions & 3 deletions js/io/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ModelFormat {
preview.camOrtho.position.add(preview.controls.target);
})*/
BARS.updateConditions()
Modes.vue.$forceUpdate()
Canvas.updateRenderSides()
return this;
}
Expand Down Expand Up @@ -994,11 +995,9 @@ BARS.defineActions(function() {
}
if (Format.animation_mode) {
if (ModelMeta.animation_path) {
Blockbench.writeFile(Prop.animation_path, {
Blockbench.writeFile(ModelMeta.animation_path, {
content: autoStringify(Animator.buildFile())
})
} else {
//
}
}
} else {
Expand Down
1 change: 0 additions & 1 deletion js/outliner/cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class Cube extends NonGroup {
for (var face in this.faces) {
this.faces[face].texture = textures[0].uuid
}
main_uv.loadData()
}
if (!this.parent || (this.parent === 'root' && Outliner.root.indexOf(this) === -1)) {
this.addTo('root')
Expand Down
Loading

0 comments on commit ae6a261

Please sign in to comment.