diff --git a/src/main/mesh.js b/src/main/mesh.js index 87a71b42..b47f3e56 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -234,6 +234,9 @@ function space_init(data) { case 'KeyR': return shiftKey ? api.tool.rebuild() : api.tool.repair(); case 'KeyE': + if (api.mode.is([ api.modes.sketch ])) { + return api.sketch.extrude(); + } return api.tool.clean(); case 'KeyV': return shiftKey ? selection.show() : selection.focus(); diff --git a/src/mesh/api.js b/src/mesh/api.js index 58310115..8b7e7f6f 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -428,6 +428,12 @@ let sketch = { list() { return sketches; + }, + + extrude() { + selection.sketches(true).forEach(sketch => { + sketch.extrude(); + }); } }; @@ -1205,7 +1211,7 @@ const api = exports({ }); function log() { - api.log.emit(...arguments); + return api.log.emit(...arguments); } const { broker } = gapp; diff --git a/src/mesh/model.js b/src/mesh/model.js index aafa7332..938f80cc 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -368,7 +368,12 @@ mesh.model = class MeshModel extends mesh.object { this._wire = undefined; this.opacity({restore: true}); } - if (bool) { + if (bool === 'edges') { + let edges = new THREE.EdgesGeometry(this.mesh.geometry, 5); + this._wire = new THREE.LineSegments(edges, materials.wireframe); + this.mesh.add(this._wire); + this.opacity({temp: opt.opacity || 0.15}); + } else if (bool) { this._wire = new Mesh(this.mesh.geometry.shallowClone(), materials.wireframe); this.mesh.add(this._wire); this.opacity({temp: opt.opacity || 0.15}); diff --git a/src/mesh/sketch.js b/src/mesh/sketch.js index 88f75289..0f0becfd 100644 --- a/src/mesh/sketch.js +++ b/src/mesh/sketch.js @@ -240,6 +240,21 @@ mesh.sketch = class MeshSketch extends mesh.object { }); this.update(); } + + extrude(opt = {}) { + let { z } = opt; + let models = []; + for (let item of this.group.children.filter(c => c.poly)) { + let vert = item.poly.extrude(z || 10); + let nmdl = new mesh.model({ file: "poly", mesh: vert.toFloat32() }); + models.push(nmdl); + } + if (models.length) { + log('extrude', this.file || this.id, 'into', models.length, 'solid(s)'); + let ngrp = api.group.new(models); + ngrp.floor(); + } + } } }); \ No newline at end of file