mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-05 22:59:52 +02:00
commit
5aa2979a86
1 changed files with 33 additions and 27 deletions
|
@ -478,6 +478,25 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.searchIndicatorOn = function(handPosition, distantPickRay) {
|
||||||
|
var SEARCH_SPHERE_SIZE = 0.011;
|
||||||
|
var SEARCH_SPHERE_FOLLOW_RATE = 0.50;
|
||||||
|
|
||||||
|
if (this.intersectionDistance > 0) {
|
||||||
|
// If we hit something with our pick ray, move the search sphere toward that distance
|
||||||
|
this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE +
|
||||||
|
this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
||||||
|
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
||||||
|
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
|
||||||
|
(this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||||
|
if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) {
|
||||||
|
this.overlayLineOn(handPosition, searchSphereLocation,
|
||||||
|
(this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.handleDistantParticleBeam = function(handPosition, objectPosition, color) {
|
this.handleDistantParticleBeam = function(handPosition, objectPosition, color) {
|
||||||
|
|
||||||
|
@ -921,7 +940,8 @@ function MyController(hand) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state == STATE_SEARCHING && !isPhysical && distance > NEAR_PICK_MAX_DISTANCE && !near) {
|
if (this.state == STATE_SEARCHING &&
|
||||||
|
!isPhysical && distance > NEAR_PICK_MAX_DISTANCE && !near && !grabbableDataForCandidate.wantsTrigger) {
|
||||||
// we can't distance-grab non-physical
|
// we can't distance-grab non-physical
|
||||||
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
|
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
|
||||||
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': not physical and too far for near-grab");
|
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': not physical and too far for near-grab");
|
||||||
|
@ -1005,24 +1025,7 @@ function MyController(hand) {
|
||||||
this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
var SEARCH_SPHERE_SIZE = 0.011;
|
this.searchIndicatorOn(handPosition, distantPickRay);
|
||||||
var SEARCH_SPHERE_FOLLOW_RATE = 0.50;
|
|
||||||
|
|
||||||
if (this.intersectionDistance > 0) {
|
|
||||||
// If we hit something with our pick ray, move the search sphere toward that distance
|
|
||||||
this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE +
|
|
||||||
this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
|
||||||
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
|
||||||
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
|
|
||||||
(this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
|
||||||
if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) {
|
|
||||||
this.overlayLineOn(handPosition, searchSphereLocation,
|
|
||||||
(this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller.setReticleVisible(false);
|
Controller.setReticleVisible(false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1543,17 +1546,20 @@ function MyController(hand) {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) {
|
if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) {
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
var intersection = Entities.findRayIntersection(pickRay, true);
|
||||||
this.lastPickTime = now;
|
if (intersection.accurate) {
|
||||||
if (intersection.entityID != this.grabbedEntity) {
|
this.lastPickTime = now;
|
||||||
this.setState(STATE_RELEASE);
|
if (intersection.entityID != this.grabbedEntity) {
|
||||||
this.callEntityMethodOnGrabbed("stopFarTrigger");
|
this.setState(STATE_RELEASE);
|
||||||
return;
|
this.callEntityMethodOnGrabbed("stopFarTrigger");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (intersection.intersects) {
|
||||||
|
this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
||||||
|
}
|
||||||
|
this.searchIndicatorOn(handPosition, pickRay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USE_ENTITY_LINES_FOR_MOVING === true) {
|
|
||||||
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
|
||||||
}
|
|
||||||
this.callEntityMethodOnGrabbed("continueFarTrigger");
|
this.callEntityMethodOnGrabbed("continueFarTrigger");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue