mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:37:31 +02:00
Merge pull request #4818 from sethalves/no-grab-gravity
while grabbing an entity, zero out its gravity.
This commit is contained in:
commit
7f8ac5013d
1 changed files with 11 additions and 3 deletions
|
@ -27,6 +27,7 @@ var ANGULAR_DAMPING_RATE = 0.40;
|
||||||
var SCREEN_TO_METERS = 0.001;
|
var SCREEN_TO_METERS = 0.001;
|
||||||
var currentPosition, currentVelocity, cameraEntityDistance, currentRotation;
|
var currentPosition, currentVelocity, cameraEntityDistance, currentRotation;
|
||||||
var velocityTowardTarget, desiredVelocity, addedVelocity, newVelocity, dPosition, camYaw, distanceToTarget, targetPosition;
|
var velocityTowardTarget, desiredVelocity, addedVelocity, newVelocity, dPosition, camYaw, distanceToTarget, targetPosition;
|
||||||
|
var originalGravity;
|
||||||
var shouldRotate = false;
|
var shouldRotate = false;
|
||||||
var dQ, theta, axisAngle, dT;
|
var dQ, theta, axisAngle, dT;
|
||||||
var angularVelocity = {
|
var angularVelocity = {
|
||||||
|
@ -65,6 +66,7 @@ function mousePressEvent(event) {
|
||||||
grabbedEntity = intersection.entityID;
|
grabbedEntity = intersection.entityID;
|
||||||
var props = Entities.getEntityProperties(grabbedEntity)
|
var props = Entities.getEntityProperties(grabbedEntity)
|
||||||
isGrabbing = true;
|
isGrabbing = true;
|
||||||
|
originalGravity = props.gravity;
|
||||||
targetPosition = props.position;
|
targetPosition = props.position;
|
||||||
currentPosition = props.position;
|
currentPosition = props.position;
|
||||||
currentVelocity = props.velocity;
|
currentVelocity = props.velocity;
|
||||||
|
@ -96,6 +98,11 @@ function updateDropLine(position) {
|
||||||
function mouseReleaseEvent() {
|
function mouseReleaseEvent() {
|
||||||
if (isGrabbing) {
|
if (isGrabbing) {
|
||||||
isGrabbing = false;
|
isGrabbing = false;
|
||||||
|
|
||||||
|
Entities.editEntity(grabbedEntity, {
|
||||||
|
gravity: originalGravity
|
||||||
|
});
|
||||||
|
|
||||||
Overlays.editOverlay(dropLine, {
|
Overlays.editOverlay(dropLine, {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
@ -194,7 +201,7 @@ function update(deltaTime) {
|
||||||
newVelocity = Vec3.subtract(newVelocity, Vec3.multiply(newVelocity, DAMPING_RATE));
|
newVelocity = Vec3.subtract(newVelocity, Vec3.multiply(newVelocity, DAMPING_RATE));
|
||||||
// Update entity
|
// Update entity
|
||||||
} else {
|
} else {
|
||||||
newVelocity = entityProps.velocity;
|
newVelocity = {x: 0, y: 0, z: 0};
|
||||||
}
|
}
|
||||||
if (shouldRotate) {
|
if (shouldRotate) {
|
||||||
angularVelocity = Vec3.subtract(angularVelocity, Vec3.multiply(angularVelocity, ANGULAR_DAMPING_RATE));
|
angularVelocity = Vec3.subtract(angularVelocity, Vec3.multiply(angularVelocity, ANGULAR_DAMPING_RATE));
|
||||||
|
@ -204,7 +211,8 @@ function update(deltaTime) {
|
||||||
|
|
||||||
Entities.editEntity(grabbedEntity, {
|
Entities.editEntity(grabbedEntity, {
|
||||||
velocity: newVelocity,
|
velocity: newVelocity,
|
||||||
angularVelocity: angularVelocity
|
angularVelocity: angularVelocity,
|
||||||
|
gravity: {x: 0, y: 0, z: 0}
|
||||||
})
|
})
|
||||||
updateDropLine(targetPosition);
|
updateDropLine(targetPosition);
|
||||||
}
|
}
|
||||||
|
@ -215,4 +223,4 @@ 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.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
Loading…
Reference in a new issue