changed grab script so user can only grab with left mouse click and we update velocityof grabbed object every frame instead of flinging it onb release

This commit is contained in:
Eric Levin 2015-04-30 11:39:27 -07:00
parent 45ba678686
commit a9c5f044c8

View file

@ -50,6 +50,9 @@ var dropLine = Overlays.addOverlay("line3d", {
function mousePressEvent(event) {
if(!event.isLeftButton){
return;
}
var pickRay = Camera.computePickRay(event.x, event.y);
var intersection = Entities.findRayIntersection(pickRay);
if (intersection.intersects && intersection.properties.collisionsWillMove) {
@ -83,7 +86,7 @@ function mousePressEvent(event) {
function mouseReleaseEvent() {
if (isGrabbing) {
flingObject();
// flingObject();
Entities.editEntity(grabbedEntity, {
gravity: savedGravity
});
@ -108,7 +111,6 @@ function flingObject() {
function mouseMoveEvent(event) {
if (isGrabbing) {
entityProps = Entities.getEntityProperties(grabbedEntity);
prevPosition = entityProps.position;
avatarEntityDistance = Vec3.distance(MyAvatar.position, entityProps.position);
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5);
deltaMouse.x = event.x - prevMouse.x;
@ -133,9 +135,17 @@ function mouseMoveEvent(event) {
z: 0
})
});
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
Entities.editEntity(grabbedEntity, {
velocity: flingVelocity
});
prevPosition = entityProps.position;
}
prevMouse.x = event.x;
prevMouse.y = event.y;
}
function keyReleaseEvent(event) {