@@ -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}
367370UnitsUtils . EARTH_RADIUS = 6371008 ;
368371UnitsUtils . 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 } ;
0 commit comments