@@ -10,10 +10,11 @@ function main() {
1010
1111 const geom = new THREE . BoxGeometry ( 20 , 20 , 20 ) ;
1212
13- const arjs = new LocationBased ( scene , camera ) ;
13+ const useAltitude = false ;
14+ const arjs = new LocationBased ( scene , camera , { useAltitude } ) ;
1415
1516 // You can change the minimum GPS accuracy needed to register a position - by default 1000m
16- //const arjs = new LocationBased(scene, camera. { gpsMinAccuracy: 30 } );
17+ //const arjs = new LocationBased(scene, camera, { gpsMinAccuracy: 30 } );
1718 const cam = new WebcamRenderer ( renderer , '#video1' ) ;
1819
1920 const mouseStep = THREE . MathUtils . degToRad ( 5 ) ;
@@ -44,7 +45,7 @@ function main() {
4445
4546 arjs . on ( "gpsupdate" , pos => {
4647 if ( first ) {
47- setupObjects ( pos . coords . longitude , pos . coords . latitude ) ;
48+ setupObjects ( pos . coords . longitude , pos . coords . latitude , useAltitude && pos . coords . altitude != null ? pos . coords . altitude : undefined ) ;
4849 first = false ;
4950 }
5051 } ) ;
@@ -119,16 +120,17 @@ function main() {
119120 camera . updateProjectionMatrix ( ) ;
120121 }
121122
122- function setupObjects ( longitude , latitude ) {
123+ function setupObjects ( longitude , latitude , altitude = 0 ) {
123124 // Use position of first GPS update (fake or real)
124125 const material = new THREE . MeshBasicMaterial ( { color : 0xff0000 } ) ;
125126 const material2 = new THREE . MeshBasicMaterial ( { color : 0xffff00 } ) ;
126127 const material3 = new THREE . MeshBasicMaterial ( { color : 0x0000ff } ) ;
127128 const material4 = new THREE . MeshBasicMaterial ( { color : 0x00ff00 } ) ;
128- arjs . add ( new THREE . Mesh ( geom , material ) , longitude , latitude + 0.001 ) ; // slightly north
129- arjs . add ( new THREE . Mesh ( geom , material2 ) , longitude , latitude - 0.001 ) ; // slightly south
130- arjs . add ( new THREE . Mesh ( geom , material3 ) , longitude - 0.001 , latitude ) ; // slightly west
131- arjs . add ( new THREE . Mesh ( geom , material4 ) , longitude + 0.001 , latitude ) ; // slightly east
129+
130+ arjs . add ( new THREE . Mesh ( geom , material ) , longitude , latitude + 0.001 , altitude ) ; // slightly north
131+ arjs . add ( new THREE . Mesh ( geom , material2 ) , longitude , latitude - 0.001 , altitude ) ; // slightly south
132+ arjs . add ( new THREE . Mesh ( geom , material3 ) , longitude - 0.001 , latitude , altitude ) ; // slightly west
133+ arjs . add ( new THREE . Mesh ( geom , material4 ) , longitude + 0.001 , latitude , altitude ) ; // slightly east
132134 }
133135
134136 requestAnimationFrame ( render ) ;
0 commit comments