partial implementation of regrouping

This commit is contained in:
Stewart Allen 2022-01-20 19:21:26 -05:00
commit 646441e5e5
4 changed files with 45 additions and 17 deletions

View file

@ -224,19 +224,6 @@ mesh.model = class MeshModel extends mesh.object {
return this.vertices / 3;
}
// todo -- put model into its own group
ungroup() {
// get current world coordinates
let { mid } = meh.getBoundingBox();
// transform mesh into world coordinates
// move mesh to origin
// create and add to group
// move group center back to original center
geo.moveMesh(-mid.x, -mid.y, -mid.z);
geo.computeBoundingBox();
this.move(mid.x, mid.y, mid.z);
}
// get, set, or toggle visibility of model and wireframe
visible(bool) {
if (bool === undefined) {
@ -417,6 +404,23 @@ mesh.model = class MeshModel extends mesh.object {
});
}
// release from a group but remain in memory and storage
// so it can be re-assigned to another group
ungroup() {
this.group.remove(this, { free: false });
this.group = undefined;
// get current world coordinates
// let { mid } = this.mesh.getBoundingBox();
// let { geometry } = this.mesh;
// move group center back to original center
// geometry.moveMesh(-mid.x, -mid.y, -mid.z);
// geometry.computeBoundingBox();
// this.move(mid.x, mid.y, mid.z);
return this;
}
// remove model from group and space
remove() {
if (arguments.length === 0) {