fixes in add.three and rename group's 3js object to group3
This commit is contained in:
parent
49d6dce8b3
commit
45e269e140
5 changed files with 18 additions and 12 deletions
|
|
@ -32,7 +32,7 @@
|
|||
},
|
||||
mid: {
|
||||
get: function() {
|
||||
return this.dim.clone().mutiplyScalar(0.5).add(this.min);
|
||||
return this.dim.clone().multiplyScalar(0.5).add(this.min);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -84,9 +84,9 @@
|
|||
let gap = this.attributes.position,
|
||||
pa = gap.array;
|
||||
for (let i=0; i < pa.length; i += 3) {
|
||||
pa[i ] -= x;
|
||||
pa[i + 1] -= y;
|
||||
pa[i + 2] -= z;
|
||||
pa[i ] += x;
|
||||
pa[i + 1] += y;
|
||||
pa[i + 2] += z;
|
||||
}
|
||||
gap.needsUpdate = true;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ let group = {
|
|||
// @param group {MeshGroup}
|
||||
add(group) {
|
||||
groups.addOnce(group);
|
||||
space.world.add(group.group);
|
||||
space.world.add(group.object);
|
||||
space.update();
|
||||
return group;
|
||||
},
|
||||
|
|
@ -200,7 +200,7 @@ let group = {
|
|||
// @param group {MeshGroup}
|
||||
remove(group) {
|
||||
groups.remove(group);
|
||||
space.world.remove(group.group);
|
||||
space.world.remove(group.object);
|
||||
space.update();
|
||||
}
|
||||
};
|
||||
|
|
@ -329,7 +329,7 @@ let api = mesh.api = {
|
|||
|
||||
objects() {
|
||||
// return model objects suitable for finding ray intersections
|
||||
return group.list().map(o => o.models).flat().map(o => o.object);
|
||||
return group.list().map(o => o.models).flat().map(o => o.mesh);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
|||
// @param group {MeshModel[]}
|
||||
constructor(models = [], id) {
|
||||
super(id);
|
||||
this.group = new THREE.Group();
|
||||
this.group3 = new THREE.Group();
|
||||
this.models = [];
|
||||
for (let model of models) {
|
||||
this.add(model);
|
||||
|
|
@ -40,14 +40,14 @@ mesh.group = class MeshGroup extends mesh.object {
|
|||
}
|
||||
|
||||
get object() {
|
||||
return this.group;
|
||||
return this.group3;
|
||||
}
|
||||
|
||||
// @param model {MeshModel}
|
||||
add(model) {
|
||||
model.group = this;
|
||||
this.models.addOnce(model);
|
||||
this.group.add(model.mesh);
|
||||
this.group3.add(model.mesh);
|
||||
space.update();
|
||||
call.model_add({model, group:this});
|
||||
worker.group_add({id: this.id, model:model.id});
|
||||
|
|
@ -67,7 +67,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
|||
return;
|
||||
}
|
||||
this.models.remove(model);
|
||||
this.group.remove(model.mesh);
|
||||
this.group3.remove(model.mesh);
|
||||
// create message for listeners
|
||||
call.model_remove({model, group:this});
|
||||
// trigger sync with worker
|
||||
|
|
@ -75,7 +75,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
|||
// ensure worker cleanup of model
|
||||
model.remove(true);
|
||||
// auto-remove group when empty
|
||||
if (this.group.children.length === 0) {
|
||||
if (this.group3.children.length === 0) {
|
||||
mesh.api.group.remove(this);
|
||||
// manage lifecycle with worker, mesh app caches, etc
|
||||
this.destroy();
|
||||
|
|
|
|||
|
|
@ -102,6 +102,10 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
meh.receiveShadow = true;
|
||||
meh.castShadow = true;
|
||||
meh.renderOrder = 1;
|
||||
// center vertices then restore mesh object position
|
||||
// let mid = meh.getBoundingBox().mid;
|
||||
// geo.moveMesh(-mid.x, -mid.y, -mid.x);
|
||||
// this.move(mid.x, mid.y, mid.x);
|
||||
// sets fallback opacity for wireframe toggle
|
||||
this.opacity(1);
|
||||
// this ref allows clicks to be traced to models and groups
|
||||
|
|
@ -227,6 +231,7 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
}
|
||||
|
||||
updateBoundsBox() {
|
||||
if (this.group)
|
||||
mesh.util.defer(this.group.deferUBB);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ mesh.object = class MeshObject {
|
|||
this.updateBoundsBox();
|
||||
space.update();
|
||||
publish.matrix({ id: this.id, matrix: this.object.matrix });
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue