diff --git a/js/API/LatticeAPI.js b/js/API/LatticeAPI.js new file mode 100644 index 0000000000000000000000000000000000000000..2f84fa3417a43674f4c5a02579c7620292494874 --- /dev/null +++ b/js/API/LatticeAPI.js @@ -0,0 +1,98 @@ +/** + * Created by aghassaei on 9/25/15. + */ + + +define(['lattice'], function(lattice){ + + return { + + //getters + + getSize: function(){ + + }, + + getAspectRatio: function(){ + return lattice.get("aspectRatio").clone(); + }, + + getCellType: function(){ + return lattice.get("cellType"); + }, + + getConnectionType: function(){ + return lattice.get("connectionType"); + }, + + getApplicationType: function(){ + return lattice.get("latticeType"); + }, + + getPartType: function(){ + return lattice.get("partType"); + }, + + + //setters + + setAspectRatio: function(x, y, z){ + if (!x || !y || !z || x<0 || y<0 || z<0) {//no 0, undefined, null, or neg #'s + console.warn("invalid aspect ratio params"); + return; + } + lattice.set("aspectRatio", new THREE.Vector3(x, y, z)); + }, + + setCellType: function(cellType){ + + }, + + setConnectionType: function(connectionType){ + + }, + + setApplicationType: function(applicationType){ + + }, + + setPartType: function(partType){ + + }, + + setLatticeType: function(cellType, connectionType, applicationType, partType){ + + }, + + + //cells + + clearCells: function(){ + lattice.clearCells(); + }, + + getSparseCells: function(){ + + }, + + getCells: function(){ + + }, + + loopSparseCells: function(){ + + }, + + loopCells: function(){ + + }, + + + //general + + save: function(filename){ + + } + } + +}); \ No newline at end of file diff --git a/js/API/MaterialAPI.js b/js/API/MaterialAPI.js new file mode 100644 index 0000000000000000000000000000000000000000..270fed12221db185a3c4f247d7ea74d0cbc03fe3 --- /dev/null +++ b/js/API/MaterialAPI.js @@ -0,0 +1,21 @@ +/** + * Created by aghassaei on 9/25/15. + */ + + +define([], function(){ + + + function init(){ + + } + + function set(){ + + } + + function destroy(){ + + } + +}); \ No newline at end of file diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index bbb75416656baf94687aa52e6b29e9a098105c54..4055942e007d59d11c50ca0fcbcb3faa1385353d 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -29,8 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis __initialize: function(){ - this._checkURL(); - this.listenTo(this, "change:partType", this._updatePartType); this.listenTo(this, "change:cellType", function(){ @@ -58,10 +56,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis this._reloadCells(); }, - _checkURL: function(){ - var path = window.location.path; -// console.log(path); - }, diff --git a/js/materials/DMAMaterial.js b/js/materials/DMAMaterial.js index 0cecddb333e4f357b2704aba3311aa3621bc48a6..35940b3a28ae4511982c97a6a0b6deee9649feaa 100644 --- a/js/materials/DMAMaterial.js +++ b/js/materials/DMAMaterial.js @@ -71,7 +71,9 @@ define(['underscore', 'appState'], function(_, appState){ }; DMAMaterial.prototype.randomHexColor = function(){ - return '#' + Math.floor(Math.random()*16777215).toString(16); + var hex = '#' + Math.floor(Math.random()*16777215).toString(16); + if (hex.match(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i) !== null) return hex; + return "#000000"; }; DMAMaterial.prototype._makeMaterialObject = function(color, transparent){ diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 4f07aa82b9be33ff868bd9aeb30c397ddfa434ed..193b720d42c694422fcf65182937b467bc22f103 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -126,8 +126,14 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex _setNumber: function($target, newVal){ var min = $target.data("min"); var max = $target.data("max"); - if (min !== undefined && (min > newVal)) newVal = min; - else if (max !== undefined && (max < newVal)) newVal = max; + if (min !== undefined && (min > newVal)) { + console.warn("number must be " + min + " or above"); + newVal = min; + } + else if (max !== undefined && (max < newVal)) { + console.warn("number must be " + max + " or below"); + newVal = max; + } var property = $target.data("property"); if (!property) { diff --git a/js/menus/templates/LatticeMenuView.html b/js/menus/templates/LatticeMenuView.html index 38144c69dd52b48c3e1c9eb583ec1091e184ca43..c57e9d86e18dc8394d650e085cd3373af1aea0df 100644 --- a/js/menus/templates/LatticeMenuView.html +++ b/js/menus/templates/LatticeMenuView.html @@ -37,9 +37,9 @@ Type: </div><br/><br/> <% } %> Aspect Ratio: - <input data-property="aspectRatio" data-key="x" value="<%= aspectRatio.x %>" placeholder="X" class="form-control lattice floatInput" type="text"> - <input data-property="aspectRatio" data-key="y" value="<%= aspectRatio.y %>" placeholder="Y" class="form-control lattice floatInput" type="text"> - <input data-property="aspectRatio" data-key="z" value="<%= aspectRatio.z %>" placeholder="Z" class="form-control lattice floatInput" type="text"><br/><br/> + <input data-property="aspectRatio" data-key="x" data-min="0.1" value="<%= aspectRatio.x %>" placeholder="X" class="form-control lattice floatInput" type="text"> + <input data-property="aspectRatio" data-key="y" data-min="0.1" value="<%= aspectRatio.y %>" placeholder="Y" class="form-control lattice floatInput" type="text"> + <input data-property="aspectRatio" data-key="z" data-min="0.1" value="<%= aspectRatio.z %>" placeholder="Z" class="form-control lattice floatInput" type="text"><br/><br/> <% if (connectionType == "gik") { %> Part Length: <input data-property="gikLength" value="<%= gikLength %>" placeholder="Length" class="form-control intInput appState" type="text"><br/><br/> <% } %>