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

eod

parent 927eda4c
Branches
No related tags found
No related merge requests found
...@@ -7,18 +7,21 @@ ...@@ -7,18 +7,21 @@
(function () { (function () {
var cellGeometry = new THREE.OctahedronGeometry(30/Math.sqrt(2)); var cellGeometry1 = new THREE.OctahedronGeometry(30/Math.sqrt(2));
cellGeometry.applyMatrix(new THREE.Matrix4().makeRotationZ(-3*Math.PI/12)); cellGeometry1.applyMatrix(new THREE.Matrix4().makeRotationZ(-3*Math.PI/12));
cellGeometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.asin(2/Math.sqrt(2)/Math.sqrt(3)))); cellGeometry1.applyMatrix(new THREE.Matrix4().makeRotationX(Math.asin(2/Math.sqrt(2)/Math.sqrt(3))));
cellGeometry.applyMatrix(new THREE.Matrix4().makeTranslation(0,-30/Math.sqrt(3)/2,30/2));
var cellGeometry2 = cellGeometry1.clone();
cellGeometry1.applyMatrix(new THREE.Matrix4().makeTranslation(0,-30/Math.sqrt(3),30/2.5));
cellGeometry2.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI));
cellGeometry2.applyMatrix(new THREE.Matrix4().makeTranslation(0,-30/Math.sqrt(3),30/2.5));
var cellMaterials = [new THREE.MeshNormalMaterial(), new THREE.MeshBasicMaterial({color:0x000000, wireframe:true})]; var cellMaterials = [new THREE.MeshNormalMaterial(), new THREE.MeshBasicMaterial({color:0x000000, wireframe:true})];
function Cell() { function Cell() {
this.mesh = THREE.SceneUtils.createMultiMaterialObject(cellGeometry, cellMaterials); this.mesh = THREE.SceneUtils.createMultiMaterialObject(cellGeometry1, cellMaterials);
// this.parts = this._createParts(nodes, config); // this.parts = this._createParts(nodes, config);
} }
......
...@@ -62,22 +62,11 @@ ThreeView = Backbone.View.extend({ ...@@ -62,22 +62,11 @@ ThreeView = Backbone.View.extend({
mouseDown: function(e){ mouseDown: function(e){
this.mouseIsDown = true; this.mouseIsDown = true;
//
// var vector = new THREE.Vector2(2*(e.pageX-this.$el.offset().left)/this.$el.width()-1, 1-2*(e.pageY-this.$el.offset().top)/this.$el.height()); if (!this.highlighter.visible) return;
// var camera = this.model.camera;
// this.mouseProjection.setFromCamera(vector, camera);
// var intersections = this.mouseProjection.intersectObjects(this.model.objects);
//
// console.log(intersections);
//
// if (intersections.length>1){
// var voxel = new THREE.Mesh(this.cubeGeometry);
// voxel.position.copy(intersections[1].point);
// if (intersections[1].face) voxel.position.add(intersections[1].face.normal);
// voxel.position.divideScalar(5).floor().multiplyScalar(5).addScalar(2.5);
// this.model.sceneAdd(voxel);
// this.model.render();
// }
}, },
mouseMoved: function(e){ mouseMoved: function(e){
...@@ -93,12 +82,18 @@ ThreeView = Backbone.View.extend({ ...@@ -93,12 +82,18 @@ ThreeView = Backbone.View.extend({
//check if we've moved to a new face //check if we've moved to a new face
var intersection = intersections[0].face; var intersection = intersections[0].face;
if (this.currentHighlightedFace == intersection) return; if (this.highlighter.visible && this.currentHighlightedFace == intersection) return;
if (intersection.normal.z<0.99){//only highlight horizontal faces
this.highlighter.visible = false;
} else {
this.highlighter.visible = true;
this.currentHighlightedFace = intersection; this.currentHighlightedFace = intersection;
var vertices = intersections[0].object.geometry.vertices; var vertices = intersections[0].object.geometry.vertices;
this.highlighter.geometry.vertices = [vertices[intersection.a], vertices[intersection.b], vertices[intersection.c]]; this.highlighter.geometry.vertices = [vertices[intersection.a], vertices[intersection.b], vertices[intersection.c]];
this.highlighter.geometry.verticesNeedUpdate = true; this.highlighter.geometry.verticesNeedUpdate = true;
}
window.three.render(); window.three.render();
}, },
...@@ -164,11 +159,7 @@ ThreeView = Backbone.View.extend({ ...@@ -164,11 +159,7 @@ ThreeView = Backbone.View.extend({
// } // }
} }
for (i = 0; i < geometry.faces.length; i ++ ) { geometry.computeFaceNormals();
var face = geometry.faces[ i ];
face.color.setHex( Math.random() * 0xffffff );
}
geometry.colorsNeedUpdate = true;
window.three.sceneAdd(new THREE.Mesh(geometry, planeMaterial)); window.three.sceneAdd(new THREE.Mesh(geometry, planeMaterial));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment