mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
Merge pull request #4729 from ericrius1/mouseGrab
can now fling up and down as well as in xz plane
This commit is contained in:
commit
dc9e5cad24
1 changed files with 12 additions and 9 deletions
|
@ -50,6 +50,9 @@ var dropLine = Overlays.addOverlay("line3d", {
|
||||||
|
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
|
if(!event.isLeftButton){
|
||||||
|
return;
|
||||||
|
}
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var intersection = Entities.findRayIntersection(pickRay);
|
var intersection = Entities.findRayIntersection(pickRay);
|
||||||
if (intersection.intersects && intersection.properties.collisionsWillMove) {
|
if (intersection.intersects && intersection.properties.collisionsWillMove) {
|
||||||
|
@ -83,7 +86,7 @@ function mousePressEvent(event) {
|
||||||
|
|
||||||
function mouseReleaseEvent() {
|
function mouseReleaseEvent() {
|
||||||
if (isGrabbing) {
|
if (isGrabbing) {
|
||||||
flingObject();
|
// flingObject();
|
||||||
Entities.editEntity(grabbedEntity, {
|
Entities.editEntity(grabbedEntity, {
|
||||||
gravity: savedGravity
|
gravity: savedGravity
|
||||||
});
|
});
|
||||||
|
@ -100,7 +103,6 @@ function flingObject() {
|
||||||
|
|
||||||
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
|
flingVelocity = Vec3.subtract(entityProps.position, prevPosition);
|
||||||
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
|
flingVelocity = Vec3.multiply(flingMultiplier, flingVelocity);
|
||||||
flingVelocity.y = 0;
|
|
||||||
Entities.editEntity(grabbedEntity, {
|
Entities.editEntity(grabbedEntity, {
|
||||||
velocity: flingVelocity
|
velocity: flingVelocity
|
||||||
});
|
});
|
||||||
|
@ -109,7 +111,6 @@ function flingObject() {
|
||||||
function mouseMoveEvent(event) {
|
function mouseMoveEvent(event) {
|
||||||
if (isGrabbing) {
|
if (isGrabbing) {
|
||||||
entityProps = Entities.getEntityProperties(grabbedEntity);
|
entityProps = Entities.getEntityProperties(grabbedEntity);
|
||||||
prevPosition = entityProps.position;
|
|
||||||
avatarEntityDistance = Vec3.distance(MyAvatar.position, entityProps.position);
|
avatarEntityDistance = Vec3.distance(MyAvatar.position, entityProps.position);
|
||||||
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5);
|
finalMoveMultiplier = baseMoveFactor * Math.pow(avatarEntityDistance, 1.5);
|
||||||
deltaMouse.x = event.x - prevMouse.x;
|
deltaMouse.x = event.x - prevMouse.x;
|
||||||
|
@ -134,9 +135,17 @@ function mouseMoveEvent(event) {
|
||||||
z: 0
|
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.x = event.x;
|
||||||
prevMouse.y = event.y;
|
prevMouse.y = event.y;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyReleaseEvent(event) {
|
function keyReleaseEvent(event) {
|
||||||
|
@ -151,11 +160,6 @@ function keyPressEvent(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
|
||||||
Entities.deleteEntity(box);
|
|
||||||
Entities.deleteEntity(box2);
|
|
||||||
Entities.deleteEntity(ground);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setUpTestObjects() {
|
function setUpTestObjects() {
|
||||||
var distance = 4;
|
var distance = 4;
|
||||||
|
@ -226,4 +230,3 @@ Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||||
Script.scriptEnding.connect(cleanup);
|
|
Loading…
Reference in a new issue