mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 00:36:47 +02:00
Limited distance to rez a point reticle
This commit is contained in:
parent
4787785660
commit
e690d4f7ef
1 changed files with 9 additions and 22 deletions
|
@ -188,44 +188,38 @@ function beginReactionWrapper(reaction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var intersectedEntityOrAvatarID = null;
|
|
||||||
|
var MAX_INTERSECTION_DISTANCE_M = 50;
|
||||||
function mouseMoveEvent(event) {
|
function mouseMoveEvent(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var avatarIntersectionData = AvatarManager.findRayIntersection(pickRay);
|
var avatarIntersectionData = AvatarManager.findRayIntersection(pickRay);
|
||||||
var entityIntersectionData = Entities.findRayIntersection(pickRay, true);
|
var entityIntersectionData = Entities.findRayIntersection(pickRay, true);
|
||||||
var avatarIntersectionDistanceM = avatarIntersectionData.intersects ? avatarIntersectionData.distance : null;
|
var avatarIntersectionDistanceM = avatarIntersectionData.intersects && avatarIntersectionData.distance < MAX_INTERSECTION_DISTANCE_M ? avatarIntersectionData.distance : null;
|
||||||
var entityIntersectionDistanceM = entityIntersectionData.intersects ? entityIntersectionData.distance : null;
|
var entityIntersectionDistanceM = entityIntersectionData.intersects && entityIntersectionData.distance < MAX_INTERSECTION_DISTANCE_M ? entityIntersectionData.distance : null;
|
||||||
var reticlePosition;
|
var reticlePosition;
|
||||||
|
|
||||||
if (avatarIntersectionDistanceM && entityIntersectionDistanceM) {
|
if (avatarIntersectionDistanceM && entityIntersectionDistanceM) {
|
||||||
if (avatarIntersectionDistanceM < entityIntersectionDistanceM) {
|
if (avatarIntersectionDistanceM < entityIntersectionDistanceM) {
|
||||||
intersectedEntityOrAvatarID = avatarIntersectionData.avatarID;
|
|
||||||
reticlePosition = avatarIntersectionData.intersection;
|
reticlePosition = avatarIntersectionData.intersection;
|
||||||
} else {
|
} else {
|
||||||
intersectedEntityOrAvatarID = entityIntersectionData.entityID;
|
|
||||||
reticlePosition = entityIntersectionData.intersection;
|
reticlePosition = entityIntersectionData.intersection;
|
||||||
}
|
}
|
||||||
} else if (avatarIntersectionDistanceM) {
|
} else if (avatarIntersectionDistanceM) {
|
||||||
intersectedEntityOrAvatarID = avatarIntersectionData.avatarID;
|
|
||||||
reticlePosition = avatarIntersectionData.intersection;
|
reticlePosition = avatarIntersectionData.intersection;
|
||||||
} else if (entityIntersectionDistanceM) {
|
} else if (entityIntersectionDistanceM) {
|
||||||
intersectedEntityOrAvatarID = entityIntersectionData.entityID;
|
|
||||||
reticlePosition = entityIntersectionData.intersection;
|
reticlePosition = entityIntersectionData.intersection;
|
||||||
} else {
|
} else {
|
||||||
print("ERROR: No intersected avatar or entity found.");
|
print("ERROR: No intersected avatar or entity found or the distance is too far.");
|
||||||
|
if (pointReticle) {
|
||||||
|
Entities.deleteEntity(pointReticle);
|
||||||
|
pointReticle = null;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (intersectedEntityOrAvatarID === avatarIntersectionData.intersects) {
|
|
||||||
// print("PICKRAY INTERSECTS AVATAR: ", intersectedEntityOrAvatarID);
|
|
||||||
//} else {
|
|
||||||
// print("PICKRAY INTERSECTS ENTITY: ", intersectedEntityOrAvatarID);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (pointReticle) {
|
if (pointReticle) {
|
||||||
Entities.editEntity(pointReticle, { position: reticlePosition });
|
Entities.editEntity(pointReticle, { position: reticlePosition });
|
||||||
} else {
|
} else {
|
||||||
// make dimensions scale to distance
|
|
||||||
pointReticle = Entities.addEntity({
|
pointReticle = Entities.addEntity({
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
name: "Point Reticle",
|
name: "Point Reticle",
|
||||||
|
@ -236,13 +230,6 @@ function mouseMoveEvent(event) {
|
||||||
ignorePickIntersection: true
|
ignorePickIntersection: true
|
||||||
}, 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue