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

bounding box calc

parent 32e9705c
No related branches found
No related tags found
No related merge requests found
......@@ -182,14 +182,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
},
calculateBoundingBox: function(){
var scale = this._allAxesScales();
var min = _.clone(this.get("cellsMin"));
var max = _.clone(this.get("cellsMax"));
_.each(_.keys(scale), function(key){
min[key] *= scale[key];
max[key] *= scale[key];
});
return {min:min, max:max};
if (!this.get("cellsMax") || !this.get("cellsMin")) return new THREE.Vector3(0,0,0);
return (new THREE.Vector3()).subVectors(this.get("cellsMax"), this.get("cellsMin")).add(new THREE.Vector3(1,1,1));
},
......
......@@ -2,7 +2,7 @@
* Created by aghassaei on 6/10/15.
*/
define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _, MenuParentView, plist, lattice){
define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals'], function($, _, MenuParentView, plist, lattice, globals){
return MenuParentView.extend({
......@@ -23,12 +23,6 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
this.listenTo(lattice.compositeEditor, "change", this.render);
},
_updateDimensions: function(cells){
this.material.dimensions.x = cells.length;
this.material.dimensions.y = cells[0].length;
this.material.dimensions.z = cells[0][0].length;
},
_changeRandomColor: function(e){
e.preventDefault();
lattice.compositeEditor._changeRandomColor();
......@@ -76,7 +70,12 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
},
_makeTemplateJSON: function(){
return _.extend(lattice.compositeEditor.toJSON());
return _.extend(plist, this.model.toJSON(), globals, lattice.compositeEditor.toJSON(),
{
materialClass:lattice.get("materialClass"),
materialType:lattice.get("materialType"),
dimensions: lattice.compositeEditor.calculateBoundingBox()
});
},
template: _.template('\
......@@ -84,10 +83,28 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
<a id="saveComposite" href="#" class="btn btn-halfWidth btn-lg pull-right btn-default">Save Composite</a><br/><br/>\
Name: &nbsp;&nbsp;<input id="compositeName" data-property="name" value="<%= name %>" placeholder="Enter Name" class="seventyFiveWidth form-control textInput compositeEditor" type="text"><br/><br/>\
Num Cells: &nbsp;&nbsp;<%= numCells %><br/><br/>\
Bounding Box: ()<br/><br/>\
Bounding Box: &nbsp;&nbsp;<%= dimensions.x %> x <%= dimensions.y %> x <%= dimensions.z %><br/><br/>\
Display Color: &nbsp;&nbsp;\
<input id="compositeColor" style="border-color: <%= color %> ;" data-property="color" value="<%= color %>" placeholder="Enter HEX" class="halfWidth compositeEditor form-control hexInput" type="text"><br/><br/>\
<a id="newRandomColor" href="#" class="btn btn-block btn-lg btn-default">New Random Color</a><br/><br/>\
<a id="newRandomColor" href="#" class="btn btn-block btn-lg btn-default">New Random Color</a><br/>\
Available Materials:<br/>\
<% _.each(_.keys(allMaterials[materialClass]), function(key){ %>\
<label class="radio colorSwatches">\
<input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
<div class="materialColorSwatch">\
<div style="background-color:<% if(realisticColorScheme){ %><%= allMaterials[materialClass][key].color %><% }else{ %><%= allMaterials[materialClass][key].altColor %><% } %>"></div>\
<span><%= allMaterials[materialClass][key].name %></span></div>\
</label>\
<% }); %>\
<% _.each(_.keys(materials.compositeMaterials), function(key){ \
if (key == id) return; %>\
<label class="radio colorSwatches">\
<input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
<div class="materialColorSwatch">\
<div style="background-color:<% if(realisticColorScheme){ %><%= materials.compositeMaterials[key].color %><% }else{ %><%= materials.compositeMaterials[key].altColor %><% } %>"></div>\
<span><%= materials.compositeMaterials[key].name %></span></div>\
</label>\
<% }); %><br/>\
<a id="finishComposite" href="#" class="btn btn-block btn-lg btn-success">Finish Composite</a><br/>\
<a id="cancelComposite" href="#" class="btn btn-halfWidth btn-lg btn-default">Cancel / Exit</a>\
<a id="deleteComposite" href="#" class="btn btn-halfWidth pull-right btn-lg btn-default"><span class="fui-trash"></span> Delete</a><br/>\
......
......@@ -19,7 +19,7 @@ define(['jquery', 'underscore', 'backbone'], function($, _, Backbone){
render: function(){
if (this.model.changedAttributes()["currentNav"]) return;
if ($("input[type=text]").is(":focus")) return;
this.$el.html(this.template(this._makeTemplateJSON()));
if (this._preRender) this._preRender();
this.$el.html(this.template(this._makeTemplateJSON()));
if (this._render) this._render();
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment