Skip to content

Commit 718c235

Browse files
committed
New version
1 parent 462b014 commit 718c235

36 files changed

+383
-356
lines changed

build/geo-three.cjs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ class UnitsUtils {
367367
const longitude = Math.atan2(dir.y, dir.x) * radToDeg;
368368
return new Geolocation(latitude, longitude);
369369
}
370+
static mapboxAltitude(color) {
371+
return ((color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1) - 10000.0;
372+
}
370373
}
371374
UnitsUtils.EARTH_RADIUS = 6371008;
372375
UnitsUtils.EARTH_RADIUS_A = 6378137.0;
@@ -543,13 +546,18 @@ class MapHeightNode extends MapNode {
543546
if (this.mapView.heightProvider === null) {
544547
throw new Error('GeoThree: MapView.heightProvider provider is null.');
545548
}
546-
const image = yield this.mapView.heightProvider.fetchTile(this.level, this.x, this.y);
547-
const canvas = CanvasUtils.createOffscreenCanvas(this.geometrySize + 1, this.geometrySize + 1);
548-
const context = canvas.getContext('2d');
549-
context.imageSmoothingEnabled = false;
550-
context.drawImage(image, 0, 0, MapHeightNode.tileSize, MapHeightNode.tileSize, 0, 0, canvas.width, canvas.height);
551-
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
552-
this.geometry = new MapNodeHeightGeometry(1, 1, this.geometrySize, this.geometrySize, true, 10.0, imageData, true);
549+
try {
550+
const image = yield this.mapView.heightProvider.fetchTile(this.level, this.x, this.y);
551+
const canvas = CanvasUtils.createOffscreenCanvas(this.geometrySize + 1, this.geometrySize + 1);
552+
const context = canvas.getContext('2d');
553+
context.imageSmoothingEnabled = false;
554+
context.drawImage(image, 0, 0, MapHeightNode.tileSize, MapHeightNode.tileSize, 0, 0, canvas.width, canvas.height);
555+
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
556+
this.geometry = new MapNodeHeightGeometry(1, 1, this.geometrySize, this.geometrySize, true, 10.0, imageData, true);
557+
}
558+
catch (e) {
559+
this.geometry = MapPlaneNode.baseGeometry;
560+
}
553561
this.heightLoaded = true;
554562
});
555563
}
@@ -783,7 +791,7 @@ class MapHeightNodeShader extends MapHeightNode {
783791
}
784792
catch (e) {
785793
console.error('Geo-Three: Failed to load node tile height data.', this);
786-
this.material.map = TextureUtils.createFillTexture('#000000');
794+
this.material.userData.heightMap.value = TextureUtils.createFillTexture('#017090');
787795
}
788796
this.material.needsUpdate = true;
789797
this.heightLoaded = true;
@@ -1844,6 +1852,7 @@ class CancelablePromise {
18441852
exports.BingMapsProvider = BingMapsProvider;
18451853
exports.CancelablePromise = CancelablePromise;
18461854
exports.DebugProvider = DebugProvider;
1855+
exports.Geolocation = Geolocation;
18471856
exports.GeolocationUtils = GeolocationUtils;
18481857
exports.GoogleMapsProvider = GoogleMapsProvider;
18491858
exports.HeightDebugProvider = HeightDebugProvider;

build/geo-three.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
31
(function (global, factory) {
42
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three')) :
53
typeof define === 'function' && define.amd ? define(['exports', 'three'], factory) :
@@ -793,7 +791,7 @@
793791
}
794792
catch (e) {
795793
console.error('Geo-Three: Failed to load node tile height data.', this);
796-
this.material.userData.heightMap.value = TextureUtils.createFillTexture('#019090');
794+
this.material.userData.heightMap.value = TextureUtils.createFillTexture('#017090');
797795
}
798796
this.material.needsUpdate = true;
799797
this.heightLoaded = true;
@@ -1882,4 +1880,3 @@
18821880
Object.defineProperty(exports, '__esModule', { value: true });
18831881

18841882
}));
1885-
//# sourceMappingURL=geo-three.js.map

build/geo-three.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/geo-three.module.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ class UnitsUtils {
363363
const longitude = Math.atan2(dir.y, dir.x) * radToDeg;
364364
return new Geolocation(latitude, longitude);
365365
}
366+
static mapboxAltitude(color) {
367+
return ((color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1) - 10000.0;
368+
}
366369
}
367370
UnitsUtils.EARTH_RADIUS = 6371008;
368371
UnitsUtils.EARTH_RADIUS_A = 6378137.0;
@@ -539,13 +542,18 @@ class MapHeightNode extends MapNode {
539542
if (this.mapView.heightProvider === null) {
540543
throw new Error('GeoThree: MapView.heightProvider provider is null.');
541544
}
542-
const image = yield this.mapView.heightProvider.fetchTile(this.level, this.x, this.y);
543-
const canvas = CanvasUtils.createOffscreenCanvas(this.geometrySize + 1, this.geometrySize + 1);
544-
const context = canvas.getContext('2d');
545-
context.imageSmoothingEnabled = false;
546-
context.drawImage(image, 0, 0, MapHeightNode.tileSize, MapHeightNode.tileSize, 0, 0, canvas.width, canvas.height);
547-
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
548-
this.geometry = new MapNodeHeightGeometry(1, 1, this.geometrySize, this.geometrySize, true, 10.0, imageData, true);
545+
try {
546+
const image = yield this.mapView.heightProvider.fetchTile(this.level, this.x, this.y);
547+
const canvas = CanvasUtils.createOffscreenCanvas(this.geometrySize + 1, this.geometrySize + 1);
548+
const context = canvas.getContext('2d');
549+
context.imageSmoothingEnabled = false;
550+
context.drawImage(image, 0, 0, MapHeightNode.tileSize, MapHeightNode.tileSize, 0, 0, canvas.width, canvas.height);
551+
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
552+
this.geometry = new MapNodeHeightGeometry(1, 1, this.geometrySize, this.geometrySize, true, 10.0, imageData, true);
553+
}
554+
catch (e) {
555+
this.geometry = MapPlaneNode.baseGeometry;
556+
}
549557
this.heightLoaded = true;
550558
});
551559
}
@@ -779,7 +787,7 @@ class MapHeightNodeShader extends MapHeightNode {
779787
}
780788
catch (e) {
781789
console.error('Geo-Three: Failed to load node tile height data.', this);
782-
this.material.map = TextureUtils.createFillTexture('#000000');
790+
this.material.userData.heightMap.value = TextureUtils.createFillTexture('#017090');
783791
}
784792
this.material.needsUpdate = true;
785793
this.heightLoaded = true;
@@ -1837,4 +1845,4 @@ class CancelablePromise {
18371845
}
18381846
}
18391847

1840-
export { BingMapsProvider, CancelablePromise, DebugProvider, GeolocationUtils, GoogleMapsProvider, HeightDebugProvider, HereMapsProvider, LODFrustum, LODRadial, LODRaycast, MapBoxProvider, MapHeightNode, MapHeightNodeShader, MapNode, MapNodeGeometry, MapNodeHeightGeometry, MapPlaneNode, MapProvider, MapSphereNode, MapSphereNodeGeometry, MapTilerProvider, MapView, OpenMapTilesProvider, OpenStreetMapsProvider, UnitsUtils, XHRUtils };
1848+
export { BingMapsProvider, CancelablePromise, DebugProvider, Geolocation, GeolocationUtils, GoogleMapsProvider, HeightDebugProvider, HereMapsProvider, LODFrustum, LODRadial, LODRaycast, MapBoxProvider, MapHeightNode, MapHeightNodeShader, MapNode, MapNodeGeometry, MapNodeHeightGeometry, MapPlaneNode, MapProvider, MapSphereNode, MapSphereNodeGeometry, MapTilerProvider, MapView, OpenMapTilesProvider, OpenStreetMapsProvider, UnitsUtils, XHRUtils };

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)