mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
first version of pointing reticle
This commit is contained in:
parent
44d0e0ba1a
commit
4787785660
1 changed files with 81 additions and 1 deletions
|
@ -159,8 +159,10 @@ function toggleReaction(reaction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var UPDATE_POINT_EMOTE_MS = 1000;
|
||||||
var reactionsBegun = [];
|
var reactionsBegun = [];
|
||||||
|
var pointReticle = null;
|
||||||
|
var mouseMoveEventsConnected = false;
|
||||||
function beginReactionWrapper(reaction) {
|
function beginReactionWrapper(reaction) {
|
||||||
reactionsBegun.forEach(function(react) {
|
reactionsBegun.forEach(function(react) {
|
||||||
endReactionWrapper(react);
|
endReactionWrapper(react);
|
||||||
|
@ -175,9 +177,74 @@ function beginReactionWrapper(reaction) {
|
||||||
case ("applaud"):
|
case ("applaud"):
|
||||||
startClappingSounds();
|
startClappingSounds();
|
||||||
break;
|
break;
|
||||||
|
case ("point"):
|
||||||
|
|
||||||
|
if (pointReticle) {
|
||||||
|
Entities.deleteEntity(pointReticle);
|
||||||
|
pointReticle = null;
|
||||||
|
}
|
||||||
|
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||||
|
mouseMoveEventsConnected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var intersectedEntityOrAvatarID = null;
|
||||||
|
function mouseMoveEvent(event) {
|
||||||
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
var avatarIntersectionData = AvatarManager.findRayIntersection(pickRay);
|
||||||
|
var entityIntersectionData = Entities.findRayIntersection(pickRay, true);
|
||||||
|
var avatarIntersectionDistanceM = avatarIntersectionData.intersects ? avatarIntersectionData.distance : null;
|
||||||
|
var entityIntersectionDistanceM = entityIntersectionData.intersects ? entityIntersectionData.distance : null;
|
||||||
|
var reticlePosition;
|
||||||
|
|
||||||
|
if (avatarIntersectionDistanceM && entityIntersectionDistanceM) {
|
||||||
|
if (avatarIntersectionDistanceM < entityIntersectionDistanceM) {
|
||||||
|
intersectedEntityOrAvatarID = avatarIntersectionData.avatarID;
|
||||||
|
reticlePosition = avatarIntersectionData.intersection;
|
||||||
|
} else {
|
||||||
|
intersectedEntityOrAvatarID = entityIntersectionData.entityID;
|
||||||
|
reticlePosition = entityIntersectionData.intersection;
|
||||||
|
}
|
||||||
|
} else if (avatarIntersectionDistanceM) {
|
||||||
|
intersectedEntityOrAvatarID = avatarIntersectionData.avatarID;
|
||||||
|
reticlePosition = avatarIntersectionData.intersection;
|
||||||
|
} else if (entityIntersectionDistanceM) {
|
||||||
|
intersectedEntityOrAvatarID = entityIntersectionData.entityID;
|
||||||
|
reticlePosition = entityIntersectionData.intersection;
|
||||||
|
} else {
|
||||||
|
print("ERROR: No intersected avatar or entity found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (intersectedEntityOrAvatarID === avatarIntersectionData.intersects) {
|
||||||
|
// print("PICKRAY INTERSECTS AVATAR: ", intersectedEntityOrAvatarID);
|
||||||
|
//} else {
|
||||||
|
// print("PICKRAY INTERSECTS ENTITY: ", intersectedEntityOrAvatarID);
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (pointReticle) {
|
||||||
|
Entities.editEntity(pointReticle, { position: reticlePosition });
|
||||||
|
} else {
|
||||||
|
// make dimensions scale to distance
|
||||||
|
pointReticle = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
name: "Point Reticle",
|
||||||
|
position: reticlePosition,
|
||||||
|
dimensions: { x: 0.1, y: 0.1, z: 0.1 },
|
||||||
|
color: { red: 255, green: 0, blue: 0 },
|
||||||
|
collisionless: true,
|
||||||
|
ignorePickIntersection: true
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cast ray from camera to 3d cursor position
|
||||||
|
// get intersection of ray
|
||||||
|
// if intersects with entity, move back along normal 1/2 depth of the entity to get reticle position or maybe just SubmeshIntersection.worldIntersectionPoint
|
||||||
|
// if intersects avatar, move backward 0.5m or maybe just SubmeshIntersection.worldIntersectionPoint
|
||||||
|
// create reticle at the position
|
||||||
|
// make avatar point at the reticle
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function triggerReactionWrapper(reaction) {
|
function triggerReactionWrapper(reaction) {
|
||||||
reactionsBegun.forEach(function(react) {
|
reactionsBegun.forEach(function(react) {
|
||||||
|
@ -202,6 +269,16 @@ function endReactionWrapper(reaction) {
|
||||||
case ("applaud"):
|
case ("applaud"):
|
||||||
maybeClearClapSoundInterval();
|
maybeClearClapSoundInterval();
|
||||||
break;
|
break;
|
||||||
|
case ("point"):
|
||||||
|
if (mouseMoveEventsConnected) {
|
||||||
|
Controller.mouseMoveEvent.disconnect(mouseMoveEvent);
|
||||||
|
}
|
||||||
|
intersectedEntityOrAvatarID = null;
|
||||||
|
if (pointReticle) {
|
||||||
|
Entities.deleteEntity(pointReticle);
|
||||||
|
pointReticle = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +577,9 @@ function onEmojiAppClosed() {
|
||||||
emojiAppWindow.fromQml.disconnect(onMessageFromEmojiApp);
|
emojiAppWindow.fromQml.disconnect(onMessageFromEmojiApp);
|
||||||
emojiAppWindow.closed.disconnect(onEmojiAppClosed);
|
emojiAppWindow.closed.disconnect(onEmojiAppClosed);
|
||||||
}
|
}
|
||||||
|
if (mouseMoveEventsConnected) {
|
||||||
|
Controller.mouseMoveEvent.disconnect(mouseMoveEvent);
|
||||||
|
}
|
||||||
emojiAppWindow = false;
|
emojiAppWindow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue