mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
Merge pull request #13089 from druiz17/RC-67-fix-highlighting
RC 67 fix entity highlighting
This commit is contained in:
commit
b426c4e85d
3 changed files with 34 additions and 5 deletions
|
@ -89,7 +89,9 @@
|
|||
}
|
||||
if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) {
|
||||
dispatcherUtils.highlightTargetEntity(props.id);
|
||||
newHighlightedEntities.push(props.id);
|
||||
if (newHighlightedEntities.indexOf(props.id) < 0) {
|
||||
newHighlightedEntities.push(props.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
/* jslint bitwise: true */
|
||||
|
||||
/* global Script, print, Entities, Picks, HMD */
|
||||
/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar*/
|
||||
|
||||
|
||||
(function() {
|
||||
|
@ -20,6 +20,7 @@
|
|||
|
||||
function MouseHighlightEntities() {
|
||||
this.highlightedEntity = null;
|
||||
this.grabbedEntity = null;
|
||||
|
||||
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
||||
5,
|
||||
|
@ -27,13 +28,18 @@
|
|||
[],
|
||||
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 {
|
||||
} else if (!this.grabbedEntity) {
|
||||
var pickResult = controllerData.mouseRayPick;
|
||||
if (pickResult.type === Picks.INTERSECTED_ENTITY) {
|
||||
var targetEntityID = pickResult.objectID;
|
||||
|
@ -70,8 +76,29 @@
|
|||
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);
|
||||
})();
|
||||
|
|
|
@ -409,7 +409,7 @@ Grabber.prototype.pressEvent = function(event) {
|
|||
var args = "mouse";
|
||||
Entities.callEntityMethod(this.entityID, "startDistanceGrab", args);
|
||||
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'grab',
|
||||
grabbedEntity: this.entityID
|
||||
}));
|
||||
|
@ -450,7 +450,7 @@ Grabber.prototype.releaseEvent = function(event) {
|
|||
var args = "mouse";
|
||||
Entities.callEntityMethod(this.entityID, "releaseGrab", args);
|
||||
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'release',
|
||||
grabbedEntity: this.entityID,
|
||||
joint: "mouse"
|
||||
|
|
Loading…
Reference in a new issue