diff --git a/data/Assem1 - OT6_00_000_octa_turret_folded_corner-1-1.STL b/data/Assem1 - OT6_00_000_octa_turret_folded_corner-1-1.STL deleted file mode 100755 index 99392315eb289536616dacfadfd2bb480c60638e..0000000000000000000000000000000000000000 Binary files a/data/Assem1 - OT6_00_000_octa_turret_folded_corner-1-1.STL and /dev/null differ diff --git a/data/Assem1 - OT6_00_000_octa_turret_folded_corner-2-1.STL b/data/Assem1 - OT6_00_000_octa_turret_folded_corner-2-1.STL deleted file mode 100755 index 49b5920fc970cc6e3499e5a0ee73f73d17418ba7..0000000000000000000000000000000000000000 Binary files a/data/Assem1 - OT6_00_000_octa_turret_folded_corner-2-1.STL and /dev/null differ diff --git a/data/triangle.stl b/data/triangle.stl deleted file mode 100755 index beeb31818b6c60de08e89bce06728278f16d63c4..0000000000000000000000000000000000000000 Binary files a/data/triangle.stl and /dev/null differ diff --git a/data/trianglePart.stl b/data/trianglePart.stl new file mode 100644 index 0000000000000000000000000000000000000000..d6aa77f02258e244d0eb425019794b989ef55e0a Binary files /dev/null and b/data/trianglePart.stl differ diff --git a/data/triangleRot.stl b/data/triangleRot.stl deleted file mode 100644 index 4ca435b41180448f1f3971749e78ddd9f0178b31..0000000000000000000000000000000000000000 Binary files a/data/triangleRot.stl and /dev/null differ diff --git a/data/triangleScaled.stl b/data/triangleScaled.stl deleted file mode 100644 index abcfa76dab8ded85363d5651358ed5b6013fb753..0000000000000000000000000000000000000000 Binary files a/data/triangleScaled.stl and /dev/null differ diff --git a/js/fea/dmaCell.js b/js/fea/dmaCell.js index b6592bd6be35549ddeeac9f6dd2e4579cacbaeda..10efcfc8a036619031ee5371dcc110de9e393d32 100644 --- a/js/fea/dmaCell.js +++ b/js/fea/dmaCell.js @@ -39,7 +39,7 @@ this.indices = indices; this.position = this._calcPositionForScale(scale); - this.parts = this._initParts(); + this.parts = this._initParts(this.position); this.drawForMode(mode); } @@ -56,18 +56,10 @@ return position; }; - DMACell.prototype._initParts = function(){ + DMACell.prototype._initParts = function(position){ var parts = []; for (var i=0;i<3;i++){ - parts.push(new DMAPart(i)); - } - return parts; - }; - - DMACell.prototype._buildPartsMesh = function(position){ - var parts = []; - for (var i=0;i<nodes.length;i++){ - parts.push(new Part(nodes[i], config[i])); + parts.push(new DMAPart(i, position)); } return parts; }; @@ -85,24 +77,26 @@ mesh.position.y = position.y; mesh.position.z = position.z; - mesh.myCell = this;//we need a reference to this instance from the mesh for intersection selection stuff return mesh; }; DMACell.prototype.drawForMode = function(mode){ + console.log(mode); if (mode == "cell"){ if (this.cellMesh) this._setCellMeshVisibility(true); else { this.cellMesh = this._buildCellMesh(this.position); window.three.sceneAdd(this.cellMesh); } + _.each(this.parts, function(part){ + part.hide(); + }); } else if (mode == "parts"){ - if (this.cellMesh) this._setCellMeshVisibility(false); - else { -// this.parts = this._buildPartsMesh(); -// window.three.sceneAdd(this.parts); - } + this._setCellMeshVisibility(false); + _.each(this.parts, function(part){ + part.show(); + }); } else { console.warn("unrecognized draw mode for cell"); } @@ -111,9 +105,6 @@ DMACell.prototype._setCellMeshVisibility = function(visibility){ if (!this.cellMesh) return; this.cellMesh.visible = visibility; -// _.each(this.cellMesh.children, function(childMesh){ -// childMesh.visible = visibility; -// }); }; DMACell.prototype.remove = function(){ diff --git a/js/fea/dmaPart.js b/js/fea/dmaPart.js index b5b20ca0a68fd389a1c1ea47d208388b14aff8a1..d9c6b229d4a76652907dfb58646dad2880ec5bc6 100644 --- a/js/fea/dmaPart.js +++ b/js/fea/dmaPart.js @@ -7,16 +7,61 @@ (function () { + //import part geometry + var loader = new THREE.STLLoader(); + loader.addEventListener('load', onMeshLoad); + loader.load("data/trianglePart.stl"); - var partGeometry1; + var partGeometry; + function onMeshLoad(e){ + console.log("part loaded"); + partGeometry = e.content; + partGeometry.computeBoundingBox(); + var unitScale = 1/partGeometry.boundingBox.max.y; + partGeometry.applyMatrix(new THREE.Matrix4().makeScale(unitScale, unitScale, unitScale)); + partGeometry.applyMatrix(new THREE.Matrix4().makeTranslation(0.2,-0.5, 0)); + partGeometry.applyMatrix(new THREE.Matrix4().makeRotationZ(-Math.PI/6)); + partGeometry.applyMatrix(new THREE.Matrix4().makeScale(30,30,30)); + } + + function DMAPart(type, position) { - function DMAPart(type) { + this.position = position; + this.type = type; // this.nodes = nodes; // this.beams = this._createBeams(nodes, config); - this.scale = 10; // this.geometry = geometry; } + DMAPart.prototype._draw = function(){ + this.mesh = this._makeMeshForType(this.type); + window.three.sceneAdd(this.mesh); + }; + + DMAPart.prototype._makeMeshForType = function(type){ + + var mesh = new THREE.Mesh(partGeometry); + mesh.position.x = this.position.x; + mesh.position.y = -30/3*Math.sqrt(3)+this.position.y; + mesh.position.z = this.position.z; + + //todo this sucks, go back and fix the real problem + if (Math.round(mesh.position.z/(2*30/Math.sqrt(6)))%2 == 1){ + mesh.position.y += 30 + 30/6; + mesh.rotateZ(Math.PI); + } + + switch(type){ + case 1: + mesh.rotateZ(2*Math.PI/3); + break; + case 2: + mesh.rotateZ(-2*Math.PI/3); + break; + } + return mesh; + }; + DMAPart.prototype._createBeams = function(nodes, config){ // var beams = []; // _.each(config, function(pair){ @@ -25,7 +70,13 @@ // return beams; }; - DMAPart.prototype.render = function(){ + DMAPart.prototype.show = function(){ + if (!this.mesh) this._draw(); + this.mesh.visibility = true; + }; + + DMAPart.prototype.hide = function(){ + if (this.mesh) this.mesh.visibility = false; }; self.DMAPart = DMAPart;