mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
Add tube shape
Fix issue with preview context menu Move "Hide Everything except selection" into view menu
This commit is contained in:
parent
5200544cff
commit
4137963abf
@ -634,7 +634,6 @@ const MenuBar = {
|
||||
})
|
||||
|
||||
new BarMenu('filter', [
|
||||
'hide_everything_except_selection',
|
||||
'remove_blank_faces',
|
||||
])
|
||||
|
||||
@ -675,6 +674,7 @@ const MenuBar = {
|
||||
'_',
|
||||
'toggle_sidebars',
|
||||
'toggle_quad_view',
|
||||
'hide_everything_except_selection',
|
||||
'focus_on_selection',
|
||||
{name: 'menu.view.screenshot', id: 'screenshot', icon: 'camera_alt', children: [
|
||||
'screenshot_model',
|
||||
|
@ -1060,6 +1060,7 @@ BARS.defineActions(function() {
|
||||
shape: {label: 'dialog.add_primitive.shape', type: 'select', options: {
|
||||
circle: 'dialog.add_primitive.shape.circle',
|
||||
cylinder: 'dialog.add_primitive.shape.cylinder',
|
||||
tube: 'dialog.add_primitive.shape.tube',
|
||||
cone: 'dialog.add_primitive.shape.cone',
|
||||
torus: 'dialog.add_primitive.shape.torus',
|
||||
sphere: 'dialog.add_primitive.shape.sphere',
|
||||
@ -1139,6 +1140,39 @@ BARS.defineActions(function() {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (result.shape == 'tube') {
|
||||
let vertex_keys = [];
|
||||
|
||||
let outer_r = result.diameter/2;
|
||||
let inner_r = (result.diameter - result.minor_diameter)/2;
|
||||
for (let i = 0; i < result.sides; i++) {
|
||||
let x = Math.sin((i / result.sides) * Math.PI * 2);
|
||||
let z = Math.cos((i / result.sides) * Math.PI * 2);
|
||||
vertex_keys.push(...mesh.addVertices(
|
||||
[x * outer_r, 0, z * outer_r],
|
||||
[x * outer_r, result.height, z * outer_r],
|
||||
[x * inner_r, 0, z * inner_r],
|
||||
[x * inner_r, result.height, z * inner_r],
|
||||
));
|
||||
}
|
||||
for (let i = 0; i < result.sides; i++) {
|
||||
let [a1, b1, c1, d1, a2, b2, c2, d2] = vertex_keys.slice(4*i, 4*i + 8);
|
||||
if (!a2) {
|
||||
a2 = vertex_keys[0];
|
||||
b2 = vertex_keys[1];
|
||||
c2 = vertex_keys[2];
|
||||
d2 = vertex_keys[3];
|
||||
}
|
||||
if (a1 && b1 && c1 && d1 && a2 && b2 && c2 && d2) {
|
||||
mesh.addFaces(
|
||||
new MeshFace( mesh, {vertices: [a1, a2, b2, b1]} ),
|
||||
new MeshFace( mesh, {vertices: [d1, d2, c2, c1]} ),
|
||||
new MeshFace( mesh, {vertices: [c1, c2, a2, a1]} ),
|
||||
new MeshFace( mesh, {vertices: [b1, b2, d2, d1]} ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.shape == 'torus') {
|
||||
let rings = [];
|
||||
|
||||
|
@ -682,8 +682,9 @@ class Preview {
|
||||
|
||||
var data = this.raycast(event);
|
||||
if (data) {
|
||||
this.controls.hasMoved = true
|
||||
|
||||
this.selection.click_target = data;
|
||||
console.log(data);
|
||||
|
||||
let select_mode = BarItems.selection_mode.value
|
||||
|
||||
if (data.element && data.element.locked) {
|
||||
@ -771,9 +772,10 @@ class Preview {
|
||||
}
|
||||
mouseup(event) {
|
||||
this.showContextMenu(event);
|
||||
if (settings.canvas_unselect.value && this.controls.hasMoved === false && !this.selection.activated && !Transformer.dragging) {
|
||||
if (settings.canvas_unselect.value && this.controls.hasMoved === false && !this.selection.activated && !Transformer.dragging && !this.selection.click_target) {
|
||||
unselectAll();
|
||||
}
|
||||
delete this.selection.click_target;
|
||||
return this;
|
||||
}
|
||||
raycastMouseCoords(x,y) {
|
||||
@ -803,6 +805,7 @@ class Preview {
|
||||
Prop.active_panel = 'preview';
|
||||
if (this.static_rclick && (event.which === 3 || (event.type == 'touchend' && this.rclick_cooldown == true))) {
|
||||
var data = this.raycast(event)
|
||||
if (data) this.selection.click_target = data;
|
||||
if (Toolbox.selected.selectElements && Modes.selected.selectElements && data && data.element && !Modes.animate) {
|
||||
data.element.showContextMenu(event);
|
||||
|
||||
|
@ -332,6 +332,7 @@
|
||||
|
||||
"dialog.add_primitive.shape": "Shape",
|
||||
"dialog.add_primitive.shape.circle": "Circle",
|
||||
"dialog.add_primitive.shape.tube": "Tube",
|
||||
"dialog.add_primitive.shape.cone": "Cone",
|
||||
"dialog.add_primitive.shape.cylinder": "Cylinder",
|
||||
"dialog.add_primitive.shape.sphere": "Sphere",
|
||||
|
Loading…
Reference in New Issue
Block a user