if the intersection distance is small, use grab-mode rather than distant-grab-mode

This commit is contained in:
Seth Alves 2015-09-15 16:55:51 -07:00
parent 848bb4fccb
commit f7193dbb97

View file

@ -97,8 +97,8 @@ function controller(side, triggerAction, pullAction, hand) {
controller.prototype.updateLine = function() { controller.prototype.updateLine = function() {
if (this.pointer != null) { if (this.pointer != null) {
if (Entities.getEntityProperties(this.pointer).id != this.poitner) { if (Entities.getEntityProperties(this.pointer).id != this.pointer) {
this.pointer == null; this.pointer = null;
} }
} }
@ -118,7 +118,6 @@ controller.prototype.updateLine = function() {
}); });
} }
var handPosition = this.getHandPosition(); var handPosition = this.getHandPosition();
var direction = Quat.getUp(this.getHandRotation()); var direction = Quat.getUp(this.getHandRotation());
@ -172,14 +171,26 @@ controller.prototype.checkForIntersections = function(origin, direction) {
if (intersection.intersects && intersection.properties.collisionsWillMove === 1) { if (intersection.intersects && intersection.properties.collisionsWillMove === 1) {
var handPosition = Controller.getSpatialControlPosition(this.palm); var handPosition = Controller.getSpatialControlPosition(this.palm);
this.distanceToEntity = Vec3.distance(handPosition, intersection.properties.position); this.distanceToEntity = Vec3.distance(handPosition, intersection.properties.position);
Entities.editEntity(this.pointer, { var intersectionDistance = Vec3.distance(handPosition, intersection.intersection);
linePoints: [
ZERO_VEC, if (intersectionDistance < 0.6) {
Vec3.multiply(direction, this.distanceToEntity) //We are grabbing an entity, so let it know we've grabbed it
] this.grabbedEntity = intersection.entityID;
}); this.activateEntity(this.grabbedEntity);
this.grabbedEntity = intersection.entityID; this.hidePointer();
return true; this.shouldDisplayLine = false;
this.grabEntity();
return true;
} else {
Entities.editEntity(this.pointer, {
linePoints: [
ZERO_VEC,
Vec3.multiply(direction, this.distanceToEntity)
]
});
this.grabbedEntity = intersection.entityID;
return true;
}
} }
return false; return false;
} }