diff --git a/js/fea/dmaCell.js b/js/fea/dmaCell.js index 2e6a19c9ae4458147c90700611c619477369a878..272571ba771f4947e4f2389dff64180270dbde32 100644 --- a/js/fea/dmaCell.js +++ b/js/fea/dmaCell.js @@ -7,18 +7,21 @@ (function () { - var cellGeometry = new THREE.OctahedronGeometry(30/Math.sqrt(2)); - cellGeometry.applyMatrix(new THREE.Matrix4().makeRotationZ(-3*Math.PI/12)); - cellGeometry.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 cellGeometry1 = new THREE.OctahedronGeometry(30/Math.sqrt(2)); + cellGeometry1.applyMatrix(new THREE.Matrix4().makeRotationZ(-3*Math.PI/12)); + cellGeometry1.applyMatrix(new THREE.Matrix4().makeRotationX(Math.asin(2/Math.sqrt(2)/Math.sqrt(3)))); + 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})]; function Cell() { - this.mesh = THREE.SceneUtils.createMultiMaterialObject(cellGeometry, cellMaterials); + this.mesh = THREE.SceneUtils.createMultiMaterialObject(cellGeometry1, cellMaterials); // this.parts = this._createParts(nodes, config); } diff --git a/js/threeViews/threeView.js b/js/threeViews/threeView.js index f2e8b72a85fd50dc894d5986880001591628a30a..7fac69a55ccaf8991e5e23c16f808b88380e003f 100644 --- a/js/threeViews/threeView.js +++ b/js/threeViews/threeView.js @@ -62,22 +62,11 @@ ThreeView = Backbone.View.extend({ mouseDown: function(e){ 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()); -// 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(); -// } + + if (!this.highlighter.visible) return; + + + }, mouseMoved: function(e){ @@ -93,12 +82,18 @@ ThreeView = Backbone.View.extend({ //check if we've moved to a new 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; - this.highlighter.geometry.vertices = [vertices[intersection.a], vertices[intersection.b], vertices[intersection.c]]; - this.highlighter.geometry.verticesNeedUpdate = true; + var vertices = intersections[0].object.geometry.vertices; + this.highlighter.geometry.vertices = [vertices[intersection.a], vertices[intersection.b], vertices[intersection.c]]; + this.highlighter.geometry.verticesNeedUpdate = true; + } window.three.render(); }, @@ -164,11 +159,7 @@ ThreeView = Backbone.View.extend({ // } } - for (i = 0; i < geometry.faces.length; i ++ ) { - var face = geometry.faces[ i ]; - face.color.setHex( Math.random() * 0xffffff ); - } - geometry.colorsNeedUpdate = true; + geometry.computeFaceNormals(); window.three.sceneAdd(new THREE.Mesh(geometry, planeMaterial));