From 45ba6786869aad82fb07f6f9f9a279158e299a37 Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Wed, 29 Apr 2015 23:40:53 -0700 Subject: [PATCH 1/3] can now fling up and down as well as in xz plane --- examples/grab.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/grab.js b/examples/grab.js index 4e0c536a1b..dc250b9d27 100644 --- a/examples/grab.js +++ b/examples/grab.js @@ -100,7 +100,6 @@ function flingObject() { flingVelocity = Vec3.subtract(entityProps.position, prevPosition); flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity); - flingVelocity.y = 0; Entities.editEntity(grabbedEntity, { velocity: flingVelocity }); From a9c5f044c88ee82742bad322c6728545a22637af Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Thu, 30 Apr 2015 11:39:27 -0700 Subject: [PATCH 2/3] 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 --- examples/grab.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/grab.js b/examples/grab.js index dc250b9d27..71264da509 100644 --- a/examples/grab.js +++ b/examples/grab.js @@ -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) { From 4c80633a41f5e72c3cf89cbe6256f9c2f2b6c022 Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Thu, 30 Apr 2015 16:42:32 -0700 Subject: [PATCH 3/3] fixed bug where non-script related content would be deleted on script ending --- examples/grab.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/examples/grab.js b/examples/grab.js index 71264da509..88e23c9a46 100644 --- a/examples/grab.js +++ b/examples/grab.js @@ -160,11 +160,6 @@ function keyPressEvent(event) { } } -function cleanup() { - Entities.deleteEntity(box); - Entities.deleteEntity(box2); - Entities.deleteEntity(ground); -} function setUpTestObjects() { var distance = 4; @@ -235,4 +230,3 @@ Controller.mousePressEvent.connect(mousePressEvent); Controller.mouseReleaseEvent.connect(mouseReleaseEvent); Controller.keyPressEvent.connect(keyPressEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent); -Script.scriptEnding.connect(cleanup); \ No newline at end of file