Skip to content

Commit

Permalink
likely fix of minDistance/maxDistance problem when using simulated la…
Browse files Browse the repository at this point in the history
…t/lon
  • Loading branch information
nickw1 committed May 1, 2021
1 parent d1c2cb0 commit 75a93a8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
39 changes: 21 additions & 18 deletions aframe/build/aframe-ar-nft.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions aframe/examples/location-based/max-min-distance/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@

</head>

<body style='margin: 0; overflow: hidden;'>
<body><!-- style='margin: 0; overflow: hidden;'>-->
<a-scene
vr-mode-ui="enabled: false"
embedded
arjs='sourceType: webcam; debugUIEnabled: false;'>
arjs='sourceType: webcam; videoTexture: true; debugUIEnabled: false;'>

<!-- too near, is like 2m far -->
<a-box material="color: red;" scale="15 15 15" gps-entity-place="latitude: 44.504493; longitude: 11.301134;"></a-box>
<a-box material="color: red;" scale="25 25 25" gps-entity-place="latitude: 44.504493; longitude: 11.301134;"></a-box>

<!-- visible, is like 400m far -->
<a-box material="color: yellow;" scale="15 15 15" gps-entity-place="latitude: 44.506477; longitude: 11.301524;"></a-box>
<a-box material="color: yellow;" scale="25 25 25" gps-entity-place="latitude: 44.506477; longitude: 11.301524;"></a-box>

<!-- too far, is like 2.5km far -->
<a-box material="color: green;" scale="15 15 15" gps-entity-place="latitude: 44.500013; longitude: 11.277351;"></a-box>
<a-box material="color: green;" scale="25 25 25" gps-entity-place="latitude: 44.500013; longitude: 11.277351;"></a-box>

<a-camera
rotation-reader
Expand Down
39 changes: 21 additions & 18 deletions aframe/src/location-based/gps-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,28 @@ AFRAME.registerComponent('gps-camera', {
},

play: function() {
this._watchPositionId = this._initWatchGPS(function (position) {
var localPosition = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
altitude: position.coords.altitude,
accuracy: position.coords.accuracy,
altitudeAccuracy: position.coords.altitudeAccuracy,
};

if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {
localPosition.latitude = this.data.simulateLatitude;
localPosition.longitude = this.data.simulateLongitude;
if (this.data.simulateAltitude !== 0) {
localPosition.altitude = this.data.simulateAltitude;
}
this.currentCoords = localPosition;
this._updatePosition();
} else {
this._watchPositionId = this._initWatchGPS(function (position) {
var localPosition = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
altitude: position.coords.altitude,
accuracy: position.coords.accuracy,
altitudeAccuracy: position.coords.altitudeAccuracy,
};

if (this.data.simulateAltitude !== 0) {
localPosition.altitude = this.data.simulateAltitude;
}

if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {
localPosition.latitude = this.data.simulateLatitude;
localPosition.longitude = this.data.simulateLongitude;
this.currentCoords = localPosition;
this._updatePosition();
} else {
this.currentCoords = localPosition;
var distMoved = this._haversineDist(
this.lastPosition,
Expand All @@ -147,8 +150,8 @@ AFRAME.registerComponent('gps-camera', {
latitude: this.currentCoords.latitude
};
}
}
}.bind(this));
}.bind(this));
}
},

tick: function () {
Expand Down Expand Up @@ -316,7 +319,7 @@ AFRAME.registerComponent('gps-camera', {
if (isPlace && this.data.maxDistance && this.data.maxDistance > 0 && distance > this.data.maxDistance) {
return Number.MAX_SAFE_INTEGER;
}

return distance;
},

Expand Down

0 comments on commit 75a93a8

Please sign in to comment.