This commit is contained in:
JannisX11 2019-01-09 15:54:35 +01:00 committed by GitHub
parent fe649db220
commit 0471db38ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 1363 additions and 1656 deletions

View File

@ -431,9 +431,6 @@
input.mediun_width {
width: 64px;
}
.custom_select.ctx ul {
display: block;
}
div.nslide {
height: 32px;
width: 79px;
@ -658,7 +655,6 @@
.single_canvas_wrapper {
height: 100%;
width: 100%;
position: relative;
}
.quad_canvas_wrapper {
height: 50%;
@ -897,29 +893,10 @@
#cubes_list > div.vue-tree > ul > li > *:not(ul) {
display: none;
}
/*
#cubes_list > div > ul > li > ul > li > ul > li > div {
padding-left: 20px;
}
#cubes_list > div > ul > li > ul > li > ul > li > ul > li > div {
padding-left: 40px;
}
#cubes_list > div > ul > li > ul > li > ul > li > ul > li > ul > li > div {
padding-left: 60px;
}
#cubes_list > div > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > div {
padding-left: 80px;
}
#cubes_list > div > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > div {
padding-left: 100px;
}
#cubes_list > div > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul li > div {
padding-left: 120px;
}
*/
.outliner_object i.fa {
.outliner_node .outliner_object i, .outliner_object i[class^="icon-"] {
text-align: center;
width: 18px;
font-size: 17.3px;
}
.outliner_opener_placeholder {
width: 18px;
@ -1777,32 +1754,6 @@
background-color: var(--color-back);
float: none;
}
#display_presets {
margin-left: 5px;
cursor: default;
}
#display_presets ul {
display: none;
position: absolute;
max-height: 214px;
overflow-y: auto;
}
#display_presets.ctx ul {
display: block;
background-color: var(--color-dark)
}
#display_presets ul li {
cursor: default;
height: 36px;
padding: 4px;
}
#display_presets ul li > * {
float: left;
margin-right: 5px;
}
#display_presets ul li > *:hover {
color: var(--color-light);
}
.dialog.paddinged {
padding: 24px;
}

1875
index.html

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
<script>
if (typeof module === 'object') {window.module = module; module = undefined;}//jQuery Fix
const isApp = typeof require !== 'undefined';
const appVersion = '2.3.1';
const appVersion = '2.3.2';
</script>
<script src="lib/vue.min.js"></script>
<script src="lib/vue_sortable.js"></script>
@ -85,7 +85,6 @@
?></div>
<div style="display: none;"></div>
<div id="blackout" onclick="$('.dialog#'+open_dialog).find('.cancel_btn:not([disabled])').click()"></div>
<div class="dialog draggable" id="welcome_screen">
@ -100,7 +99,6 @@
<div id="updater_content"></div>
<div class="progress_bar" id="update_bar">
<div class="progress_bar_inner"></div>
</div>
@ -283,7 +281,7 @@
<h2 class="dialog_handle tl">dialog.scale.title</h2>
<div class="dialog_bar narrow">
<label for="file_folder" class="tl">dialog.scale.axis</label>
<label class="tl">dialog.scale.axis</label>
</div>
<div class="dialog_bar" style="height: 32px;">
@ -296,7 +294,7 @@
</div>
<div class="dialog_bar narrow">
<label for="file_folder" class="tl">dialog.scale.scale</label>
<label class="tl">dialog.scale.scale</label>
</div>
<div class="dialog_bar" style="height: 32px;">
@ -374,12 +372,12 @@
</div>
<div class="dialog_bar">
<label class="name_space_left tl" for="selgen_new">dialog.select.name</label>
<label class="name_space_left tl">dialog.select.name</label>
<input type="text" class="dark_bordered half" id="selgen_name">
</div>
<div class="dialog_bar">
<label class="name_space_left tl" for="selgen_new">dialog.select.random</label>
<label class="name_space_left tl">dialog.select.random</label>
<input type="range" min="0" max="100" step="1" value="100" class="tool half" id="selgen_random">
</div>
@ -410,13 +408,13 @@
</div>
<div class="dialog_bar" class="name_space_left block_mode_only">
<label for="project_description" class="name_space_left tl">dialog.project.ao</label>
<label for="project_ambientocclusion" class="name_space_left tl">dialog.project.ao</label>
<input v-model="Project.ambientocclusion" type="checkbox" id="project_ambientocclusion">
</div>
<div class="dialog_bar narrow">
<label for="project_description" class="tl">dialog.project.texture_size</label>
<label class="tl">dialog.project.texture_size</label>
</div>
<div class="dialog_bar">
<label for="project_texsize_x" class="inline_label tl">dialog.project.width</label>
@ -783,8 +781,8 @@
v-bind:min="Math.abs(slot.translation[axis]) < 10 ? -20 : (slot.translation[axis] > 0 ? -70*3+10 : -80)"
v-bind:max="Math.abs(slot.translation[axis]) < 10 ? 20 : (slot.translation[axis] < 0 ? 70*3-10 : 80)"
v-bind:step="Math.abs(slot.translation[axis]) < 10 ? 0.25 : 1"
value="0" @input="change(axis, 'rotation')" @mousedown="start" @change="save">
<input type="number" class="tool disp_text" v-model.number="slot.translation[axis]" min="-80" max="80" step="0.5" value="0" @input="change(axis, 'rotation');save()" @mousedown="start">
value="0" @input="change(axis, 'translation')" @mousedown="start" @change="save">
<input type="number" class="tool disp_text" v-model.number="slot.translation[axis]" min="-80" max="80" step="0.5" value="0" @input="change(axis, 'translation');save()" @mousedown="start">
</div>
<p class="tl">display.scale</p><div class="tool head_right" v-on:click="resetChannel('scale')"><i class="material-icons">replay</i></div>

View File

@ -5,14 +5,6 @@
* @author WestLangley / http://github.com/WestLangley
* @author erich666 / http://erichaines.com
*/
// This set of controls performs orbiting, dollying (zooming), and panning.
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
//
// Orbit - left mouse / touch: one finger move
// Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
// Pan - right mouse, or arrow keys / touch: three finger swipe
THREE.OrbitControls = function ( object, preview ) {
this.object = object;
@ -72,9 +64,7 @@ THREE.OrbitControls = function ( object, preview ) {
scope.object.updateProjectionMatrix();
scope.dispatchEvent( changeEvent );
scope.update();
state = STATE.NONE;
};
@ -246,7 +236,6 @@ THREE.OrbitControls = function ( object, preview ) {
}
function getZoomScale() {
return Math.pow( 0.95, scope.zoomSpeed );
}
@ -254,7 +243,6 @@ THREE.OrbitControls = function ( object, preview ) {
function rotateLeft( angle ) {
sphericalDelta.theta -= angle;
}
function rotateUp( angle ) {
@ -358,15 +346,12 @@ THREE.OrbitControls = function ( object, preview ) {
function dollyOut( dollyScale ) {
if ( scope.object instanceof THREE.PerspectiveCamera ) {
scale *= dollyScale;
} else if ( scope.object instanceof THREE.OrthographicCamera ) {
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
scope.object.updateProjectionMatrix();
zoomChanged = true;
} else {
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
@ -376,38 +361,21 @@ THREE.OrbitControls = function ( object, preview ) {
}
//
// event callbacks - update the object state
//
function handleMouseDownRotate( event ) {
//console.log( 'handleMouseDownRotate' );
rotateStart.set( event.clientX, event.clientY );
}
function handleMouseDownDolly( event ) {
//console.log( 'handleMouseDownDolly' );
dollyStart.set( event.clientX, event.clientY );
}
function handleMouseDownPan( event ) {
//console.log( 'handleMouseDownPan' );
panStart.set( event.clientX, event.clientY );
}
function handleMouseMoveRotate( event ) {
//console.log( 'handleMouseMoveRotate' );
rotateEnd.set( event.clientX, event.clientY );
rotateDelta.subVectors( rotateEnd, rotateStart );
@ -424,75 +392,48 @@ THREE.OrbitControls = function ( object, preview ) {
scope.update();
scope.updateSceneScale();
}
function handleMouseMoveDolly( event ) {
//console.log( 'handleMouseMoveDolly' );
dollyEnd.set( event.clientX, event.clientY );
dollyDelta.subVectors( dollyEnd, dollyStart );
if ( dollyDelta.y > 0 ) {
dollyIn( getZoomScale() );
} else if ( dollyDelta.y < 0 ) {
dollyOut( getZoomScale() );
}
dollyStart.copy( dollyEnd );
scope.update();
scope.updateSceneScale();
}
function handleMouseMovePan( event ) {
//console.log( 'handleMouseMovePan' );
panEnd.set( event.clientX, event.clientY );
panDelta.subVectors( panEnd, panStart );
pan( panDelta.x, panDelta.y );
panStart.copy( panEnd );
scope.update();
scope.updateSceneScale();
}
function handleMouseUp( event ) {
// console.log( 'handleMouseUp' );
}
function handleMouseWheel( event ) {
// console.log( 'handleMouseWheel' );
if ( event.deltaY < 0 ) {
dollyOut( getZoomScale() );
} else if ( event.deltaY > 0 ) {
dollyIn( getZoomScale() );
}
scope.update();
scope.updateSceneScale();
}
@ -522,23 +463,15 @@ THREE.OrbitControls = function ( object, preview ) {
pan( - scope.keyPanSpeed, 0 );
scope.update();
break;
}
}
function handleTouchStartRotate( event ) {
//console.log( 'handleTouchStartRotate' );
rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
}
function handleTouchStartDolly( event ) {
//console.log( 'handleTouchStartDolly' );
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
@ -549,17 +482,11 @@ THREE.OrbitControls = function ( object, preview ) {
}
function handleTouchStartPan( event ) {
//console.log( 'handleTouchStartPan' );
panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
}
function handleTouchMoveRotate( event ) {
//console.log( 'handleTouchMoveRotate' );
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
rotateDelta.subVectors( rotateEnd, rotateStart );
@ -578,18 +505,13 @@ THREE.OrbitControls = function ( object, preview ) {
}
function handleTouchMoveDolly( event ) {
//console.log( 'handleTouchMoveDolly' );
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
var distance = Math.sqrt( dx * dx + dy * dy );
dollyEnd.set( 0, distance );
dollyDelta.subVectors( dollyEnd, dollyStart );
if ( dollyDelta.y > 0 ) {
dollyOut( getZoomScale() );
@ -608,8 +530,6 @@ THREE.OrbitControls = function ( object, preview ) {
function handleTouchMovePan( event ) {
//console.log( 'handleTouchMovePan' );
panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
panDelta.subVectors( panEnd, panStart );
@ -622,95 +542,41 @@ THREE.OrbitControls = function ( object, preview ) {
}
function handleTouchEnd( event ) {
//console.log( 'handleTouchEnd' );
}
//
// event handlers - FSM: listen for events and reset state
//
function onMouseDown( event ) {
if ( scope.isEnabled() === false ) return;
if (scope.isEnabled() === false || Transformer.dragging) return;
event.preventDefault();
scope.hasMoved = false
if ( Keybinds.extra.preview_rotate.keybind.isTriggered(event) ) {
if (/**/false/**/ && scope.object.isOrthographicCamera === true && scope.enablePan === true) {
handleMouseDownPan( event );
state = STATE.PAN;
} else {
if ( scope.enableRotate === false ) return;
if (event.which === 1 && Canvas.raycast() && display_mode === false) {
return;
}
handleMouseDownRotate( event );
state = STATE.ROTATE;
}
} else if ( Keybinds.extra.preview_drag.keybind.isTriggered(event) ) {
if ( scope.enablePan === false ) return;
if (event.which === 1 && Canvas.raycast() && display_mode === false) {
return;
}
handleMouseDownPan( event );
state = STATE.PAN;
}
/*
if ( event.button === scope.mouseButtons.ORBIT ) {
if ( scope.enableRotate === false ) return;
handleMouseDownRotate( event );
state = STATE.ROTATE;
} else if ( event.button === scope.mouseButtons.ZOOM ) {
if ( scope.enableZoom === false ) return;
handleMouseDownDolly( event );
state = STATE.DOLLY;
} else if ( event.button === scope.mouseButtons.PAN ) {
if ( scope.enablePan === false ) return;
handleMouseDownPan( event );
state = STATE.PAN;
}
*/
if ( state !== STATE.NONE ) {
document.addEventListener( 'mousemove', onMouseMove, false );
document.addEventListener( 'mouseup', onMouseUp, false );
scope.dispatchEvent( startEvent );
}
@ -719,32 +585,26 @@ THREE.OrbitControls = function ( object, preview ) {
function onMouseMove( event ) {
if ( scope.isEnabled() === false ) return;
if (scope.isEnabled() === false || Transformer.dragging) return;
event.preventDefault();
scope.hasMoved = true
if ( state === STATE.ROTATE ) {
if ( scope.enableRotate === false ) return;
handleMouseMoveRotate( event );
} else if ( state === STATE.DOLLY ) {
if ( scope.enableZoom === false ) return;
handleMouseMoveDolly( event );
} else if ( state === STATE.PAN ) {
if ( scope.enablePan === false ) return;
handleMouseMovePan( event );
}
}
function onMouseUp( event ) {
@ -755,9 +615,7 @@ THREE.OrbitControls = function ( object, preview ) {
document.removeEventListener( 'mousemove', onMouseMove, false );
document.removeEventListener( 'mouseup', onMouseUp, false );
scope.dispatchEvent( endEvent );
state = STATE.NONE;
if (scope.hasMoved === false && settings.canvas_unselect.value) {
@ -777,18 +635,12 @@ THREE.OrbitControls = function ( object, preview ) {
event.stopPropagation();
handleMouseWheel( event );
scope.dispatchEvent( startEvent ); // not sure why these are here...
scope.dispatchEvent( endEvent );
}
function onKeyDown( event ) {
if ( scope.isEnabled() === false || scope.enableKeys === false || scope.enablePan === false ) return;
handleKeyDown( event );
}
function onTouchStart( event ) {
@ -807,7 +659,6 @@ THREE.OrbitControls = function ( object, preview ) {
handleTouchStartRotate( event );
state = STATE.TOUCH_ROTATE;
}
break;
case 2: // two-fingered touch: dolly
@ -827,11 +678,8 @@ THREE.OrbitControls = function ( object, preview ) {
handleTouchStartPan( event );
state = STATE.TOUCH_PAN;
break;
default:
state = STATE.NONE;
}
@ -868,7 +716,6 @@ THREE.OrbitControls = function ( object, preview ) {
break;
case 2: // two-fingered touch: dolly
if ( scope.enableZoom === false ) return;
if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?...
@ -877,7 +724,6 @@ THREE.OrbitControls = function ( object, preview ) {
break;
case 3: // three-fingered touch: pan
if ( scope.enablePan === false ) return;
if ( state !== STATE.TOUCH_PAN ) return; // is this needed?...
@ -886,174 +732,29 @@ THREE.OrbitControls = function ( object, preview ) {
break;
default:
state = STATE.NONE;
}
}
function onTouchEnd( event ) {
if ( scope.isEnabled() === false ) return;
handleTouchEnd( event );
scope.dispatchEvent( endEvent );
state = STATE.NONE;
}
function onContextMenu( event ) {
event.preventDefault();
}
//
scope.domElement.addEventListener( 'contextmenu', onContextMenu, false );
scope.domElement.addEventListener( 'mousedown', onMouseDown, false );
scope.domElement.addEventListener( 'wheel', onMouseWheel, false );
scope.domElement.addEventListener( 'touchstart', onTouchStart, false );
scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
scope.domElement.addEventListener( 'touchmove', onTouchMove, false );
window.addEventListener( 'keydown', onKeyDown, false );
// force an update at start
this.update();
};
THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
Object.defineProperties( THREE.OrbitControls.prototype, {
center: {
get: function () {
console.warn( 'THREE.OrbitControls: .center has been renamed to .target' );
return this.target;
}
},
// backward compatibility
noZoom: {
get: function () {
console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
return ! this.enableZoom;
},
set: function ( value ) {
console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
this.enableZoom = ! value;
}
},
noRotate: {
get: function () {
console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
return ! this.enableRotate;
},
set: function ( value ) {
console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
this.enableRotate = ! value;
}
},
noPan: {
get: function () {
console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
return ! this.enablePan;
},
set: function ( value ) {
console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
this.enablePan = ! value;
}
},
noKeys: {
get: function () {
console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
return ! this.enableKeys;
},
set: function ( value ) {
console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
this.enableKeys = ! value;
}
},
staticMoving: {
get: function () {
console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
return ! this.enableDamping;
},
set: function ( value ) {
console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
this.enableDamping = ! value;
}
},
dynamicDampingFactor: {
get: function () {
console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
return this.dampingFactor;
},
set: function ( value ) {
console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
this.dampingFactor = value;
}
}
} );

View File

@ -707,7 +707,7 @@
object = display_area;
} else if (Blockbench.entity_mode && selected_group) {
if (Toolbox.selected.transformerMode !== 'scale' && selected_group.parent.type === 'group') {
object = selected_group.parent.getMesh()
object = selected_group.parent.mesh
}
}
if (scope.objects.length == 0 && !selected_group && !display_mode && !Animator.open) {
@ -791,12 +791,13 @@
this.setCanvas(domElement)
function onPointerHover( event ) {
if ( scope.objects.length === 0 || ( event.button !== undefined && event.button !== 0 ) ) return;
var pointer = event.changedTouches ? event.changedTouches[ 0 ] : event;
var intersect = intersectObjects( pointer, _gizmo[ _mode ].pickers.children );
if (intersect) {
scope.dragging = true
//scope.dragging = true
}
if (_dragging === true) return;
scope.hoverAxis = null;
@ -825,7 +826,7 @@
scope.dragging = true
Transformer.getWorldPosition(worldPosition)
if (scope.camera.axis && (scope.hoverAxis.toLowerCase() === scope.camera.axis) === (_mode !== 'rotate')) return;
if (scope.camera.axis && (scope.hoverAxis && scope.hoverAxis.toLowerCase() === scope.camera.axis) === (_mode !== 'rotate')) return;
event.preventDefault();
event.stopPropagation();
scope.dispatchEvent( mouseDownEvent );
@ -1061,17 +1062,18 @@
point.applyQuaternion(rotation.inverse())
var channel = animation_channels[_mode]
if (channel === 'position') channel = 'translation'
var value = (Toolbox.selected.id === 'rotate_tool') ? angle : point[axis]
if (channel === 'scale') {
value = Math.round(value*64)/(64*8)
if (!scope.direction) value *= -1;
} else {
value = Math.round(value*4)/4
}
if (Toolbox.selected.id === 'rotate_tool') {
value = Math.trimDeg(value)
if (channel === 'position') channel = 'translation';
var value = point[axis]
var bf = display[display_slot][channel][axisNumber] - (previousValue||0)
if (channel === 'rotation') {
value = Math.trimDeg(bf + Math.round(angle*4)/4) - bf;
} else if (channel === 'translation') {
value = limitNumber( bf+Math.round(value*4)/4, -80, 80) - bf;
} else /* scale */ {
value = limitNumber( bf+Math.round(value*64)/(64*8)*(scope.direction ? 1 : -1), 0, 4) - bf;
}
if (display_slot.includes('lefthand')) {
if (channel === 'rotation' && axisNumber) {
value *= -1
@ -1087,7 +1089,7 @@
var difference = value - (previousValue||0)
display[display_slot][channel][axisNumber] += difference
if (event.shiftKey) {
if (event.shiftKey && channel === 'scale') {
var val = display[display_slot][channel][axisNumber]
display[display_slot][channel][(axisNumber+1)%3] = val
display[display_slot][channel][(axisNumber+2)%3] = val

View File

@ -1,4 +1,4 @@
var Toolbars, BarItems, MenuBar, open_menu, Toolbox;
var Toolbars, BarItems, open_menu, Toolbox;
//Bars
class MenuSeparator {
constructor() {
@ -196,7 +196,6 @@ class Action extends BarItem {
}
}
}
class Tool extends Action {
constructor(data) {
super(data)
@ -213,7 +212,7 @@ class Tool extends Action {
if (!this.condition) {
this.condition = function() {
return scope.modes && scope.modes.includes(Modes.id)
return !scope.modes || scope.modes.includes(Modes.id);
}
}
this.onCanvasClick = data.onCanvasClick;
@ -806,7 +805,7 @@ class Toolbar {
}
}
var BARS = {
const BARS = {
stored: {},
editing_bar: undefined,
action_definers: [],
@ -946,7 +945,7 @@ var BARS = {
category: 'file',
condition: () => isApp,
click: function (e) {
shell.showItemInFolder(app.app.getPath('userData')+osfs+'backups'+osfs+'.')
shell.showItemInFolder(app.getPath('userData')+osfs+'backups'+osfs+'.')
}
})
new Action({
@ -1831,7 +1830,7 @@ class BarMenu extends Menu {
return this;
}
}
var MenuBar = {
const MenuBar = {
menues: {},
open: undefined,
setup: function() {
@ -2020,7 +2019,7 @@ var MenuBar = {
'_',
'toggle_wireframe',
'toggle_quad_view',
{name: 'menu.view.screenshot', id: 'screenshot', condition: isApp, icon: 'camera_alt', children: [
{name: 'menu.view.screenshot', id: 'screenshot', icon: 'camera_alt', children: [
'screenshot_model',
'screenshot_app',
'record_model_gif',
@ -2062,7 +2061,7 @@ var MenuBar = {
}
}
}
var Keybinds = {
const Keybinds = {
actions: [],
stored: {},
extra: {},

View File

@ -177,7 +177,6 @@ class Animation {
delete
*/
])
class BoneAnimator {
constructor() {
this.keyframes = []
@ -237,13 +236,13 @@ class BoneAnimator {
}
doRender() {
this.getGroup()
if (this.group && this.group.children && this.group.getMesh()) {
let mesh = this.group.getMesh()
if (this.group && this.group.children && this.group.mesh) {
let mesh = this.group.mesh
return (mesh && mesh.fix_rotation)
}
}
displayRotation(arr) {
var bone = this.group.getMesh()
var bone = this.group.mesh
bone.rotation.copy(bone.fix_rotation)
if (!arr) {
@ -260,7 +259,7 @@ class BoneAnimator {
return this;
}
displayPosition(arr) {
var bone = this.group.getMesh()
var bone = this.group.mesh
bone.position.copy(bone.fix_position)
if (arr) {
bone.position.add(new THREE.Vector3().fromArray(arr))
@ -268,7 +267,7 @@ class BoneAnimator {
return this;
}
displayScale(arr) {
var bone = this.group.getMesh()
var bone = this.group.mesh
if (arr) {
bone.scale.x = bone.scale.y = bone.scale.z = arr[0] ? arr[0] : 0.00001
} else {
@ -349,7 +348,7 @@ class BoneAnimator {
this.displayScale(result)
}
}
this.group.getMesh().updateMatrixWorld()
this.group.mesh.updateMatrixWorld()
}
select() {
var duplicates;
@ -591,6 +590,7 @@ class Keyframe {
if (this.parent) {
this.parent.keyframes.remove(this)
}
Timeline.selected.remove(this)
}
extend(data) {
if (data.channel && Animator.possible_channels[data.channel]) {
@ -649,7 +649,6 @@ class Keyframe {
*/
])
function updateKeyframeValue(obj) {
var axis = $(obj).attr('axis')
var value = $(obj).val()
@ -731,7 +730,6 @@ function removeSelectedKeyframes() {
Undo.finishEdit('remove keyframes')
}
const Animator = {
possible_channels: {rotation: true, position: true, scale: true},
channel_index: ['rotation', 'position', 'scale'],
@ -890,7 +888,6 @@ const Animator = {
animations: animations
}
}
}
const Timeline = {
keyframes: [],//frames
@ -949,25 +946,26 @@ const Timeline = {
Animator.preview()
}
})
.mousemove(e => {
$(document).mousemove(e => {
if (Timeline.dragging_marker) {
let time = e.offsetX / Timeline.vue._data.size
let offset = mouse_pos.x - $('#timeline_inner #timeline_time').offset().left
let time = offset / Timeline.vue._data.size
Timeline.setTime(time)
if (Animator.selected) {
Animator.preview()
}
Animator.preview()
}
})
$(document).mouseup(e => {
.mouseup(e => {
if (Timeline.dragging_marker) {
delete Timeline.dragging_marker
}
})
//Keyframe inputs
$('.keyframe_input').click(e => {
Undo.initEdit({keyframes: Timeline.selected, keep_saved: true})
}).focusout(e => {
Undo.finishEdit('edit keyframe')
})
//Enter Time
$('#timeline_corner').click(e => {
if ($('#timeline_corner').attr('contenteditable') == 'true') return;
@ -994,7 +992,6 @@ const Timeline = {
range.setEnd(node, sel[1])
selection.removeAllRanges();
selection.addRange(range);
})
.on('focusout keydown', e => {
if (e.type === 'focusout' || Keybinds.extra.confirm.keybind.isTriggered(e) || Keybinds.extra.cancel.keybind.isTriggered(e)) {

View File

@ -172,10 +172,6 @@ class API {
} else {
jq_dialog.css('width', limitNumber(options.buttons.length*170+44, 380, 894)+'px')
}
setTimeout(function() {
$('.context_handler.ctx').removeClass('ctx')
}, 64)
open_dialog = 'message_box'
open_interface = 'message_box'
return jq_dialog
@ -226,7 +222,7 @@ class API {
options.extensions = ['png', 'jpg', 'jpeg', 'bmp', 'tiff', 'tif', 'gif']
}
app.dialog.showOpenDialog(
electron.dialog.showOpenDialog(
currentwindow,
{
title: options.title ? options.title : '',
@ -401,7 +397,7 @@ class API {
cb()
}
} else {
app.dialog.showSaveDialog(currentwindow, {
electron.dialog.showSaveDialog(currentwindow, {
filters: [ {
name: options.type,
extensions: options.extensions
@ -517,7 +513,7 @@ class API {
delete this.drag_handlers[id]
}
}
var Blockbench = new API()
const Blockbench = new API()
function Dialog(settings) {
var scope = this;
@ -619,9 +615,6 @@ function Dialog(settings) {
if (this.width) {
jq_dialog.css('width', this.width+'px')
}
setTimeout(function() {
$('.context_handler.ctx').removeClass('ctx')
}, 64)
open_dialog = scope.id
open_interface = scope
Prop.active_panel = 'dialog'

View File

@ -1,22 +1,22 @@
var app = require('electron').remote,
fs = require('fs'),
nativeImage = require('electron').nativeImage,
exec = require('child_process').exec,
originalFs = require('original-fs'),
https = require('https'),
currentwindow = app.getCurrentWindow(),
dialog_win = null,
const electron = require('electron').remote;
const {clipboard, shell, nativeImage} = require('electron');
const app = electron.app;
const fs = require('fs');
const zlib = require('zlib');
const exec = require('child_process').exec;
const originalFs = require('original-fs');
const https = require('https');
const currentwindow = electron.getCurrentWindow();
var dialog_win = null,
latest_version = false,
preventClosing = true;
recent_projects= undefined
const shell = require('electron').shell;
const {clipboard} = require('electron')
recent_projects= undefined;
$(document).ready(function() {
if (app.process.argv.length >= 2) {
if (app.process.argv[1].substr(-5) == '.json') {
readFile(app.process.argv[1], true)
if (electron.process.argv.length >= 2) {
if (electron.process.argv[1].substr(-5) == '.json') {
readFile(electron.process.argv[1], true)
}
}
$('.open-in-browser').click((event) => {
@ -24,8 +24,8 @@ $(document).ready(function() {
shell.openExternal(event.target.href);
return true;
});
if (fs.existsSync(app.app.getPath('userData')+osfs+'backups') === false) {
fs.mkdirSync( app.app.getPath('userData')+osfs+'backups')
if (fs.existsSync(app.getPath('userData')+osfs+'backups') === false) {
fs.mkdirSync( app.getPath('userData')+osfs+'backups')
}
createBackup(true)
$('.web_only').remove()
@ -38,22 +38,22 @@ getLatestVersion(true)
//Called on start to show message
function getLatestVersion(init) {
if (process.platform == 'linux') return;
$.getJSON('https://blockbench.net/api/index.json', (data) => {
$.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) {
Blockbench.showMessageBox({
Blockbench.showMessageBox({
translateKey: 'update_notification',
message: tl('message.update_notification.message', [latest_version]),
icon: 'update',
buttons: [tl('message.update_notification.install'), tl('message.update_notification.later')],
confirm: 0, cancel: 1
}, (result) => {
if (result === 0) {
checkForUpdates(true)
}
})
}, (result) => {
if (result === 0) {
checkForUpdates(true)
}
})
} else if (init === false) {
checkForUpdates()
@ -209,7 +209,7 @@ function changeImageEditor(texture) {
}).show()
}
function selectImageEditorFile(texture) {
app.dialog.showOpenDialog(currentwindow, {
electron.dialog.showOpenDialog(currentwindow, {
title: tl('message.image_editor.exe'),
filters: [{name: 'Executable Program', extensions: ['exe']}]
}, function(filePaths) {
@ -223,7 +223,7 @@ function selectImageEditorFile(texture) {
}
//Default Pack
function openDefaultTexturePath() {
var answer = app.dialog.showMessageBox(currentwindow, {
var answer = electron.dialog.showMessageBox(currentwindow, {
type: 'info',
buttons: (
settings.default_path.value ? [tl('dialog.cancel'), tl('message.default_textures.continue'), tl('message.default_textures.remove')]
@ -237,7 +237,7 @@ function openDefaultTexturePath() {
if (answer === 0) {
return;
} else if (answer === 1) {
app.dialog.showOpenDialog(currentwindow, {
electron.dialog.showOpenDialog(currentwindow, {
title: tl('message.default_textures.select'),
properties: ['openDirectory'],
}, function(filePaths) {
@ -406,7 +406,7 @@ function writeFileEntity(content, filepath) {
obj = JSON.parse(data.replace(/\/\*[^(\*\/)]*\*\/|\/\/.*/g, ''))
} catch (err) {
err = err+''
var answer = app.dialog.showMessageBox(currentwindow, {
var answer = electron.dialog.showMessageBox(currentwindow, {
type: 'warning',
buttons: [
tl('message.bedrock_overwrite_error.backup_overwrite'),
@ -461,7 +461,7 @@ function writeFileEntity(content, filepath) {
Blockbench.showQuickMessage('message.save_entity')
Prop.project_saved = true;
setProjectTitle(pathToName(filepath, false))
addRecentProject({name: pathToName(filepath, 'mobs_id'), path: filepath})
addRecentProject({name: pathToName(filepath, 'mobs_id'), path: filepath})
if (Blockbench.hasFlag('close_after_saving')) {
closeBlockbenchWindow()
}
@ -503,25 +503,25 @@ function writeFileObj(content, filepath) {
//Open
function readFile(filepath, makeNew) {
fs.readFile(filepath, 'utf-8', function (err, data) {
if (err) {
console.log(err)
Blockbench.showMessageBox({
fs.readFile(filepath, 'utf-8', function (err, data) {
if (err) {
console.log(err)
Blockbench.showMessageBox({
translateKey: 'file_not_found',
icon: 'error_outline'
})
return;
}
addRecentProject({name: pathToName(filepath, 'mobs_id'), path: filepath})
loadModel(data, filepath, !makeNew)
})
})
return;
}
addRecentProject({name: pathToName(filepath, 'mobs_id'), path: filepath})
loadModel(data, filepath, !makeNew)
})
}
//Backup
function createBackup(init) {
setTimeout(createBackup, limitNumber(parseFloat(settings.backup_interval.value), 1, 10e8)*60000)
var duration = parseInt(settings.backup_retain.value)+1
var folder_path = app.app.getPath('userData')+osfs+'backups'
var folder_path = app.getPath('userData')+osfs+'backups'
var d = new Date()
var days = d.getDate() + (d.getMonth()+1)*30.44 + (d.getYear()-100)*365.25
@ -598,7 +598,7 @@ function showSaveDialog(close) {
}
})
if ((Prop.project_saved === false && elements.length > 0) || unsaved_textures) {
var answer = app.dialog.showMessageBox(currentwindow, {
var answer = electron.dialog.showMessageBox(currentwindow, {
type: 'question',
buttons: [tl('dialog.save'), tl('dialog.discard'), tl('dialog.cancel')],
title: 'Blockbench',

View File

@ -34,8 +34,8 @@ const Project = {
texture_height : 16,
ambientocclusion: true,
}
var mouse_pos = {x:0,y:0}
var sort_collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
const mouse_pos = {x:0,y:0}
const sort_collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
$.ajaxSetup({ cache: false });
@ -222,9 +222,9 @@ function setupVue() {
DisplayMode.slot.scale[2] = val;
}
} else if (channel === 'translation') {
DisplayMode.slot.translation[axis] = limitNumber(DisplayMode.slot.translation[axis], -80, 80)
DisplayMode.slot.translation[axis] = limitNumber(DisplayMode.slot.translation[axis], -80, 80)||0;
} else {
DisplayMode.slot.rotation[axis] = Math.trimDeg(DisplayMode.slot.rotation[axis])
DisplayMode.slot.rotation[axis] = Math.trimDeg(DisplayMode.slot.rotation[axis])||0;
}
DisplayMode.updateDisplayBase()
},
@ -347,11 +347,11 @@ function updateSelection() {
}
if (obj.selected === true) {
if (Toolbox.selected.transformerMode !== 'hidden' && obj.visibility === true && (Toolbox.selected.transformerMode !== 'rotate' || !Blockbench.entity_mode)) {
Transformer.attach(obj.getMesh())
Transformer.attach(obj.mesh)
}
}
if (obj.visibility) {
var mesh = obj.getMesh()
var mesh = obj.mesh
if (mesh && mesh.outline) {
mesh.outline.visible = obj.selected
}
@ -375,10 +375,10 @@ function updateSelection() {
if (selected_group) {
$('.selection_only#options').css('visibility', 'visible')
if (settings.origin_size.value > 0 && selected_group.visibility) {
selected_group.getMesh().add(rot_origin)
selected_group.mesh.add(rot_origin)
}
if (Toolbox.selected.transformerMode === 'rotate') {
Transformer.attach(selected_group.getMesh())
Transformer.attach(selected_group.mesh)
}
} else {
$('.selection_only#options').css('visibility', 'hidden')
@ -392,7 +392,7 @@ function updateSelection() {
} else {
//Origin Helper
if (selected.length === 1 && selected[0].visibility) {
let mesh = selected[0].getMesh()
let mesh = selected[0].mesh
if (mesh) {
mesh.add(rot_origin)
}
@ -416,7 +416,7 @@ function updateSelection() {
i++;
}
if (first_visible && typeof origin === 'object') {
let mesh = first_visible.getMesh()
let mesh = first_visible.mesh
if (mesh) {
mesh.add(rot_origin)
}
@ -518,7 +518,6 @@ class Mode extends KeybindItem {
Modes.selected = this;
updateInterface()
Canvas.updateRenderSides()
resizeWindow()
if (BarItems[this.default_tool]) {
BarItems[this.default_tool].select()
} else {
@ -577,12 +576,6 @@ BARS.defineActions(function() {
//Misc
var Screencam = {
fullScreen: function(options, cb) {
setTimeout(function() {
$('.context_handler.ctx').removeClass('ctx')
$('.context_handler.ctx').removeClass('ctx')
$('.context_handler.ctx').removeClass('ctx')
$('.context_handler.ctx').removeClass('ctx')
}, 10)
setTimeout(function() {
currentwindow.capturePage(function(screenshot) {
var dataUrl = screenshot.toDataURL()
@ -621,7 +614,7 @@ var Screencam = {
cancel: 0
}, function(result) {
if (result === 1) {
app.dialog.showSaveDialog(currentwindow, {filters: [ {name: tl('data.image'), extensions: [is_gif ? 'gif' : 'png']} ]}, function (fileName) {
electron.dialog.showSaveDialog(currentwindow, {filters: [ {name: tl('data.image'), extensions: [is_gif ? 'gif' : 'png']} ]}, function (fileName) {
if (fileName === undefined) {
return;
}
@ -788,8 +781,6 @@ var Clipbench = {
Vue.nextTick(Timeline.update)
}
}
} else if (p == 'uv' || p == 'preview') {
main_uv.paste(event)
} else if (p == 'textures' && isApp) {
@ -808,6 +799,7 @@ var Clipbench = {
var group = 'root'
if (selected_group) {
group = selected_group
selected_group.isOpen = true
} else if (selected[0]) {
group = selected[0]
}
@ -826,6 +818,9 @@ var Clipbench = {
} catch (err) {}
}
if (Clipbench.group) {
if (typeof Clipbench.group.duplicate !== 'function') {
Clipbench.group = new Group(Clipbench.group)
}
Clipbench.group.duplicate(group)
} else {
Clipbench.cubes.forEach(function(obj) {
@ -988,15 +983,15 @@ var Vertexsnap = {
$('#preview').get(0).removeEventListener("mousemove", Vertexsnap.hoverCanvas)
$('#preview').get(0).addEventListener("mousemove", Vertexsnap.hoverCanvas)
var o_vertices = cube.getMesh().geometry.vertices
cube.getMesh().updateMatrixWorld()
var o_vertices = cube.mesh.geometry.vertices
cube.mesh.updateMatrixWorld()
o_vertices.forEach(function(v, id) {
var outline_color = '0x'+app_colors.accent.hex.replace('#', '')
var mesh = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), new THREE.MeshBasicMaterial({color: parseInt(outline_color)}))
var pos = mesh.position.copy(v)
pos.applyMatrix4(cube.getMesh().matrixWorld)
pos.applyMatrix4(cube.mesh.matrixWorld)
pos.addScalar(8)
mesh.rotation.copy(cube.getMesh().rotation)
mesh.rotation.copy(cube.mesh.rotation)
mesh.cube = cube
mesh.isVertex = true
mesh.vertex_id = id
@ -1096,7 +1091,7 @@ var Vertexsnap = {
}
Vertexsnap.cubes.forEach(function(obj) {
var q = obj.getMesh().getWorldQuaternion(new THREE.Quaternion()).inverse()
var q = obj.mesh.getWorldQuaternion(new THREE.Quaternion()).inverse()
var cube_pos = new THREE.Vector3().copy(pos).applyQuaternion(q)
for (i=0; i<3; i++) {
@ -1118,7 +1113,7 @@ var Vertexsnap = {
obj.origin[1] += cube_pos.getComponent(1)
obj.origin[2] += cube_pos.getComponent(2)
} else {
var q = obj.getMesh().getWorldQuaternion(new THREE.Quaternion()).inverse()
var q = obj.mesh.getWorldQuaternion(new THREE.Quaternion()).inverse()
cube_pos.applyQuaternion(q)
}
obj.from[0] += cube_pos.getComponent(0)

View File

@ -5,7 +5,6 @@ var ground_animation = false;
var ground_timer = 0
var display_slot;
var display_preview;
var display_clipboard;
var enterDisplaySettings, exitDisplaySettings;
const DisplayMode = {};
@ -13,11 +12,15 @@ const DisplayMode = {};
class DisplaySlot {
constructor(id, data) {
this.default()
if (data) this.extend(data)
}
default() {
this.rotation = [0, 0, 0];
this.translation = [0, 0, 0];
this.scale = [1, 1, 1];
this.mirror = [false, false, false]
if (data) this.extend(data)
return this;
}
copy() {
return {
@ -56,7 +59,7 @@ class DisplaySlot {
return this;
}
update() {
if (this === DisplayMode.slot) {
if (display_mode && this === DisplayMode.slot) {
DisplayMode.vue.$forceUpdate()
DisplayMode.updateDisplayBase()
}
@ -1251,18 +1254,19 @@ window.displayReferenceObjects = {
'thirdperson_righthand',
'thirdperson_lefthand',
'firstperson_righthand',
'firstperson_righthand',
'firstperson_lefthand',
'ground',
'gui',
'head',
'fixed',
]
}
DisplayMode.slots = displayReferenceObjects.slots
enterDisplaySettings = function() { //Enterung Display Setting Mode, changes the scene etc
display_mode = true;
selected = []
selected.empty()
updateSelection()
if (!display_preview) {
@ -1280,14 +1284,13 @@ enterDisplaySettings = function() { //Enterung Display Setting Mode, changes th
$('.m_edit').hide()
$('.m_disp').show()
$('#display_bar input#thirdperson_righthand').prop("checked", true)
updateInterface()
buildGrid()
setShading()
DisplayMode.loadThirdRight()
Canvas.updateRenderSides()
resizeWindow()
display_area.updateMatrixWorld()
display_base.updateMatrixWorld()
DisplayMode.centerTransformer()
@ -1388,7 +1391,10 @@ DisplayMode.applyPreset = function(preset, all) {
};
Undo.initEdit({display_slots: slots})
slots.forEach(function(sl) {
DisplayMode.slot.extend(preset.areas[sl])
if (!display[sl]) {
display[sl] = new DisplaySlot()
}
display[sl].extend(preset.areas[sl])
})
DisplayMode.updateDisplayBase()
Undo.finishEdit('apply display preset')
@ -1420,7 +1426,6 @@ DisplayMode.loadJSON = function(data) {
}
}
var setDisplayArea = DisplayMode.setBase = function(x, y, z, rx, ry, rz, sx, sy, sz) {//Sets the Work Area to the given Space
display_area.rotation['x'] = Math.PI / (180 / rx);
display_area.rotation['y'] = Math.PI / (180 / ry);
@ -1464,7 +1469,6 @@ function loadDisp(key) { //Loads The Menu and slider values, common for all Radi
DisplayMode.vue._data.slot = display[key]
DisplayMode.slot = display[key]
DisplayMode.updateDisplayBase()
DisplayMode.centerTransformer()
}
DisplayMode.loadThirdRight = function() { //Loader
@ -1551,11 +1555,11 @@ DisplayMode.load = function(slot) {
}
DisplayMode.copy = function() {
display_clipboard = DisplayMode.slot.copy()
Clipbench.display_slot = DisplayMode.slot.copy()
}
DisplayMode.paste = function() {
Undo.initEdit({display_slots: [display_slot]})
DisplayMode.slot.extend(display_clipboard)
DisplayMode.slot.extend(Clipbench.display_slot)
DisplayMode.updateDisplayBase()
Undo.finishEdit('paste display slot')
}

View File

@ -40,9 +40,11 @@ var OutlinerButtons = {
},
shading: {
id: 'shading',
title: tl('switches.shading'),
icon: ' fa fa-star',
icon_off: ' fa fa-star-o',
get title() {return Blockbench.entity_mode ? tl('switches.mirror') : tl('switches.shading')},
get icon() {return Blockbench.entity_mode ? 'fa fa-star' : 'fa fa-star'},
get icon_off() {return Blockbench.entity_mode ? 'fa fa-star-half-o' : 'fa fa-star-o'},
//icon: ' fa fa-star',
//icon_off: ' fa fa-star-o',
advanced_option: true,
click: function(obj) {
obj.toggle('shade')
@ -346,7 +348,7 @@ class Cube extends OutlinerElement {
if (!this.parent || (this.parent === 'root' && TreeElements.indexOf(this) === -1)) {
this.addTo()
}
if (this.visibility && (!this.getMesh() || !scene.children.includes(this.getMesh()))) {
if (this.visibility && (!this.mesh || !scene.children.includes(this.mesh))) {
Canvas.addCube(this)
}
if (update !== false) {
@ -385,9 +387,12 @@ class Cube extends OutlinerElement {
return this.rotation_axis;
}
getMesh() {
return Canvas.meshes[this.uuid]
return this.mesh;
}
index() {
get mesh() {
return Canvas.meshes[this.uuid];
}
get index() {
return elements.indexOf(this)
}
select(event, isOutlinerClick) {
@ -539,7 +544,7 @@ class Cube extends OutlinerElement {
remove(update) {
TreeElements.clearObjectRecursive(this)
if (this.visibility) {
var mesh = this.getMesh()
var mesh = this.mesh
if (mesh) {
if (mesh.parent) {
mesh.parent.remove(mesh)
@ -552,7 +557,7 @@ class Cube extends OutlinerElement {
if (selected.includes(this)) {
selected.splice(selected.indexOf(this), 1)
}
elements.splice(this.index(), 1)
elements.splice(this.index, 1)
if (Transformer.dragging) {
outlines.remove(outlines.getObjectByName(this.uuid+'_ghost_outline'))
}
@ -1049,6 +1054,9 @@ class Group extends OutlinerElement {
}
}
getMesh() {
return this.mesh;
}
get mesh() {
var bone = Canvas.bones[this.uuid]
if (!bone) {
bone = new THREE.Object3D()
@ -1289,9 +1297,11 @@ class Group extends OutlinerElement {
} else if (destination !== 'cache') {
base_group.addTo(destination, false)
}
base_group.createUniqueName()
Canvas.updatePositions()
loadOutlinerDraggable()
if (destination !== 'cache') {
base_group.createUniqueName()
Canvas.updatePositions()
loadOutlinerDraggable()
}
return base_group;
}
getChildlessCopy() {
@ -1424,8 +1434,7 @@ Array.prototype.clearObjectRecursive = function(obj) {
Array.prototype.findRecursive = function(key1, val) {
var i = 0
while (i < this.length) {
let tag = this[i][key1]
if (tag === val) {
if (this[i][key1] === val) {
return this[i];
} else if (this[i].children && this[i].children.length > 0) {
let inner = this[i].children.findRecursive(key1, val)
@ -1854,7 +1863,7 @@ function renameCubes(element) {
Blockbench.textPrompt(tl('message.rename_cubes'), selected[0].name, function (name) {
Undo.initEdit({cubes: selected})
selected.forEach(function(obj, i) {
obj.name = name.split('%').join(obj.index()).split('$').join(i)
obj.name = name.replace(/%/g, obj.index).replace(/\$/g, i)
})
Undo.finishEdit('rename')
})
@ -1915,6 +1924,7 @@ BARS.defineActions(function() {
id: 'add_group',
icon: 'create_new_folder',
category: 'edit',
condition: () => !Animator.open,
keybind: new Keybind({key: 71, ctrl: true}),
click: function () {
addGroup();

View File

@ -166,7 +166,7 @@ var Interface = {
right_bar_width: 300,
quad_view_x: 50,
quad_view_y: 50,
left_bar: ['uv', 'textures', 'display'],
left_bar: ['uv', 'textures', 'display', 'animations', 'keyframe', 'variable_placeholders'],
right_bar: ['options', 'outliner']
},
Resizers: {
@ -397,9 +397,6 @@ function setupInterface() {
unselectTextures()
})
$(document).mousedown(function(event) {
if ($('.ctx').find(event.target).length === 0) {
$('.context_handler.ctx').removeClass('ctx')
}
if (open_menu && $('.contextMenu').find(event.target).length === 0 && $('.menu_bar_point.opened:hover').length === 0) {
open_menu.hide();
}
@ -472,20 +469,26 @@ function updateInterface() {
BARS.updateConditions()
MenuBar.update()
resizeWindow()
resizeWindow()
localStorage.setItem('interface_data', JSON.stringify(Interface.data))
}
function updateInterfacePanels() {
var left_width = $('.sidebar#left_bar > .panel:visible').length ? Interface.data.left_bar_width : 0
var right_width = $('.sidebar#right_bar > .panel:visible').length ? Interface.data.right_bar_width : 0
$('body').css(
'grid-template-columns',
left_width+'px auto '+ right_width +'px'
Interface.data.left_bar_width+'px auto '+ Interface.data.right_bar_width +'px'
)
for (var key in Interface.Panels) {
var panel = Interface.Panels[key]
panel.update()
}
var left_width = $('.sidebar#left_bar > .panel:visible').length ? Interface.data.left_bar_width : 0
var right_width = $('.sidebar#right_bar > .panel:visible').length ? Interface.data.right_bar_width : 0
if (!left_width || !right_width) {
$('body').css(
'grid-template-columns',
left_width+'px auto '+ right_width +'px'
)
}
$('.quad_canvas_wrapper.qcw_x').css('width', Interface.data.quad_view_x+'%')
$('.quad_canvas_wrapper.qcw_y').css('height', Interface.data.quad_view_y+'%')
$('.quad_canvas_wrapper:not(.qcw_x)').css('width', (100-Interface.data.quad_view_x)+'%')
@ -496,6 +499,26 @@ function updateInterfacePanels() {
}
}
function resizeWindow(event) {
if (!previews || (event && event.target && event.target !== window)) {
return;
}
if (Animator.open) {
Timeline.updateSize()
}
if (Interface.data) {
updateInterfacePanels()
}
previews.forEach(function(prev) {
if (prev.canvas.isConnected) {
prev.resize()
}
})
BARS.updateToolToolbar()
}
$(window).resize(resizeWindow)
function setActivePanel(panel) {
Prop.active_panel = panel
}
@ -524,9 +547,6 @@ function showDialog(dialog) {
$('.dialog').hide(0)
$('#blackout').fadeIn(200)
obj.fadeIn(200)
setTimeout(function() {
$('.context_handler.ctx').removeClass('ctx')
}, 64)
open_dialog = dialog
open_interface = dialog
Prop.active_panel = 'dialog'

View File

@ -869,7 +869,7 @@ function buildBlockModel(options) {
if (s.export == false) return;
//Create Element
var element = {}
element_index_lut[s.index()] = clear_elements.length
element_index_lut[s.index] = clear_elements.length
if ((options.cube_name !== false && !settings.minifiedout.value) || options.cube_name === true) {
if (s.name !== 'cube') {
@ -1036,11 +1036,14 @@ function buildBlockModel(options) {
if (checkExport('display', Object.keys(display).length >= 1)) {
var new_display = {}
var entries = 0;
for (var key in display) {
var slot = display[key].export()
if (slot) {
new_display[key] = display[key].export()
entries++;
for (var i in DisplayMode.slots) {
var key = DisplayMode.slots[i]
if (DisplayMode.slots.hasOwnProperty(i) && display[key]) {
var slot = display[key].export()
if (slot) {
new_display[key] = display[key].export()
entries++;
}
}
}
if (entries) {
@ -1122,7 +1125,7 @@ function buildEntityModel(options) {
cube.mirror = !s.shade
}
//Visible Bounds
var mesh = s.getMesh()
var mesh = s.mesh
if (mesh) {
visible_box.expandByObject(mesh)
}
@ -1583,8 +1586,9 @@ BARS.defineActions(function() {
category: 'file',
keybind: new Keybind({key: 78, ctrl: true, shift: true}),
click: function () {
newProject(true);
showDialog('project_settings');
if (newProject(true)) {
showDialog('project_settings');
}
}
})
//Import

View File

@ -1,4 +1,3 @@
class Keybind {
constructor(keys) {
this.key = -1;
@ -166,8 +165,6 @@ class Keybind {
}
}
function setupKeybindings() {
Keybinds.vue = new Vue({
el: 'ul#keybindlist',
@ -215,7 +212,6 @@ function setupKeybindings() {
})
}
$(document).keydown(function(e) {
if (Keybinds.recording) return;
//Shift
@ -243,7 +239,7 @@ $(document).keydown(function(e) {
}
//Hardcoded Keys
if (e.ctrlKey === true && e.which == 73 && isApp) {
app.getCurrentWindow().toggleDevTools()
electron.getCurrentWindow().toggleDevTools()
used = true
} else if (e.which === 18 && Toolbox.selected.alt_tool && !Toolbox.original) {
//Alt Tool
@ -253,6 +249,8 @@ $(document).keydown(function(e) {
alt.select()
Toolbox.original = orig
}
} else if (Keybinds.extra.cancel.keybind.isTriggered(e) && (Transformer.dragging/* || ...*/)) {
Undo.cancelEdit()
}
//Keybinds
if (!input_focus) {
@ -303,4 +301,4 @@ $(document).keyup(function(e) {
Toolbox.original.select()
delete Toolbox.original;
}
});
})

View File

@ -63,7 +63,7 @@ function loadLanguage() {
dataType: "json",
url: 'lang/'+Language.code+'.json',
//data: data,
async: false,
//async: false,
success: function(data) {
Language.data = data
translateUI()

View File

@ -3,8 +3,8 @@ Plugin Loader for Blockbench
By JannisX11
*/
var onUninstall, onInstall;
var Plugins = {
apipath: 'https://blockbench.net/api/plugins.json',
const Plugins = {
apipath: 'https://raw.githubusercontent.com/JannisX11/blockbench-plugins/master/plugins.json',
Vue: [], //Vue Object
installed: [], //Simple List of Names
json: undefined, //Json from website
@ -27,16 +27,14 @@ var Plugins = {
}
if (isApp) {
Plugins.path = app.app.getPath('userData')+osfs+'plugins'+osfs
Plugins.path = app.getPath('userData')+osfs+'plugins'+osfs
fs.readdir(Plugins.path, function(err) {
if (err) {
fs.mkdir(Plugins.path, function(a) {})
}
})
} else {
Plugins.apipath = '../api/plugins.json'
}
$.getJSON('https://blockbench.net/api/plugins.json', function(data) {
$.getJSON(Plugins.apipath, function(data) {
Plugins.json = data
if (Plugins.loadingStep === true) {
loadInstalledPlugins()
@ -217,7 +215,7 @@ function loadPlugin(id, cb, install) {
saveInstalledPlugins()
})
} else {
$.getScript('https://blockbench.net/api/plugins/'+id+'.js', function() {
$.getScript('https://raw.githubusercontent.com/JannisX11/blockbench-plugins/master/plugins/'+id+'.js', function() {
if (onUninstall) {
Plugins.data.findInArray('id', id).uninstall = onUninstall
onUninstall = undefined
@ -305,7 +303,7 @@ function downloadPlugin(id, is_install) {
//$('.uc_btn').attr('disabled', true)
var file = originalFs.createWriteStream(Plugins.path+id+'.js')
var request = https.get('https://blockbench.net/api/plugins/'+id+'.js', function(response) {
var request = https.get('https://raw.githubusercontent.com/JannisX11/blockbench-plugins/master/plugins/'+id+'.js', function(response) {
response.pipe(file);
response.on('end', function() {
setTimeout(function() {

View File

@ -445,7 +445,7 @@ class Preview {
if ((event.shiftKey || event.ctrlKey) && scope.selection.old_selected.indexOf(cube) >= 0) {
var isSelected = true
} else {
var mesh = cube.getMesh()
var mesh = cube.mesh
var from = new THREE.Vector3().copy(mesh.geometry.vertices[6]).applyMatrix4(mesh.matrixWorld)
var to = new THREE.Vector3().copy(mesh.geometry.vertices[0]).applyMatrix4(mesh.matrixWorld)
var cube_rect = getRectangle(
@ -592,7 +592,7 @@ class Preview {
edit(rot_origin)
edit(Vertexsnap.vertexes)
selected.forEach(function(obj) {
var m = obj.getMesh()
var m = obj.mesh
if (m && m.outline) {
edit(m.outline)
}
@ -643,8 +643,15 @@ class Preview {
var wrapper = $('<div class="single_canvas_wrapper"></div>')
wrapper.append(this.canvas)
$('#preview').append(wrapper)
resizeWindow()
previews.forEach(function(prev) {
if (prev.canvas.isConnected) {
prev.resize()
}
})
if (Interface.data) {
updateInterfacePanels()
}
return this;
}
toggleFullscreen() {
@ -940,25 +947,6 @@ function animate() {
DisplayMode.groundAnimation()
}
}
function resizeWindow(event) {
if (!previews || (event && event.target && event.target !== window)) {
return;
}
previews.forEach(function(prev) {
if (prev.canvas.isConnected) {
prev.resize()
}
})
if (Interface.data) {
updateInterfacePanels()
}
if (Animator.open) {
Timeline.updateSize()
}
BARS.updateToolToolbar()
}
$(window).resize(resizeWindow)
function setShading() {
scene.remove(lights)
@ -1093,7 +1081,7 @@ function centerTransformer(offset) {
var rotate_tool = Toolbox.selected.transformerMode === 'rotate'
if (Animator.open && selected_group) {
var g_mesh = selected_group.getMesh()
var g_mesh = selected_group.mesh
g_mesh.getWorldPosition(Transformer.position)
Transformer.position.x += 8;
@ -1120,7 +1108,7 @@ function centerTransformer(offset) {
var center = [0, 0, 0]
var i = 0;
selected.forEach(function(obj) {
var m = obj.getMesh()
var m = obj.mesh
if (obj.visibility && m) {
var pos = new THREE.Vector3(
obj.from[0] + obj.size(0)/2,
@ -1176,7 +1164,7 @@ function centerTransformer(offset) {
Transformer.rotation.set(0, 0, 0)
Transformer.position.copy(vec)
var mesh = first_obj.getMesh()
var mesh = first_obj.mesh
if (mesh && Blockbench.globalMovement === false && !rotate_tool) {
Transformer.rotation.copy(mesh.rotation)
}
@ -1184,7 +1172,7 @@ function centerTransformer(offset) {
//Entity Mode
if (selected_group && rotate_tool) {
var mesh = selected_group.getMesh()
var mesh = selected_group.mesh
if (mesh) {
mesh.getWorldPosition(Transformer.position)
}
@ -1215,7 +1203,7 @@ function centerTransformer(offset) {
vec.x -= group.origin[0]
vec.y -= group.origin[1]
vec.z -= group.origin[2]
vec.applyEuler(first_obj.getMesh().rotation)
vec.applyEuler(first_obj.mesh.rotation)
vec.x += group.origin[0]
vec.y += group.origin[1]
vec.z += group.origin[2]
@ -1223,7 +1211,7 @@ function centerTransformer(offset) {
Transformer.position.copy(vec)
if (Blockbench.globalMovement === false && !rotate_tool) {
var rotation = new THREE.Quaternion()
first_obj.getMesh().getWorldQuaternion(rotation)
first_obj.mesh.getWorldQuaternion(rotation)
Transformer.rotation.setFromQuaternion( rotation )
} else {
Transformer.rotation.set(0, 0, 0)
@ -1344,7 +1332,7 @@ class CanvasController {
}
updateVisibility() {
elements.forEach(function(s) {
var mesh = s.getMesh()
var mesh = s.mesh
if (s.visibility == true) {
if (!mesh) {
Canvas.addCube(s)
@ -1408,7 +1396,7 @@ class CanvasController {
arr = selected
}
arr.forEach(function(obj) {
var mesh = obj.getMesh()
var mesh = obj.mesh
if (mesh !== undefined) {
mesh.parent.remove(mesh)
}
@ -1461,7 +1449,7 @@ class CanvasController {
outlineObjects(arr) {
arr.forEach(function(obj) {
if (!obj.visibility) return;
var mesh = obj.getMesh()
var mesh = obj.mesh
if (mesh === undefined) return;
var line = Canvas.getOutlineMesh(mesh)
@ -1478,7 +1466,7 @@ class CanvasController {
updateAllBones() {
getAllOutlinerGroups().forEach((obj) => {
let mesh = obj.getMesh()
let mesh = obj.mesh
if (obj.visibility && mesh) {
mesh.rotation.reorder('ZYX')
@ -1494,7 +1482,7 @@ class CanvasController {
mesh.position.y -= obj.parent.origin[1]
mesh.position.z -= obj.parent.origin[2]
var parent_mesh = obj.parent.getMesh()
var parent_mesh = obj.parent.mesh
parent_mesh.add(mesh)
} else {
scene.add(mesh)
@ -1526,7 +1514,7 @@ class CanvasController {
adaptObjectPosition(obj, mesh, parent) {
if (!obj.visibility) return;
if (!mesh || mesh > 0) mesh = obj.getMesh()
if (!mesh || mesh > 0) mesh = obj.mesh
function setSize(geo) {
if (Blockbench.entity_mode && obj.inflate !== undefined) {
@ -1549,7 +1537,7 @@ class CanvasController {
mesh.position.set(0, 0, 0)
mesh.rotation.reorder('YZX')
if (obj.parent.type === 'group') {
obj.parent.getMesh().add(mesh)
obj.parent.mesh.add(mesh)
mesh.position.x -= obj.parent.origin[0]
mesh.position.y -= obj.parent.origin[1]
mesh.position.z -= obj.parent.origin[2]
@ -1586,7 +1574,7 @@ class CanvasController {
function iterate(obj, mesh) {
//Iterate inside (cube) > outside
if (!mesh) {
mesh = obj.getMesh()
mesh = obj.mesh
}
if (obj.type === 'group') {
mesh.rotation.reorder('ZYX')
@ -1621,7 +1609,7 @@ class CanvasController {
iterate(el, elmesh)
}
adaptObjectFaces(obj, mesh) {
if (!mesh) mesh = obj.getMesh()
if (!mesh) mesh = obj.mesh
if (!mesh) return;
if (!Prop.wireframe) {
var materials = []
@ -1646,7 +1634,7 @@ class CanvasController {
}
updateUV(obj, animation, force_entity_mode) {
if (Prop.wireframe === true) return;
var mesh = obj.getMesh()
var mesh = obj.mesh
if (mesh === undefined) return;
mesh.geometry.faceVertexUvs[0] = [];
@ -1689,34 +1677,34 @@ class CanvasController {
f.from[1] /= Project.texture_height / 16
f.size[0] /= Project.texture_width / 16
f.size[1] /= Project.texture_height / 16
var data = {
uv: [
f.from[0] + Math.floor(obj.uv_offset[0]+0.0000001) / Project.texture_width * 16,
f.from[1] + Math.floor(obj.uv_offset[1]+0.0000001) / Project.texture_height * 16,
f.from[0] + f.size[0] + Math.floor(obj.uv_offset[0]+0.0000001) / Project.texture_width * 16,
f.from[1] + f.size[1] + Math.floor(obj.uv_offset[1]+0.0000001) / Project.texture_height * 16
]
}
data.uv.forEach(function(s, si) {
data.uv[si] *= 1
var uv= [
f.from[0] + obj.uv_offset[0] / Project.texture_width * 16,
f.from[1] + obj.uv_offset[1] / Project.texture_height * 16,
f.from[0] + f.size[0] + obj.uv_offset[0] / Project.texture_width * 16,
f.from[1] + f.size[1] + obj.uv_offset[1] / Project.texture_height * 16
]
uv.forEach(function(s, si) {
uv[si] *= 1
})
obj.faces[f.face].uv[0] = data.uv[0]
obj.faces[f.face].uv[1] = data.uv[1]
obj.faces[f.face].uv[2] = data.uv[2]
obj.faces[f.face].uv[3] = data.uv[3]
obj.faces[f.face].uv[0] = uv[0]
obj.faces[f.face].uv[1] = uv[1]
obj.faces[f.face].uv[2] = uv[2]
obj.faces[f.face].uv[3] = uv[3]
var uvArray = getUVArray(data, 0)
mesh.geometry.faceVertexUvs[0][f.fIndex] = [
uvArray[0],
uvArray[1],
uvArray[3]
];
mesh.geometry.faceVertexUvs[0][f.fIndex+1] = [
uvArray[1],
uvArray[2],
uvArray[3]
];
var do_cl = Math.random()<0.001
//Fight Bleeding
for (var si = 0; si < 2; si++) {
let margin = 16/(si?Project.texture_height:Project.texture_width)/16;
if (uv[si] > uv[si+2]) {
margin = -margin
}
uv[si] += margin
uv[si+2] -= margin
}
Canvas.updateUVFace(mesh.geometry.faceVertexUvs[0], f.fIndex, {uv: uv}, 0)
})
} else {
@ -1726,15 +1714,6 @@ class CanvasController {
var frame = 0
for (var face in obj) {
if (obj.hasOwnProperty(face)) {
var fIndex = 0;
switch(face) {
case 'north': fIndex = 10;break;
case 'east': fIndex = 0; break;
case 'south': fIndex = 8; break;
case 'west': fIndex = 2; break;
case 'up': fIndex = 4; break;
case 'down': fIndex = 6; break;
}
stretch = 1
frame = 0
if (obj[face].texture && obj[face].texture !== null) {
@ -1746,17 +1725,7 @@ class CanvasController {
}
}
}
var uvArray = getUVArray(obj[face], frame, stretch)
mesh.geometry.faceVertexUvs[0][fIndex] = [
uvArray[0],
uvArray[1],
uvArray[3]
];
mesh.geometry.faceVertexUvs[0][fIndex+1] = [
uvArray[1],
uvArray[2],
uvArray[3]
];
Canvas.updateUVFace(mesh.geometry.faceVertexUvs[0], Canvas.face_order.indexOf(face)*2, obj[face], frame, stretch)
}
}
@ -1764,6 +1733,55 @@ class CanvasController {
mesh.geometry.elementsNeedUpdate = true;
return mesh.geometry
}
updateUVFace(vertex_uvs, index, face, frame, stretch) {
if (stretch === undefined) {
stretch = -1
} else {
stretch = stretch*(-1)
}
if (!vertex_uvs[index]) vertex_uvs[index] = [];
if (!vertex_uvs[index+1]) vertex_uvs[index+1] = [];
var arr = [
vertex_uvs[index][0],
vertex_uvs[index][1],
vertex_uvs[index+1][1],
vertex_uvs[index+1][2],
]
for (var i = 0; i < 4; i++) {
if (arr[i] === undefined) {
arr[i] = new THREE.Vector2()
}
}
arr[0].set(face.uv[0]/16, (face.uv[1]/16)/stretch+1), //0,1
arr[1].set(face.uv[0]/16, (face.uv[3]/16)/stretch+1), //0,0
arr[2].set(face.uv[2]/16, (face.uv[3]/16)/stretch+1), //1,0
arr[3].set(face.uv[2]/16, (face.uv[1]/16)/stretch+1) //1,1
if (frame > 0 && stretch !== -1) {
//Animate
var offset = (1/stretch) * frame
arr[0].y += offset
arr[1].y += offset
arr[2].y += offset
arr[3].y += offset
}
var rot = (face.rotation+0)
while (rot > 0) {
arr.push(arr.shift())
rot = rot-90;
}
vertex_uvs[index] = [
arr[0],
arr[1],
arr[3]
];
vertex_uvs[index+1] = [
arr[1],
arr[2],
arr[3]
];
}
//Outline
getOutlineMesh(mesh) {
var vs = mesh.geometry.vertices
@ -1782,7 +1800,7 @@ class CanvasController {
}
buildOutline(obj) {
if (obj.visibility == false) return;
var mesh = obj.getMesh();
var mesh = obj.mesh;
if (mesh === undefined) return;
if (mesh.outline) {
@ -1800,7 +1818,7 @@ class CanvasController {
mesh.add(line);
}
}
var Canvas = new CanvasController()
const Canvas = new CanvasController()
BARS.defineActions(function() {
new Action({
@ -1863,6 +1881,7 @@ BARS.defineActions(function() {
id: 'screenshot_app',
icon: 'icon-bb_interface',
category: 'view',
condition: isApp,
click: function () {Screencam.fullScreen()}
})
new Action({
@ -1874,25 +1893,6 @@ BARS.defineActions(function() {
main_preview.toggleFullscreen()
}
})
//{icon: getBtn(0, true), name: 'menu.preview.perspective.normal', click: function(preview) {preview.setNormalCamera()}},
//{icon: getBtn(0), name: 'direction.top', color: 'y', (0)}},
//{icon: getBtn(1), name: 'direction.bottom', color: 'y', (1)}},
//{icon: getBtn(2), name: 'direction.south', color: 'z', (2)}},
//{icon: getBtn(3), name: 'direction.north', color: 'z', (3)}},
//{icon: getBtn(4), name: 'direction.east', color: 'x', (4)}},
//{icon: getBtn(5), name: 'direction.west', color: 'x', (5)}}
/*
reset_view: {shift: false, ctrl: false, alt: false, code: 96, name: 'Reset View', char: 'NUMPAD 0'},
view_normal: {shift: false, ctrl: false, alt: false, code: 101, name: 'Normal View', char: 'NUMPAD 5'},
view_0: {shift: false, ctrl: false, alt: false, code: 104, name: 'Top View', char: 'NUMPAD 8'},
view_1: {shift: false, ctrl: false, alt: false, code: 98, name: 'Bottom View', char: 'NUMPAD 2'},
view_2: {shift: false, ctrl: false, alt: false, code: 100, name: 'South View', char: 'NUMPAD 4'},
view_3: {shift: false, ctrl: false, alt: false, code: 102, name: 'North View', char: 'NUMPAD 6'},
view_4: {shift: false, ctrl: false, alt: false, code: 103, name: 'East View', char: 'NUMPAD 7'},
view_5: {shift: false, ctrl: false, alt: false, code: 105, name: 'West View', char: 'NUMPAD 9'}
*/
new Action({
id: 'camera_reset',
name: 'direction.top',

View File

@ -567,7 +567,7 @@ class Texture {
if (fs.existsSync(settings.image_editor.value)) {
require('child_process').spawn(settings.image_editor.value, [this.path])
} else {
var answer = app.dialog.showMessageBox(currentwindow, {
var answer = electron.dialog.showMessageBox(currentwindow, {
type: 'info',
noLink: true,
title: tl('message.image_editor_missing.title'),
@ -909,7 +909,7 @@ function changeTexturesFolder() {
path.splice(-1)
path = path.join(osfs)
app.dialog.showOpenDialog(currentwindow, {
electron.dialog.showOpenDialog(currentwindow, {
title: tl('message.default_textures.select'),
properties: ['openDirectory'],
defaultPath: path

View File

@ -49,8 +49,8 @@ function origin2geometry() {
element_center.y -= obj.origin[1]
element_center.z -= obj.origin[2]
if (obj.getMesh()) {
element_center.applyEuler(obj.getMesh().rotation)
if (obj.mesh) {
element_center.applyEuler(obj.mesh.rotation)
}
obj.origin[0] += element_center.x
obj.origin[1] += element_center.y
@ -171,7 +171,7 @@ function moveCube(obj, val, axis, move_origin) {
m[getAxisLetter(axis)] = difference
var rotation = new THREE.Quaternion()
obj.getMesh().getWorldQuaternion(rotation)
obj.mesh.getWorldQuaternion(rotation)
m.applyQuaternion(rotation.inverse())
obj.from[0] += m.x;

View File

@ -35,6 +35,12 @@ var Undo = {
Prop.project_saved = false;
}
},
cancelEdit: function() {
if (!Undo.current_save) return;
outlines.children.length = 0
Undo.loadSave(Undo.current_save, new Undo.save(Undo.current_save.aspects))
delete Undo.current_save;
},
undo: function() {
if (Undo.history.length <= 0 || Undo.index < 1) return;
@ -146,7 +152,11 @@ var Undo = {
if (aspects.display_slots) {
scope.display_slots = {}
aspects.display_slots.forEach(slot => {
scope.display_slots[slot] = display[slot].copy()
if (display[slot]) {
scope.display_slots[slot] = display[slot].copy()
} else {
scope.display_slots[slot] = null
}
})
}
},
@ -155,7 +165,7 @@ var Undo = {
for (var uuid in save.cubes) {
if (save.cubes.hasOwnProperty(uuid)) {
var data = save.cubes[uuid]
var obj = TreeElements.findRecursive('uuid', uuid)
var obj = elements.findInArray('uuid', uuid)
if (obj) {
for (var face in obj.faces) {
obj.faces[face] = {uv: []}
@ -171,7 +181,7 @@ var Undo = {
}
for (var uuid in reference.cubes) {
if (reference.cubes.hasOwnProperty(uuid) && !save.cubes.hasOwnProperty(uuid)) {
var obj = TreeElements.findRecursive('uuid', uuid)
var obj = elements.findInArray('uuid', uuid)
if (obj) {
obj.remove(false)
}
@ -275,22 +285,19 @@ var Undo = {
var animation = false;
if (Animator.selected.uuid !== save.keyframes.animation) {
animation = Animator.animations.findInArray('uuid', save.keyframes.animation)
} else {
animation = Animator.selected
if (animation.select) {
animation.select()
}
}
if (animation.select && animation !== Animator.selected) {
animation.select()
}
var bone = false;
if (Animator.selected.uuid !== save.keyframes.animation) {
animation = Animator.animations.findInArray('uuid', save.keyframes.animation)
} else {
animation = Animator.selected
}
if (animation.select && animation !== Animator.selected) {
animation.select()
var bone = Animator.selected.getBoneAnimator();
if (!bone || bone.uuid !== save.keyframes.bone) {
for (var uuid in Animator.selected.bones) {
if (uuid === save.keyframes.bone) {
bone = Animator.selected.bones[uuid]
bone.select()
}
}
}
@ -312,11 +319,14 @@ var Undo = {
kf.extend(data)
} else {
kf = new Keyframe(data)
kf.parent = bone;
kf.uuid = uuid;
Timeline.keyframes.push(kf)
added++;
}
}
}
for (var uuid in reference.keyframes) {
if (uuid.length === 36 && reference.keyframes.hasOwnProperty(uuid) && !save.keyframes.hasOwnProperty(uuid)) {
var kf = getKeyframe(uuid)
@ -329,14 +339,19 @@ var Undo = {
Vue.nextTick(Timeline.update)
}
updateKeyframeSelection()
Animator.preview()
}
if (save.display_slots) {
for (var slot in save.display_slots) {
if (!display[slot]) {
var data = save.display_slots[slot]
if (!display[slot] && data) {
display[slot] = new DisplaySlot()
} else if (data === null && display[slot]) {
display[slot].default()
}
display[slot].extend(save.display_slots[slot]).update()
display[slot].extend(data).update()
}
}
updateSelection()

View File

@ -205,13 +205,10 @@ Array.prototype.empty = function() {
this.length = 0;
}
Array.prototype.findInArray = function(key, value) {
if (this.length === 0) return {};
var i = 0
while (i < this.length) {
for (var i = 0; i < this.length; i++) {
if (this[i][key] === value) return this[i]
i++;
}
return {};
return false;
}
Array.prototype.positiveItems = function() {
var x = 0, i = 0;

View File

@ -431,7 +431,7 @@ class UVEditor {
forCubes(cb) {
var i = 0;
while (i < selected.length) {
cb(selected[i], selected[i].index())
cb(selected[i])
i++;
}
}
@ -603,7 +603,7 @@ class UVEditor {
applyTexture(id) {
var scope = this;
Undo.initEdit({cubes: selected, uv_only: true})
this.forCubes(function(obj) {
this.forCubes(obj => {
obj.faces[scope.face].texture = '#'+id
})
this.loadData()
@ -834,20 +834,20 @@ class UVEditor {
//Events
disableAutoUV() {
this.forCubes(function(obj) {
this.forCubes(obj => {
obj.autouv = 0
})
}
toggleUV() {
var scope = this
var state = selected[0].faces[this.face].enabled === false
this.forCubes(function(obj) {
this.forCubes(obj => {
obj.faces[scope.face].enabled = state
})
}
maximize(event) {
var scope = this;
this.forCubes(function(obj) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
obj.faces[side].uv = [0, 0, 16, 16]
})
@ -861,7 +861,7 @@ class UVEditor {
var scope = this;
var top, left, top2, left2;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
left = top = 0;
if (side == 'north' || side == 'south') {
@ -884,7 +884,7 @@ class UVEditor {
}
setRelativeAutoSize(event) {
var scope = this;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
var uv = obj.faces[side].uv
switch (side) {
@ -950,7 +950,7 @@ class UVEditor {
}
mirrorX(event) {
var scope = this;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
var proxy = obj.faces[side].uv[0]
obj.faces[side].uv[0] = obj.faces[side].uv[2]
@ -964,7 +964,7 @@ class UVEditor {
}
mirrorY(event) {
var scope = this;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
var proxy = obj.faces[side].uv[1]
obj.faces[side].uv[1] = obj.faces[side].uv[3]
@ -978,7 +978,7 @@ class UVEditor {
}
applyAll(event) {
var scope = this;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
uv_dialog.allFaces.forEach(function(side) {
$.extend(true, obj.faces[side], obj.faces[scope.face])
})
@ -991,7 +991,7 @@ class UVEditor {
clear(event) {
var scope = this;
Undo.initEdit({cubes: selected, uv_only: true})
this.forCubes(function(obj, i) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
obj.faces[side].uv = [0, 0, 0, 0]
obj.faces[side].texture = null;
@ -1008,7 +1008,7 @@ class UVEditor {
Undo.initEdit({cubes: selected, uv_only: true})
var val = BarItems.cullface.get()
if (val === 'off') val = false
this.forCubes(function(obj) {
this.forCubes(obj => {
if (val) {
obj.faces[scope.face].cullface = val
} else {
@ -1027,7 +1027,7 @@ class UVEditor {
var val = selected[0].faces[scope.face].tintindex === undefined
if (event === true || event === false) val = event
this.forCubes(function(obj) {
this.forCubes(obj => {
if (val) {
obj.faces[scope.face].tintindex = 0
} else {
@ -1044,7 +1044,7 @@ class UVEditor {
rotate() {
var scope = this;
var value = BarItems.uv_rotation.get()
this.forCubes(function(obj, i) {
this.forCubes(obj => {
if (value == 0) {
delete obj.faces[scope.face].rotation
} else {
@ -1057,7 +1057,7 @@ class UVEditor {
}
setRotation(value) {
var scope = this;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
if (value == 0) {
delete obj.faces[scope.face].rotation
} else {
@ -1072,7 +1072,7 @@ class UVEditor {
}
autoCullface(event) {
var scope = this;
this.forCubes(function(obj) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
obj.faces[side].cullface = side
})
@ -1192,7 +1192,7 @@ class UVEditor {
}
reset(event) {
var scope = this;
this.forCubes(function(obj, i) {
this.forCubes(obj => {
scope.getFaces(event).forEach(function(side) {
obj.faces[side].uv = [0, 0, 1, 1]
delete obj.faces[side].texture;
@ -1321,7 +1321,7 @@ class UVEditor {
])
var uv_dialog = {
const uv_dialog = {
isSetup: false,
single: false,
clipboard: null,

View File

@ -1,5 +1,8 @@
(function() {
$.getScript("lib/file_saver.js");
$.getScript('https://rawgit.com/nodeca/pako/master/dist/pako.js', function() {
window.zlib = pako
})
})()
$(document).ready(function() {

View File

@ -823,5 +823,7 @@
"action.color_picker": "Farbpipette",
"action.color_picker.desc": "Wählt die Farbe eines Pixels der Textur aus.",
"action.open_backup_folder": "Backup-Ordner öffnen",
"action.open_backup_folder.desc": "Öffnet den Backup-Ordner von Blockbench"
"action.open_backup_folder.desc": "Öffnet den Backup-Ordner von Blockbench",
"switches.mirror": "UV Spiegeln",
"language_name": "Deutsch"
}

View File

@ -1,4 +1,6 @@
{
"language_name": "English",
"dialog.ok": "OK",
"dialog.cancel": "Cancel",
"dialog.confirm": "Confirm",
@ -826,6 +828,7 @@
"switches.visibility": "Visibility",
"switches.export": "Export",
"switches.shading": "Shade",
"switches.mirror": "Mirror UV",
"switches.autouv": "Auto UV",
"panel.uv": "UV",

View File

@ -823,5 +823,7 @@
"action.color_picker": "Seleccionador de Color",
"action.color_picker.desc": "Herramienta para seleccionar el color de píxeles en tu textura",
"action.open_backup_folder": "Abrir Carpeta de Backups",
"action.open_backup_folder.desc": "Abre la carpeta de backups de Blockbench"
"action.open_backup_folder.desc": "Abre la carpeta de backups de Blockbench",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -823,5 +823,7 @@
"action.color_picker": "Pipette à couleurs",
"action.color_picker.desc": "Outil pour choisir la couleur des pixels sur votre texture",
"action.open_backup_folder": "Ouvrir le dossier de sauvegarde",
"action.open_backup_folder.desc": "Ouvre le dossier de sauvegarde de Blockbench"
"action.open_backup_folder.desc": "Ouvre le dossier de sauvegarde de Blockbench",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -806,15 +806,15 @@
"action.export_class_entity.desc": "エンティティモデルをjava としてエクスポートする",
"settings.seethrough_outline": "X-Rey アウトライン",
"settings.seethrough_outline.desc": "オブジェクトを通してアウトラインを表示する",
"mode.edit": "Edit",
"mode.paint": "Paint",
"mode.display": "Display",
"mode.animate": "Animate",
"mode.edit": "編集",
"mode.paint": "ペイント",
"mode.display": "ディスプレイ",
"mode.animate": "生き物",
"status_bar.recording_gif": "Recording GIF",
"status_bar.processing_gif": "Processing GIF",
"settings.backup_retain": "Backup Retain Duration",
"settings.backup_retain.desc": "Set how long Blockbench retains old backups in days",
"action.rotate_tool": "Rotate",
"action.rotate_tool": "回転",
"action.rotate_tool.desc": "Tool to select and rotate elements",
"action.fill_tool": "Paint Bucket",
"action.fill_tool.desc": "Paint bucket to fill entire faces with one color",
@ -823,5 +823,7 @@
"action.color_picker": "Color Picker",
"action.color_picker.desc": "Tool to pick the color of pixels on your texture",
"action.open_backup_folder": "Open Backup Folder",
"action.open_backup_folder.desc": "Opens the Blockbench backup folder"
"action.open_backup_folder.desc": "Opens the Blockbench backup folder",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -823,5 +823,7 @@
"action.color_picker": "Color Picker",
"action.color_picker.desc": "Tool to pick the color of pixels on your texture",
"action.open_backup_folder": "Open Backup Folder",
"action.open_backup_folder.desc": "Opens the Blockbench backup folder"
"action.open_backup_folder.desc": "Opens the Blockbench backup folder",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -823,5 +823,7 @@
"action.color_picker": "Color Picker",
"action.color_picker.desc": "Tool to pick the color of pixels on your texture",
"action.open_backup_folder": "Open Backup Folder",
"action.open_backup_folder.desc": "Opens the Blockbench backup folder"
"action.open_backup_folder.desc": "Opens the Blockbench backup folder",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -38,7 +38,7 @@
"keys.down": "Стрелка вниз",
"keys.pageup": "Page Up",
"keys.pagedown": "Page Down",
"keys.plus": "+",
"keys.plus": "Плюс",
"keys.comma": ",",
"keys.point": ".",
"keys.minus": "-",
@ -810,8 +810,8 @@
"mode.paint": "Красить",
"mode.display": "Предпросмотр",
"mode.animate": "Анимировать",
"status_bar.recording_gif": "Recording GIF",
"status_bar.processing_gif": "Processing GIF",
"status_bar.recording_gif": "Запись GIF",
"status_bar.processing_gif": "Обработка GIF",
"settings.backup_retain": "Продолжительность хранения автосохранений",
"settings.backup_retain.desc": "Set how long Blockbench retains old backups in days",
"action.rotate_tool": "Вращать",
@ -822,6 +822,8 @@
"action.eraser.desc": "Eraser tool to replace colors on a texture with transparency",
"action.color_picker": "Color Picker",
"action.color_picker.desc": "Tool to pick the color of pixels on your texture",
"action.open_backup_folder": "Открыть папку",
"action.open_backup_folder.desc": "Opens the Blockbench backup folder"
"action.open_backup_folder": "Открыть папку автосохранений",
"action.open_backup_folder.desc": "Opens the Blockbench backup folder",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -823,5 +823,7 @@
"action.color_picker": "Color Picker",
"action.color_picker.desc": "Tool to pick the color of pixels on your texture",
"action.open_backup_folder": "Open Backup Folder",
"action.open_backup_folder.desc": "Opens the Blockbench backup folder"
"action.open_backup_folder.desc": "Opens the Blockbench backup folder",
"switches.mirror": "Mirror UV",
"language_name": "English"
}

View File

@ -823,5 +823,7 @@
"action.color_picker": "颜色选择器",
"action.color_picker.desc": "用于选择材质纹理上像素颜色的工具",
"action.open_backup_folder": "打开备份文件夹",
"action.open_backup_folder.desc": "打开Blockbench备份文件夹"
"action.open_backup_folder.desc": "打开Blockbench备份文件夹",
"switches.mirror": "Mirror UV",
"language_name": "中文"
}

10
main.js
View File

@ -17,9 +17,9 @@ function createWindow () {
}
})
var index_path = path.join(__dirname, 'index.html')
if (__dirname.includes('xampp\\htdocs\\')) {
//index_path = path.join(__dirname, 'index.php')
}
/*if (__dirname.includes('xampp\\htdocs\\')) {
index_path = path.join(__dirname, 'index.php')
}*/
win.setMenu(null);
win.maximize()
win.show()
@ -35,15 +35,15 @@ function createWindow () {
}
app.commandLine.appendSwitch('ignore-gpu-blacklist')
app.on('ready', createWindow)
app.on('window-all-closed', () => {
app.quit()
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
})

View File

@ -1,7 +1,7 @@
{
"name": "Blockbench",
"description": "Minecraft Block Model Editor",
"version": "2.3.1",
"version": "2.3.2",
"license": "MIT",
"author": {
"name": "JannisX11",
@ -42,7 +42,7 @@
"x": 200,
"y": 100,
"width": 440,
"height": 220
"height": 220
},
"contents": [
{
@ -71,10 +71,12 @@
},
"scripts": {
"dist": "build --publish=always",
"dist32": "build -w --ia32 --publish=always"
"win64": "build -w --ia32 --publish=always",
"win32": "build -w --x64 --publish=always"
},
"devDependencies": {
"async": "^2.4.1",
"electron": "4.0.1",
"electron-builder": "^20.38.4"
}
}