persist object scale / rotation / position
This commit is contained in:
parent
1e5a84dfe9
commit
55b59d9cb1
7 changed files with 81 additions and 22 deletions
|
|
@ -393,7 +393,7 @@ function ui_build() {
|
|||
selection_scale: defer_selection,
|
||||
selection_rotate: defer_selection,
|
||||
selection_qrotate: defer_selection,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -77,10 +77,8 @@ mesh.group = class MeshGroup extends mesh.object {
|
|||
// auto-remove group when empty
|
||||
if (this.group.children.length === 0) {
|
||||
mesh.api.group.remove(this);
|
||||
// update worker state
|
||||
worker.object_destroy({id: this.id});
|
||||
// update object store
|
||||
mesh.db.space.remove(this.id);
|
||||
// manage lifecycle with worker, mesh app caches, etc
|
||||
this.destroy();
|
||||
} else {
|
||||
// update data store
|
||||
mesh.db.space.put(this.id, this.models.map(m => m.id));
|
||||
|
|
|
|||
|
|
@ -219,16 +219,15 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
this.group = undefined;
|
||||
this.removed = 'pending';
|
||||
} else {
|
||||
// update worker state
|
||||
worker.object_destroy({id: this.id});
|
||||
// update object store
|
||||
mesh.db.space.remove(this.id);
|
||||
// manage lifecycle with worker, mesh app caches, etc
|
||||
this.destroy();
|
||||
// tag removed for debugging
|
||||
this.removed = 'complete';
|
||||
}
|
||||
}
|
||||
|
||||
updateBoundsBox() {
|
||||
this.updateMatrix();
|
||||
mesh.util.defer(this.group.deferUBB);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
gapp.register("mesh.object", [
|
||||
"add.three", // dep: add.three
|
||||
"moto.license", // dep: moto.license
|
||||
"moto.broker", // dep: moto.broker
|
||||
"mesh.api", // dep: mesh.api
|
||||
]);
|
||||
|
||||
|
|
@ -16,6 +17,12 @@ if (mesh.object) return;
|
|||
let space = moto.Space;
|
||||
let worker = moto.client.fn;
|
||||
|
||||
// broker updates generated by objects
|
||||
let publish = {
|
||||
matrix: gapp.broker.bind("object_matrix"),
|
||||
destroy: gapp.broker.bind("object_destroy"),
|
||||
};
|
||||
|
||||
mesh.object = class MeshObject {
|
||||
|
||||
constructor(id) {
|
||||
|
|
@ -37,8 +44,30 @@ mesh.object = class MeshObject {
|
|||
return mesh.util.bounds(this.object);
|
||||
}
|
||||
|
||||
// manage lifecycle with worker, mesh app caches, etc
|
||||
destroy() {
|
||||
// update worker state
|
||||
worker.object_destroy({id: this.id});
|
||||
// update object store
|
||||
mesh.db.space.remove(this.id);
|
||||
// main app cache workspace updates
|
||||
publish.destroy(this.id);
|
||||
}
|
||||
|
||||
updateMatrix() {
|
||||
publish.matrix({ id: this.id, matrix: this.object.matrix });
|
||||
}
|
||||
|
||||
applyMatrix(elements) {
|
||||
if (elements) {
|
||||
this.object.applyMatrix4(new THREE.Matrix4().fromArray(elements));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
focus() {
|
||||
mesh.api.focus(this.object);
|
||||
return this;
|
||||
}
|
||||
|
||||
floor() {
|
||||
|
|
@ -132,6 +161,7 @@ mesh.object = class MeshObject {
|
|||
}
|
||||
|
||||
updateBoundsBox() {
|
||||
this.updateMatrix();
|
||||
let helper = this._boundsBox;
|
||||
let world = space.world;
|
||||
if (helper) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue