diff --git a/js/highlighter/Highlighter.js b/js/highlighter/Highlighter.js index 4a29025fb2c36fa715a7d166c27a49db250ab1c3..182fa9c6d6e4b52bd0e84fff2a218466784dab31 100644 --- a/js/highlighter/Highlighter.js +++ b/js/highlighter/Highlighter.js @@ -121,7 +121,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' getHighlightedObjectPosition: function(){//origin selection if (this.highlightedObject instanceof DMACell) { - var position = this.highlightedObject.getPosition(); + var position = this.highlightedObject.getAbsolutePosition(); return new THREE.Vector3(parseFloat(position.x.toFixed(4)), parseFloat(position.y.toFixed(4)), parseFloat(position.z.toFixed(4))); diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index ff64886543aae7ad9a5f669998eacf776a37ed1b..a489ad75e90f01c388a69fa02abdc8918599944a 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -199,20 +199,24 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre calculateBoundingBox: function(){ if (!this.get("cellsMax") || !this.get("cellsMin")) return new THREE.Vector3(0,0,0); - var dimVector = this.get("cellsMax").clone().sub(this.get("cellsMin")).add(new THREE.Vector3(1,1,1)); + var dimMax = this.get("cellsMax").clone().sub(this.get("cellsMin")).add(new THREE.Vector3(1,1,1)); + var dimMin = new THREE.Vector3(0,0,0); this._loopCells(this.sparseCells, function(cell, x, y, z){ if (cell){ var material = cell.getMaterial(); if (material.dimensions){ - var subCellMax = (new THREE.Vector3(x, y, z)).add(cell.applyAbsoluteRotation(material.dimensions.clone())); - dimVector.max(subCellMax); + console.log(cell.applyAbsoluteRotation(material.dimensions.clone())); + var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyAbsoluteRotation(material.dimensions.clone())); + dimMax.max(subCellRange); + dimMin.min(subCellRange); } else if (cell.length){ - var subCellMax = (new THREE.Vector3(x, y, z)).add(cell.applyAbsoluteRotation(new THREE.Vector3(cell.length, 1, 1))); - dimVector.max(subCellMax); + var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyAbsoluteRotation(new THREE.Vector3(cell.length, 1, 1))); + dimMax.max(subCellRange); + dimMin.min(subCellRange); } } }); - return dimVector + return dimMax.sub(dimMin); }, diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index 3ab962e51fbf69f735e64c53305569c038559eba..7e039900487167f0f035a5e400880c32dd88f59d 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -14,7 +14,10 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu if (id && data === null) return deleteMaterial(id); if (!materials[id]) materials[id] = {}; var oldColor = materials[id].color; - _.extend(materials[id], data);//todo trigger change on all instances + _.each(_.keys(data), function(key){//todo trigger change on all instances + if (data[key] && data[key].x) materials[id][key] = new THREE.Vector3(data[key].x, data[key].y, data[key].z); + else materials[id][key] = data[key]; + }); if (materials[id].threeMaterial || oldColor != materials[id].color) changeSingleMaterialColorScheme(id); return false; }