diff --git a/dependencies/main.html b/dependencies/main.html deleted file mode 100644 index 7a901763472ef87af5389119b16a6533ae7bfd5c..0000000000000000000000000000000000000000 --- a/dependencies/main.html +++ /dev/null @@ -1,128 +0,0 @@ -<!DOCTYPE html> -<html><head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> - - <title></title> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <script src="main_files/analytics_002.js" async=""></script><script src="main_files/analytics.js"></script> - - <!--UI--> - <script src="main_files/jquery-2.js"></script> - <script src="main_files/underscore.js"></script> - - <!--backbone model/view framework--> - <script src="main_files/backbone.js"></script> - - <!--flatUI bootstrap theme--> - <link href="main_files/bootstrap.css" rel="stylesheet"><!-- Loading Bootstrap --> - <link href="main_files/flat-ui.css" rel="stylesheet"><!-- Loading Flat UI --> - <script src="main_files/flat-ui.js"></script> - <!--<script src="dependencies/flatUI/js/vendor/video.js"></script>--> - - <!--bootstrap slider--> - <link href="main_files/bootstrap-slider.css" rel="stylesheet"> - <script src="main_files/bootstrap-slider.js"></script> - - <!--threeJS--> - <script src="main_files/three.js"></script> - <script src="main_files/OrbitControls.js"></script> - - <!--stl import/export--> - <script src="main_files/THREE2STL.js"></script> - <script src="main_files/STLLoader.js"></script> - - <!--numerical javascript--> - <script src="main_files/numeric-1.js"></script> - - <!--multi-threading--> - <script src="main_files/worker.js"></script> - <script src="main_files/persistentWorkers.js"></script><!--global workers--> - - <!--fea stuff--> - <script src="main_files/dmaCell.js"></script> - <script src="main_files/dmaPart.js"></script> - <!--<script src="js/fea/dmaBeam.js"></script>--> - <script src="main_files/dmaNode.js"></script> - - <!--models--> - <script src="main_files/threeModel.js"></script> - <script src="main_files/fillGeometry.js"></script> - <script src="main_files/lattice.js"></script> - - <!--views--> - <script src="main_files/meshHandle.js"></script> - <script src="main_files/threeView.js"></script> - <script src="main_files/pushPullMeshView.js"></script> - <script src="main_files/importView.js"></script> - <script src="main_files/fillGeometryView.js"></script> - <script src="main_files/latticeView.js"></script> - - <script src="main_files/main.js"></script> - - - <!--<script src="js/views/elementMenu.js"></script>--> - <script src="main_files/exportMenu.js"></script> - <script src="main_files/navbar.js"></script> - <link rel="stylesheet" type="text/css" href="main_files/main.css"> - -</head> -<body> - -<nav class="navbar navbar-inverse navbar-embossed" role="navigation"> - <div class="navbar-header"> - <!--<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-01">--> - <!--<span class="sr-only">Toggle navigation</span>--> - <!--</button>--> - <a id="mainNavLink" class="navbar-brand" href="http://cba.mit.edu/">CBA.MIT.EDU</a> - </div> - <div class="collapse navbar-collapse" id="navbar-collapse-01"> - <ul class="nav navbar-nav navbar-left"> - <li><a data-menu-id="importGeometry" class="menuHoverControls" href="#">Import</a></li> - <li><a data-menu-id="element" class="menuHoverControls" href="#">Element</a></li> - - <!--<li><a data-menu-id="controls1Menu" class="menuHoverControls" href="#">Controls1</a></li>--> - <!--<li><a data-menu-id="controls2Menu" class="menuHoverControls" href="#">Controls2</a></li>--> - <!--<li><a data-menu-id="controls3Menu" class="menuHoverControls" href="#">Glyphs</a></li>--> - <!--<li><a data-menu-id="controls4Menu" class="menuHoverControls" href="#">Buttons</a></li>--> - <!--<li><a data-menu-id="controls5Menu" class="menuHoverControls" href="#">Inputs</a></li>--> - <li class="dropdown navDropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <b class="caret"></b></a> - <span class="dropdown-arrow"></span> - <ul class="dropdown-menu"> - <li><a id="exportSTL" href="#">Export STL</a></li> - <li><a href="#">Another action</a></li> - <li><a href="#">Something else here</a></li> - <li class="divider"></li> - <li><a href="#">Separated link</a></li> - </ul> - </li> - <li><a data-menu-id="about" class="menuHoverControls" href="#">About</a></li> - </ul> - <ul class="nav navbar-nav navbar-right"> - <li><a id="clearAll" class="menuHoverControls" href="#">Clear All</a></li> - </ul> - <!--<a href="#fakelink" id="clearAll" class=" btn btn-lg btn-primary">Clear All</a>--> - </div><!-- /.navbar-collapse --> - </nav> -<div style="display: none;" id="importGeometry" class="row navMenu"> -</div> -<div style="display: none;" id="element" class="row navMenu"> - <div class="row demo-row"> - <div class="col-xs-3"> - <a id="elementCube" href="#">Cube</a> - </div> - </div> -</div> -<div style="display: none;" id="about" class="row navMenu"> - <div class="row demo-row"> - <div class="col-xs-3"> - Latest code available on github - </div> - </div> -</div> - -<div id="threeContainer"><canvas style="width: 1145px; height: 947px;" height="947" width="1145"></canvas></div> - - -</body></html> \ No newline at end of file diff --git a/js/fea/dmaCell.js b/js/fea/dmaCell.js index 93e07b0f1b8d1fa3cd505c025d3f8068fc6fe250..5143e96a9e567edbda64243a66cc874a2840a574 100644 --- a/js/fea/dmaCell.js +++ b/js/fea/dmaCell.js @@ -56,26 +56,35 @@ return mesh; }; - Cell.prototype._draw = function(){ - window.three.sceneAdd(this.mesh); - }; - Cell.prototype.drawForMode = function(mode, position){ - if (this.mesh) this.remove(); - this.mesh = null; position = position || this.position; if (mode == "cell"){ - this.mesh = this._buildCellMesh(position); + if (this.cellMesh) this._setCellMeshVisibility(true); + else { + this.cellMesh = this._buildCellMesh(position); + window.three.sceneAdd(this.cellMesh); + } } else if (mode == "parts"){ - this.mesh = this._buildPartsMesh(); + if (this.cellMesh) this._setCellMeshVisibility(false); + else { +// this.parts = this._buildPartsMesh(); +// window.three.sceneAdd(this.parts); + } } else { console.warn("unrecognized draw mode for cell"); } - if (this.mesh) this._draw(); + }; + + Cell.prototype._setCellMeshVisibility = function(visibility){ + if (!this.cellMesh) return; + this.cellMesh.visible = visibility; +// _.each(this.cellMesh.children, function(childMesh){ +// childMesh.visible = visibility; +// }); }; Cell.prototype.remove = function(){ - window.three.sceneRemove(this.mesh); + if (this.cellMesh) window.three.sceneRemove(this.cellMesh); }; @@ -86,9 +95,8 @@ }; Cell.prototype._destroy = function(){ - this.mesh.myCell = null; - } - + if (this.cellMesh) this.cellMesh.myCell = null; + }; self.Cell = Cell; diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index e3efeaaccd98307ac05f5f10327ee34c40dc9a5a..446ced46f5bb65454b4d0ccd90fbe6c052538896 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -46,7 +46,6 @@ LatticeMenuView = Backbone.View.extend({ Cell Type: <%= formattedCellType %><br/>\ Cell Connection: <%= formattedConnectionType %><br/>\ Scale: <%= scale %><br/>\ - Column Separation:<br/>\ NumCells: <%= numCells %><br/>\ Show Bounding Box:<br/><br/>\ <a href="#" id="latticeMenuClearCells" class=" btn btn-block btn-lg btn-default">Clear All Cells</a><br/>\ diff --git a/js/menus/MenuWrapper.js b/js/menus/MenuWrapperView.js similarity index 100% rename from js/menus/MenuWrapper.js rename to js/menus/MenuWrapperView.js diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js index fd43d7172bbc44fef90d8861e61c530ea341b061..6bdbd32a9a269bffe4402fbe7618a091e5592470 100644 --- a/js/menus/PartMenuView.js +++ b/js/menus/PartMenuView.js @@ -25,6 +25,7 @@ PartMenuView = Backbone.View.extend({ template: _.template('\ Part Type: <%= partType %><br/>\ + Column Separation:<br/>\ ') }); \ No newline at end of file diff --git a/js/models/lattice.js b/js/models/lattice.js index e049f664e9fc2bf8fdebe96e2d5a18a13e175021..3335c5c79301c80c2d59e3b86793ef3531459174 100644 --- a/js/models/lattice.js +++ b/js/models/lattice.js @@ -21,6 +21,7 @@ Lattice = Backbone.Model.extend({ initialize: function(){ //bind events + this.listenTo(this, "change:cellMode", this._cellModeDidChange); }, addCell: function(position){ @@ -33,14 +34,15 @@ Lattice = Backbone.Model.extend({ removeCell: function(object){ var cells = this.get("cells"); - var index = cells.indexOf(object.parent.myCell); + var cell = object.parent.myCell; + var index = cells.indexOf(cell); if (index == -1) {//I think this is happening when two intersection/remove calls are done on the same cell before the next render loop finished console.warn("problem locating cell in cell array"); return; } cells.splice(index, 1); + cell.remove(); this.set("numCells", cells.length); - window.three.sceneRemove(object); window.three.render(); }, @@ -51,6 +53,14 @@ Lattice = Backbone.Model.extend({ this.set("cells", []); this.set("numCells", 0); window.three.render(); + }, + + _cellModeDidChange: function(){ + var mode = this.get("cellMode"); + _.each(this.get("cells"), function(cell){ + cell.drawForMode(mode); + }); + window.three.render(); } }); \ No newline at end of file diff --git a/js/threeViews/latticeView.js b/js/threeViews/latticeView.js deleted file mode 100644 index 04c91590873005e03952a51d21b977d65a7fb6b4..0000000000000000000000000000000000000000 --- a/js/threeViews/latticeView.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Created by aghassaei on 1/16/15. - */ - -LatticeView = Backbone.View.extend({ - - events: { - }, - - el: "#threeContainer", - - controls: null, - - initialize: function(options){ - - this.three = options.three; - this.fillGeometry = options.fillGeometry; - - - //bind events - this.listenTo(this.model, "change:bounds", this.updateBuildPlanes()); - - this.buildPlanes(); - this.render(); - - }, - - updateBuildPlanes: function(){ - }, - - buildPlanes: function(){ - var xyPlaneGeo = new THREE.Geometry(); - var xzPlaneGeo = new THREE.Geometry(); - var yzPlaneGeo = new THREE.Geometry(); - - var size=50, step = 5; - for (var i=-size;i<=size;i+=step){ - xyPlaneGeo.vertices.push(new THREE.Vector3(-size, i, -size)); - xyPlaneGeo.vertices.push(new THREE.Vector3(size, i, -size)); - xyPlaneGeo.vertices.push(new THREE.Vector3(i, -size, -size)); - xyPlaneGeo.vertices.push(new THREE.Vector3(i, size, -size)); - - xzPlaneGeo.vertices.push(new THREE.Vector3(-size, i, -size)); - xzPlaneGeo.vertices.push(new THREE.Vector3(-size, i, size)); - xzPlaneGeo.vertices.push(new THREE.Vector3(-size, -size, i)); - xzPlaneGeo.vertices.push(new THREE.Vector3(-size, size, i)); - - yzPlaneGeo.vertices.push(new THREE.Vector3(-size, -size, i)); - yzPlaneGeo.vertices.push(new THREE.Vector3(size, -size, i)); - yzPlaneGeo.vertices.push(new THREE.Vector3(i, -size, -size)); - yzPlaneGeo.vertices.push(new THREE.Vector3(i, -size, size)); - } - - this.addPlane(xyPlaneGeo); -// this.addPlane(yzPlaneGeo); -// this.addPlane(xzPlaneGeo); - - }, - - addPlane: function(planeGeo){ - var plane = new THREE.Line(planeGeo, new THREE.LineBasicMaterial({color:0x000000, opacity:0.3}), THREE.LinePieces); - this.three.sceneAdd(plane); - }, - - render: function(){ - this.three.render(); - } -}); \ No newline at end of file diff --git a/main.html b/main.html index 42cbf8d20cff4829c30326b8d291d9d3c54664df..398fb3ba86f9f11550cc4bd16219720445509fbb 100644 --- a/main.html +++ b/main.html @@ -52,7 +52,7 @@ <script src="js/models/extrudeVisualizer.js"></script> <!--views--> - <script src="js/menus/MenuWrapper.js"></script> + <script src="js/menus/MenuWrapperView.js"></script> <script src="js/menus/Navbar.js"></script> <script src="js/menus/LatticeMenuView.js"></script> <script src="js/menus/ImportMenuView.js"></script>