fix sketch normal, extrude to match sketch normal
This commit is contained in:
parent
9b6e80ae6a
commit
f36808c160
2 changed files with 14 additions and 12 deletions
|
|
@ -408,9 +408,11 @@ function space_init(data) {
|
||||||
// set focus on intersected face
|
// set focus on intersected face
|
||||||
const { x, y, z } = int.point;
|
const { x, y, z } = int.point;
|
||||||
// rotate normal using group's matrix
|
// rotate normal using group's matrix
|
||||||
const normal = shiftKey ? int.face.normal : undefined;
|
const normal = shiftKey ? int.face.normal.clone(): undefined;
|
||||||
|
// ransform the normal to align with sketch group
|
||||||
|
normal?.transformDirection(int.object.sketch.group.matrix);
|
||||||
// y,z swap due to world rotation for orbit controls
|
// y,z swap due to world rotation for orbit controls
|
||||||
api.focus({center: { x, y:-z, z:y }, normal});
|
api.focus({ center: { x, y:-z, z:y }, normal });
|
||||||
} else {
|
} else {
|
||||||
selection.toggle(sketch);
|
selection.toggle(sketch);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// use: mesh.group
|
// use: mesh.group
|
||||||
gapp.register("mesh.sketch", [], (root, exports) => {
|
gapp.register("mesh.sketch", [], (root, exports) => {
|
||||||
|
|
||||||
const { BufferGeometry, BufferAttribute } = THREE;
|
const { BufferGeometry, BufferAttribute, Quaternion } = THREE;
|
||||||
const { MeshBasicMaterial, LineBasicMaterial, LineSegments, DoubleSide } = THREE;
|
const { MeshBasicMaterial, LineBasicMaterial, LineSegments, DoubleSide } = THREE;
|
||||||
const { PlaneGeometry, EdgesGeometry, SphereGeometry, Vector3, Mesh, Group } = THREE;
|
const { PlaneGeometry, EdgesGeometry, SphereGeometry, Vector3, Mesh, Group } = THREE;
|
||||||
const { base, mesh, moto } = root;
|
const { base, mesh, moto } = root;
|
||||||
|
|
@ -85,7 +85,7 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
const { group, plane, outline, center, handles, corners, normal, scale } = this;
|
let { group, plane, outline, center, handles, corners, normal, scale } = this;
|
||||||
|
|
||||||
plane.scale.set(scale.x, scale.y, 1);
|
plane.scale.set(scale.x, scale.y, 1);
|
||||||
outline.scale.set(scale.x, scale.y, 1);
|
outline.scale.set(scale.x, scale.y, 1);
|
||||||
|
|
@ -101,12 +101,8 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { position } = group;
|
normal = new THREE.Vector3(normal.x, normal.y, normal.z).normalize();
|
||||||
group.lookAt(new Vector3(
|
group.quaternion.copy(new Quaternion().setFromUnitVectors(new Vector3(0, 0, 1), normal));
|
||||||
normal.x + position.x,
|
|
||||||
normal.z + position.z,
|
|
||||||
normal.y - position.y
|
|
||||||
));
|
|
||||||
|
|
||||||
this.#db_save();
|
this.#db_save();
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +113,7 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
#db_save() {
|
#db_save() {
|
||||||
const { center, normal, scale, type, file, items } = this;
|
let { center, normal, scale, type, file, items } = this;
|
||||||
mapp.db.space.put(this.id, { center, normal, scale, type, file, items });
|
mapp.db.space.put(this.id, { center, normal, scale, type, file, items });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -456,7 +452,6 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
extrude(opt = {}) {
|
extrude(opt = {}) {
|
||||||
console.log('extrude',opt);
|
|
||||||
let { selection, height, chamfer, chamfer_top, chamfer_bottom } = opt;
|
let { selection, height, chamfer, chamfer_top, chamfer_bottom } = opt;
|
||||||
let models = [];
|
let models = [];
|
||||||
let items = this.group.children
|
let items = this.group.children
|
||||||
|
|
@ -477,6 +472,11 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
let ngrp = api.group.new(models);
|
let ngrp = api.group.new(models);
|
||||||
ngrp.floor();
|
ngrp.floor();
|
||||||
ngrp.move(center.x, center.y, center.z);
|
ngrp.move(center.x, center.y, center.z);
|
||||||
|
// align extrusion with sketch plane
|
||||||
|
const euler = this.group.rotation;
|
||||||
|
const quaternion = new THREE.Quaternion();
|
||||||
|
quaternion.setFromEuler(euler);
|
||||||
|
ngrp.qrotation(quaternion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue