diff --git a/build/Main.d.ts b/build/Main.d.ts index f3de450..b0e74b2 100644 --- a/build/Main.d.ts +++ b/build/Main.d.ts @@ -16,13 +16,15 @@ export { HeightDebugProvider } from './providers/HeightDebugProvider'; export { MapNodeGeometry } from './geometries/MapNodeGeometry'; export { MapNodeHeightGeometry } from './geometries/MapNodeHeightGeometry'; export { MapSphereNodeGeometry } from './geometries/MapSphereNodeGeometry'; -export { MapHeightNode } from './nodes/MapHeightNode'; export { MapNode } from './nodes/MapNode'; +export { MapHeightNode } from './nodes/MapHeightNode'; export { MapPlaneNode } from './nodes/MapPlaneNode'; export { MapSphereNode } from './nodes/MapSphereNode'; export { MapHeightNodeShader } from './nodes/MapHeightNodeShader'; export { UnitsUtils } from './utils/UnitsUtils'; +export { CanvasUtils } from './utils/CanvasUtils'; export { Geolocation } from './utils/Geolocation'; export { GeolocationUtils } from './utils/GeolocationUtils'; export { CancelablePromise } from './utils/CancelablePromise'; export { XHRUtils } from './utils/XHRUtils'; +export { TextureUtils } from './utils/TextureUtils'; diff --git a/build/examples/providers.d.ts b/build/examples/providers.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/build/examples/providers.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/build/examples/transition.d.ts b/build/examples/transition.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/build/examples/transition.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/build/geo-three.cjs b/build/geo-three.cjs index 92474eb..dd442b7 100644 --- a/build/geo-three.cjs +++ b/build/geo-three.cjs @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var three = require('three'); /*! ***************************************************************************** @@ -388,7 +386,7 @@ class UnitsUtils { return new three.Vector3(-Math.cos(rotX + Math.PI) * cos, Math.sin(rotY), Math.sin(rotX + Math.PI) * cos); } static mapboxAltitude(color) { - return ((color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1) - 10000.0; + return (color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1 - 10000.0; } } UnitsUtils.EARTH_RADIUS = 6371008; @@ -1616,14 +1614,14 @@ class GoogleMapsProvider extends MapProvider { } class HereMapsProvider extends MapProvider { - constructor(appId, appCode, style, scheme, format, size) { + constructor(appId = '', appCode = '', style = 'base', scheme = 'normal.day', format = 'png', size = 512) { super(); - this.appId = appId !== undefined ? appId : ''; - this.appCode = appCode !== undefined ? appCode : ''; - this.style = style !== undefined ? style : 'base'; - this.scheme = scheme !== undefined ? scheme : 'normal.day'; - this.format = format !== undefined ? format : 'png'; - this.size = size !== undefined ? size : 512; + this.appId = appId; + this.appCode = appCode; + this.style = style; + this.scheme = scheme; + this.format = format; + this.size = size; this.version = 'newest'; this.server = 1; } @@ -1905,6 +1903,7 @@ class CancelablePromise { exports.BingMapsProvider = BingMapsProvider; exports.CancelablePromise = CancelablePromise; +exports.CanvasUtils = CanvasUtils; exports.DebugProvider = DebugProvider; exports.Geolocation = Geolocation; exports.GeolocationUtils = GeolocationUtils; @@ -1928,5 +1927,6 @@ exports.MapTilerProvider = MapTilerProvider; exports.MapView = MapView; exports.OpenMapTilesProvider = OpenMapTilesProvider; exports.OpenStreetMapsProvider = OpenStreetMapsProvider; +exports.TextureUtils = TextureUtils; exports.UnitsUtils = UnitsUtils; exports.XHRUtils = XHRUtils; diff --git a/build/geo-three.js b/build/geo-three.js index 58c7472..c9f0381 100644 --- a/build/geo-three.js +++ b/build/geo-three.js @@ -388,7 +388,7 @@ return new three.Vector3(-Math.cos(rotX + Math.PI) * cos, Math.sin(rotY), Math.sin(rotX + Math.PI) * cos); } static mapboxAltitude(color) { - return ((color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1) - 10000.0; + return (color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1 - 10000.0; } } UnitsUtils.EARTH_RADIUS = 6371008; @@ -1616,14 +1616,14 @@ } class HereMapsProvider extends MapProvider { - constructor(appId, appCode, style, scheme, format, size) { + constructor(appId = '', appCode = '', style = 'base', scheme = 'normal.day', format = 'png', size = 512) { super(); - this.appId = appId !== undefined ? appId : ''; - this.appCode = appCode !== undefined ? appCode : ''; - this.style = style !== undefined ? style : 'base'; - this.scheme = scheme !== undefined ? scheme : 'normal.day'; - this.format = format !== undefined ? format : 'png'; - this.size = size !== undefined ? size : 512; + this.appId = appId; + this.appCode = appCode; + this.style = style; + this.scheme = scheme; + this.format = format; + this.size = size; this.version = 'newest'; this.server = 1; } @@ -1905,6 +1905,7 @@ exports.BingMapsProvider = BingMapsProvider; exports.CancelablePromise = CancelablePromise; + exports.CanvasUtils = CanvasUtils; exports.DebugProvider = DebugProvider; exports.Geolocation = Geolocation; exports.GeolocationUtils = GeolocationUtils; @@ -1928,9 +1929,8 @@ exports.MapView = MapView; exports.OpenMapTilesProvider = OpenMapTilesProvider; exports.OpenStreetMapsProvider = OpenStreetMapsProvider; + exports.TextureUtils = TextureUtils; exports.UnitsUtils = UnitsUtils; exports.XHRUtils = XHRUtils; - Object.defineProperty(exports, '__esModule', { value: true }); - })); diff --git a/build/geo-three.module.js b/build/geo-three.module.js index d7290b5..ca6c8a9 100644 --- a/build/geo-three.module.js +++ b/build/geo-three.module.js @@ -384,7 +384,7 @@ class UnitsUtils { return new Vector3(-Math.cos(rotX + Math.PI) * cos, Math.sin(rotY), Math.sin(rotX + Math.PI) * cos); } static mapboxAltitude(color) { - return ((color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1) - 10000.0; + return (color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1 - 10000.0; } } UnitsUtils.EARTH_RADIUS = 6371008; @@ -1612,14 +1612,14 @@ class GoogleMapsProvider extends MapProvider { } class HereMapsProvider extends MapProvider { - constructor(appId, appCode, style, scheme, format, size) { + constructor(appId = '', appCode = '', style = 'base', scheme = 'normal.day', format = 'png', size = 512) { super(); - this.appId = appId !== undefined ? appId : ''; - this.appCode = appCode !== undefined ? appCode : ''; - this.style = style !== undefined ? style : 'base'; - this.scheme = scheme !== undefined ? scheme : 'normal.day'; - this.format = format !== undefined ? format : 'png'; - this.size = size !== undefined ? size : 512; + this.appId = appId; + this.appCode = appCode; + this.style = style; + this.scheme = scheme; + this.format = format; + this.size = size; this.version = 'newest'; this.server = 1; } @@ -1899,4 +1899,4 @@ class CancelablePromise { } } -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 }; +export { BingMapsProvider, CancelablePromise, CanvasUtils, DebugProvider, Geolocation, GeolocationUtils, GoogleMapsProvider, HeightDebugProvider, HereMapsProvider, LODFrustum, LODRadial, LODRaycast, MapBoxProvider, MapHeightNode, MapHeightNodeShader, MapNode, MapNodeGeometry, MapNodeHeightGeometry, MapPlaneNode, MapProvider, MapSphereNode, MapSphereNodeGeometry, MapTilerProvider, MapView, OpenMapTilesProvider, OpenStreetMapsProvider, TextureUtils, UnitsUtils, XHRUtils }; diff --git a/build/providers/HereMapsProvider.d.ts b/build/providers/HereMapsProvider.d.ts index db4b1e6..fb0ee1d 100644 --- a/build/providers/HereMapsProvider.d.ts +++ b/build/providers/HereMapsProvider.d.ts @@ -9,7 +9,7 @@ export declare class HereMapsProvider extends MapProvider { size: number; version: string; server: number; - constructor(appId: string, appCode: string, style: string, scheme: string, format: string, size: number); + constructor(appId?: string, appCode?: string, style?: string, scheme?: string, format?: string, size?: number); nextServer(): void; getMetaData(): Promise; fetchTile(zoom: number, x: number, y: number): Promise; diff --git a/build/utils/CanvasUtils.d.ts b/build/utils/CanvasUtils.d.ts index 650524d..38399ea 100644 --- a/build/utils/CanvasUtils.d.ts +++ b/build/utils/CanvasUtils.d.ts @@ -1,4 +1,3 @@ -/// export declare class CanvasUtils { static createOffscreenCanvas(width: number, height: number): (HTMLCanvasElement | OffscreenCanvas); } diff --git a/rollup.config.js b/rollup.config.js index 2a2cee1..296651f 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,9 +4,12 @@ import typescript from '@rollup/plugin-typescript'; export default [ { input: 'source/Main.ts', + external: ['three'], plugins: [ - typescript({ tsconfig: './tsconfig.json' }), + typescript({ + tsconfig: './tsconfig.json' + }), strip({ functions: ['assert.*', 'debug', 'alert', 'console.*'] }) diff --git a/rollup.example.js b/rollup.example.js index 1fd0cd7..8d3a759 100644 --- a/rollup.example.js +++ b/rollup.example.js @@ -24,6 +24,7 @@ export default [ resolve(), typescript({ declaration: false + }) ], output: [ diff --git a/source/nodes/MapHeightNode.ts b/source/nodes/MapHeightNode.ts index d36d705..a7b9194 100644 --- a/source/nodes/MapHeightNode.ts +++ b/source/nodes/MapHeightNode.ts @@ -1,4 +1,4 @@ -import {LinearFilter, Material, MeshPhongMaterial, BufferGeometry, RGBAFormat, Texture, Vector3, Raycaster, Intersection} from 'three'; +import {Material, MeshPhongMaterial, BufferGeometry, Vector3, Raycaster, Intersection} from 'three'; import {MapNodeGeometry} from '../geometries/MapNodeGeometry'; import {MapNode, QuadTreePosition} from './MapNode'; import {MapPlaneNode} from './MapPlaneNode'; @@ -6,7 +6,6 @@ import {UnitsUtils} from '../utils/UnitsUtils'; import {MapView} from '../MapView'; import {MapNodeHeightGeometry} from '../geometries/MapNodeHeightGeometry'; import {CanvasUtils} from '../utils/CanvasUtils'; -import {TextureUtils} from '../utils/TextureUtils'; /** * Represents a height map tile node that can be subdivided into other height nodes. @@ -131,7 +130,7 @@ export class MapHeightNode extends MapNode const canvas = CanvasUtils.createOffscreenCanvas(this.geometrySize + 1, this.geometrySize + 1); - const context = canvas.getContext('2d'); + const context = canvas.getContext('2d') as CanvasRenderingContext2D; context.imageSmoothingEnabled = false; context.drawImage(image, 0, 0, MapHeightNode.tileSize, MapHeightNode.tileSize, 0, 0, canvas.width, canvas.height); diff --git a/source/nodes/MapMartiniHeightNode.ts b/source/nodes/MapMartiniHeightNode.ts index cd6aa42..e9f7095 100644 --- a/source/nodes/MapMartiniHeightNode.ts +++ b/source/nodes/MapMartiniHeightNode.ts @@ -291,7 +291,7 @@ export class MapMartiniHeightNode extends MapHeightNode const gridSize = tileSize + 1; var canvas = CanvasUtils.createOffscreenCanvas(tileSize, tileSize); - var context = canvas.getContext('2d'); + var context = canvas.getContext('2d') as CanvasRenderingContext2D; context.imageSmoothingEnabled = false; context.drawImage(image, 0, 0, tileSize, tileSize, 0, 0, canvas.width, canvas.height); diff --git a/source/providers/DebugProvider.ts b/source/providers/DebugProvider.ts index 21c9256..551a988 100644 --- a/source/providers/DebugProvider.ts +++ b/source/providers/DebugProvider.ts @@ -15,7 +15,7 @@ export class DebugProvider extends MapProvider public fetchTile(zoom: number, x: number, y: number): Promise { const canvas = CanvasUtils.createOffscreenCanvas(this.resolution, this.resolution); - const context = canvas.getContext('2d'); + const context = canvas.getContext('2d') as CanvasRenderingContext2D; const green = new Color(0x00ff00); const red = new Color(0xff0000); diff --git a/source/providers/HeightDebugProvider.ts b/source/providers/HeightDebugProvider.ts index fe73659..f013c6c 100644 --- a/source/providers/HeightDebugProvider.ts +++ b/source/providers/HeightDebugProvider.ts @@ -37,7 +37,7 @@ export class HeightDebugProvider extends MapProvider const resolution = 256; const canvas = CanvasUtils.createOffscreenCanvas(resolution, resolution); - const context = canvas.getContext('2d'); + const context = canvas.getContext('2d') as CanvasRenderingContext2D; context.drawImage(image, 0, 0, resolution, resolution, 0, 0, resolution, resolution); diff --git a/tsconfig.json b/tsconfig.json index de01f42..a892147 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,8 +32,9 @@ "source/**/*" ], "exclude": [ + "source/examples/**/*", "node_modules/**/*", "docs/**/*", - "build/**/*" + "build/**/*", ] } \ No newline at end of file