Skip to content

Commit

Permalink
v1.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 authored Jan 2, 2018
1 parent af893a2 commit 24de749
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 58 deletions.
20 changes: 17 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,22 @@
<script src="js/plugin_loader.js"></script>
<script>if (window.module) module = window.module;</script>

<div id="post_model" class="web_only post_data" hidden></div>
<div id="post_textures" class="web_only post_data" hidden></div>
<div id="post_model" class="web_only post_data" hidden><?php
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
$model = $_POST['model'];
if ($model != "text") {
echo $model;
}
}
?></div>
<div id="post_textures" class="web_only post_data" hidden><?php
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
$textures = $_POST['textures'];
if ($textures != "text") {
echo $textures;
}
}
?></div>
<!---->
<div id="blackout" onclick="$('.dialog#'+open_dialog).find('.cancel_btn:not([disabled])').click()"></div>

Expand Down Expand Up @@ -697,7 +711,7 @@ <h2 class="dialog_handle">Input</h2>
</div>

<div class="dialog_bar">
<button type="button" class="large confirm_btn" onclick="hideDialog()">Save</button>
<button type="button" class="large confirm_btn" onclick="hideDialog()">Confirm</button>
<button type="button" class="large cancel_btn" onclick="hideDialog()">Cancel</button>
</div>
<div id="dialog_close_button" onclick="$('.dialog#'+open_dialog).find('.cancel_btn:not([disabled])').click()"><i class="material-icons">clear</i></div>
Expand Down
21 changes: 10 additions & 11 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<div id="welcome_content"></div>
<button type="button" class="large cancel_btn hidden" onclick="hideDialog()">Cancel</button>
<div id="dialog_close_button" onclick="$('.dialog#'+open_dialog).find('.cancel_btn:not([disabled])').click()"><i class="material-icons">clear</i></div>

</div>

<div class="dialog draggable paddinged" id="file_loader">
Expand Down Expand Up @@ -284,7 +283,7 @@

<div class="dialog_bar" style="height: 32px;">
<input type="range" id="model_scale_range" value="1" min="0" max="4" step="0.02" oninput="modelScaleSync()">
<input type="number" class="f_left" id="model_scale_label" min="0" max="4" value="1" oninput="modelScaleSync(true)">
<input type="number" class="f_left" id="model_scale_label" min="0" max="4" step="0.02" value="1" oninput="modelScaleSync(true)">
</div>
<div class="dialog_bar narrow" id="scaling_clipping_warning"></div>

Expand Down Expand Up @@ -712,7 +711,7 @@
</div>

<div class="dialog_bar">
<button type="button" class="large confirm_btn" onclick="hideDialog()">Save</button>
<button type="button" class="large confirm_btn" onclick="hideDialog()">Confirm</button>
<button type="button" class="large cancel_btn" onclick="hideDialog()">Cancel</button>
</div>
<div id="dialog_close_button" onclick="$('.dialog#'+open_dialog).find('.cancel_btn:not([disabled])').click()"><i class="material-icons">clear</i></div>
Expand Down Expand Up @@ -764,6 +763,7 @@
<li onclick="showDialog('settings');setSettingsTab('setting')"><i class="material-icons">settings</i>Settings...</li>
<li onclick="showDialog('plugins')"><i class="material-icons">extension</i>Plugins...</li>
<li class="local_only" onclick="checkForUpdates()"><i class="material-icons">update</i>Updates...</li>
<li onclick="randomHelpMessage()"><i class="material-icons">help</i>Tip</li>
<li><i class="material-icons">loyalty</i><a class="open-in-browser" href="http://blockbench.net/donate.html">Donate</a></li>
</ul>
</li>
Expand Down Expand Up @@ -893,7 +893,7 @@
<div class="tool wide m_edit nslide_tool selection_only"><div class="nslide" n-action="size_x"></div><div class="tooltip">Scale X</div></div>
<div class="tool wide m_edit nslide_tool selection_only"><div class="nslide" n-action="size_y"></div><div class="tooltip">Scale Y</div></div>
<div class="tool wide m_edit nslide_tool selection_only"><div class="nslide" n-action="size_z"></div><div class="tooltip">Scale Z</div></div>
<dir class="mode_tab" id="mode_display_tab" onclick="if (!display_mode) {enterDisplaySettings()}">Display</dir>
<dir class="mode_tab block_mode_only" id="mode_display_tab" onclick="if (!display_mode) {enterDisplaySettings()}">Display</dir>
<dir class="mode_tab open" id="mode_edit_tab" onclick="if (display_mode) {exitDisplaySettings()}">Edit</dir>
</header>
<div id="left_bar" class="sidebar">
Expand Down Expand Up @@ -950,8 +950,8 @@
<input class="hidden" type="radio" name="display" id="gui">
<label class="tool" for="gui" onclick="loadDispGUI()"><i class="material-icons">border_style</i><div class="tooltip">GUI</div></label>
</div>
<p>Reference Model</p>
<div id="display_ref_bar" class="bar tabs_small">
<p class="reference_model_bar">Reference Model</p>
<div id="display_ref_bar" class="bar tabs_small reference_model_bar">
</div>

