better version

This commit is contained in:
Dante Ruiz 2017-07-18 23:48:21 +01:00
parent 8cbe63f296
commit b3ec306063

View file

@ -1801,14 +1801,19 @@ function MyController(hand) {
this.processStylus(); this.processStylus();
if (isInEditMode() && !this.isNearStylusTarget && HMD.isHandControllerAvailable() && HMD.active) { if (isInEditMode() && !this.isNearStylusTarget && HMD.isHandControllerAvailable()) {
// Always showing lasers while in edit mode and hands/stylus is not active. // Always showing lasers while in edit mode and hands/stylus is not active.
var rayPickInfo = this.calcRayPickInfo(this.hand); var rayPickInfo = this.calcRayPickInfo(this.hand);
if (rayPickInfo.isValid) {
this.intersectionDistance = (rayPickInfo.entityID || rayPickInfo.overlayID) ? rayPickInfo.distance : 0; this.intersectionDistance = (rayPickInfo.entityID || rayPickInfo.overlayID) ? rayPickInfo.distance : 0;
this.searchIndicatorOn(rayPickInfo.searchRay); this.searchIndicatorOn(rayPickInfo.searchRay);
} else { } else {
this.searchIndicatorOff(); this.searchIndicatorOff();
} }
} else {
this.searchIndicatorOff();
}
}; };
this.handleLaserOnHomeButton = function(rayPickInfo) { this.handleLaserOnHomeButton = function(rayPickInfo) {
@ -1854,12 +1859,14 @@ function MyController(hand) {
this.calcRayPickInfo = function(hand, pickRayOverride) { this.calcRayPickInfo = function(hand, pickRayOverride) {
var pickRay; var pickRay;
var valid = true
if (pickRayOverride) { if (pickRayOverride) {
pickRay = pickRayOverride; pickRay = pickRayOverride;
} else { } else {
var controllerLocation = getControllerWorldLocation(this.handToController(), true); var controllerLocation = getControllerWorldLocation(this.handToController(), true);
var worldHandPosition = controllerLocation.position; var worldHandPosition = controllerLocation.position;
var worldHandRotation = controllerLocation.orientation; var worldHandRotation = controllerLocation.orientation;
valid = !(worldHandPosition === undefined);
pickRay = { pickRay = {
origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position, origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position,
@ -1874,7 +1881,8 @@ function MyController(hand) {
entityID: null, entityID: null,
overlayID: null, overlayID: null,
searchRay: pickRay, searchRay: pickRay,
distance: PICK_MAX_DISTANCE distance: PICK_MAX_DISTANCE,
isValid: valid
}; };
var now = Date.now(); var now = Date.now();