add support for tab additions in lathe mode
This commit is contained in:
parent
3104b7c7dd
commit
c71786e56a
2 changed files with 28 additions and 2 deletions
|
|
@ -62,7 +62,8 @@ class Topo4 {
|
|||
|
||||
this.zBottom = state.zBottom;
|
||||
this.resolution = resolution;
|
||||
this.vertices = widget.getGeoVertices().toShared();
|
||||
this.vertices = widget.getGeoVertices();
|
||||
this.tabverts = widget.getTabVertices();
|
||||
this.tool = tool.generateProfile(resolution).profile;
|
||||
this.maxo = tool.profileDim.maxo * resolution;
|
||||
this.diam = tool.fluteDiameter();
|
||||
|
|
@ -87,7 +88,7 @@ class Topo4 {
|
|||
}
|
||||
|
||||
async slice(onupdate) {
|
||||
const { vertices, resolution } = this;
|
||||
const { vertices, resolution, tabverts } = this;
|
||||
|
||||
const range = this.range = { min: Infinity, max: -Infinity };
|
||||
const box = this.box = new THREE.Box2();
|
||||
|
|
@ -106,6 +107,15 @@ class Topo4 {
|
|||
range.min -= this.diam / 2;
|
||||
range.max += this.diam / 2;
|
||||
|
||||
// merge in tab vertices (so they don't affect slice range / dimensions)
|
||||
for (let i=0, l=tabverts.length; i<l; i += 3) {
|
||||
const x = tabverts[i];
|
||||
const z = tabverts[i + 2];
|
||||
tabverts[i] = z;
|
||||
tabverts[i + 2] = x;
|
||||
}
|
||||
this.vertices = [].appendAll(vertices).appendAll(tabverts).toFloat32().toShared();
|
||||
|
||||
const shards = Math.ceil(Math.min(25, vertices.length / 27000));
|
||||
const step = (range.max - range.min) / shards;
|
||||
|
||||
|
|
|
|||
|
|
@ -626,6 +626,22 @@ class Widget {
|
|||
this.points = null;
|
||||
}
|
||||
|
||||
getTabVertices() {
|
||||
const vert = [];
|
||||
if (this.anno && this.anno.tab) {
|
||||
for (let tab of this.anno.tab) {
|
||||
const { pos, dim, rot } = tab;
|
||||
const box = new THREE.BoxGeometry(dim.x, dim.y, dim.z).toNonIndexed();
|
||||
box.applyMatrix4(
|
||||
new THREE.Matrix4().makeRotationFromQuaternion(rot)
|
||||
);
|
||||
box.translate(pos.x, pos.y, pos.z);
|
||||
vert.appendAll(box.attributes.position.array);
|
||||
}
|
||||
}
|
||||
return vert;
|
||||
}
|
||||
|
||||
getGeoVertices(opt = {}) {
|
||||
const { unroll, translate } = opt;
|
||||
let geo = this.mesh.geometry;
|
||||
|
|
|
|||
Loading…
Reference in a new issue