mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +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)) {
|
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);
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -409,7 +409,7 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
var args = "mouse";
|
var args = "mouse";
|
||||||
Entities.callEntityMethod(this.entityID, "startDistanceGrab", args);
|
Entities.callEntityMethod(this.entityID, "startDistanceGrab", args);
|
||||||
|
|
||||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||||
action: 'grab',
|
action: 'grab',
|
||||||
grabbedEntity: this.entityID
|
grabbedEntity: this.entityID
|
||||||
}));
|
}));
|
||||||
|
@ -450,7 +450,7 @@ Grabber.prototype.releaseEvent = function(event) {
|
||||||
var args = "mouse";
|
var args = "mouse";
|
||||||
Entities.callEntityMethod(this.entityID, "releaseGrab", args);
|
Entities.callEntityMethod(this.entityID, "releaseGrab", args);
|
||||||
|
|
||||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||||
action: 'release',
|
action: 'release',
|
||||||
grabbedEntity: this.entityID,
|
grabbedEntity: this.entityID,
|
||||||
joint: "mouse"
|
joint: "mouse"
|
||||||
|
|
Loading…
Reference in a new issue