mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 12:24:26 +02:00
fix highlighting issues
This commit is contained in:
parent
028ea11405
commit
c258e8c248
2 changed files with 32 additions and 3 deletions
|
@ -89,7 +89,9 @@
|
||||||
}
|
}
|
||||||
if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) {
|
if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) {
|
||||||
dispatcherUtils.highlightTargetEntity(props.id);
|
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 */
|
/* jslint bitwise: true */
|
||||||
|
|
||||||
/* global Script, print, Entities, Picks, HMD */
|
/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar*/
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
function MouseHighlightEntities() {
|
function MouseHighlightEntities() {
|
||||||
this.highlightedEntity = null;
|
this.highlightedEntity = null;
|
||||||
|
this.grabbedEntity = null;
|
||||||
|
|
||||||
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
||||||
5,
|
5,
|
||||||
|
@ -27,13 +28,18 @@
|
||||||
[],
|
[],
|
||||||
100);
|
100);
|
||||||
|
|
||||||
|
this.setGrabbedEntity = function(entity) {
|
||||||
|
this.grabbedEntity = entity;
|
||||||
|
this.highlightedEntity = null;
|
||||||
|
};
|
||||||
|
|
||||||
this.isReady = function(controllerData) {
|
this.isReady = function(controllerData) {
|
||||||
if (HMD.active) {
|
if (HMD.active) {
|
||||||
if (this.highlightedEntity) {
|
if (this.highlightedEntity) {
|
||||||
dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity);
|
dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity);
|
||||||
this.highlightedEntity = null;
|
this.highlightedEntity = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!this.grabbedEntity) {
|
||||||
var pickResult = controllerData.mouseRayPick;
|
var pickResult = controllerData.mouseRayPick;
|
||||||
if (pickResult.type === Picks.INTERSECTED_ENTITY) {
|
if (pickResult.type === Picks.INTERSECTED_ENTITY) {
|
||||||
var targetEntityID = pickResult.objectID;
|
var targetEntityID = pickResult.objectID;
|
||||||
|
@ -70,8 +76,29 @@
|
||||||
var mouseHighlightEntities = new MouseHighlightEntities();
|
var mouseHighlightEntities = new MouseHighlightEntities();
|
||||||
dispatcherUtils.enableDispatcherModule("MouseHighlightEntities", 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() {
|
function cleanup() {
|
||||||
dispatcherUtils.disableDispatcherModule("MouseHighlightEntities");
|
dispatcherUtils.disableDispatcherModule("MouseHighlightEntities");
|
||||||
}
|
}
|
||||||
|
Messages.subscribe('Hifi-Object-Manipulation');
|
||||||
|
Messages.messageReceived.connect(handleMessage);
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue