mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
Adds laser selection of particle systems while in edit mode in HMD.
This commit is contained in:
parent
b1a3b1f48b
commit
8479d835b2
3 changed files with 55 additions and 15 deletions
|
@ -2237,15 +2237,22 @@ function MyController(hand) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isInEditMode()) {
|
||||
this.searchIndicatorOn(rayPickInfo.searchRay);
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
if (!this.editTriggered && rayPickInfo.entityID) {
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "selectEntity",
|
||||
entityID: rayPickInfo.entityID
|
||||
}));
|
||||
if (!this.editTriggered){
|
||||
if (rayPickInfo.entityID) {
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "selectEntity",
|
||||
entityID: rayPickInfo.entityID
|
||||
}));
|
||||
} else if (rayPickInfo.overlayID) {
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "selectOverlay",
|
||||
overlayID: rayPickInfo.overlayID
|
||||
}));
|
||||
}
|
||||
}
|
||||
this.editTriggered = true;
|
||||
}
|
||||
|
|
|
@ -638,6 +638,27 @@ function findClickedEntity(event) {
|
|||
};
|
||||
}
|
||||
|
||||
// Handles selections on overlays while in edit mode by querying entities from
|
||||
// entityIconOverlayManager.
|
||||
function handleOverlaySelectionToolUpdates(channel, message, sender) {
|
||||
if (sender !== MyAvatar.sessionUUID || channel !== 'entityToolUpdates')
|
||||
return;
|
||||
|
||||
var data = JSON.parse(message);
|
||||
|
||||
if (data.method === "selectOverlay") {
|
||||
print("setting selection to overlay " + data.overlayID);
|
||||
var entity = entityIconOverlayManager.findEntity(data.overlayID);
|
||||
|
||||
if (entity !== null) {
|
||||
selectionManager.setSelections([entity]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Messages.subscribe("entityToolUpdates");
|
||||
Messages.messageReceived.connect(handleOverlaySelectionToolUpdates);
|
||||
|
||||
var mouseHasMovedSincePress = false;
|
||||
var mousePressStartTime = 0;
|
||||
var mousePressStartPosition = {
|
||||
|
@ -1047,6 +1068,13 @@ Script.scriptEnding.connect(function () {
|
|||
|
||||
Controller.keyReleaseEvent.disconnect(keyReleaseEvent);
|
||||
Controller.keyPressEvent.disconnect(keyPressEvent);
|
||||
|
||||
Controller.mousePressEvent.disconnect(mousePressEvent);
|
||||
Controller.mouseMoveEvent.disconnect(mouseMoveEventBuffered);
|
||||
Controller.mouseReleaseEvent.disconnect(mouseReleaseEvent);
|
||||
|
||||
Messages.messageReceived.disconnect(handleOverlaySelectionToolUpdates);
|
||||
Messages.unsubscribe("entityToolUpdates");
|
||||
});
|
||||
|
||||
var lastOrientation = null;
|
||||
|
|
|
@ -32,20 +32,25 @@ EntityIconOverlayManager = function(entityTypes, getOverlayPropertiesFunc) {
|
|||
}
|
||||
};
|
||||
|
||||
// Finds the id for the corresponding entity that is associated with an overlay id.
|
||||
// Returns null if the overlay id is not contained in this manager.
|
||||
this.findEntity = function(overlayId) {
|
||||
for (var id in entityOverlays) {
|
||||
if (overlayId === entityOverlays[id]) {
|
||||
return entityIDs[id];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
this.findRayIntersection = function(pickRay) {
|
||||
var result = Overlays.findRayIntersection(pickRay);
|
||||
var found = false;
|
||||
|
||||
if (result.intersects) {
|
||||
for (var id in entityOverlays) {
|
||||
if (result.overlayID === entityOverlays[id]) {
|
||||
result.entityID = entityIDs[id];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.entityID = this.findEntity(result.overlayID);
|
||||
|
||||
if (!found) {
|
||||
if (result.entityID === null) {
|
||||
result.intersects = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue