Skip to content

Commit 44fb646

Browse files
nickw1kalwalt
authored andcommitted
Emit GPS update event from three.js LocationBased
1 parent a0c187a commit 44fb646

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class LocationBased {
66
this.scene = scene;
77
this.camera = camera;
88
this.proj = new SphMercProjection();
9+
this.eventHandlers = { };
910
}
1011

1112
setProjection(proj) {
@@ -20,6 +21,9 @@ class LocationBased {
2021
position.coords.longitude,
2122
position.coords.latitude
2223
);
24+
if(this.eventHandlers["gpsupdate"]) {
25+
this.eventHandlers["gpsupdate"](position);
26+
}
2327
}, error => {
2428
alert(`GPS listen error: code ${error}`);
2529
}, {
@@ -61,6 +65,10 @@ class LocationBased {
6165
setElevation(elev) {
6266
this.camera.position.y = elev;
6367
}
68+
69+
on(eventName, eventHandler) {
70+
this.eventHandlers[eventName] = eventHandler;
71+
}
6472
}
6573

6674
export { LocationBased };

0 commit comments

Comments
 (0)