<p>Rotation</p><div class="tool head_right" onclick="resetDisplaySettings('rotation')"><i class="material-icons">replay</i></div>
Expand Down Expand Up @@ -1012,7 +1012,6 @@
<div class="bar">
<div class="tool" onclick="openTexture()"><i class="material-icons">library_add</i><div class="tooltip">Add Texture</div></div>
<div class="tool local_only" onclick="reloadTextures()"><i class="material-icons">refresh</i><div class="tooltip">Reload Textures</div></div>
<div class="tool" onclick="openTextureMenu()"><i class="material-icons">settings</i><div class="tooltip">Edit Texture</div></div>
<div class="tool" onclick="TextureAnimator.start()" id="texture_animation_button" style="display: none;"><i class="material-icons">play_arrow</i><div class="tooltip">
Animations</div></div>
<div id="particle_label">Particle</div>
Expand Down Expand Up @@ -1057,22 +1056,22 @@ class="texture" v-on:click.stop="selectT(texture, $event)"
<option value="z" id="z">Z Axis</option>
</select>
<div class="tool" id="cube_rescale_tool"><input type="checkbox" id="cube_rescale" class="rotation_tool" onclick="Rotation.set()"><div class="tooltip">Rescale</div></div>
<div class="tool right_tool" id="origin2geometry" onclick="Rotation.remove()"><i class="material-icons">clear</i><div class="tooltip">Remove Rotation</div></div>
<div class="tool right_tool" id="rotation_function_button" onclick="Rotation.fn()"><i class="material-icons">clear</i><div class="tooltip clip_right">Remove Rotation</div></div>
</div>
<div class="bar">
<div class="placeholder"></div>Origin
<div class="placeholder"></div><div id="rotation_origin_label">Origin</div>
</div>
<div class="bar">
<div class="tool wide nslide_tool"><div class="nslide" n-action="origin_x"></div><div class="tooltip">Origin X</div></div>
<div class="tool wide nslide_tool"><div class="nslide" n-action="origin_y"></div><div class="tooltip">Origin Y</div></div>
<div class="tool wide nslide_tool"><div class="nslide" n-action="origin_z"></div><div class="tooltip">Origin Z</div></div>
<div class="tool right_tool" id="origin2geometry" onclick="origin2geometry()"><i class="material-icons">center_focus_strong</i><div class="tooltip">Origin To Geometry</div></div>
<div class="tool right_tool" id="origin2geometry" onclick="origin2geometry()"><i class="material-icons">center_focus_strong</i><div class="tooltip clip_right">Origin To Geometry</div></div>
</div>
</div>
<div id="outliner" class="ui">
<h3>Outliner</h3>
<div class="bar m_edit">
<div class="tool" onclick="addCube(0,0,0,canvas_grid,canvas_grid,canvas_grid)"><i class="material-icons">add_box</i><div class="tooltip">Add Cube</div></div>
<div class="tool" onclick="addCube()"><i class="material-icons">add_box</i><div class="tooltip">Add Cube</div></div>
<div class="tool" onclick="addGroup()"><i class="material-icons">create_new_folder</i><div class="tooltip">Add Group</div></div>
<div class="tool" id="outliner_option_toggle" onclick="toggleOutlinerOptions()"><i class="material-icons">view_stream</i><div class="tooltip">More Options</div></div>
<div id="outliner_stats">0/0</div>
Expand Down
2 changes: 1 addition & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function installUpdate() {
var received_bytes = 0;
var total_bytes = 0;

$('.uc_btn').attr('disabled', true)
$('.uc_btn').css('visibility', 'hidden')

var asar_path = __dirname
if (asar_path.includes('.asar') === false) {
Expand Down
20 changes: 1 addition & 19 deletions js/blockbench.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var appVersion = '1.10.2'
var appVersion = '1.10.3'
var osfs = '/'
var File, i;
var browser_name = 'electron'
Expand Down Expand Up @@ -52,15 +52,9 @@ var Prop = {
}
var sort_collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
var movementAxis = true;
var showSplashScreen = localStorage.getItem('welcomed_version') != appVersion

$.ajaxSetup({ cache: false });

$.getJSON('http://blockbench.net/api/index.json', function (data) {
if (data.forceSplashScreen == true) {
showSplashScreen = true
}
})

function initializeApp() {
//Browser Support Detection
Expand Down Expand Up @@ -126,8 +120,6 @@ function initializeApp() {
{icon: 'dns', name: 'Toggle Options', click: function() {toggleOutlinerOptions()} },
])
})


