Skip to content

Commit 75a93a8

Browse files
committed
likely fix of minDistance/maxDistance problem when using simulated lat/lon
1 parent d1c2cb0 commit 75a93a8

File tree

3 files changed

+47
-42
lines changed

3 files changed

+47
-42
lines changed

aframe/build/aframe-ar-nft.js

Lines changed: 21 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aframe/examples/location-based/max-min-distance/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@
99

1010
</head>
1111

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

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

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

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

2726
<a-camera
2827
rotation-reader

aframe/src/location-based/gps-camera.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,28 @@ AFRAME.registerComponent('gps-camera', {
115115
},
116116

117117
play: function() {
118-
this._watchPositionId = this._initWatchGPS(function (position) {
119-
var localPosition = {
120-
latitude: position.coords.latitude,
121-
longitude: position.coords.longitude,
122-
altitude: position.coords.altitude,
123-
accuracy: position.coords.accuracy,
124-
altitudeAccuracy: position.coords.altitudeAccuracy,
125-
};
126-
118+
if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {
119+
localPosition.latitude = this.data.simulateLatitude;
120+
localPosition.longitude = this.data.simulateLongitude;
127121
if (this.data.simulateAltitude !== 0) {
128122
localPosition.altitude = this.data.simulateAltitude;
129123
}
124+
this.currentCoords = localPosition;
125+
this._updatePosition();
126+
} else {
127+
this._watchPositionId = this._initWatchGPS(function (position) {
128+
var localPosition = {
129+
latitude: position.coords.latitude,
130+
longitude: position.coords.longitude,
131+
altitude: position.coords.altitude,
132+
accuracy: position.coords.accuracy,
133+
altitudeAccuracy: position.coords.altitudeAccuracy,
134+
};
135+
136+
if (this.data.simulateAltitude !== 0) {
137+
localPosition.altitude = this.data.simulateAltitude;
138+
}
130139

131-
if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {
132-
localPosition.latitude = this.data.simulateLatitude;
133-
localPosition.longitude = this.data.simulateLongitude;
134-
this.currentCoords = localPosition;
135-
this._updatePosition();
136-
} else {
137140
this.currentCoords = localPosition;
138141
var distMoved = this._haversineDist(
139142
this.lastPosition,
@@ -147,8 +150,8 @@ AFRAME.registerComponent('gps-camera', {
147150
latitude: this.currentCoords.latitude
148151
};
149152
}
150-
}
151-
}.bind(this));
153+
}.bind(this));
154+
}
152155
},
153156

154157
tick: function () {
@@ -316,7 +319,7 @@ AFRAME.registerComponent('gps-camera', {
316319
if (isPlace && this.data.maxDistance && this.data.maxDistance > 0 && distance > this.data.maxDistance) {
317320
return Number.MAX_SAFE_INTEGER;
318321
}
319-
322+
320323
return distance;
321324
},
322325

0 commit comments

Comments
 (0)