Skip to content

Commit a6a14c6

Browse files
committed
Allow specifying altitude offset
1 parent 2eb9f93 commit a6a14c6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

three.js/examples/location-based/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function main() {
1111
const geom = new THREE.BoxGeometry(20,20,20);
1212

1313
const useAltitude = false;
14-
const arjs = new LocationBased(scene, camera, { useAltitude });
14+
const altitudeOffset = 0;
15+
const arjs = new LocationBased(scene, camera, { useAltitude, altitudeOffset });
1516

1617
// You can change the minimum GPS accuracy needed to register a position - by default 1000m
1718
//const arjs = new LocationBased(scene, camera, { gpsMinAccuracy: 30 } );

three.js/src/location-based/js/location-based.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class LocationBased {
2525
options.initialPositionAsOrigin ||
2626
false;
2727
this.useAltitude = options.useAltitude || false;
28+
this.altitudeOffset = options.altitudeOffset || 0;
2829
}
2930

3031
setProjection(proj) {
@@ -154,7 +155,7 @@ class LocationBased {
154155
position.coords.longitude,
155156
position.coords.latitude,
156157
this.useAltitude && position.coords.altitude != null
157-
? position.coords.altitude
158+
? position.coords.altitude + this.altitudeOffset
158159
: undefined,
159160
);
160161

0 commit comments

Comments
 (0)