mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:19:05 +02:00
commit
84b515827e
2 changed files with 9 additions and 54 deletions
|
@ -66,6 +66,7 @@ var MSEC_PER_SEC = 1000.0;
|
||||||
// these control how long an abandoned pointer line will hang around
|
// these control how long an abandoned pointer line will hang around
|
||||||
var startTime = Date.now();
|
var startTime = Date.now();
|
||||||
var LIFETIME = 10;
|
var LIFETIME = 10;
|
||||||
|
var ACTION_LIFETIME = 120; // 2 minutes
|
||||||
|
|
||||||
// states for the state machine
|
// states for the state machine
|
||||||
var STATE_OFF = 0;
|
var STATE_OFF = 0;
|
||||||
|
@ -81,16 +82,6 @@ var STATE_RELEASE = 8;
|
||||||
var GRAB_USER_DATA_KEY = "grabKey";
|
var GRAB_USER_DATA_KEY = "grabKey";
|
||||||
var GRABBABLE_DATA_KEY = "grabbableKey";
|
var GRABBABLE_DATA_KEY = "grabbableKey";
|
||||||
|
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
var AVATAR_COLLISIONS_MENU_ITEM = "Enable avatar collisions";
|
|
||||||
|
|
||||||
|
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
var initialAvatarCollisionsMenu = Menu.isOptionChecked(AVATAR_COLLISIONS_MENU_ITEM);
|
|
||||||
var currentAvatarCollisionsMenu = initialAvatarCollisionsMenu;
|
|
||||||
var noCollisionsCount = 0; // how many hands want collisions disabled?
|
|
||||||
|
|
||||||
|
|
||||||
function getTag() {
|
function getTag() {
|
||||||
return "grab-" + MyAvatar.sessionUUID;
|
return "grab-" + MyAvatar.sessionUUID;
|
||||||
}
|
}
|
||||||
|
@ -173,28 +164,6 @@ function MyController(hand, triggerAction) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.disableAvatarCollisions = function() {
|
|
||||||
noCollisionsCount += 1;
|
|
||||||
if (currentAvatarCollisionsMenu != false) {
|
|
||||||
currentAvatarCollisionsMenu = false;
|
|
||||||
Menu.setIsOptionChecked(AVATAR_COLLISIONS_MENU_ITEM, false);
|
|
||||||
MyAvatar.updateMotionBehaviorFromMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.revertAvatarCollisions = function() {
|
|
||||||
noCollisionsCount -= 1;
|
|
||||||
if (noCollisionsCount < 1) {
|
|
||||||
if (currentAvatarCollisionsMenu != initialAvatarCollisionsMenu) {
|
|
||||||
currentAvatarCollisionsMenu = initialAvatarCollisionsMenu;
|
|
||||||
Menu.setIsOptionChecked(AVATAR_COLLISIONS_MENU_ITEM, initialAvatarCollisionsMenu);
|
|
||||||
MyAvatar.updateMotionBehaviorFromMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.lineOn = function(closePoint, farPoint, color) {
|
this.lineOn = function(closePoint, farPoint, color) {
|
||||||
// draw a line
|
// draw a line
|
||||||
if (this.pointer === null) {
|
if (this.pointer === null) {
|
||||||
|
@ -328,9 +297,6 @@ function MyController(hand, triggerAction) {
|
||||||
|
|
||||||
this.distanceHolding = function() {
|
this.distanceHolding = function() {
|
||||||
|
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.disableAvatarCollisions();
|
|
||||||
|
|
||||||
var handControllerPosition = Controller.getSpatialControlPosition(this.palm);
|
var handControllerPosition = Controller.getSpatialControlPosition(this.palm);
|
||||||
var handRotation = Quat.multiply(MyAvatar.orientation, Controller.getSpatialControlRawRotation(this.palm));
|
var handRotation = Quat.multiply(MyAvatar.orientation, Controller.getSpatialControlRawRotation(this.palm));
|
||||||
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, ["position", "rotation"]);
|
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, ["position", "rotation"]);
|
||||||
|
@ -349,7 +315,7 @@ function MyController(hand, triggerAction) {
|
||||||
targetRotation: this.currentObjectRotation,
|
targetRotation: this.currentObjectRotation,
|
||||||
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||||
tag: getTag(),
|
tag: getTag(),
|
||||||
lifetime: 5
|
lifetime: ACTION_LIFETIME
|
||||||
});
|
});
|
||||||
if (this.actionID === NULL_ACTION_ID) {
|
if (this.actionID === NULL_ACTION_ID) {
|
||||||
this.actionID = null;
|
this.actionID = null;
|
||||||
|
@ -373,9 +339,6 @@ function MyController(hand, triggerAction) {
|
||||||
|
|
||||||
this.continueDistanceHolding = function() {
|
this.continueDistanceHolding = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.revertAvatarCollisions();
|
|
||||||
|
|
||||||
this.state = STATE_RELEASE;
|
this.state = STATE_RELEASE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -450,19 +413,13 @@ function MyController(hand, triggerAction) {
|
||||||
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||||
targetRotation: this.currentObjectRotation,
|
targetRotation: this.currentObjectRotation,
|
||||||
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
angularTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||||
lifetime: 5
|
lifetime: ACTION_LIFETIME
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.nearGrabbing = function() {
|
this.nearGrabbing = function() {
|
||||||
|
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.disableAvatarCollisions();
|
|
||||||
|
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.revertAvatarCollisions();
|
|
||||||
|
|
||||||
this.state = STATE_RELEASE;
|
this.state = STATE_RELEASE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -491,7 +448,7 @@ function MyController(hand, triggerAction) {
|
||||||
relativePosition: offsetPosition,
|
relativePosition: offsetPosition,
|
||||||
relativeRotation: offsetRotation,
|
relativeRotation: offsetRotation,
|
||||||
tag: getTag(),
|
tag: getTag(),
|
||||||
lifetime: 5
|
lifetime: ACTION_LIFETIME
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.actionID === NULL_ACTION_ID) {
|
if (this.actionID === NULL_ACTION_ID) {
|
||||||
|
@ -514,9 +471,6 @@ function MyController(hand, triggerAction) {
|
||||||
|
|
||||||
this.continueNearGrabbing = function() {
|
this.continueNearGrabbing = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
// HACK -- until we have collision groups, don't allow held object to collide with avatar
|
|
||||||
this.revertAvatarCollisions();
|
|
||||||
|
|
||||||
this.state = STATE_RELEASE;
|
this.state = STATE_RELEASE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +493,7 @@ function MyController(hand, triggerAction) {
|
||||||
this.currentObjectTime = now;
|
this.currentObjectTime = now;
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrab");
|
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrab");
|
||||||
|
|
||||||
Entities.updateAction(this.grabbedEntity, this.actionID, {lifetime: 5});
|
Entities.updateAction(this.grabbedEntity, this.actionID, {lifetime: ACTION_LIFETIME});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.nearGrabbingNonColliding = function() {
|
this.nearGrabbingNonColliding = function() {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed
|
var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed
|
||||||
var ZERO_VEC3 = {x: 0, y: 0, z: 0};
|
var ZERO_VEC3 = {x: 0, y: 0, z: 0};
|
||||||
var IDENTITY_QUAT = {x: 0, y: 0, z: 0, w: 0};
|
var IDENTITY_QUAT = {x: 0, y: 0, z: 0, w: 0};
|
||||||
|
var ACTION_LIFETIME = 120; // 2 minutes
|
||||||
|
|
||||||
function getTag() {
|
function getTag() {
|
||||||
return "grab-" + MyAvatar.sessionUUID;
|
return "grab-" + MyAvatar.sessionUUID;
|
||||||
|
@ -307,7 +308,7 @@ Grabber.prototype.moveEvent = function(event) {
|
||||||
}
|
}
|
||||||
this.currentPosition = entityProperties.position;
|
this.currentPosition = entityProperties.position;
|
||||||
|
|
||||||
var actionArgs = {tag: getTag(), lifetime: 5};
|
var actionArgs = {tag: getTag(), lifetime: ACTION_LIFETIME};
|
||||||
|
|
||||||
if (this.mode === "rotate") {
|
if (this.mode === "rotate") {
|
||||||
var drag = mouse.getDrag();
|
var drag = mouse.getDrag();
|
||||||
|
@ -322,7 +323,7 @@ Grabber.prototype.moveEvent = function(event) {
|
||||||
// var qZero = entityProperties.rotation;
|
// var qZero = entityProperties.rotation;
|
||||||
//var qZero = this.lastRotation;
|
//var qZero = this.lastRotation;
|
||||||
this.lastRotation = Quat.multiply(deltaQ, this.lastRotation);
|
this.lastRotation = Quat.multiply(deltaQ, this.lastRotation);
|
||||||
actionArgs = {targetRotation: this.lastRotation, angularTimeScale: 0.1, tag: getTag(), lifetime: 5};
|
actionArgs = {targetRotation: this.lastRotation, angularTimeScale: 0.1, tag: getTag(), lifetime: ACTION_LIFETIME};
|
||||||
} else {
|
} else {
|
||||||
var newPointOnPlane;
|
var newPointOnPlane;
|
||||||
if (this.mode === "verticalCylinder") {
|
if (this.mode === "verticalCylinder") {
|
||||||
|
@ -346,7 +347,7 @@ Grabber.prototype.moveEvent = function(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.targetPosition = Vec3.subtract(newPointOnPlane, this.offset);
|
this.targetPosition = Vec3.subtract(newPointOnPlane, this.offset);
|
||||||
actionArgs = {targetPosition: this.targetPosition, linearTimeScale: 0.1, tag: getTag(), lifetime: 5};
|
actionArgs = {targetPosition: this.targetPosition, linearTimeScale: 0.1, tag: getTag(), lifetime: ACTION_LIFETIME};
|
||||||
|
|
||||||
beacon.updatePosition(this.targetPosition);
|
beacon.updatePosition(this.targetPosition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue