This commit is contained in:
JannisX11 2018-01-02 20:34:44 +01:00 committed by GitHub
parent af893a20ab
commit 24de749431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 143 additions and 58 deletions

View File

@ -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>
@ -697,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>

View File

@ -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">
@ -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>
@ -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>
@ -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>
@ -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">
@ -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>
@ -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>
@ -1057,22 +1056,22 @@
<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>

View File

@ -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) {

View File

@ -1,4 +1,4 @@
var appVersion = '1.10.2'
var appVersion = '1.10.3'
var osfs = '/'
var File, i;
var browser_name = 'electron'
@ -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
@ -126,8 +120,6 @@ function initializeApp() {
{icon: 'dns', name: 'Toggle Options', click: function() {toggleOutlinerOptions()} },
])
})
//Events
$(window).on( "unload", saveLocalStorages)
@ -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() {

View File

@ -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()
@ -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()
@ -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]
}
@ -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) {
@ -619,6 +647,7 @@ class Group extends OutlinerElement {
return array
}
renameChildren() {
this.selectChildren()
stopRenameCubes()
textPrompt('Rename Elements', '', elements[selected[0]].name, renameCubeList)
}
@ -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) {
@ -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}
}
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]
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)
}
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')

View File

@ -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) {
@ -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({
@ -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))
@ -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)

View File

@ -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)) {
@ -133,8 +133,6 @@ 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 {
@ -142,6 +140,8 @@ function loadFile(data, filepath, makeNew) { //Load File Into GUI
}
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

View File

@ -76,7 +76,7 @@ function loadInstalledPlugins() {
installed: Plugins.installed.includes(id)
}
if (obj.installed) {
loadPlugin(id)
downloadPlugin(id)
}
Plugins.data.push(obj)
Plugins.data.sort(function(a,b) {
@ -84,6 +84,7 @@ function loadInstalledPlugins() {
});
}
} else if (Plugins.installed.length > 0) {
//Only show downloaded plugins in the plugin window
Plugins.installed.forEach(function(id) {
loadPlugin(id, function() {
//Plugin Data Comes from the plugin file
@ -170,7 +171,7 @@ function saveInstalledPlugins() {
localStorage.setItem('installed_plugins', JSON.stringify(Plugins.installed))
hideDialog()
}
function loadPlugin(id, cb, install) {
function loadPlugin(id, cb, install, allow_update) {
if (isApp === true) {
$.getScript(Plugins.path + id + '.js', function(a) {
if (onUninstall) {

View File

@ -120,18 +120,17 @@ function settingSetup() {
headline3: {is_title: true, title: "Edit"},
entity_mode: {value: false, name: 'Entity Model Mode', desc: 'Unrestricted editing mode for Bedrock and Optifine models'},
undo_limit: {value: 20, is_number: true, name: 'Undo Limit', desc: 'Number of steps you can undo'},
restricted_canvas:{value: true, name: 'Restricted Canvas', desc: 'Move rotated elements on their own axes if possible'},
restricted_canvas:{value: true, name: 'Restricted Canvas', desc: 'Restrict Canvas to 3x3 block area to prevent invalid models'},
move_origin: {value: false, name: 'Move on Relative Axes', desc: 'Move rotated elements on their own axes if possible'},
autouv: {value: true, name: 'Auto UV', desc: 'Enable AutoUV by default'},
create_rename:{value: false, name: 'Rename new Cube', desc: 'Focus name field when creating new element or group'},
create_rename:{value: false, name: 'Rename New Cube', desc: 'Focus name field when creating new element or group'},
canvas_unselect:{value: false, name: 'Canvas Click Unselect', desc: 'Unselects all elements when clicking on the canvas background'},
show_actions: {value: false, name: 'Tell Actions', desc: 'Display every action in the status bar'},
show_actions: {value: false, name: 'Display Actions', desc: 'Display every action in the status bar'},
//Snapping
headline4: {is_title: true, title: "Snapping"},
edit_size: {value: 16, is_number: true, name: 'Grid Resolution', desc: 'Resolution of the grid that cubes snap to'},
shift_size: {value: 64, is_number: true, name: 'Shift Resolution', desc: 'Resolution of the grid while holding shift'},
ctrl_size: {value: 160, is_number: true, name: 'Control Resolution', desc: 'Resolution of the grid while holding control'},
//rotation_snap:{value: true, name: 'Rotation Snap', desc: 'Snap Rotations to 22.5° (limit of the Minecraft model format)'},
snapnslide: {value: false, name: 'Snap Slider', desc: 'Snaps combo-sliders to their valid positions'},
//Export
headline5: {is_title: true, title: "Export"},

View File

@ -29,9 +29,9 @@ function tryLoadPOSTModel() {
tex.load()
})
}
return false;
return true;
} else {
return showSplashScreen
return false
}
}

View File

@ -1,7 +1,7 @@
{
"name": "Blockbench",
"description": "Minecraft Block Model Editor",
"version": "1.10.2",
"version": "1.10.3",
"author": {
"name": "JannisX11",
"email": "info@blockbench.net"