//Events
$(window).on( "unload", saveLocalStorages)

Expand Down Expand Up @@ -173,16 +165,6 @@ function initializeApp() {
$(this).addClass('ctx')
}
})
if (!isApp) {
showSplashScreen = tryLoadPOSTModel()
}
if (showSplashScreen) {
$('#welcome_content').load('http://www.blockbench.net/api/welcome/index.html', function() {
$('#welcome_screen #welcome_content').css('max-height', ($(window).height() - 460)+'px')
showDialog('welcome_screen')
localStorage.setItem('welcomed_version', appVersion)
})
}
Undo.add('Blank')
}
function setupVue() {
Expand Down
73 changes: 63 additions & 10 deletions js/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ class Cube extends OutlinerElement {
if (settings.entity_mode.value) return;
var scope = this
if (scope.display.autouv === 2) {
//Relative UV
var all_faces = ['north', 'south', 'west', 'east', 'up', 'down']
all_faces.forEach(function(side) {
var uv = scope.faces[side].uv.slice()
Expand Down Expand Up @@ -431,6 +432,13 @@ class Cube extends OutlinerElement {
var sy = scope.faces[face].uv[1]
var rot = scope.faces[face].rotation

//Use Texture resolution
var tex = getTextureById(scope.faces[face].texture)
if (tex && tex.res && tex.res != 16) {
size[0] *= 16 / tex.res
size[1] *= 16 / tex.res
}

//Match To Rotation
if (rot === 90 || rot === 270) {
size.reverse()
Expand Down Expand Up @@ -459,8 +467,6 @@ class Cube extends OutlinerElement {
//Prevent Mirroring
if (x < sx) x = sx
if (y < sy) y = sy

//if ()
//Return
return [sx, sy, x, y]
}
Expand Down Expand Up @@ -556,6 +562,28 @@ class Group extends OutlinerElement {
}
updateSelection()
}
selectChildren(event) {
var scope = this;
if (currently_renaming) return;
if (!event) event = {shiftKey: false}
var firstChildSelected = false

//Clear Old Group
if (selected_group) selected_group.unselect()
selected.length = 0

//Select This Group
getAllOutlinerGroups().forEach(function(s) {
s.display.isselected = false
})
this.display.isselected = true
selected_group = this

scope.children.forEach(function(s) {
s.selectLow()
})
updateSelection()
}
selectLow(highlight) {
//Only Select
if (highlight !== false) {
Expand Down Expand Up @@ -619,6 +647,7 @@ class Group extends OutlinerElement {
return array
}
renameChildren() {
this.selectChildren()
stopRenameCubes()
textPrompt('Rename Elements', '', elements[selected[0]].name, renameCubeList)
}
Expand Down Expand Up @@ -905,9 +934,9 @@ function parseGroups(array) {
obj.reset = true
}
obj.isOpen = array[i].isOpen
obj.display.visibility = array[i].display.visibility
obj.display.export = array[i].display.export
obj.display.autouv = array[i].display.autouv
if (array[i].display.visibility !== undefined) obj.display.visibility = array[i].display.visibility
if (array[i].display.export !== undefined) obj.display.export = array[i].display.export
if (array[i].display.autouv !== undefined) obj.display.autouv = array[i].display.autouv
obj.children.length = 0
obj.display.parent = addGroup
if (array[i].children.length > 0) {
Expand Down Expand Up @@ -1151,12 +1180,36 @@ function duplicateCubes() {
}
function origin2geometry() {
selected.forEach(function(s) {
if (elements[s].rotation == undefined) {
elements[s].rotation = {origin:[8,8,8], axis: 'y', angle: 0}

var obj = elements[s]
var element_size = obj.size()
var element_center = new THREE.Vector3(
(element_size[0] / 2) + obj.from[0],
(element_size[1] / 2) + obj.from[1],
(element_size[2] / 2) + obj.from[2]
)

if (obj.rotation == undefined) {
obj.rotation = {origin:[8,8,8], axis: 'y', angle: 0}
}
element_center.x -= obj.rotation.origin[0]
element_center.y -= obj.rotation.origin[1]
element_center.z -= obj.rotation.origin[2]

if (obj.display.mesh) {
element_center.applyEuler(obj.display.mesh.rotation)
}
elements[s].rotation.origin[0] = (elements[s].size(0) / 2) + elements[s].from[0]
elements[s].rotation.origin[1] = (elements[s].size(1) / 2) + elements[s].from[1]
elements[s].rotation.origin[2] = (elements[s].size(2) / 2) + elements[s].from[2]
obj.rotation.origin[0] += element_center.x
obj.rotation.origin[1] += element_center.y
obj.rotation.origin[2] += element_center.z

obj.to[0] = obj.rotation.origin[0] + element_size[0] / 2
obj.to[1] = obj.rotation.origin[1] + element_size[1] / 2
obj.to[2] = obj.rotation.origin[2] + element_size[2] / 2

obj.from[0] = obj.rotation.origin[0] - element_size[0] / 2
obj.from[1] = obj.rotation.origin[1] - element_size[1] / 2
obj.from[2] = obj.rotation.origin[2] - element_size[2] / 2
})
Canvas.updatePositions()
setUndo('Set origin to geometry')
Expand Down
41 changes: 39 additions & 2 deletions js/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function textPrompt(title, var_string, value, callback) {
console.error(err)
}
})
// textPrompt('Texture Name', 'textures[0].name')
}
function renameCubeList(name) {
selected.forEach(function(s, i) {
Expand All @@ -135,7 +134,8 @@ function randomHelpMessage() {
'You can load a blueprint of your model to make it easier to get the proportions right. Enter a side view and drag the image into the background. Use the menu on the bottom right to adjust it.',
'There are many useful plugins by the community in the plugin menu. Just click install and go.',
'Keep Blockbench updated. Updates add new functions to Blockbench, fix bugs and installing them is as easy opening the updates screen from the File menu and clicking the Update button',
'Check the Move Relative box in the Edit menu to move cubes on their rotated axis.'
'Check the Move Relative box in the Edit menu to move cubes on their rotated axis.',
'When you are renaming multiple elements, you can number them by adding the placeholders $ (relative) or % (absolute).'
]
var message = tips[Math.floor(Math.random()*tips.length)]
Blockbench.showMessageBox({
Expand Down Expand Up @@ -309,6 +309,7 @@ function updateUIColor() {
}
}
var grid_color = '0x'+app_colors.hover.hex.replace('#', '')
$('meta[name=theme-color]').attr('content', app_colors.ui.hex)

try {
three_grid.getObjectByName('grid').material.color = new THREE.Color(parseInt(grid_color, 16))
Expand Down Expand Up @@ -419,6 +420,42 @@ function updateMenu() {
})
}

//SplashScreen
var splashScreen = {
attempt: function(res) {
//NOW: Internet Available! -- DOM Ready!

//Post Model
if (!isApp && tryLoadPOSTModel()) {
return;
}

//Show
if (res[1] ||//Forced
localStorage.getItem('welcomed_version') != appVersion//Updated
) {
splashScreen.show()
}
},
show: function() {
$('#welcome_content').load('http://www.blockbench.net/api/welcome/index.html', function() {
$('#welcome_screen #welcome_body').css('max-height', ($(window).height() - 478) + 'px')
showDialog('welcome_screen')
localStorage.setItem('welcomed_version', appVersion)
})
},
p_doc: new Promise(function(resolve, reject) {
$(document).ready(function() {
resolve(true)
})
}),
p_force: new Promise(function(resolve, reject) {
$.getJSON('http://blockbench.net/api/index.json', function (data) {
resolve(data.forceSplashScreen)
})
})
}
Promise.all([splashScreen.p_doc, splashScreen.p_force]).then(splashScreen.attempt)



Expand Down
6 changes: 3 additions & 3 deletions js/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function buildBlockModel(options) { //Export Blockmodel
if (checkExport('parent', Project.parent != '')) {
blockmodel.parent = Project.parent
}
if (checkExport('ambientocclusion', Project.ambientocclusion)) {
if (checkExport('ambientocclusion', Project.ambientocclusion === false)) {
blockmodel.ambientocclusion = false
}
if (checkExport('textures', Object.keys(texturesObj).length >= 1)) {
Expand Down Expand Up @@ -133,15 +133,15 @@ function loadFile(data, filepath, makeNew) { //Load File Into GUI
if (makeNew === true) {
//Create New Project
if (newProject() == false) return;
Prop.file_name = pathToName(Prop.file_path, true)
Project.name = pathToName(Prop.file_path, false)
if (Project.name.length > 0) {
$('title').text(Project.name+' - Blockbench')
} else {
$('title').text('Blockbench')
}
Prop.project_saved = true;
Prop.file_path = filepath
Prop.file_name = pathToName(Prop.file_path, true)
Project.name = pathToName(Prop.file_path, false)
} else {
//Add to Current Project
previous_length = elements.length
Expand Down
Loading

0 comments on commit 24de749

Please sign in to comment.