Skip to content
Snippets Groups Projects
Commit 13321102 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

add and remove cubes

parent 81274c7a
No related branches found
No related tags found
No related merge requests found
......@@ -247,7 +247,7 @@ DMACell.prototype.destroy = function(){
DMACubeCell.prototype._calcPosition = function(scale, indices){
var position = _.clone(indices);
_.each(_.keys(position), function(key){
position.key *= scale;
position[key] *= scale;
});
return position;
};
......@@ -266,6 +266,22 @@ DMACell.prototype.destroy = function(){
return mesh;
};
self.DMAVertexOctaCell = DMACubeCell;
DMACubeCell.prototype.getHighlighterVertices = function(face){
if (face.normal.z<0.99) return null;//only highlight horizontal faces
//the vertices don't include the position transformation applied to cell. Add these to create highlighter vertices
var mesh = this.cellMesh.children[0];
var vertices = mesh.geometry.vertices;
var newVertices = [vertices[face.a].clone(), vertices[face.b].clone(), vertices[face.c].clone(), new THREE.Vector3(0,0,0)];
var scale = this.cellMesh.scale.x;
var position = (new THREE.Vector3()).setFromMatrixPosition(mesh.matrixWorld);
_.each(newVertices, function(vertex){//apply scale
vertex.multiplyScalar(scale);
vertex.add(position);
});
return newVertices;
}
self.DMACubeCell = DMACubeCell;
})();
......@@ -237,6 +237,7 @@ SquareBasePlane = BasePlane.extend({
getHighlighterVertices: function(face, position){
//the vertices don't include the position transformation applied to cell. Add these to create highlighter vertices
var index = window.lattice.getIndexForPosition(position);
index.z += 1;
var scale = this.get("mesh")[0].scale.x;
var vertices = [];
vertices.push(new THREE.Vector3(index.x*scale, index.y*scale, index.z*scale));
......
......@@ -521,7 +521,7 @@ Lattice = Backbone.Model.extend({
var index = {};
index.x = Math.round((absPosition.x-scale/2)/scale);
index.y = Math.round((absPosition.y-scale/2)/scale);
index.z = Math.round(absPosition.z/scale);
index.z = Math.round(absPosition.z/scale)-1;
return index;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment