mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:57:25 +02:00
Merge pull request #6049 from sethalves/less-picky
grab script picks less
This commit is contained in:
commit
b7b2c30eaa
1 changed files with 10 additions and 0 deletions
|
@ -67,6 +67,8 @@ var MSEC_PER_SEC = 1000.0;
|
||||||
var startTime = Date.now();
|
var startTime = Date.now();
|
||||||
var LIFETIME = 10;
|
var LIFETIME = 10;
|
||||||
var ACTION_LIFETIME = 10; // seconds
|
var ACTION_LIFETIME = 10; // seconds
|
||||||
|
var PICKS_PER_SECOND_PER_HAND = 5;
|
||||||
|
var MSECS_PER_SEC = 1000.0;
|
||||||
|
|
||||||
// states for the state machine
|
// states for the state machine
|
||||||
var STATE_OFF = 0;
|
var STATE_OFF = 0;
|
||||||
|
@ -239,6 +241,7 @@ function MyController(hand, triggerAction) {
|
||||||
|
|
||||||
this.off = function() {
|
this.off = function() {
|
||||||
if (this.triggerSmoothedSqueezed()) {
|
if (this.triggerSmoothedSqueezed()) {
|
||||||
|
this.lastPickTime = 0;
|
||||||
this.setState(STATE_SEARCHING);
|
this.setState(STATE_SEARCHING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +262,13 @@ function MyController(hand, triggerAction) {
|
||||||
|
|
||||||
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||||
|
|
||||||
|
// don't pick 60x per second. do this check after updating the line so it's not jumpy.
|
||||||
|
var now = Date.now();
|
||||||
|
if (now - this.lastPickTime < MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.lastPickTime = now;
|
||||||
|
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
var intersection = Entities.findRayIntersection(pickRay, true);
|
||||||
if (intersection.intersects && intersection.properties.locked === 0) {
|
if (intersection.intersects && intersection.properties.locked === 0) {
|
||||||
// the ray is intersecting something we can move.
|
// the ray is intersecting something we can move.
|
||||||
|
|
Loading…
Reference in a new issue