remove old object bounds, persist new bounds state
This commit is contained in:
parent
7231f25088
commit
d6e88e7461
4 changed files with 21 additions and 44 deletions
|
|
@ -178,6 +178,8 @@ async function restore_space() {
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
// hide loading curtain
|
// hide loading curtain
|
||||||
$d('curtain','none');
|
$d('curtain','none');
|
||||||
|
// restore handles visibility
|
||||||
|
handles.setVisible(api.prefs.map.space.bounds);
|
||||||
if (api.prefs.map.info.welcome !== false) {
|
if (api.prefs.map.info.welcome !== false) {
|
||||||
api.welcome(version);
|
api.welcome(version);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { history } from './history.js';
|
||||||
import { client as motoClient } from '../moto/client.js';
|
import { client as motoClient } from '../moto/client.js';
|
||||||
import { space as motoSpace } from '../moto/space.js';
|
import { space as motoSpace } from '../moto/space.js';
|
||||||
import { base } from '../geo/base.js';
|
import { base } from '../geo/base.js';
|
||||||
|
import { handles } from './handles.js';
|
||||||
import { util as meshUtil } from './util.js';
|
import { util as meshUtil } from './util.js';
|
||||||
import { edges as meshEdges } from './edges.js';
|
import { edges as meshEdges } from './edges.js';
|
||||||
import { group as meshGroup } from './group.js';
|
import { group as meshGroup } from './group.js';
|
||||||
|
|
@ -282,9 +283,7 @@ const selection = {
|
||||||
},
|
},
|
||||||
|
|
||||||
boundsBox() {
|
boundsBox() {
|
||||||
for (let m of selection.groups()) {
|
handles.toggleBounds();
|
||||||
m.showBounds(...arguments);
|
|
||||||
}
|
|
||||||
return selection;
|
return selection;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1532,7 +1531,6 @@ const api = {
|
||||||
|
|
||||||
// @param object {MeshObject | MeshObject[] | Object}
|
// @param object {MeshObject | MeshObject[] | Object}
|
||||||
focus(object) {
|
focus(object) {
|
||||||
console.log({ focus: object });
|
|
||||||
let { center } = object.center ? object : meshUtil.bounds(object);
|
let { center } = object.center ? object : meshUtil.bounds(object);
|
||||||
// when no valid objects supplied, set origin
|
// when no valid objects supplied, set origin
|
||||||
if (isNaN(center.x * center.y * center.z)) {
|
if (isNaN(center.x * center.y * center.z)) {
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,11 @@ class TransformTool {
|
||||||
this.lines = []; // Add array to track connecting lines
|
this.lines = []; // Add array to track connecting lines
|
||||||
this.mode = '2d'; // or '3d'
|
this.mode = '2d'; // or '3d'
|
||||||
this.bounds = null;
|
this.bounds = null;
|
||||||
this.handleSize = 2; // Fixed size in world units
|
this.handleSize = 2;
|
||||||
this.handleColor = 0x0088ff;
|
this.handleColor = 0x0088ff;
|
||||||
this.handleOpacity = 0.5;
|
this.handleOpacity = 0.5;
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
this.visible = true;
|
||||||
|
|
||||||
// Create materials
|
// Create materials
|
||||||
this.handleMaterial = new MeshBasicMaterial({
|
this.handleMaterial = new MeshBasicMaterial({
|
||||||
|
|
@ -66,14 +67,25 @@ class TransformTool {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setVisible(visible) {
|
||||||
|
this.visible = visible;
|
||||||
|
this.group.visible = this.visible;
|
||||||
|
if (meshApi && meshApi.prefs) {
|
||||||
|
meshApi.prefs.map.space.bounds = this.visible;
|
||||||
|
meshApi.prefs.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.visible = true;
|
this.setVisible(true);
|
||||||
this.group.visible = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
this.visible = false;
|
this.setVisible(false);
|
||||||
this.group.visible = false;
|
}
|
||||||
|
|
||||||
|
toggleBounds() {
|
||||||
|
this.setVisible(!this.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
|
@ -88,9 +100,6 @@ class TransformTool {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show transform tool
|
|
||||||
this.show();
|
|
||||||
|
|
||||||
// Get bounds based on selection type
|
// Get bounds based on selection type
|
||||||
let bounds;
|
let bounds;
|
||||||
if (sketch) {
|
if (sketch) {
|
||||||
|
|
|
||||||
|
|
@ -152,40 +152,8 @@ class MeshObject {
|
||||||
throw "position() requires implementation";
|
throw "position() requires implementation";
|
||||||
}
|
}
|
||||||
|
|
||||||
showBounds(bool) {
|
|
||||||
let was = this._showBounds;
|
|
||||||
if (bool && bool.toggle) {
|
|
||||||
bool = !this._showBounds;
|
|
||||||
}
|
|
||||||
if (was === bool) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._showBounds = bool;
|
|
||||||
this.updateBoundsBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateBoundsBox() {
|
|
||||||
this.log('update-bounds-box', this._showBounds);
|
|
||||||
let helper = this._boundsBox;
|
|
||||||
let world = motoSpace.world;
|
|
||||||
if (helper) {
|
|
||||||
world.remove(helper);
|
|
||||||
}
|
|
||||||
if (this._showBounds) {
|
|
||||||
let { mid, dim } = this.bounds;
|
|
||||||
let b3 = new Box3().setFromCenterAndSize(
|
|
||||||
new Vector3(mid.x, mid.y, mid.z),
|
|
||||||
new Vector3(dim.x, dim.y, dim.z)
|
|
||||||
);
|
|
||||||
let helper = this._boundsBox = new Box3Helper(b3, 0x555555);
|
|
||||||
world.add(helper);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
metaChanged(values = {}) {
|
metaChanged(values = {}) {
|
||||||
this.object.updateMatrix();
|
this.object.updateMatrix();
|
||||||
this.updateBoundsBox();
|
|
||||||
motoSpace.update();
|
motoSpace.update();
|
||||||
Object.assign(this.meta, values, {
|
Object.assign(this.meta, values, {
|
||||||
// matrix: this.object.matrix.elements
|
// matrix: this.object.matrix.elements
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue