Commit 80a92a00 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

offsets working in sim

parent 4348a612
......@@ -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);
};
......
......@@ -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);
};
......
......@@ -31,7 +31,7 @@ Parent: &nbsp;&nbsp;
<% 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/>
......
......@@ -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"
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment