Separate line selection mode

Vertex gizmo border
Show filter menu even when empty
Hide inverse kinematics toolbar for now
This commit is contained in:
JannisX11 2021-09-07 18:19:39 +02:00
parent e7bb7ad1df
commit 5ac0ec6306
7 changed files with 36 additions and 6 deletions

BIN
assets/vertex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1870,6 +1870,7 @@ const BARS = {
'rescale_toggle'
]
})
/*
Toolbars.inverse_kinematics = new Toolbar({
id: 'inverse_kinematics',
children: [
@ -1877,7 +1878,7 @@ const BARS = {
'slider_ik_chain_length'
],
default_place: !Blockbench.isMobile
})
})*/
Toolbars.palette = new Toolbar({

View File

@ -439,6 +439,8 @@ class BarMenu extends Menu {
this.children = [];
this.condition = options.condition
this.node = $('<ul class="contextMenu"></ul>')[0]
this.node.style.minHeight = '8px';
this.node.style.minWidth = '150px';
this.name = tl(options.name || `menu.${id}`);
this.label = $(`<li class="menu_bar_point">${this.name}</li>`)[0]
$(this.label).click(function() {

View File

@ -232,15 +232,13 @@ function setupPanels() {
condition: !Blockbench.isMobile && {modes: ['animate']},
selection_only: true,
toolbars: {
inverse_kinematics: Toolbars.inverse_kinematics,
//inverse_kinematics: Toolbars.inverse_kinematics,
},
component: {
template: `
<div>
<p>${ tl('panel.element.origin') }</p>
<div class="toolbar_wrapper bone_origin"></div>
<p>${ tl('panel.bone.ik') }</p>
<div class="toolbar_wrapper inverse_kinematics"></div>
</div>
`
}

View File

@ -695,6 +695,7 @@ BARS.defineActions(function() {
options: {
object: true,
face: true,
line: true,
vertex: true,
},
condition: () => Format && Format.meshes,

View File

@ -354,7 +354,7 @@ class Preview {
if (element.mesh.vertex_points && element.mesh.vertex_points.visible) {
objects.push(element.mesh.vertex_points);
}
if (element instanceof Mesh && element.mesh.outline.visible && BarItems.selection_mode.value == 'vertex') {
if (element instanceof Mesh && element.mesh.outline.visible && BarItems.selection_mode.value == 'line') {
objects.push(element.mesh.outline);
}
}
@ -985,6 +985,21 @@ class Preview {
}
}
} else if (selection_mode == 'line') {
for (let fkey in element.faces) {
let face = element.faces[fkey];
let vertices = face.getSortedVertices();
for (let i = 0; i < vertices.length; i++) {
let vkey = vertices[i];
let vkey2 = vertices[i+1]||vertices[0];
let p1 = vertex_points[vkey];
let p2 = vertex_points[vkey2];
if (lineIntersectsReactangle(p1, p2, rect_start, rect_end)) {
selected_vertices.safePush(vkey);
}
}
}
} else {
for (let fkey in element.faces) {
let face = element.faces[fkey];
@ -2155,6 +2170,18 @@ function initCanvas() {
alphaTest: 0.2
})
// Vertex gizmos
var vertex_img = new Image();
vertex_img.src = 'assets/vertex.png';
vertex_img.tex = new THREE.Texture(vertex_img);
vertex_img.tex.magFilter = THREE.NearestFilter;
vertex_img.tex.minFilter = THREE.NearestFilter;
vertex_img.onload = function() {
this.tex.needsUpdate = true;
}
Canvas.meshVertexMaterial.map = vertex_img.tex;
Canvas.meshVertexMaterial.transparent = true;
//Rotation Pivot
var helper1 = new THREE.AxesHelper(2)
var helper2 = new THREE.AxesHelper(2)

View File

@ -1013,7 +1013,8 @@
"action.selection_mode.desc": "Change how elements can be selected in the viewport",
"action.selection_mode.object": "Object",
"action.selection_mode.face": "Face",
"action.selection_mode.vertex": "Vertex/Line",
"action.selection_mode.line": "Line",
"action.selection_mode.vertex": "Vertex",
"action.create_face": "Create Face",
"action.create_face.desc": "Creates a new face or line between the selected vertices",
"action.convert_to_mesh": "Convert to Mesh",