mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 06:23:35 +02:00
remove entity highlighting
This commit is contained in:
parent
b72f462028
commit
d6fbcb1668
9 changed files with 31 additions and 359 deletions
|
@ -129,9 +129,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
return getControllerWorldLocation(Controller.Standard.RightHand, true);
|
return getControllerWorldLocation(Controller.Standard.RightHand, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
Selection.enableListHighlight(DISPATCHER_HOVERING_LIST, DISPATCHER_HOVERING_STYLE);
|
|
||||||
Selection.enableListToScene(DISPATCHER_HOVERING_LIST);
|
|
||||||
|
|
||||||
this.updateTimings = function () {
|
this.updateTimings = function () {
|
||||||
_this.intervalCount++;
|
_this.intervalCount++;
|
||||||
var thisInterval = Date.now();
|
var thisInterval = Date.now();
|
||||||
|
@ -525,7 +522,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
Controller.disableMapping(MAPPING_NAME);
|
Controller.disableMapping(MAPPING_NAME);
|
||||||
_this.pointerManager.removePointers();
|
_this.pointerManager.removePointers();
|
||||||
Pointers.removePointer(this.mouseRayPick);
|
Pointers.removePointer(this.mouseRayPick);
|
||||||
Selection.disableListHighlight(DISPATCHER_HOVERING_LIST);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,13 +459,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
||||||
this.dropGestureReset();
|
this.dropGestureReset();
|
||||||
this.clearEquipHaptics();
|
this.clearEquipHaptics();
|
||||||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
||||||
unhighlightTargetEntity(this.targetEntityID);
|
|
||||||
var message = {
|
|
||||||
hand: this.hand,
|
|
||||||
entityID: this.targetEntityID
|
|
||||||
};
|
|
||||||
|
|
||||||
Messages.sendLocalMessage('Hifi-unhighlight-entity', JSON.stringify(message));
|
|
||||||
var grabbedProperties = Entities.getEntityProperties(this.targetEntityID, DISPATCHER_PROPERTIES);
|
var grabbedProperties = Entities.getEntityProperties(this.targetEntityID, DISPATCHER_PROPERTIES);
|
||||||
var grabData = getGrabbableData(grabbedProperties);
|
var grabData = getGrabbableData(grabbedProperties);
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.entityWithContextOverlay = false;
|
this.entityWithContextOverlay = false;
|
||||||
this.contextOverlayTimer = false;
|
this.contextOverlayTimer = false;
|
||||||
this.locked = false;
|
this.locked = false;
|
||||||
this.highlightedEntity = null;
|
|
||||||
this.reticleMinX = MARGIN;
|
this.reticleMinX = MARGIN;
|
||||||
this.reticleMaxX = null;
|
this.reticleMaxX = null;
|
||||||
this.reticleMinY = MARGIN;
|
this.reticleMinY = MARGIN;
|
||||||
|
@ -410,9 +409,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE ||
|
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE ||
|
||||||
(this.notPointingAtEntity(controllerData) && Window.isPhysicsEnabled()) || this.targetIsNull()) {
|
(this.notPointingAtEntity(controllerData) && Window.isPhysicsEnabled()) || this.targetIsNull()) {
|
||||||
this.endFarGrabAction();
|
this.endFarGrabAction();
|
||||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity",
|
|
||||||
this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
this.restoreIgnoredEntities();
|
this.restoreIgnoredEntities();
|
||||||
return makeRunningValues(false, [], []);
|
return makeRunningValues(false, [], []);
|
||||||
}
|
}
|
||||||
|
@ -466,9 +462,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
|
if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
|
||||||
if (controllerData.triggerClicks[this.hand]) {
|
if (controllerData.triggerClicks[this.hand]) {
|
||||||
var entityID = rayPickInfo.objectID;
|
var entityID = rayPickInfo.objectID;
|
||||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity",
|
|
||||||
this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
var targetProps = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
var targetProps = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
||||||
if (targetProps.href !== "") {
|
if (targetProps.href !== "") {
|
||||||
AddressManager.handleLookupString(targetProps.href);
|
AddressManager.handleLookupString(targetProps.href);
|
||||||
|
@ -513,66 +506,43 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.startFarGrabAction(controllerData, targetProps);
|
this.startFarGrabAction(controllerData, targetProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!this.entityWithContextOverlay) {
|
||||||
var targetEntityID = rayPickInfo.objectID;
|
var _this = this;
|
||||||
if (this.highlightedEntity !== targetEntityID) {
|
|
||||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity",
|
|
||||||
this.highlightedEntity);
|
|
||||||
var selectionTargetProps = Entities.getEntityProperties(targetEntityID, DISPATCHER_PROPERTIES);
|
|
||||||
|
|
||||||
var selectionTargetObject = new TargetObject(targetEntityID, selectionTargetProps);
|
if (_this.potentialEntityWithContextOverlay !== rayPickInfo.objectID) {
|
||||||
selectionTargetObject.parentProps = getEntityParents(selectionTargetProps);
|
if (_this.contextOverlayTimer) {
|
||||||
var selectionTargetEntity = selectionTargetObject.getTargetEntity();
|
Script.clearTimeout(_this.contextOverlayTimer);
|
||||||
|
|
||||||
if (entityIsGrabbable(selectionTargetEntity.props) ||
|
|
||||||
entityIsGrabbable(selectionTargetObject.entityProps)) {
|
|
||||||
|
|
||||||
Selection.addToSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", rayPickInfo.objectID);
|
|
||||||
}
|
}
|
||||||
this.highlightedEntity = rayPickInfo.objectID;
|
_this.contextOverlayTimer = false;
|
||||||
|
_this.potentialEntityWithContextOverlay = rayPickInfo.objectID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.entityWithContextOverlay) {
|
if (!_this.contextOverlayTimer) {
|
||||||
var _this = this;
|
_this.contextOverlayTimer = Script.setTimeout(function () {
|
||||||
|
if (!_this.entityWithContextOverlay &&
|
||||||
if (_this.potentialEntityWithContextOverlay !== rayPickInfo.objectID) {
|
_this.contextOverlayTimer &&
|
||||||
if (_this.contextOverlayTimer) {
|
_this.potentialEntityWithContextOverlay === rayPickInfo.objectID) {
|
||||||
Script.clearTimeout(_this.contextOverlayTimer);
|
var props = 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, props),
|
||||||
|
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.contextOverlayTimer = false;
|
||||||
_this.potentialEntityWithContextOverlay = rayPickInfo.objectID;
|
}, 500);
|
||||||
}
|
|
||||||
|
|
||||||
if (!_this.contextOverlayTimer) {
|
|
||||||
_this.contextOverlayTimer = Script.setTimeout(function () {
|
|
||||||
if (!_this.entityWithContextOverlay &&
|
|
||||||
_this.contextOverlayTimer &&
|
|
||||||
_this.potentialEntityWithContextOverlay === rayPickInfo.objectID) {
|
|
||||||
var props = 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, props),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.distanceRotating) {
|
} else if (this.distanceRotating) {
|
||||||
this.distanceRotate(otherFarGrabModule);
|
this.distanceRotate(otherFarGrabModule);
|
||||||
} else if (this.highlightedEntity) {
|
|
||||||
Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.exitIfDisabled(controllerData);
|
return this.exitIfDisabled(controllerData);
|
||||||
|
|
|
@ -1,155 +0,0 @@
|
||||||
//
|
|
||||||
// highlightNearbyEntities.js
|
|
||||||
//
|
|
||||||
// Created by Dante Ruiz 2018-4-10
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
|
|
||||||
|
|
||||||
/* global Script, MyAvatar, entityIsCloneable, Messages, print */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|
||||||
Script.include("/~/system/libraries/controllers.js");
|
|
||||||
Script.include("/~/system/libraries/cloneEntityUtils.js");
|
|
||||||
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
|
||||||
|
|
||||||
function differenceInArrays(firstArray, secondArray) {
|
|
||||||
var differenceArray = firstArray.filter(function(element) {
|
|
||||||
return secondArray.indexOf(element) < 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
return differenceArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
function HighlightNearbyEntities(hand) {
|
|
||||||
this.hand = hand;
|
|
||||||
this.otherHand = hand === dispatcherUtils.RIGHT_HAND ? dispatcherUtils.LEFT_HAND :
|
|
||||||
dispatcherUtils.RIGHT_HAND;
|
|
||||||
this.highlightedEntities = [];
|
|
||||||
|
|
||||||
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
|
||||||
480,
|
|
||||||
this.hand === dispatcherUtils.RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
|
||||||
[],
|
|
||||||
100);
|
|
||||||
|
|
||||||
|
|
||||||
this.isGrabable = function(controllerData, props) {
|
|
||||||
var canGrabEntity = false;
|
|
||||||
if (dispatcherUtils.entityIsGrabbable(props) || entityIsCloneable(props)) {
|
|
||||||
// if we've attempted to grab a child, roll up to the root of the tree
|
|
||||||
var groupRootProps = dispatcherUtils.findGroupParent(controllerData, props);
|
|
||||||
canGrabEntity = true;
|
|
||||||
if (!dispatcherUtils.entityIsGrabbable(groupRootProps)) {
|
|
||||||
canGrabEntity = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return canGrabEntity;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.clearAll = function() {
|
|
||||||
this.highlightedEntities.forEach(function(entity) {
|
|
||||||
dispatcherUtils.unhighlightTargetEntity(entity);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.hasHyperLink = function(props) {
|
|
||||||
return (props.href !== "" && props.href !== undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.removeEntityFromHighlightList = function(entityID) {
|
|
||||||
var index = this.highlightedEntities.indexOf(entityID);
|
|
||||||
if (index > -1) {
|
|
||||||
this.highlightedEntities.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getOtherModule = function() {
|
|
||||||
var otherModule = this.hand === dispatcherUtils.RIGHT_HAND ? leftHighlightNearbyEntities :
|
|
||||||
rightHighlightNearbyEntities;
|
|
||||||
return otherModule;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getOtherHandHighlightedEntities = function() {
|
|
||||||
return this.getOtherModule().highlightedEntities;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.highlightEntities = function(controllerData) {
|
|
||||||
var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
|
|
||||||
var otherHandHighlightedEntities = this.getOtherHandHighlightedEntities();
|
|
||||||
var newHighlightedEntities = [];
|
|
||||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
|
||||||
for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
|
|
||||||
var props = nearbyEntitiesProperties[i];
|
|
||||||
if (props.distance > dispatcherUtils.NEAR_GRAB_RADIUS * sensorScaleFactor) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) {
|
|
||||||
dispatcherUtils.highlightTargetEntity(props.id);
|
|
||||||
if (newHighlightedEntities.indexOf(props.id) < 0) {
|
|
||||||
newHighlightedEntities.push(props.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var unhighlightEntities = differenceInArrays(this.highlightedEntities, newHighlightedEntities);
|
|
||||||
|
|
||||||
unhighlightEntities.forEach(function(entityID) {
|
|
||||||
if (otherHandHighlightedEntities.indexOf(entityID) < 0 ) {
|
|
||||||
dispatcherUtils.unhighlightTargetEntity(entityID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.highlightedEntities = newHighlightedEntities;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.isReady = function(controllerData) {
|
|
||||||
this.highlightEntities(controllerData);
|
|
||||||
return dispatcherUtils.makeRunningValues(false, [], []);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.run = function(controllerData) {
|
|
||||||
return this.isReady(controllerData);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var handleMessage = function(channel, message, sender) {
|
|
||||||
var data;
|
|
||||||
if (sender === MyAvatar.sessionUUID) {
|
|
||||||
if (channel === 'Hifi-unhighlight-entity') {
|
|
||||||
try {
|
|
||||||
data = JSON.parse(message);
|
|
||||||
var hand = data.hand;
|
|
||||||
if (hand === dispatcherUtils.LEFT_HAND) {
|
|
||||||
leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID);
|
|
||||||
} else if (hand === dispatcherUtils.RIGHT_HAND) {
|
|
||||||
rightHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("highlightNearbyEntities -- Failed to parse message: " + JSON.stringify(message));
|
|
||||||
}
|
|
||||||
} else if (channel === 'Hifi-unhighlight-all') {
|
|
||||||
leftHighlightNearbyEntities.clearAll();
|
|
||||||
rightHighlightNearbyEntities.clearAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var leftHighlightNearbyEntities = new HighlightNearbyEntities(dispatcherUtils.LEFT_HAND);
|
|
||||||
var rightHighlightNearbyEntities = new HighlightNearbyEntities(dispatcherUtils.RIGHT_HAND);
|
|
||||||
|
|
||||||
dispatcherUtils.enableDispatcherModule("LeftHighlightNearbyEntities", leftHighlightNearbyEntities);
|
|
||||||
dispatcherUtils.enableDispatcherModule("RightHighlightNearbyEntities", rightHighlightNearbyEntities);
|
|
||||||
|
|
||||||
function cleanup() {
|
|
||||||
dispatcherUtils.disableDispatcherModule("LeftHighlightNearbyEntities");
|
|
||||||
dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities");
|
|
||||||
}
|
|
||||||
Messages.subscribe('Hifi-unhighlight-entity');
|
|
||||||
Messages.subscribe('Hifi-unhighlight-all');
|
|
||||||
Messages.messageReceived.connect(handleMessage);
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
|
||||||
}());
|
|
|
@ -1,104 +0,0 @@
|
||||||
//
|
|
||||||
// mouseHighlightEntities.js
|
|
||||||
//
|
|
||||||
// scripts/system/controllers/controllerModules/
|
|
||||||
//
|
|
||||||
// Created by Dante Ruiz 2018-4-11
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
/* jslint bitwise: true */
|
|
||||||
|
|
||||||
/* global Script, print, Entities, Messages, Picks, HMD, MyAvatar, isInEditMode, DISPATCHER_PROPERTIES */
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
Script.include("/~/system/libraries/utils.js");
|
|
||||||
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
|
||||||
|
|
||||||
function MouseHighlightEntities() {
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
this.grabbedEntity = null;
|
|
||||||
|
|
||||||
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
|
||||||
5,
|
|
||||||
["mouse"],
|
|
||||||
[],
|
|
||||||
100);
|
|
||||||
|
|
||||||
this.setGrabbedEntity = function(entity) {
|
|
||||||
this.grabbedEntity = entity;
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.isReady = function(controllerData) {
|
|
||||||
if (HMD.active) {
|
|
||||||
if (this.highlightedEntity) {
|
|
||||||
dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
}
|
|
||||||
} else if (!this.grabbedEntity && !isInEditMode()) {
|
|
||||||
var pickResult = controllerData.mouseRayPick;
|
|
||||||
if (pickResult.type === Picks.INTERSECTED_ENTITY) {
|
|
||||||
var targetEntityID = pickResult.objectID;
|
|
||||||
|
|
||||||
if (this.highlightedEntity !== targetEntityID) {
|
|
||||||
var targetProps = Entities.getEntityProperties(targetEntityID, DISPATCHER_PROPERTIES);
|
|
||||||
|
|
||||||
if (this.highlightedEntity) {
|
|
||||||
dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dispatcherUtils.entityIsGrabbable(targetProps)) {
|
|
||||||
// highlight entity
|
|
||||||
dispatcherUtils.highlightTargetEntity(targetEntityID);
|
|
||||||
this.highlightedEntity = targetEntityID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (this.highlightedEntity) {
|
|
||||||
dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dispatcherUtils.makeRunningValues(false, [], []);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.run = function(controllerData) {
|
|
||||||
return this.isReady(controllerData);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var mouseHighlightEntities = new MouseHighlightEntities();
|
|
||||||
dispatcherUtils.enableDispatcherModule("MouseHighlightEntities", mouseHighlightEntities);
|
|
||||||
|
|
||||||
var handleMessage = function(channel, message, sender) {
|
|
||||||
var data;
|
|
||||||
if (sender === MyAvatar.sessionUUID) {
|
|
||||||
if (channel === 'Hifi-Object-Manipulation') {
|
|
||||||
try {
|
|
||||||
data = JSON.parse(message);
|
|
||||||
if (data.action === 'grab') {
|
|
||||||
var grabbedEntity = data.grabbedEntity;
|
|
||||||
mouseHighlightEntities.setGrabbedEntity(grabbedEntity);
|
|
||||||
} else if (data.action === 'release') {
|
|
||||||
mouseHighlightEntities.setGrabbedEntity(null);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("Warning: mouseHighlightEntities -- error parsing Hifi-Object-Manipulation: " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function cleanup() {
|
|
||||||
dispatcherUtils.disableDispatcherModule("MouseHighlightEntities");
|
|
||||||
}
|
|
||||||
Messages.subscribe('Hifi-Object-Manipulation');
|
|
||||||
Messages.messageReceived.connect(handleMessage);
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
|
||||||
})();
|
|
|
@ -115,13 +115,6 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
|
||||||
|
|
||||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||||
Entities.callEntityMethod(this.targetEntityID, "startNearGrab", args);
|
Entities.callEntityMethod(this.targetEntityID, "startNearGrab", args);
|
||||||
unhighlightTargetEntity(this.targetEntityID);
|
|
||||||
var message = {
|
|
||||||
hand: this.hand,
|
|
||||||
entityID: this.targetEntityID
|
|
||||||
};
|
|
||||||
|
|
||||||
Messages.sendLocalMessage('Hifi-unhighlight-entity', JSON.stringify(message));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is for when the action is going to time-out
|
// this is for when the action is going to time-out
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS,
|
TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS,
|
||||||
findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH,
|
findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH,
|
||||||
HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, findHandChildEntities, TEAR_AWAY_DISTANCE, MSECS_PER_SEC, TEAR_AWAY_CHECK_TIME,
|
HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, findHandChildEntities, TEAR_AWAY_DISTANCE, MSECS_PER_SEC, TEAR_AWAY_CHECK_TIME,
|
||||||
TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid, highlightTargetEntity, unhighlightTargetEntity,
|
TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid,
|
||||||
distanceBetweenEntityLocalPositionAndBoundingBox, getGrabbableData, getGrabPointSphereOffset, DISPATCHER_PROPERTIES
|
distanceBetweenEntityLocalPositionAndBoundingBox, getGrabbableData, getGrabPointSphereOffset, DISPATCHER_PROPERTIES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.autoUnequipCounter = 0;
|
this.autoUnequipCounter = 0;
|
||||||
this.lastUnexpectedChildrenCheckTime = 0;
|
this.lastUnexpectedChildrenCheckTime = 0;
|
||||||
this.robbed = false;
|
this.robbed = false;
|
||||||
this.highlightedEntity = null;
|
|
||||||
this.cloneAllowed = true;
|
this.cloneAllowed = true;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
|
@ -95,14 +94,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.startNearParentingGrabEntity = function (controllerData, targetProps) {
|
this.startNearParentingGrabEntity = function (controllerData, targetProps) {
|
||||||
var grabData = getGrabbableData(targetProps);
|
var grabData = getGrabbableData(targetProps);
|
||||||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
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;
|
var handJointIndex;
|
||||||
if (grabData.grabFollowsController) {
|
if (grabData.grabFollowsController) {
|
||||||
handJointIndex = getControllerJointIndex(this.hand);
|
handJointIndex = getControllerJointIndex(this.hand);
|
||||||
|
@ -164,8 +156,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
grabbedEntity: this.targetEntityID,
|
grabbedEntity: this.targetEntityID,
|
||||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||||
}));
|
}));
|
||||||
unhighlightTargetEntity(this.targetEntityID);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
this.grabbing = false;
|
this.grabbing = false;
|
||||||
this.targetEntityID = null;
|
this.targetEntityID = null;
|
||||||
this.robbed = false;
|
this.robbed = false;
|
||||||
|
@ -290,15 +281,9 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it
|
return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it
|
||||||
} else {
|
} else {
|
||||||
this.targetEntityID = targetProps.id;
|
this.targetEntityID = targetProps.id;
|
||||||
this.highlightedEntity = this.targetEntityID;
|
|
||||||
highlightTargetEntity(this.targetEntityID);
|
|
||||||
return makeRunningValues(true, [this.targetEntityID], []);
|
return makeRunningValues(true, [this.targetEntityID], []);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.highlightedEntity) {
|
|
||||||
unhighlightTargetEntity(this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
}
|
|
||||||
this.hapticTargetID = null;
|
this.hapticTargetID = null;
|
||||||
this.robbed = false;
|
this.robbed = false;
|
||||||
return makeRunningValues(false, [], []);
|
return makeRunningValues(false, [], []);
|
||||||
|
@ -316,8 +301,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID];
|
var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID];
|
||||||
if (!props) {
|
if (!props) {
|
||||||
// entity was deleted
|
// entity was deleted
|
||||||
unhighlightTargetEntity(this.targetEntityID);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
this.grabbing = false;
|
this.grabbing = false;
|
||||||
this.targetEntityID = null;
|
this.targetEntityID = null;
|
||||||
this.hapticTargetID = null;
|
this.hapticTargetID = null;
|
||||||
|
@ -335,12 +318,10 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||||
Entities.callEntityMethod(this.targetEntityID, "continueNearGrab", args);
|
Entities.callEntityMethod(this.targetEntityID, "continueNearGrab", args);
|
||||||
} else {
|
} else {
|
||||||
// still searching / highlighting
|
// still searching
|
||||||
var readiness = this.isReady(controllerData);
|
var readiness = this.isReady(controllerData);
|
||||||
if (!readiness.active) {
|
if (!readiness.active) {
|
||||||
this.robbed = false;
|
this.robbed = false;
|
||||||
unhighlightTargetEntity(this.highlightedEntity);
|
|
||||||
this.highlightedEntity = null;
|
|
||||||
return readiness;
|
return readiness;
|
||||||
}
|
}
|
||||||
if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
|
if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* global Script, Entities, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, getGrabbableData,
|
/* global Script, Entities, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, getGrabbableData,
|
||||||
Vec3, TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS, unhighlightTargetEntity
|
Vec3, TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -55,7 +55,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
this.startNearTrigger = function (controllerData) {
|
this.startNearTrigger = function (controllerData) {
|
||||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||||
Entities.callEntityMethod(this.targetEntityID, "startNearTrigger", args);
|
Entities.callEntityMethod(this.targetEntityID, "startNearTrigger", args);
|
||||||
unhighlightTargetEntity(this.targetEntityID);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.continueNearTrigger = function (controllerData) {
|
this.continueNearTrigger = function (controllerData) {
|
||||||
|
|
|
@ -35,9 +35,7 @@ var CONTOLLER_SCRIPTS = [
|
||||||
"controllerModules/hudOverlayPointer.js",
|
"controllerModules/hudOverlayPointer.js",
|
||||||
"controllerModules/mouseHMD.js",
|
"controllerModules/mouseHMD.js",
|
||||||
"controllerModules/scaleEntity.js",
|
"controllerModules/scaleEntity.js",
|
||||||
"controllerModules/highlightNearbyEntities.js",
|
|
||||||
"controllerModules/nearGrabHyperLinkEntity.js",
|
"controllerModules/nearGrabHyperLinkEntity.js",
|
||||||
"controllerModules/mouseHighlightEntities.js",
|
|
||||||
"controllerModules/nearTabletHighlight.js"
|
"controllerModules/nearTabletHighlight.js"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue