@@ -10,10 +10,11 @@ function main() {
10
10
11
11
const geom = new THREE . BoxGeometry ( 20 , 20 , 20 ) ;
12
12
13
- const arjs = new LocationBased ( scene , camera ) ;
13
+ const useAltitude = false ;
14
+ const arjs = new LocationBased ( scene , camera , { useAltitude } ) ;
14
15
15
16
// 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 } );
17
18
const cam = new WebcamRenderer ( renderer , '#video1' ) ;
18
19
19
20
const mouseStep = THREE . MathUtils . degToRad ( 5 ) ;
@@ -44,7 +45,7 @@ function main() {
44
45
45
46
arjs . on ( "gpsupdate" , pos => {
46
47
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 ) ;
48
49
first = false ;
49
50
}
50
51
} ) ;
@@ -119,16 +120,17 @@ function main() {
119
120
camera . updateProjectionMatrix ( ) ;
120
121
}
121
122
122
- function setupObjects ( longitude , latitude ) {
123
+ function setupObjects ( longitude , latitude , altitude = 0 ) {
123
124
// Use position of first GPS update (fake or real)
124
125
const material = new THREE . MeshBasicMaterial ( { color : 0xff0000 } ) ;
125
126
const material2 = new THREE . MeshBasicMaterial ( { color : 0xffff00 } ) ;
126
127
const material3 = new THREE . MeshBasicMaterial ( { color : 0x0000ff } ) ;
127
128
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
132
134
}
133
135
134
136
requestAnimationFrame ( render ) ;
0 commit comments