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: {
|
mid: {
|
||||||
get: function() {
|
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,
|
let gap = this.attributes.position,
|
||||||
pa = gap.array;
|
pa = gap.array;
|
||||||
for (let i=0; i < pa.length; i += 3) {
|
for (let i=0; i < pa.length; i += 3) {
|
||||||
pa[i ] -= x;
|
pa[i ] += x;
|
||||||
pa[i + 1] -= y;
|
pa[i + 1] += y;
|
||||||
pa[i + 2] -= z;
|
pa[i + 2] += z;
|
||||||
}
|
}
|
||||||
gap.needsUpdate = true;
|
gap.needsUpdate = true;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ let group = {
|
||||||
// @param group {MeshGroup}
|
// @param group {MeshGroup}
|
||||||
add(group) {
|
add(group) {
|
||||||
groups.addOnce(group);
|
groups.addOnce(group);
|
||||||
space.world.add(group.group);
|
space.world.add(group.object);
|
||||||
space.update();
|
space.update();
|
||||||
return group;
|
return group;
|
||||||
},
|
},
|
||||||
|
|
@ -200,7 +200,7 @@ let group = {
|
||||||
// @param group {MeshGroup}
|
// @param group {MeshGroup}
|
||||||
remove(group) {
|
remove(group) {
|
||||||
groups.remove(group);
|
groups.remove(group);
|
||||||
space.world.remove(group.group);
|
space.world.remove(group.object);
|
||||||
space.update();
|
space.update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -329,7 +329,7 @@ let api = mesh.api = {
|
||||||
|
|
||||||
objects() {
|
objects() {
|
||||||
// return model objects suitable for finding ray intersections
|
// 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[]}
|
// @param group {MeshModel[]}
|
||||||
constructor(models = [], id) {
|
constructor(models = [], id) {
|
||||||
super(id);
|
super(id);
|
||||||
this.group = new THREE.Group();
|
this.group3 = new THREE.Group();
|
||||||
this.models = [];
|
this.models = [];
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
this.add(model);
|
this.add(model);
|
||||||
|
|
@ -40,14 +40,14 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
get object() {
|
get object() {
|
||||||
return this.group;
|
return this.group3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @param model {MeshModel}
|
// @param model {MeshModel}
|
||||||
add(model) {
|
add(model) {
|
||||||
model.group = this;
|
model.group = this;
|
||||||
this.models.addOnce(model);
|
this.models.addOnce(model);
|
||||||
this.group.add(model.mesh);
|
this.group3.add(model.mesh);
|
||||||
space.update();
|
space.update();
|
||||||
call.model_add({model, group:this});
|
call.model_add({model, group:this});
|
||||||
worker.group_add({id: this.id, model:model.id});
|
worker.group_add({id: this.id, model:model.id});
|
||||||
|
|
@ -67,7 +67,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.models.remove(model);
|
this.models.remove(model);
|
||||||
this.group.remove(model.mesh);
|
this.group3.remove(model.mesh);
|
||||||
// create message for listeners
|
// create message for listeners
|
||||||
call.model_remove({model, group:this});
|
call.model_remove({model, group:this});
|
||||||
// trigger sync with worker
|
// trigger sync with worker
|
||||||
|
|
@ -75,7 +75,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
// ensure worker cleanup of model
|
// ensure worker cleanup of model
|
||||||
model.remove(true);
|
model.remove(true);
|
||||||
// auto-remove group when empty
|
// auto-remove group when empty
|
||||||
if (this.group.children.length === 0) {
|
if (this.group3.children.length === 0) {
|
||||||
mesh.api.group.remove(this);
|
mesh.api.group.remove(this);
|
||||||
// manage lifecycle with worker, mesh app caches, etc
|
// manage lifecycle with worker, mesh app caches, etc
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,10 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
meh.receiveShadow = true;
|
meh.receiveShadow = true;
|
||||||
meh.castShadow = true;
|
meh.castShadow = true;
|
||||||
meh.renderOrder = 1;
|
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
|
// sets fallback opacity for wireframe toggle
|
||||||
this.opacity(1);
|
this.opacity(1);
|
||||||
// this ref allows clicks to be traced to models and groups
|
// this ref allows clicks to be traced to models and groups
|
||||||
|
|
@ -227,6 +231,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBoundsBox() {
|
updateBoundsBox() {
|
||||||
|
if (this.group)
|
||||||
mesh.util.defer(this.group.deferUBB);
|
mesh.util.defer(this.group.deferUBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ mesh.object = class MeshObject {
|
||||||
this.updateBoundsBox();
|
this.updateBoundsBox();
|
||||||
space.update();
|
space.update();
|
||||||
publish.matrix({ id: this.id, matrix: this.object.matrix });
|
publish.matrix({ id: this.id, matrix: this.object.matrix });
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue