mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Backgrounds are now saved per tab
Improve missing texture + ground graphic Fix mesh template angles
This commit is contained in:
parent
67dcd3a071
commit
40090c51e6
Binary file not shown.
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 130 B |
@ -179,7 +179,7 @@ const Settings = {
|
||||
currentwindow.webContents.setZoomFactor(factor)
|
||||
resizeWindow()
|
||||
}});
|
||||
new Setting('hide_tab_bar', {category: 'interface', value: !isApp, onChange() {
|
||||
new Setting('hide_tab_bar', {category: 'interface', value: Blockbench.isMobile, onChange() {
|
||||
updateTabBarVisibility();
|
||||
}});
|
||||
new Setting('origin_size', {category: 'interface', value: 10, type: 'number'});
|
||||
|
@ -168,10 +168,9 @@ var codec = new Codec('project', {
|
||||
// Backgrounds
|
||||
const backgrounds = {};
|
||||
|
||||
for (var key in canvas_scenes) {
|
||||
let scene = canvas_scenes[key];
|
||||
if (scene.image && scene.save_in_project !== false) {
|
||||
scene.save_in_project = true;
|
||||
for (var key in Project.backgrounds) {
|
||||
let scene = Project.backgrounds[key];
|
||||
if (scene.image) {
|
||||
backgrounds[key] = scene.getSaveCopy();
|
||||
}
|
||||
}
|
||||
@ -304,12 +303,10 @@ var codec = new Codec('project', {
|
||||
}
|
||||
if (model.backgrounds) {
|
||||
for (var key in model.backgrounds) {
|
||||
if (canvas_scenes.hasOwnProperty(key)) {
|
||||
if (Project.backgrounds.hasOwnProperty(key)) {
|
||||
|
||||
let store = model.backgrounds[key]
|
||||
let real = canvas_scenes[key]
|
||||
|
||||
real.save_in_project = true;
|
||||
let real = Project.backgrounds[key]
|
||||
|
||||
if (store.image !== undefined) {real.image = store.image}
|
||||
if (store.size !== undefined) {real.size = store.size}
|
||||
|
@ -28,6 +28,16 @@ class ModelProject {
|
||||
this.previews = {};
|
||||
this.EditSession = null;
|
||||
|
||||
this.backgrounds = {
|
||||
normal: new PreviewBackground({name: 'menu.preview.perspective.normal', lock: null}),
|
||||
ortho_top: new PreviewBackground({name: 'direction.top', lock: true}),
|
||||
ortho_bottom: new PreviewBackground({name: 'direction.bottom', lock: true}),
|
||||
ortho_south: new PreviewBackground({name: 'direction.south', lock: true}),
|
||||
ortho_north: new PreviewBackground({name: 'direction.north', lock: true}),
|
||||
ortho_east: new PreviewBackground({name: 'direction.east', lock: true}),
|
||||
ortho_west: new PreviewBackground({name: 'direction.west', lock: true}),
|
||||
}
|
||||
|
||||
// Data
|
||||
this.elements = [];
|
||||
this.groups = [];
|
||||
@ -191,6 +201,9 @@ class ModelProject {
|
||||
|
||||
Blockbench.dispatchEvent('select_project', {project: this});
|
||||
|
||||
Preview.all.forEach(p => {
|
||||
if (p.canvas.isConnected) p.loadBackground()
|
||||
})
|
||||
if (Preview.selected) Preview.selected.occupyTransformer();
|
||||
setProjectTitle(this.name);
|
||||
setStartScreen(!Project);
|
||||
|
@ -1242,9 +1242,9 @@ class Preview {
|
||||
this.background = canvas_scenes.normal
|
||||
}
|
||||
} else if (this.angle !== null) {
|
||||
this.background = canvas_scenes['ortho_'+this.angle]
|
||||
this.background = Project && Project.backgrounds['ortho_'+this.angle]
|
||||
} else {
|
||||
this.background = canvas_scenes.normal
|
||||
this.background = Project && Project.backgrounds.normal
|
||||
}
|
||||
return this.background
|
||||
}
|
||||
@ -1465,9 +1465,6 @@ class Preview {
|
||||
{id: 'background', icon: 'wallpaper', name: 'menu.preview.background', children(preview) {
|
||||
var has_background = !!preview.background.image
|
||||
function applyBackground(image) {
|
||||
if (!preview.background.image) {
|
||||
preview.background.save_in_project = null;
|
||||
}
|
||||
preview.background.image = image;
|
||||
preview.loadBackground();
|
||||
Settings.saveLocalStorages();
|
||||
@ -2128,7 +2125,6 @@ class PreviewBackground {
|
||||
this.x = data.x||0
|
||||
this.y = data.y||0
|
||||
this.lock = data.lock||false
|
||||
this.save_in_project = false;
|
||||
this.defaults = Object.assign({}, this);
|
||||
this.defaults.image = this.image;
|
||||
this.imgtag = new Image();
|
||||
@ -2192,16 +2188,7 @@ function initCanvas() {
|
||||
|
||||
|
||||
canvas_scenes = {
|
||||
normal: new PreviewBackground({name: 'menu.preview.perspective.normal', lock: null}),
|
||||
ortho_top: new PreviewBackground({name: 'direction.top', lock: true}),
|
||||
ortho_bottom: new PreviewBackground({name: 'direction.bottom', lock: true}),
|
||||
ortho_south: new PreviewBackground({name: 'direction.south', lock: true}),
|
||||
ortho_north: new PreviewBackground({name: 'direction.north', lock: true}),
|
||||
ortho_east: new PreviewBackground({name: 'direction.east', lock: true}),
|
||||
ortho_west: new PreviewBackground({name: 'direction.west', lock: true}),
|
||||
|
||||
monitor: new PreviewBackground({name: 'display.reference.monitor' }),
|
||||
|
||||
inventory_nine: new PreviewBackground({name: 'display.reference.inventory_nine', image: './assets/inventory_nine.png', x: 0, y: -525, size: 1051, lock: true}),
|
||||
inventory_full: new PreviewBackground({name: 'display.reference.inventory_full', image: './assets/inventory_full.png', x: 0, y: -1740, size: 2781, lock: true}),
|
||||
hud: new PreviewBackground({name: 'display.reference.hud', image: './assets/hud.png', x: -224, y: -447.5, size: 3391, lock: true}),
|
||||
@ -2219,9 +2206,6 @@ function initCanvas() {
|
||||
let store = stored_canvas_scenes[key]
|
||||
let real = canvas_scenes[key]
|
||||
|
||||
if (store.save_in_project) continue;
|
||||
if (store.save_in_project == null) {real.save_in_project = false}
|
||||
|
||||
if (store.image !== undefined) {real.image = store.image}
|
||||
if (store.size !== undefined) {real.size = store.size}
|
||||
if (store.x !== undefined) {real.x = store.x}
|
||||
@ -2231,7 +2215,6 @@ function initCanvas() {
|
||||
}
|
||||
}
|
||||
}
|
||||
active_scene = canvas_scenes.normal
|
||||
|
||||
MediaPreview = new Preview({id: 'media', offscreen: true})
|
||||
|
||||
|
@ -654,7 +654,7 @@ const TextureGenerator = {
|
||||
vec2.fromArray(mesh.vertices[face_group.faces[0].vertices[0]])
|
||||
)
|
||||
let rot = cameraTargetToRotation([0, 0, 0], normal_vec.toArray());
|
||||
let e = new THREE.Euler(Math.degToRad(rot[1] - 90), Math.degToRad(rot[0]), 0);
|
||||
let e = new THREE.Euler(Math.degToRad(-rot[1] - 90), Math.degToRad(rot[0]), 0);
|
||||
let vertex_uvs = {};
|
||||
face_group.faces.forEach(face => {
|
||||
face.vertices.forEach(vkey => {
|
||||
|
@ -756,10 +756,12 @@ const UVEditor = {
|
||||
normal_vec,
|
||||
vec2.fromArray(obj.vertices[face.vertices[0]])
|
||||
)
|
||||
let rot = cameraTargetToRotation([0, 0, 0], normal_vec.toArray());
|
||||
let e = new THREE.Euler(Math.degToRad(-rot[1] - 90), Math.degToRad(rot[0]), 0);
|
||||
console.log({rot, e, normal_vec})
|
||||
face.vertices.forEach(vkey => {
|
||||
let coplanar_pos = plane.projectPoint(vec3.fromArray(obj.vertices[vkey]), vec4.set(0, 0, 0));
|
||||
let q = quat.setFromUnitVectors(normal_vec, THREE.NormalY);
|
||||
coplanar_pos.applyQuaternion(q);
|
||||
coplanar_pos.applyEuler(e);
|
||||
vertex_uvs[vkey] = [
|
||||
Math.roundTo(coplanar_pos.x, 4),
|
||||
Math.roundTo(coplanar_pos.z, 4),
|
||||
|
Loading…
Reference in New Issue
Block a user