add sample extrusion capability
This commit is contained in:
parent
2cfe6bac38
commit
63620bfcbe
4 changed files with 31 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue