diff --git a/src/main/mesh.js b/src/main/mesh.js index ce4a7bb5..fe0927d3 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -428,13 +428,14 @@ function space_init(data) { selection.update(); } else { let { modes } = api; - let radians = 0; + let { surface } = api.prefs.map; + let opt = { radians: 0, radius: surface.radius }; switch(api.mode.get()) { case modes.object: selection.toggle(shiftKey ? model : model.group); break; case modes.surface: - radians = api.prefs.map.surface.radians; + opt.radians = surface.radians; case modes.face: case modes.line: case modes.vertex: @@ -442,7 +443,7 @@ function space_init(data) { model.find(int, altKey ? { toggle: true } : shiftKey ? { clear: true } : { select: true }, - radians); + opt); break; } } @@ -553,7 +554,13 @@ function set_normals_color(color) { function set_surface_radians(radians) { let { prefs } = mesh.api; - prefs.map.surface.radians = radians || 0.1; + prefs.map.surface.radians = parseFloat(radians || 0.1); + prefs.save(); +} + +function set_surface_radius(radius) { + let { prefs } = mesh.api; + prefs.map.surface.radius = parseFloat(radius || 0.2); prefs.save(); } @@ -568,7 +575,8 @@ broker.listeners({ set_darkmode, set_normals_color, set_normals_length, - set_surface_radians + set_surface_radians, + set_surface_radius }); // remove version cache bust from url diff --git a/src/mesh/api.js b/src/mesh/api.js index 8978d31e..9073c6ac 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -542,7 +542,8 @@ const prefs = { color_dark: 0x00ffff }, surface: { - radians: 0.1 + radians: 0.1, + radius: 0.2 } }, diff --git a/src/mesh/build.js b/src/mesh/build.js index d75da2b5..b20b9564 100644 --- a/src/mesh/build.js +++ b/src/mesh/build.js @@ -248,7 +248,7 @@ api.settings = function() { h.label(''), h.label('normals'), h.label('length'), - h.input({ type: "text", size: 5, value: normals.length, + h.input({ type: "text", size: 5, value: parseFloat(normals.length), onchange: ev => call.set_normals_length(ev.target.value) }), h.label('color'), @@ -262,11 +262,13 @@ api.settings = function() { h.label(''), h.label('surface'), h.label('radians'), - h.input({ type: "text", size: 5, value: surface.radians, + h.input({ type: "text", size: 5, value: parseFloat(surface.radians), onchange: ev => call.set_surface_radians(ev.target.value) }), - h.label(' '), - h.label(' ') + h.label('radius'), + h.input({ type: "text", size: 5, value: parseFloat(surface.radius || 0.2), + onchange: ev => call.set_surface_radius(ev.target.value) + }), ]); modal.show('settings', h.div({ class: "settings" }, [ col1, col2, col3 ] )); diff --git a/src/mesh/model.js b/src/mesh/model.js index ba005fe5..96447ba3 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -588,7 +588,8 @@ mesh.model = class MeshModel extends mesh.object { } // find adjacent faces to clicked point/line on a face - find(int, action, radians = 0) { + find(int, action, opt) { + let { radians, radius } = opt; let { point, face } = int; let { x, y, z } = point; let { a, b, c } = face; @@ -597,7 +598,7 @@ mesh.model = class MeshModel extends mesh.object { mesh.api.log.emit("matching surface").pin(); }, 150); worker.model_select({ - id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, radians + id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, radians, radius }).then(data => { if (timer) { clearTimeout(timer); diff --git a/src/mesh/work.js b/src/mesh/work.js index ca8ac0da..b4d800e1 100644 --- a/src/mesh/work.js +++ b/src/mesh/work.js @@ -282,7 +282,7 @@ let model = { // given model and point, locate matching vertices, lines, and faces select(data) { - let { id, x, y, z, a, b, c, matrix, radians } = data; + let { id, x, y, z, a, b, c, matrix, radians, radius } = data; // translate point into mesh matrix space let v3 = new Vector3(x,y,z).applyMatrix4( core_matrix.clone().multiply(new Matrix4().fromArray(matrix)).invert() @@ -291,11 +291,12 @@ let model = { const rec = cache[id]; const arr = rec.geo.attributes.position.array; // distance tolerance for click to vertex (rough distance) - const eps = 0.25; + const eps = radius || 0.2; const faces = []; const verts = []; const edges = []; let point; + if (!radians) for (let i=0, l=arr.length; i