mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
port over PR-14429
This commit is contained in:
parent
9900040ece
commit
1c1e648b8b
2 changed files with 31 additions and 77 deletions
|
@ -53,7 +53,6 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.potentialEntityWithContextOverlay = false;
|
||||
this.entityWithContextOverlay = false;
|
||||
this.contextOverlayTimer = false;
|
||||
this.highlightedEntity = null;
|
||||
this.reticleMinX = MARGIN;
|
||||
this.reticleMaxX = 0;
|
||||
this.reticleMinY = MARGIN;
|
||||
|
@ -339,8 +338,6 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE ||
|
||||
this.notPointingAtEntity(controllerData) || this.targetIsNull()) {
|
||||
this.endFarGrabEntity(controllerData);
|
||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", this.highlightedEntity);
|
||||
this.highlightedEntity = null;
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
this.intersectionDistance = controllerData.rayPicks[this.hand].distance;
|
||||
|
@ -387,8 +384,6 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
|
||||
if (controllerData.triggerClicks[this.hand]) {
|
||||
var entityID = rayPickInfo.objectID;
|
||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", this.highlightedEntity);
|
||||
this.highlightedEntity = null;
|
||||
var targetProps = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
||||
if (targetProps.href !== "") {
|
||||
AddressManager.handleLookupString(targetProps.href);
|
||||
|
@ -419,64 +414,42 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.distanceHolding = true;
|
||||
this.startFarGrabEntity(controllerData, targetProps);
|
||||
}
|
||||
} else {
|
||||
var targetEntityID = rayPickInfo.objectID;
|
||||
if (this.highlightedEntity !== targetEntityID) {
|
||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", this.highlightedEntity);
|
||||
var selectionTargetProps = Entities.getEntityProperties(targetEntityID, DISPATCHER_PROPERTIES);
|
||||
} else if (!this.entityWithContextOverlay) {
|
||||
var _this = this;
|
||||
|
||||
var selectionTargetObject = new TargetObject(targetEntityID, selectionTargetProps);
|
||||
selectionTargetObject.parentProps = getEntityParents(selectionTargetProps);
|
||||
var selectionTargetEntity = selectionTargetObject.getTargetEntity();
|
||||
|
||||
if (entityIsGrabbable(selectionTargetEntity.props) ||
|
||||
entityIsGrabbable(selectionTargetObject.entityProps)) {
|
||||
|
||||
Selection.addToSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", rayPickInfo.objectID);
|
||||
if (_this.potentialEntityWithContextOverlay !== rayPickInfo.objectID) {
|
||||
if (_this.contextOverlayTimer) {
|
||||
Script.clearTimeout(_this.contextOverlayTimer);
|
||||
}
|
||||
this.highlightedEntity = rayPickInfo.objectID;
|
||||
_this.contextOverlayTimer = false;
|
||||
_this.potentialEntityWithContextOverlay = rayPickInfo.objectID;
|
||||
}
|
||||
|
||||
if (!this.entityWithContextOverlay) {
|
||||
var _this = this;
|
||||
|
||||
if (_this.potentialEntityWithContextOverlay !== rayPickInfo.objectID) {
|
||||
if (_this.contextOverlayTimer) {
|
||||
Script.clearTimeout(_this.contextOverlayTimer);
|
||||
if (!_this.contextOverlayTimer) {
|
||||
_this.contextOverlayTimer = Script.setTimeout(function () {
|
||||
if (!_this.entityWithContextOverlay &&
|
||||
_this.contextOverlayTimer &&
|
||||
_this.potentialEntityWithContextOverlay === rayPickInfo.objectID) {
|
||||
var cotProps = Entities.getEntityProperties(rayPickInfo.objectID,
|
||||
DISPATCHER_PROPERTIES);
|
||||
var pointerEvent = {
|
||||
type: "Move",
|
||||
id: _this.hand + 1, // 0 is reserved for hardware mouse
|
||||
pos2D: projectOntoEntityXYPlane(rayPickInfo.objectID,
|
||||
rayPickInfo.intersection, cotProps),
|
||||
pos3D: rayPickInfo.intersection,
|
||||
normal: rayPickInfo.surfaceNormal,
|
||||
direction: Vec3.subtract(ZERO_VEC, rayPickInfo.surfaceNormal),
|
||||
button: "Secondary"
|
||||
};
|
||||
if (ContextOverlay.createOrDestroyContextOverlay(rayPickInfo.objectID, pointerEvent)) {
|
||||
_this.entityWithContextOverlay = rayPickInfo.objectID;
|
||||
}
|
||||
}
|
||||
_this.contextOverlayTimer = false;
|
||||
_this.potentialEntityWithContextOverlay = rayPickInfo.objectID;
|
||||
}
|
||||
|
||||
if (!_this.contextOverlayTimer) {
|
||||
_this.contextOverlayTimer = Script.setTimeout(function () {
|
||||
if (!_this.entityWithContextOverlay &&
|
||||
_this.contextOverlayTimer &&
|
||||
_this.potentialEntityWithContextOverlay === rayPickInfo.objectID) {
|
||||
var cotProps = Entities.getEntityProperties(rayPickInfo.objectID,
|
||||
DISPATCHER_PROPERTIES);
|
||||
var pointerEvent = {
|
||||
type: "Move",
|
||||
id: _this.hand + 1, // 0 is reserved for hardware mouse
|
||||
pos2D: projectOntoEntityXYPlane(rayPickInfo.objectID,
|
||||
rayPickInfo.intersection, cotProps),
|
||||
pos3D: rayPickInfo.intersection,
|
||||
normal: rayPickInfo.surfaceNormal,
|
||||
direction: Vec3.subtract(ZERO_VEC, rayPickInfo.surfaceNormal),
|
||||
button: "Secondary"
|
||||
};
|
||||
if (ContextOverlay.createOrDestroyContextOverlay(rayPickInfo.objectID, pointerEvent)) {
|
||||
_this.entityWithContextOverlay = rayPickInfo.objectID;
|
||||
}
|
||||
}
|
||||
_this.contextOverlayTimer = false;
|
||||
}, 500);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
} else if (this.highlightedEntity) {
|
||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", this.highlightedEntity);
|
||||
this.highlightedEntity = null;
|
||||
}
|
||||
}
|
||||
return this.exitIfDisabled(controllerData);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE,
|
||||
makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent, Vec3,
|
||||
cloneEntity, entityIsCloneable, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE,
|
||||
distanceBetweenPointAndEntityBoundingBox, highlightTargetEntity, unhighlightTargetEntity, getGrabbableData,
|
||||
distanceBetweenPointAndEntityBoundingBox, getGrabbableData,
|
||||
DISPATCHER_PROPERTIES, HMD, NEAR_GRAB_DISTANCE
|
||||
*/
|
||||
|
||||
|
@ -24,7 +24,6 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.hand = hand;
|
||||
this.targetEntityID = null;
|
||||
this.grabbing = false;
|
||||
this.highlightedEntity = null;
|
||||
this.cloneAllowed = true;
|
||||
this.grabID = null;
|
||||
|
||||
|
@ -37,14 +36,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.startNearGrabEntity = function (controllerData, targetProps) {
|
||||
var grabData = getGrabbableData(targetProps);
|
||||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
||||
unhighlightTargetEntity(this.targetEntityID);
|
||||
this.highlightedEntity = null;
|
||||
var message = {
|
||||
hand: this.hand,
|
||||
entityID: this.targetEntityID
|
||||
};
|
||||
|
||||
Messages.sendLocalMessage('Hifi-unhighlight-entity', JSON.stringify(message));
|
||||
var handJointIndex;
|
||||
if (HMD.mounted && HMD.isHandControllerAvailable() && grabData.grabFollowsController) {
|
||||
handJointIndex = getControllerJointIndex(this.hand);
|
||||
|
@ -87,8 +79,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
grabbedEntity: this.targetEntityID,
|
||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||
}));
|
||||
unhighlightTargetEntity(this.targetEntityID);
|
||||
this.highlightedEntity = null;
|
||||
|
||||
this.grabbing = false;
|
||||
this.targetEntityID = null;
|
||||
};
|
||||
|
@ -135,14 +126,8 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
var targetProps = this.getTargetProps(controllerData);
|
||||
if (targetProps) {
|
||||
this.targetEntityID = targetProps.id;
|
||||
this.highlightedEntity = this.targetEntityID;
|
||||
highlightTargetEntity(this.targetEntityID);
|
||||
return makeRunningValues(true, [this.targetEntityID], []);
|
||||
} else {
|
||||
if (this.highlightedEntity) {
|
||||
unhighlightTargetEntity(this.highlightedEntity);
|
||||
this.highlightedEntity = null;
|
||||
}
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
};
|
||||
|
@ -167,8 +152,6 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
props = Entities.getEntityProperties(this.targetEntityID, DISPATCHER_PROPERTIES);
|
||||
if (!props) {
|
||||
// entity was deleted
|
||||
unhighlightTargetEntity(this.targetEntityID);
|
||||
this.highlightedEntity = null;
|
||||
this.grabbing = false;
|
||||
this.targetEntityID = null;
|
||||
return makeRunningValues(false, [], []);
|
||||
|
@ -178,11 +161,9 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||
Entities.callEntityMethod(this.targetEntityID, "continueNearGrab", args);
|
||||
} else {
|
||||
// still searching / highlighting
|
||||
// still searching
|
||||
var readiness = this.isReady(controllerData);
|
||||
if (!readiness.active) {
|
||||
unhighlightTargetEntity(this.highlightedEntity);
|
||||
this.highlightedEntity = null;
|
||||
return readiness;
|
||||
}
|
||||
if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
|
||||
|
|
Loading…
Reference in a new issue