mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
trying to get tablet overlay to show up in the right place
This commit is contained in:
parent
273f0130f3
commit
b4be942348
3 changed files with 115 additions and 108 deletions
|
@ -56,6 +56,7 @@ QVariantMap convertOverlayLocationFromScriptSemantics(const QVariantMap& propert
|
|||
|
||||
// make "position" and "orientation" be relative-to-parent
|
||||
if (result["localPosition"].isValid()) {
|
||||
result.remove("localPosition");
|
||||
result["position"] = result["localPosition"];
|
||||
} else if (result["position"].isValid()) {
|
||||
glm::vec3 localPosition = SpatiallyNestable::worldToLocal(vec3FromVariant(result["position"]),
|
||||
|
@ -65,6 +66,7 @@ QVariantMap convertOverlayLocationFromScriptSemantics(const QVariantMap& propert
|
|||
|
||||
if (result["localOrientation"].isValid()) {
|
||||
result["orientation"] = result["localOrientation"];
|
||||
result.remove("localOrientation");
|
||||
} else if (result["orientation"].isValid()) {
|
||||
glm::quat localOrientation = SpatiallyNestable::worldToLocal(quatFromVariant(result["orientation"]),
|
||||
parentID, parentJointIndex, success);
|
||||
|
|
|
@ -28,7 +28,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
//
|
||||
|
||||
var WANT_DEBUG = false;
|
||||
var WANT_DEBUG_STATE = true;
|
||||
var WANT_DEBUG_STATE = false;
|
||||
var WANT_DEBUG_SEARCH_NAME = null;
|
||||
|
||||
var FORCE_IGNORE_IK = false;
|
||||
|
@ -777,7 +777,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.actionID = null; // action this script created...
|
||||
this.grabbedEntity = null; // on this entity.
|
||||
this.grabbedThingID = null; // on this entity.
|
||||
this.grabbedOverlay = null;
|
||||
this.state = STATE_OFF;
|
||||
this.pointer = null; // entity-id of line object
|
||||
|
@ -858,11 +858,11 @@ function MyController(hand) {
|
|||
return;
|
||||
}
|
||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||
Entities.callEntityMethod(this.grabbedEntity, entityMethodName, args);
|
||||
Entities.callEntityMethod(this.grabbedThingID, entityMethodName, args);
|
||||
};
|
||||
|
||||
this.setState = function(newState, reason) {
|
||||
if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID )&& (newState !== STATE_OFF &&
|
||||
if ((isInEditMode() && this.grabbedThingID !== HMD.tabletID) && (newState !== STATE_OFF &&
|
||||
newState !== STATE_SEARCHING &&
|
||||
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) {
|
||||
return;
|
||||
|
@ -1597,7 +1597,7 @@ function MyController(hand) {
|
|||
|
||||
var farSearching = this.triggerSmoothedSqueezed() && (Date.now() - this.searchStartTime > FAR_SEARCH_DELAY);
|
||||
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.grabbedOverlay = null;
|
||||
this.isInitialGrab = false;
|
||||
this.preparingHoldRelease = false;
|
||||
|
@ -1605,7 +1605,7 @@ function MyController(hand) {
|
|||
this.checkForUnexpectedChildren();
|
||||
|
||||
if ((this.triggerSmoothedReleased() && this.secondaryReleased())) {
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "trigger released");
|
||||
return;
|
||||
}
|
||||
|
@ -1626,9 +1626,9 @@ function MyController(hand) {
|
|||
if (potentialEquipHotspot) {
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && holdEnabled) {
|
||||
this.grabbedHotspot = potentialEquipHotspot;
|
||||
this.grabbedEntity = potentialEquipHotspot.entityID;
|
||||
this.grabbedThingID = potentialEquipHotspot.entityID;
|
||||
this.grabbedIsOverlay = false;
|
||||
this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'");
|
||||
this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedThingID).name + "'");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1644,8 +1644,6 @@ function MyController(hand) {
|
|||
return Overlays.getProperty(overlayID, "grabbable");
|
||||
});
|
||||
|
||||
print("candidateOverlays: " + candidateOverlays.length + ", grabbableOverlays: " + grabbableOverlays.length);
|
||||
|
||||
if (rayPickInfo.entityID) {
|
||||
this.intersectionDistance = rayPickInfo.distance;
|
||||
if (this.entityIsGrabbable(rayPickInfo.entityID) && rayPickInfo.distance < NEAR_GRAB_PICK_RADIUS) {
|
||||
|
@ -1665,11 +1663,11 @@ function MyController(hand) {
|
|||
var bDistance = Vec3.distance(bPosition, handPosition);
|
||||
return aDistance - bDistance;
|
||||
});
|
||||
this.grabbedEntity = grabbableOverlays[0];
|
||||
this.grabbedThingID = grabbableOverlays[0];
|
||||
this.grabbedIsOverlay = true;
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) {
|
||||
this.setState(STATE_NEAR_GRABBING, "near grab overlay '" +
|
||||
Overlays.getProperty(this.grabbedEntity, "name") + "'");
|
||||
Overlays.getProperty(this.grabbedThingID, "name") + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1684,7 +1682,7 @@ function MyController(hand) {
|
|||
});
|
||||
entity = grabbableEntities[0];
|
||||
name = entityPropertiesCache.getProps(entity).name;
|
||||
this.grabbedEntity = entity;
|
||||
this.grabbedThingID = entity;
|
||||
this.grabbedIsOverlay = false;
|
||||
if (this.entityWantsTrigger(entity)) {
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
|
@ -1719,7 +1717,7 @@ function MyController(hand) {
|
|||
name = entityPropertiesCache.getProps(entity).name;
|
||||
if (this.entityWantsTrigger(entity)) {
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
this.grabbedEntity = entity;
|
||||
this.grabbedThingID = entity;
|
||||
this.grabbedIsOverlay = false;
|
||||
this.setState(STATE_FAR_TRIGGER, "far trigger '" + name + "'");
|
||||
return;
|
||||
|
@ -1728,7 +1726,7 @@ function MyController(hand) {
|
|||
}
|
||||
} else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) {
|
||||
if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled && farSearching) {
|
||||
this.grabbedEntity = entity;
|
||||
this.grabbedThingID = entity;
|
||||
this.grabbedIsOverlay = false;
|
||||
this.grabbedDistance = rayPickInfo.distance;
|
||||
this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'");
|
||||
|
@ -1809,7 +1807,7 @@ function MyController(hand) {
|
|||
Entities.sendHoverOverEntity(entity, pointerEvent);
|
||||
}
|
||||
|
||||
this.grabbedEntity = entity;
|
||||
this.grabbedThingID = entity;
|
||||
this.grabbedIsOverlay = false;
|
||||
this.setState(STATE_ENTITY_STYLUS_TOUCHING, "begin touching entity '" + name + "'");
|
||||
return true;
|
||||
|
@ -1938,7 +1936,7 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
if (this.triggerSmoothedGrab() && (!isEditing() || this.isTablet(entity))) {
|
||||
this.grabbedEntity = entity;
|
||||
this.grabbedThingID = entity;
|
||||
this.grabbedIsOverlay = false;
|
||||
this.setState(STATE_ENTITY_LASER_TOUCHING, "begin touching entity '" + name + "'");
|
||||
return true;
|
||||
|
@ -2050,7 +2048,7 @@ function MyController(hand) {
|
|||
var worldToSensorMat = Mat4.inverse(MyAvatar.getSensorToWorldMatrix());
|
||||
var roomControllerPosition = Mat4.transformPoint(worldToSensorMat, worldControllerPosition);
|
||||
|
||||
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
|
||||
var grabbedProperties = Entities.getEntityProperties(this.grabbedThingID, GRABBABLE_PROPERTIES);
|
||||
var now = Date.now();
|
||||
|
||||
// add the action and initialize some variables
|
||||
|
@ -2080,7 +2078,7 @@ function MyController(hand) {
|
|||
var timeScale = this.distanceGrabTimescale(this.mass, distanceToObject);
|
||||
|
||||
this.actionID = NULL_UUID;
|
||||
this.actionID = Entities.addAction("spring", this.grabbedEntity, {
|
||||
this.actionID = Entities.addAction("spring", this.grabbedThingID, {
|
||||
targetPosition: this.currentObjectPosition,
|
||||
linearTimeScale: timeScale,
|
||||
targetRotation: this.currentObjectRotation,
|
||||
|
@ -2105,12 +2103,12 @@ function MyController(hand) {
|
|||
this.ensureDynamic = function() {
|
||||
// if we distance hold something and keep it very still before releasing it, it ends up
|
||||
// non-dynamic in bullet. If it's too still, give it a little bounce so it will fall.
|
||||
var props = Entities.getEntityProperties(this.grabbedEntity, ["velocity", "dynamic", "parentID"]);
|
||||
var props = Entities.getEntityProperties(this.grabbedThingID, ["velocity", "dynamic", "parentID"]);
|
||||
if (props.dynamic && props.parentID == NULL_UUID) {
|
||||
var velocity = props.velocity;
|
||||
if (Vec3.length(velocity) < 0.05) { // see EntityMotionState.cpp DYNAMIC_LINEAR_VELOCITY_THRESHOLD
|
||||
velocity = { x: 0.0, y: 0.2, z:0.0 };
|
||||
Entities.editEntity(this.grabbedEntity, { velocity: velocity });
|
||||
Entities.editEntity(this.grabbedThingID, { velocity: velocity });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2132,7 +2130,7 @@ function MyController(hand) {
|
|||
var worldToSensorMat = Mat4.inverse(MyAvatar.getSensorToWorldMatrix());
|
||||
var roomControllerPosition = Mat4.transformPoint(worldToSensorMat, worldControllerPosition);
|
||||
|
||||
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
|
||||
var grabbedProperties = Entities.getEntityProperties(this.grabbedThingID, GRABBABLE_PROPERTIES);
|
||||
|
||||
var now = Date.now();
|
||||
var deltaObjectTime = (now - this.currentObjectTime) / MSECS_PER_SEC; // convert to seconds
|
||||
|
@ -2187,7 +2185,7 @@ function MyController(hand) {
|
|||
newTargetPosition = Vec3.sum(newTargetPosition, this.offsetPosition);
|
||||
|
||||
var objectToAvatar = Vec3.subtract(this.currentObjectPosition, MyAvatar.position);
|
||||
var handControllerData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultMoveWithHeadData);
|
||||
var handControllerData = getEntityCustomData('handControllerKey', this.grabbedThingID, defaultMoveWithHeadData);
|
||||
if (handControllerData.disableMoveWithHead !== true) {
|
||||
// mix in head motion
|
||||
if (MOVE_WITH_HEAD) {
|
||||
|
@ -2216,7 +2214,7 @@ function MyController(hand) {
|
|||
this.overlayLineOn(rayPickInfo.searchRay.origin, Vec3.subtract(grabbedProperties.position, this.offsetPosition), COLORS_GRAB_DISTANCE_HOLD);
|
||||
|
||||
var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, this.currentObjectPosition));
|
||||
var success = Entities.updateAction(this.grabbedEntity, this.actionID, {
|
||||
var success = Entities.updateAction(this.grabbedThingID, this.actionID, {
|
||||
targetPosition: newTargetPosition,
|
||||
linearTimeScale: this.distanceGrabTimescale(this.mass, distanceToObject),
|
||||
targetRotation: this.currentObjectRotation,
|
||||
|
@ -2233,7 +2231,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.setupHoldAction = function() {
|
||||
this.actionID = Entities.addAction("hold", this.grabbedEntity, {
|
||||
this.actionID = Entities.addAction("hold", this.grabbedThingID, {
|
||||
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
||||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
||||
relativePosition: this.offsetPosition,
|
||||
|
@ -2323,28 +2321,28 @@ function MyController(hand) {
|
|||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
||||
|
||||
if (this.entityActivated) {
|
||||
var saveGrabbedID = this.grabbedEntity;
|
||||
var saveGrabbedID = this.grabbedThingID;
|
||||
this.release();
|
||||
this.grabbedEntity = saveGrabbedID;
|
||||
this.grabbedThingID = saveGrabbedID;
|
||||
}
|
||||
|
||||
var grabbedProperties;
|
||||
if (this.grabbedIsOverlay) {
|
||||
grabbedProperties = {
|
||||
position: Overlays.getProperty(this.grabbedEntity, "position"),
|
||||
rotation: Overlays.getProperty(this.grabbedEntity, "rotation"),
|
||||
parentID: Overlays.getProperty(this.grabbedEntity, "parentID"),
|
||||
parentJointIndex: Overlays.getProperty(this.grabbedEntity, "parentJointIndex"),
|
||||
position: Overlays.getProperty(this.grabbedThingID, "position"),
|
||||
rotation: Overlays.getProperty(this.grabbedThingID, "rotation"),
|
||||
parentID: Overlays.getProperty(this.grabbedThingID, "parentID"),
|
||||
parentJointIndex: Overlays.getProperty(this.grabbedThingID, "parentJointIndex"),
|
||||
dynamic: false,
|
||||
shapeType: "none"
|
||||
};
|
||||
this.ignoreIK = true;
|
||||
} else {
|
||||
grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
|
||||
grabbedProperties = Entities.getEntityProperties(this.grabbedThingID, GRABBABLE_PROPERTIES);
|
||||
if (FORCE_IGNORE_IK) {
|
||||
this.ignoreIK = true;
|
||||
} else {
|
||||
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
|
||||
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedThingID, DEFAULT_GRABBABLE_DATA);
|
||||
this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true;
|
||||
}
|
||||
}
|
||||
|
@ -2386,7 +2384,7 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
var isPhysical = propsArePhysical(grabbedProperties) ||
|
||||
(!this.grabbedIsOverlay && entityHasActions(this.grabbedEntity));
|
||||
(!this.grabbedIsOverlay && entityHasActions(this.grabbedThingID));
|
||||
if (isPhysical && this.state == STATE_NEAR_GRABBING && grabbedProperties.parentID === NULL_UUID) {
|
||||
// grab entity via action
|
||||
if (!this.setupHoldAction()) {
|
||||
|
@ -2394,7 +2392,7 @@ function MyController(hand) {
|
|||
}
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'grab',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
grabbedEntity: this.grabbedThingID,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
} else {
|
||||
|
@ -2421,29 +2419,29 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
if (this.grabbedIsOverlay) {
|
||||
Overlays.editOverlay(this.grabbedEntity, reparentProps);
|
||||
Overlays.editOverlay(this.grabbedThingID, reparentProps);
|
||||
} else {
|
||||
Entities.editEntity(this.grabbedEntity, reparentProps);
|
||||
Entities.editEntity(this.grabbedThingID, reparentProps);
|
||||
}
|
||||
|
||||
if (this.thisHandIsParent(grabbedProperties)) {
|
||||
// this should never happen, but if it does, don't set previous parent to be this hand.
|
||||
// this.previousParentID[this.grabbedEntity] = NULL;
|
||||
// this.previousParentJointIndex[this.grabbedEntity] = -1;
|
||||
// this.previousParentID[this.grabbedThingID] = NULL;
|
||||
// this.previousParentJointIndex[this.grabbedThingID] = -1;
|
||||
} else {
|
||||
this.previousParentID[this.grabbedEntity] = grabbedProperties.parentID;
|
||||
this.previousParentJointIndex[this.grabbedEntity] = grabbedProperties.parentJointIndex;
|
||||
this.previousParentID[this.grabbedThingID] = grabbedProperties.parentID;
|
||||
this.previousParentJointIndex[this.grabbedThingID] = grabbedProperties.parentJointIndex;
|
||||
}
|
||||
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'equip',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
grabbedEntity: this.grabbedThingID,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
}
|
||||
|
||||
if (!this.grabbedIsOverlay) {
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
Entities.editEntity(this.grabbedThingID, {
|
||||
velocity: { x: 0, y: 0, z: 0 },
|
||||
angularVelocity: { x: 0, y: 0, z: 0 },
|
||||
// dynamic: false
|
||||
|
@ -2514,17 +2512,17 @@ function MyController(hand) {
|
|||
|
||||
if (dropDetected && !this.waitForTriggerRelease && this.triggerSmoothedGrab()) {
|
||||
// store the offset attach points into preferences.
|
||||
if (USE_ATTACH_POINT_SETTINGS && this.grabbedHotspot && this.grabbedEntity) {
|
||||
var prefprops = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "localRotation"]);
|
||||
if (USE_ATTACH_POINT_SETTINGS && this.grabbedHotspot && this.grabbedThingID) {
|
||||
var prefprops = Entities.getEntityProperties(this.grabbedThingID, ["localPosition", "localRotation"]);
|
||||
if (prefprops && prefprops.localPosition && prefprops.localRotation) {
|
||||
storeAttachPointForHotspotInSettings(this.grabbedHotspot, this.hand,
|
||||
prefprops.localPosition, prefprops.localRotation);
|
||||
}
|
||||
}
|
||||
|
||||
var grabbedEntity = this.grabbedEntity;
|
||||
var grabbedEntity = this.grabbedThingID;
|
||||
this.release();
|
||||
this.grabbedEntity = grabbedEntity;
|
||||
this.grabbedThingID = grabbedEntity;
|
||||
this.setState(STATE_NEAR_GRABBING, "drop gesture detected");
|
||||
return;
|
||||
}
|
||||
|
@ -2534,16 +2532,16 @@ function MyController(hand) {
|
|||
var props;
|
||||
if (this.grabbedIsOverlay) {
|
||||
props = {
|
||||
localPosition: Overlays.getProperty(this.grabbedEntity, "localPosition"),
|
||||
parentID: Overlays.getProperty(this.grabbedEntity, "parentID"),
|
||||
parentJointIndex: Overlays.getProperty(this.grabbedEntity, "parentJointIndex"),
|
||||
position: Overlays.getProperty(this.grabbedEntity, "position"),
|
||||
rotation: Overlays.getProperty(this.grabbedEntity, "rotation"),
|
||||
dimensions: Overlays.getProperty(this.grabbedEntity, "dimensions"),
|
||||
localPosition: Overlays.getProperty(this.grabbedThingID, "localPosition"),
|
||||
parentID: Overlays.getProperty(this.grabbedThingID, "parentID"),
|
||||
parentJointIndex: Overlays.getProperty(this.grabbedThingID, "parentJointIndex"),
|
||||
position: Overlays.getProperty(this.grabbedThingID, "position"),
|
||||
rotation: Overlays.getProperty(this.grabbedThingID, "rotation"),
|
||||
dimensions: Overlays.getProperty(this.grabbedThingID, "dimensions"),
|
||||
registrationPoint: { x: 0.5, y: 0.5, z: 0.5 }
|
||||
};
|
||||
} else {
|
||||
props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID", "parentJointIndex",
|
||||
props = Entities.getEntityProperties(this.grabbedThingID, ["localPosition", "parentID", "parentJointIndex",
|
||||
"position", "rotation", "dimensions",
|
||||
"registrationPoint"]);
|
||||
}
|
||||
|
@ -2558,7 +2556,7 @@ function MyController(hand) {
|
|||
// someone took it from us or otherwise edited the parentID. end the grab. We don't do this
|
||||
// for equipped things so that they can be adjusted while equipped.
|
||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "someone took it");
|
||||
return;
|
||||
}
|
||||
|
@ -2640,7 +2638,7 @@ function MyController(hand) {
|
|||
|
||||
if (this.actionID && this.actionTimeout - now < ACTION_TTL_REFRESH * MSECS_PER_SEC) {
|
||||
// if less than a 5 seconds left, refresh the actions ttl
|
||||
var success = Entities.updateAction(this.grabbedEntity, this.actionID, {
|
||||
var success = Entities.updateAction(this.grabbedThingID, this.actionID, {
|
||||
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
||||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
||||
relativePosition: this.offsetPosition,
|
||||
|
@ -2654,14 +2652,14 @@ function MyController(hand) {
|
|||
this.actionTimeout = now + (ACTION_TTL * MSECS_PER_SEC);
|
||||
} else {
|
||||
print("continueNearGrabbing -- updateAction failed");
|
||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||
Entities.deleteAction(this.grabbedThingID, this.actionID);
|
||||
this.setupHoldAction();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.maybeScale = function(props) {
|
||||
if (!objectScalingEnabled || this.isTablet(this.grabbedEntity) || this.grabbedIsOverlay) {
|
||||
if (!objectScalingEnabled || this.isTablet(this.grabbedThingID) || this.grabbedIsOverlay) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2683,7 +2681,7 @@ function MyController(hand) {
|
|||
this.getOtherHandController().getHandPosition()));
|
||||
var currentRescale = scalingCurrentDistance / this.scalingStartDistance;
|
||||
var newDimensions = Vec3.multiply(currentRescale, this.scalingStartDimensions);
|
||||
Entities.editEntity(this.grabbedEntity, { dimensions: newDimensions });
|
||||
Entities.editEntity(this.grabbedThingID, { dimensions: newDimensions });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2734,7 +2732,7 @@ function MyController(hand) {
|
|||
this.nearTrigger = function(deltaTime, timestamp) {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.callEntityMethodOnGrabbed("stopNearTrigger");
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "trigger released");
|
||||
return;
|
||||
}
|
||||
|
@ -2744,7 +2742,7 @@ function MyController(hand) {
|
|||
this.farTrigger = function(deltaTime, timestamp) {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.callEntityMethodOnGrabbed("stopFarTrigger");
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "trigger released");
|
||||
return;
|
||||
}
|
||||
|
@ -2759,9 +2757,9 @@ function MyController(hand) {
|
|||
var intersection = findRayIntersection(pickRay, true, [], [], true);
|
||||
if (intersection.accurate || intersection.overlayID) {
|
||||
this.lastPickTime = now;
|
||||
if (intersection.entityID != this.grabbedEntity) {
|
||||
if (intersection.entityID != this.grabbedThingID) {
|
||||
this.callEntityMethodOnGrabbed("stopFarTrigger");
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "laser moved off of entity");
|
||||
return;
|
||||
}
|
||||
|
@ -2783,13 +2781,13 @@ function MyController(hand) {
|
|||
|
||||
this.entityTouchingEnter = function() {
|
||||
// test for intersection between controller laser and web entity plane.
|
||||
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity,
|
||||
var intersectInfo = handLaserIntersectEntity(this.grabbedThingID,
|
||||
getControllerWorldLocation(this.handToController(), true));
|
||||
if (intersectInfo) {
|
||||
var pointerEvent = {
|
||||
type: "Press",
|
||||
id: this.hand + 1, // 0 is reserved for hardware mouse
|
||||
pos2D: projectOntoEntityXYPlane(this.grabbedEntity, intersectInfo.point),
|
||||
pos2D: projectOntoEntityXYPlane(this.grabbedThingID, intersectInfo.point),
|
||||
pos3D: intersectInfo.point,
|
||||
normal: intersectInfo.normal,
|
||||
direction: intersectInfo.searchRay.direction,
|
||||
|
@ -2797,8 +2795,8 @@ function MyController(hand) {
|
|||
isPrimaryHeld: true
|
||||
};
|
||||
|
||||
Entities.sendMousePressOnEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendClickDownOnEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendMousePressOnEntity(this.grabbedThingID, pointerEvent);
|
||||
Entities.sendClickDownOnEntity(this.grabbedThingID, pointerEvent);
|
||||
|
||||
this.touchingEnterTimer = 0;
|
||||
this.touchingEnterPointerEvent = pointerEvent;
|
||||
|
@ -2820,7 +2818,7 @@ function MyController(hand) {
|
|||
|
||||
this.entityTouchingExit = function() {
|
||||
// test for intersection between controller laser and web entity plane.
|
||||
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity,
|
||||
var intersectInfo = handLaserIntersectEntity(this.grabbedThingID,
|
||||
getControllerWorldLocation(this.handToController(), true));
|
||||
if (intersectInfo) {
|
||||
var pointerEvent;
|
||||
|
@ -2828,7 +2826,7 @@ function MyController(hand) {
|
|||
pointerEvent = {
|
||||
type: "Release",
|
||||
id: this.hand + 1, // 0 is reserved for hardware mouse
|
||||
pos2D: projectOntoEntityXYPlane(this.grabbedEntity, intersectInfo.point),
|
||||
pos2D: projectOntoEntityXYPlane(this.grabbedThingID, intersectInfo.point),
|
||||
pos3D: intersectInfo.point,
|
||||
normal: intersectInfo.normal,
|
||||
direction: intersectInfo.searchRay.direction,
|
||||
|
@ -2841,11 +2839,11 @@ function MyController(hand) {
|
|||
pointerEvent.isPrimaryHeld = false;
|
||||
}
|
||||
|
||||
Entities.sendMouseReleaseOnEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendClickReleaseOnEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendHoverLeaveEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendMouseReleaseOnEntity(this.grabbedThingID, pointerEvent);
|
||||
Entities.sendClickReleaseOnEntity(this.grabbedThingID, pointerEvent);
|
||||
Entities.sendHoverLeaveEntity(this.grabbedThingID, pointerEvent);
|
||||
}
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.grabbedOverlay = null;
|
||||
};
|
||||
|
||||
|
@ -2853,7 +2851,7 @@ function MyController(hand) {
|
|||
|
||||
this.touchingEnterTimer += dt;
|
||||
|
||||
entityPropertiesCache.addEntity(this.grabbedEntity);
|
||||
entityPropertiesCache.addEntity(this.grabbedThingID);
|
||||
|
||||
if (this.state == STATE_ENTITY_LASER_TOUCHING && !this.triggerSmoothedGrab()) {
|
||||
this.setState(STATE_OFF, "released trigger");
|
||||
|
@ -2861,7 +2859,7 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
// test for intersection between controller laser and web entity plane.
|
||||
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity,
|
||||
var intersectInfo = handLaserIntersectEntity(this.grabbedThingID,
|
||||
getControllerWorldLocation(this.handToController(), true));
|
||||
if (intersectInfo) {
|
||||
|
||||
|
@ -2871,15 +2869,15 @@ function MyController(hand) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Entities.keyboardFocusEntity != this.grabbedEntity) {
|
||||
if (Entities.keyboardFocusEntity != this.grabbedThingID) {
|
||||
Overlays.keyboardFocusOverlay = 0;
|
||||
Entities.keyboardFocusEntity = this.grabbedEntity;
|
||||
Entities.keyboardFocusEntity = this.grabbedThingID;
|
||||
}
|
||||
|
||||
var pointerEvent = {
|
||||
type: "Move",
|
||||
id: this.hand + 1, // 0 is reserved for hardware mouse
|
||||
pos2D: projectOntoEntityXYPlane(this.grabbedEntity, intersectInfo.point),
|
||||
pos2D: projectOntoEntityXYPlane(this.grabbedThingID, intersectInfo.point),
|
||||
pos3D: intersectInfo.point,
|
||||
normal: intersectInfo.normal,
|
||||
direction: intersectInfo.searchRay.direction,
|
||||
|
@ -2890,8 +2888,8 @@ function MyController(hand) {
|
|||
var POINTER_PRESS_TO_MOVE_DELAY = 0.25; // seconds
|
||||
if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY ||
|
||||
Vec3.distance(intersectInfo.point, this.touchingEnterPointerEvent.pos3D) > this.deadspotRadius) {
|
||||
Entities.sendMouseMoveOnEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendHoldingClickOnEntity(this.grabbedEntity, pointerEvent);
|
||||
Entities.sendMouseMoveOnEntity(this.grabbedThingID, pointerEvent);
|
||||
Entities.sendHoldingClickOnEntity(this.grabbedThingID, pointerEvent);
|
||||
this.deadspotExpired = true;
|
||||
}
|
||||
|
||||
|
@ -2901,7 +2899,7 @@ function MyController(hand) {
|
|||
}
|
||||
Reticle.setVisible(false);
|
||||
} else {
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "grabbed entity was destroyed");
|
||||
return;
|
||||
}
|
||||
|
@ -2986,7 +2984,7 @@ function MyController(hand) {
|
|||
Overlays.sendMouseReleaseOnOverlay(this.grabbedOverlay, pointerEvent);
|
||||
Overlays.sendHoverLeaveOverlay(this.grabbedOverlay, pointerEvent);
|
||||
}
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.grabbedOverlay = null;
|
||||
};
|
||||
|
||||
|
@ -3009,7 +3007,7 @@ function MyController(hand) {
|
|||
|
||||
if (this.state == STATE_OVERLAY_STYLUS_TOUCHING &&
|
||||
intersectInfo.distance > WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET + WEB_TOUCH_Y_TOUCH_DEADZONE_SIZE) {
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "pulled away from overlay");
|
||||
return;
|
||||
}
|
||||
|
@ -3066,7 +3064,7 @@ function MyController(hand) {
|
|||
}
|
||||
Reticle.setVisible(false);
|
||||
} else {
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.setState(STATE_OFF, "grabbed overlay was destroyed");
|
||||
return;
|
||||
}
|
||||
|
@ -3075,7 +3073,7 @@ function MyController(hand) {
|
|||
this.release = function() {
|
||||
this.turnOffVisualizations();
|
||||
|
||||
if (this.grabbedEntity !== null) {
|
||||
if (this.grabbedThingID !== null) {
|
||||
if (this.state === STATE_HOLD) {
|
||||
this.callEntityMethodOnGrabbed("releaseEquip");
|
||||
}
|
||||
|
@ -3083,26 +3081,33 @@ function MyController(hand) {
|
|||
// Make a small release haptic pulse if we really were holding something
|
||||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
||||
if (this.actionID !== null) {
|
||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||
Entities.deleteAction(this.grabbedThingID, this.actionID);
|
||||
} else {
|
||||
// no action, so it's a parenting grab
|
||||
if (this.grabbedIsOverlay) {
|
||||
Overlays.editOverlay(this.grabbedEntity, {
|
||||
parentID: NULL_UUID,
|
||||
parentJointIndex: -1
|
||||
});
|
||||
} else {
|
||||
if (this.previousParentID[this.grabbedEntity] === NULL_UUID) {
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
parentID: this.previousParentID[this.grabbedEntity],
|
||||
parentJointIndex: this.previousParentJointIndex[this.grabbedEntity]
|
||||
if (this.previousParentID[this.grabbedThingID] === NULL_UUID) {
|
||||
if (this.grabbedIsOverlay) {
|
||||
Overlays.editOverlay(this.grabbedThingID, {
|
||||
parentID: NULL_UUID,
|
||||
parentJointIndex: -1
|
||||
});
|
||||
} else {
|
||||
Entities.editEntity(this.grabbedThingID, {
|
||||
parentID: this.previousParentID[this.grabbedThingID],
|
||||
parentJointIndex: this.previousParentJointIndex[this.grabbedThingID]
|
||||
});
|
||||
this.ensureDynamic();
|
||||
}
|
||||
} else {
|
||||
if (this.grabbedIsOverlay) {
|
||||
Overlays.editOverlay(this.grabbedThingID, {
|
||||
parentID: this.previousParentID[this.grabbedThingID],
|
||||
parentJointIndex: this.previousParentJointIndex[this.grabbedThingID],
|
||||
});
|
||||
} else {
|
||||
// we're putting this back as a child of some other parent, so zero its velocity
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
parentID: this.previousParentID[this.grabbedEntity],
|
||||
parentJointIndex: this.previousParentJointIndex[this.grabbedEntity],
|
||||
Entities.editEntity(this.grabbedThingID, {
|
||||
parentID: this.previousParentID[this.grabbedThingID],
|
||||
parentJointIndex: this.previousParentJointIndex[this.grabbedThingID],
|
||||
velocity: {x: 0, y: 0, z: 0},
|
||||
angularVelocity: {x: 0, y: 0, z: 0}
|
||||
});
|
||||
|
@ -3112,13 +3117,13 @@ function MyController(hand) {
|
|||
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'release',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
grabbedEntity: this.grabbedThingID,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
}
|
||||
|
||||
this.actionID = null;
|
||||
this.grabbedEntity = null;
|
||||
this.grabbedThingID = null;
|
||||
this.grabbedOverlay = null;
|
||||
this.grabbedHotspot = null;
|
||||
|
||||
|
|
|
@ -130,13 +130,13 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
|
||||
this.cleanUpOldTablets();
|
||||
|
||||
// this.tabletEntityID = Entities.addEntity(tabletProperties, clientOnly);
|
||||
// this.tabletIsOverlay = false;
|
||||
|
||||
tabletProperties.parentID = "{00000000-0000-0000-0000-000000000000}";
|
||||
// tabletProperties.parentJointIndex = -2;
|
||||
this.tabletEntityID = Overlays.addOverlay("model", tabletProperties);
|
||||
this.tabletIsOverlay = true;
|
||||
if (true || Settings.getValue("tabletVisibleToOthers")) {
|
||||
this.tabletEntityID = Entities.addEntity(tabletProperties, clientOnly);
|
||||
this.tabletIsOverlay = false;
|
||||
} else {
|
||||
this.tabletEntityID = Overlays.addOverlay("model", tabletProperties);
|
||||
this.tabletIsOverlay = true;
|
||||
}
|
||||
|
||||
if (this.webOverlayID) {
|
||||
Overlays.deleteOverlay(this.webOverlayID);
|
||||
|
|
Loading…
Reference in a new issue