diff --git a/js/cam/assemblers/Assembler.js b/js/cam/assemblers/Assembler.js index a7906d528ef565260941726e58c7159ad547db9b..381dc7f2dbdd313df16e9fbc1d9d10f846b6f6ae 100644 --- a/js/cam/assemblers/Assembler.js +++ b/js/cam/assemblers/Assembler.js @@ -210,14 +210,14 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' stock.show(); }); if (index.z%2 != 0) {//rotate on odd rows - this.components.frame.rotateTo(new THREE.Vector3(0, 0, Math.PI/2), speed, callback); + this.components.substrate.rotateTo(new THREE.Vector3(0, 0, Math.PI/2), speed, callback); return; } - this.components.frame.rotateTo(new THREE.Vector3(0, 0, 0), speed, callback); + this.components.substrate.rotateTo(new THREE.Vector3(0, 0, 0), speed, callback); }; Assembler.prototype.rotateTo = function(index, speed, settings, callback){ - this.components.frame.rotateTo(new THREE.Vector3(0, 0, Math.PI/2), speed, callback); + this.components.substrate.rotateTo(new THREE.Vector3(0, 0, Math.PI/2), speed, callback); }; Assembler.prototype.releaseStock = function(index, settings){ @@ -237,11 +237,11 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' callback(); } - var startingPos = this.components.xAxis.getPosition().add(this.components.frame.getPosition().add(this.components.zAxis.getPosition()));//this.components.zAxis.getAbsolutePosition();//get position of end effector + var startingPos = this.components.xAxis.getPosition().add(this.components.yAxis.getPosition().add(this.components.zAxis.getPosition()));//this.components.zAxis.getAbsolutePosition();//get position of end effector speed = this._normalizeSpeed(startingPos, position, new THREE.Vector3(speed, speed, speed));//todo fix this this.components.xAxis.moveTo(position, speed.x, sketchyCallback); - this.components.frame.moveTo(position, speed.y, sketchyCallback); + this.components.yAxis.moveTo(position, speed.y, sketchyCallback); this.components.zAxis.moveTo(position, speed.z, sketchyCallback); }; diff --git a/js/cam/assemblers/Component.js b/js/cam/assemblers/Component.js index 3069c7b4e40ec8e555e7037951bcf826f27166c7..f8a418fb0dcab5dacd7debb0a1afe344120d7c36 100644 --- a/js/cam/assemblers/Component.js +++ b/js/cam/assemblers/Component.js @@ -31,6 +31,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ Component.prototype.makeGeometry = function(geo, material){ this.stl = new THREE.Mesh(geo, material); this.object3D.add(this.stl); + if (this.rotary) this.stl.position.set(-this.centerOfRotation.x, -this.centerOfRotation.y, -this.centerOfRotation.z); }; Component.prototype.addChild = function(child){ @@ -44,7 +45,19 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ } this.children.push(child); child._addParent(this, this.id); - this.object3D.add(child.getObject3D()); + + if (this.rotary){ + var wrapper = new THREE.Object3D(); + wrapper.add(child.getObject3D()); + wrapper.position.set(-this.centerOfRotation.x, -this.centerOfRotation.y, -this.centerOfRotation.z); + console.log("here"); + this.secondWrapper = new THREE.Object3D(); + this.secondWrapper.add(wrapper); + this.object3D.add(this.secondWrapper); + this.object3D.position.set(this.centerOfRotation.x, this.centerOfRotation.y, this.centerOfRotation.z); + } else { + this.object3D.add(child.getObject3D()); + } }; Component.prototype.checkAncestry = function(component){//return true if this is a parent/grandparent/great-grandparent... @@ -110,7 +123,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ }; Component.prototype.getRotation = function(){//for rotary axes - return this.object3D.rotation.toVector3().clone(); + return this.secondWrapper.rotation.toVector3().clone(); }; Component.prototype.getOrientation = function(){ @@ -191,14 +204,14 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ if (callback) callback(); return; } else if (remainingDist < Math.abs(increment)){ - self.object3D.rotation.x = target.x; - self.object3D.rotation.y = target.y; - self.object3D.rotation.z = target.z; + self.secondWrapper.rotation.x = target.x; + self.secondWrapper.rotation.y = target.y; + self.secondWrapper.rotation.z = target.z; if (callback) callback(); return; } - self.object3D.rotateOnAxis(axis.clone().normalize(), increment); + self.secondWrapper.rotateOnAxis(axis.clone().normalize(), increment); self._incrementalRotation(increment, target, axis, callback); }, 10); }; diff --git a/js/menus/templates/EditComponentMenuView.html b/js/menus/templates/EditComponentMenuView.html index 56f5e3ea7ab3034fd1601182bcdcba0e93502f41..6a430099fc20714c4b9c8f26b5794291a16cd0ce 100644 --- a/js/menus/templates/EditComponentMenuView.html +++ b/js/menus/templates/EditComponentMenuView.html @@ -31,7 +31,7 @@ Parent: <% if (descendants.indexOf(id)<0) return; %> <% var component = components[id] || stock[id]; %> <% treeLevel++; %> - <div class="assemblerTree" <% if (treeLevel%2 == 0){ %> style="background-color:#ddd"<% } %> ><label style="padding-left:<%= (level-tree[editingComponent]-1)*10 + 20 %>px"><%= component.name %> + <div class="alternatingColorList<% if (treeLevel%2 == 0){ %> evenListItem<% } %>" ><label style="padding-left:<%= (level-tree[editingComponent]-1)*10 + 20 %>px"><%= component.name %> <% if(tree[editingComponent]+1 == level){ %><a data-id="<%= id %>" class="removeChild pull-right" href="#">Remove</a><% } %></label></div><br/> <% }); %><br/> diff --git a/js/plists/CamPList.js b/js/plists/CamPList.js index 8f251ae61647ece016e2bfce67a7b75d265280f5..88c3563758c19218b50ee887c67ed65ea2cee1d0 100644 --- a/js/plists/CamPList.js +++ b/js/plists/CamPList.js @@ -80,7 +80,8 @@ define(['three'], function(THREE){ //minBound //maxBound parent: "frame", - isStatic: true, + motionVector: {x:0, y:1, z:0}, +// isStatic: true, stl: { filename: "assets/stls/stapler/frame.stl" }