├── .eslintrc ├── .prettierrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bili.config.js ├── bili.config.worker.js ├── build └── ThreeMap.min.js ├── docs ├── .nojekyll ├── API │ ├── classes │ │ ├── extension.extension-1.md │ │ ├── threemap.map.md │ │ ├── tile.tile-1.md │ │ ├── tilegrid.tilegrid-1.md │ │ ├── tilelist.tilelist-1.md │ │ └── workerpool.workerpool-1.md │ ├── enums │ │ └── geometryconstructor.datatypes.md │ ├── interfaces │ │ ├── extension.ihandlers.md │ │ ├── extension.ionfeatureevent.md │ │ ├── extension.iontilecreatedevent.md │ │ ├── extension.iontileremovedevent.md │ │ ├── extension.ionupdateevent.md │ │ ├── geometryconstructor.iresponse.md │ │ ├── interfaces.ilayerstyle.md │ │ ├── interfaces.istyle.md │ │ ├── interfaces.itilebuffers.md │ │ ├── interfaces.itileobject.md │ │ ├── interfaces.iview.md │ │ ├── interfaces.iworkerdata.md │ │ ├── interfaces.iworkerevent.md │ │ ├── interfaces.iworkereventdata.md │ │ ├── interfaces.iworkermessage.md │ │ ├── linestringconstructor.ilinesegment.md │ │ └── threemapglobals.ithreemap.md │ └── modules │ │ ├── extension.md │ │ ├── geometryconstructor.md │ │ ├── interfaces.md │ │ ├── linestringconstructor.md │ │ ├── polygonconstructor.md │ │ ├── threemap.md │ │ ├── threemapglobals.md │ │ ├── tile.md │ │ ├── tilegrid.md │ │ ├── tilelist.md │ │ ├── utils.md │ │ └── workerpool.md ├── README.md ├── _coverpage.md ├── _sidebar.md ├── api-classes-extension.extension-1.md ├── api-classes-threemap.map.md ├── api-classes-tile.tile-1.md ├── api-classes-tilegrid.tilegrid-1.md ├── api-classes-tilelist.tilelist-1.md ├── api-classes-workerpool.workerpool-1.md ├── api-enums-geometryconstructor.datatypes.md ├── api-interfaces-extension.ihandlers.md ├── api-interfaces-extension.ionfeatureevent.md ├── api-interfaces-extension.iontilecreatedevent.md ├── api-interfaces-extension.iontileremovedevent.md ├── api-interfaces-extension.ionupdateevent.md ├── api-interfaces-geometryconstructor.iresponse.md ├── api-interfaces-interfaces.ilayerstyle.md ├── api-interfaces-interfaces.istyle.md ├── api-interfaces-interfaces.itilebuffers.md ├── api-interfaces-interfaces.itileobject.md ├── api-interfaces-interfaces.iview.md ├── api-interfaces-interfaces.iworkerdata.md ├── api-interfaces-interfaces.iworkerevent.md ├── api-interfaces-interfaces.iworkereventdata.md ├── api-interfaces-interfaces.iworkermessage.md ├── api-interfaces-linestringconstructor.ilinesegment.md ├── api-interfaces-threemapglobals.ithreemap.md ├── api-modules-extension.md ├── api-modules-geometryconstructor.md ├── api-modules-interfaces.md ├── api-modules-linestringconstructor.md ├── api-modules-polygonconstructor.md ├── api-modules-threemap.md ├── api-modules-threemapglobals.md ├── api-modules-tile.md ├── api-modules-tilegrid.md ├── api-modules-tilelist.md ├── api-modules-utils.md ├── api-modules-workerpool.md ├── api-readme.md ├── contribute.md └── index.html ├── example └── index.html ├── package.json ├── src ├── Extension.ts ├── ThreeMap.interfaces.ts ├── ThreeMap.ts ├── constructor ├── index.ts ├── tile.ts ├── tilegrid.ts ├── tilelist.ts ├── utils.ts └── workerpool.ts ├── tdconfig.json ├── tsconfig.json └── tslint.json /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "typescript-eslint-parser", 3 | "plugins": [ 4 | "typescript", "jsdoc" 5 | ], 6 | "parserOptions": { 7 | "sourceType": "module", 8 | "ecmaVersion": 8, 9 | "ecmaFeatures": { 10 | "jsx": true 11 | } 12 | }, 13 | "env": { 14 | "worker": true, 15 | "es6": true 16 | }, 17 | "rules": { 18 | "require-jsdoc": ["warn", { 19 | "require": { 20 | "FunctionDeclaration": true, 21 | "MethodDefinition": true, 22 | "ClassDeclaration": true, 23 | "ArrowFunctionExpression": true 24 | } 25 | }], 26 | "valid-jsdoc": "off", 27 | "jsdoc/check-param-names": 1, 28 | "jsdoc/check-tag-names": 0, 29 | "jsdoc/check-types": 1, 30 | "jsdoc/newline-after-description": 1, 31 | "jsdoc/no-undefined-types": 1, 32 | "jsdoc/require-description-complete-sentence": 1, 33 | "jsdoc/require-example": 1, 34 | "jsdoc/require-hyphen-before-param-description": 1, 35 | "jsdoc/require-param": 1, 36 | "jsdoc/require-param-description": 1, 37 | "jsdoc/require-param-name": 1, 38 | "jsdoc/require-param-type": 0, 39 | "jsdoc/require-returns-description": 1, 40 | "jsdoc/require-returns-type": 0, 41 | "jsdoc/valid-types": 1 42 | } 43 | } -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "typescript", 3 | "trailingComma": "all", 4 | "printWidth": 120 5 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute? 2 | ThreeMap is in dire need of contributors. Aspects that 3 | `require(most attention)` :smile: are 4 | * Performance - even if ThreeMap uses WebWorkers it's still not enough 5 | * New features & improvements - for example points implementation & roads cups & joins 6 | 7 | ThreeMap is written in Typescript. If you don't know this language then checkout 8 | [this guide](https://www.typescriptlang.org/docs/home.html). 9 | If you don't want to use this and still want to contribute then 10 | in your issues write code in JS and I'll try to port it to TS. 11 | 12 | For better understanding of code, explore [API](api-readme.md). 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Areknawo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ThreeMap Dev 0.0.1 :earth_americas::earth_africa::earth_asia: 3 | 4 | !> It's highly **Work In Progress** - there is still a lot to be done. 5 | *Do not use it in production!* 6 | If you're willing to help :heartpulse: - checkout **Contribiution guide**. 7 | 8 | Library for high-quality :high_brightness: fully-customizable vector maps 9 | built with THREE.JS for creating stunning :sunglasses: visualizations with ease. 10 | 11 | ## Installation 12 | 13 | Just run:
14 | `npm install three-map`
15 | Or use cdn from [rawgit](https://rawgit.com/areknawo/ThreeMap/master/build/ThreeMap.min.js) 16 | 17 | ## Example 18 | 19 | [ThreeMap](https://cdn.rawgit.com/areknawo/ThreeMap/a76571ba/example/index.html) 20 | -------------------------------------------------------------------------------- /bili.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | input: './src/index.ts', 3 | outDir: './build', 4 | banner: { 5 | version: 'Dev 0.0.1', 6 | name: 'Three-Map', 7 | year: '2018', 8 | author: 'Areknawo', 9 | license: 'Mit' 10 | }, 11 | name: 'ThreeMap', 12 | moduleName: 'ThreeMap', 13 | globals: { 14 | "three": "THREE" 15 | }, 16 | plugins: [ 17 | require('rollup-plugin-bundle-worker')() 18 | ], 19 | uglify: { 20 | compress: { 21 | comparisons: false 22 | } 23 | }, 24 | format: 'umd-min' 25 | }; -------------------------------------------------------------------------------- /bili.config.worker.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | input: "./src/constructor/construct.ts", 3 | outDir: "./src", 4 | filename: "worker.tmp.js", 5 | format: 'umd-min' 6 | }; -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/areknawo/ThreeMap/4a674def666d34415c00b501a1be643ee9827e61/docs/.nojekyll -------------------------------------------------------------------------------- /docs/API/classes/extension.extension-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) > [Extension](../classes/extension.extension-1.md) 2 | 3 | # Class: Extension 4 | 5 | Base class provided for creating ThreeMap Extensions 6 | 7 | ## Hierarchy 8 | 9 | **Extension** 10 | 11 | ## Index 12 | 13 | ### Constructors 14 | 15 | * [constructor](extension.extension-1.md#constructor) 16 | 17 | ### Properties 18 | 19 | * [map](extension.extension-1.md#map) 20 | * [onFeature](extension.extension-1.md#onfeature) 21 | * [onTileCreated](extension.extension-1.md#ontilecreated) 22 | * [onTileRemoved](extension.extension-1.md#ontileremoved) 23 | * [onUpdate](extension.extension-1.md#onupdate) 24 | * [style](extension.extension-1.md#style) 25 | 26 | --- 27 | 28 | ## Constructors 29 | 30 | 31 | 32 | ### constructor 33 | 34 | ⊕ **new Extension**(handlers: *[IHandlers](../interfaces/extension.ihandlers.md)*): [Extension](extension.extension-1.md) 35 | 36 | *Defined in [Extension.ts:70](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L70)* 37 | 38 | *__example__*: `new Extension({onFeature: ()=>{}, onTileCreated: ()=>{}, onTileRemoved: ()=>{}, onUpdate: ()=>{}});` 39 | 40 | **Parameters:** 41 | 42 | | Param | Type | Description | 43 | | ------ | ------ | ------ | 44 | | handlers | [IHandlers](../interfaces/extension.ihandlers.md) | Functions to apply for ThreeMap's corresponding events. | 45 | 46 | **Returns:** [Extension](extension.extension-1.md) 47 | 48 | ___ 49 | 50 | ## Properties 51 | 52 | 53 | 54 | ### map 55 | 56 | **● map**: *`Object3D`* 57 | 58 | *Defined in [Extension.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L50)* 59 | 60 | ThreeMap ThreeJS base object - tiles container 61 | 62 | ___ 63 | 64 | 65 | ### onFeature 66 | 67 | **● onFeature**: *`function`* 68 | 69 | *Defined in [Extension.ts:54](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L54)* 70 | 71 | Function to be executed when new tile feature is loaded. 72 | 73 | #### Type declaration 74 | ▸(e: *[IOnFeatureEvent](../interfaces/extension.ionfeatureevent.md)*): `__type` 75 | 76 | **Parameters:** 77 | 78 | | Param | Type | 79 | | ------ | ------ | 80 | | e | [IOnFeatureEvent](../interfaces/extension.ionfeatureevent.md) | 81 | 82 | **Returns:** `__type` 83 | 84 | ___ 85 | 86 | 87 | ### onTileCreated 88 | 89 | **● onTileCreated**: *`function`* 90 | 91 | *Defined in [Extension.ts:58](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L58)* 92 | 93 | Function to be executed when new tile is added to ThreeMap parent element 94 | 95 | #### Type declaration 96 | ▸(e: *[IOnTileCreatedEvent](../interfaces/extension.iontilecreatedevent.md)*): `__type` 97 | 98 | **Parameters:** 99 | 100 | | Param | Type | 101 | | ------ | ------ | 102 | | e | [IOnTileCreatedEvent](../interfaces/extension.iontilecreatedevent.md) | 103 | 104 | **Returns:** `__type` 105 | 106 | ___ 107 | 108 | 109 | ### onTileRemoved 110 | 111 | **● onTileRemoved**: *`function`* 112 | 113 | *Defined in [Extension.ts:62](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L62)* 114 | 115 | Function to be executed when tile is removed from ThreeMap parent element 116 | 117 | #### Type declaration 118 | ▸(e: *[IOnTileRemovedEvent](../interfaces/extension.iontileremovedevent.md)*): `__type` 119 | 120 | **Parameters:** 121 | 122 | | Param | Type | 123 | | ------ | ------ | 124 | | e | [IOnTileRemovedEvent](../interfaces/extension.iontileremovedevent.md) | 125 | 126 | **Returns:** `__type` 127 | 128 | ___ 129 | 130 | 131 | ### onUpdate 132 | 133 | **● onUpdate**: *`function`* 134 | 135 | *Defined in [Extension.ts:66](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L66)* 136 | 137 | Function to be executed on every ThreeJS controls update - e.g. pan, move etc. 138 | 139 | #### Type declaration 140 | ▸(e: *[IOnUpdateEvent](../interfaces/extension.ionupdateevent.md)*): `__type` 141 | 142 | **Parameters:** 143 | 144 | | Param | Type | 145 | | ------ | ------ | 146 | | e | [IOnUpdateEvent](../interfaces/extension.ionupdateevent.md) | 147 | 148 | **Returns:** `__type` 149 | 150 | ___ 151 | 152 | 153 | ### style 154 | 155 | **● style**: *[IStyle](../interfaces/interfaces.istyle.md)* 156 | 157 | *Defined in [Extension.ts:70](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L70)* 158 | 159 | ThreeMap style configuration object 160 | 161 | ___ 162 | 163 | -------------------------------------------------------------------------------- /docs/API/classes/tile.tile-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Tile](../modules/tile.md) > [Tile](../classes/tile.tile-1.md) 2 | 3 | # Class: Tile 4 | 5 | Full-fledged tile - used for View instances 6 | 7 | ## Hierarchy 8 | 9 | **Tile** 10 | 11 | ## Index 12 | 13 | ### Constructors 14 | 15 | * [constructor](tile.tile-1.md#constructor) 16 | 17 | ### Properties 18 | 19 | * [bounds](tile.tile-1.md#bounds) 20 | * [id](tile.tile-1.md#id) 21 | * [x](tile.tile-1.md#x) 22 | * [y](tile.tile-1.md#y) 23 | * [z](tile.tile-1.md#z) 24 | 25 | ### Methods 26 | 27 | * [build](tile.tile-1.md#build) 28 | * [getBounds](tile.tile-1.md#getbounds) 29 | * [remove](tile.tile-1.md#remove) 30 | 31 | --- 32 | 33 | ## Constructors 34 | 35 | 36 | 37 | ### constructor 38 | 39 | ⊕ **new Tile**(tile: *[TilePrimitive](../modules/interfaces.md#tileprimitive)*, id?: *`string`*): [Tile](tile.tile-1.md) 40 | 41 | *Defined in [tile.ts:39](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L39)* 42 | 43 | *__example__*: `new Tile([10, 15, 8], "00003232");` 44 | 45 | **Parameters:** 46 | 47 | | Param | Type | Description | 48 | | ------ | ------ | ------ | 49 | | tile | [TilePrimitive](../modules/interfaces.md#tileprimitive) | Array of tile coordinates \[x,y,z\]. | 50 | | `Optional` id | `string` | Optional pre-generated tile's quadkey. | 51 | 52 | **Returns:** [Tile](tile.tile-1.md) 53 | 54 | ___ 55 | 56 | ## Properties 57 | 58 | 59 | 60 | ### bounds 61 | 62 | **● bounds**: *`Box3`* 63 | 64 | *Defined in [tile.ts:19](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L19)* 65 | 66 | Tile's bounds 67 | 68 | ___ 69 | 70 | 71 | ### id 72 | 73 | **● id**: *`string`* 74 | 75 | *Defined in [tile.ts:23](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L23)* 76 | 77 | Tile's id a.k.a. QuadKey 78 | 79 | ___ 80 | 81 | 82 | ### x 83 | 84 | **● x**: *`number`* 85 | 86 | *Defined in [tile.ts:27](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L27)* 87 | 88 | Tile's x coordinate 89 | 90 | ___ 91 | 92 | 93 | ### y 94 | 95 | **● y**: *`number`* 96 | 97 | *Defined in [tile.ts:31](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L31)* 98 | 99 | Tile's y coordinate 100 | 101 | ___ 102 | 103 | 104 | ### z 105 | 106 | **● z**: *`number`* 107 | 108 | *Defined in [tile.ts:35](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L35)* 109 | 110 | Tile's zoom level 111 | 112 | ___ 113 | 114 | ## Methods 115 | 116 | 117 | 118 | ### build 119 | 120 | ▸ **build**(): `void` 121 | 122 | *Defined in [tile.ts:57](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L57)* 123 | 124 | Send task to worker to start creating geometry. 125 | *__example__*: `Tile.build();` 126 | 127 | **Returns:** `void` 128 | 129 | ___ 130 | 131 | 132 | ### getBounds 133 | 134 | ▸ **getBounds**(): `Box3` 135 | 136 | *Defined in [tile.ts:66](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L66)* 137 | 138 | Get tile's bounds. 139 | *__example__*: `Tile.getBounds();` 140 | 141 | **Returns:** `Box3` 142 | ThreeJS bounding box. 143 | 144 | ___ 145 | 146 | 147 | ### remove 148 | 149 | ▸ **remove**(): `void` 150 | 151 | *Defined in [tile.ts:74](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L74)* 152 | 153 | Remove tile from grid. 154 | *__example__*: `Tile.remove();` 155 | 156 | **Returns:** `void` 157 | 158 | ___ 159 | 160 | -------------------------------------------------------------------------------- /docs/API/classes/tilegrid.tilegrid-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [TileGrid](../modules/tilegrid.md) > [TileGrid](../classes/tilegrid.tilegrid-1.md) 2 | 3 | # Class: TileGrid 4 | 5 | Grid - main tile-grouping unit 6 | 7 | ## Hierarchy 8 | 9 | **TileGrid** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [position](tilegrid.tilegrid-1.md#position) 16 | * [tiles](tilegrid.tilegrid-1.md#tiles) 17 | * [zoom](tilegrid.tilegrid-1.md#zoom) 18 | 19 | ### Methods 20 | 21 | * [getTilesForView](tilegrid.tilegrid-1.md#gettilesforview) 22 | * [update](tilegrid.tilegrid-1.md#update) 23 | * [render](tilegrid.tilegrid-1.md#render) 24 | 25 | --- 26 | 27 | ## Properties 28 | 29 | 30 | 31 | ### position 32 | 33 | **● position**: *`number`[]* 34 | 35 | *Defined in [tilegrid.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L36)* 36 | 37 | Current mercator position 38 | 39 | ___ 40 | 41 | 42 | ### tiles 43 | 44 | **● tiles**: *[TileList](tilelist.tilelist-1.md)* 45 | 46 | *Defined in [tilegrid.ts:40](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L40)* 47 | 48 | Current tiles in view 49 | 50 | ___ 51 | 52 | 53 | ### zoom 54 | 55 | **● zoom**: *`number`* 56 | 57 | *Defined in [tilegrid.ts:44](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L44)* 58 | 59 | Current zoom level 60 | 61 | ___ 62 | 63 | ## Methods 64 | 65 | 66 | 67 | ### getTilesForView 68 | 69 | ▸ **getTilesForView**(): [TileList](tilelist.tilelist-1.md) 70 | 71 | *Defined in [tilegrid.ts:55](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L55)* 72 | 73 | Gets tiles inside current view. 74 | *__example__*: ``` 75 | var gridInstance = new Grid(); 76 | gridInstance.getTilesForView(); 77 | ``` 78 | 79 | **Returns:** [TileList](tilelist.tilelist-1.md) 80 | Tiles in view. 81 | 82 | ___ 83 | 84 | 85 | ### update 86 | 87 | ▸ **update**(): `void` 88 | 89 | *Defined in [tilegrid.ts:83](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L83)* 90 | 91 | Updates view on change. 92 | *__example__*: `gridInstance.update();` 93 | 94 | **Returns:** `void` 95 | 96 | ___ 97 | 98 | 99 | ### `` render 100 | 101 | ▸ **render**(view: *[IView](../interfaces/interfaces.iview.md)*): `void` 102 | 103 | *Defined in [tilegrid.ts:21](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L21)* 104 | 105 | 'Renders' tiles - sends tasks to build & remove them. 106 | *__example__*: `Grid.render({toRender: [...], toRemove: [...]});` 107 | 108 | **Parameters:** 109 | 110 | | Param | Type | Description | 111 | | ------ | ------ | ------ | 112 | | view | [IView](../interfaces/interfaces.iview.md) | List of tiles to render & remove. | 113 | 114 | **Returns:** `void` 115 | 116 | ___ 117 | 118 | -------------------------------------------------------------------------------- /docs/API/classes/tilelist.tilelist-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [TileList](../modules/tilelist.md) > [TileList](../classes/tilelist.tilelist-1.md) 2 | 3 | # Class: TileList 4 | 5 | TileList - collection of tiles 6 | 7 | ## Hierarchy 8 | 9 | `Object` 10 | 11 | **↳ TileList** 12 | 13 | ## Index 14 | 15 | ### Properties 16 | 17 | * [Object](tilelist.tilelist-1.md#object) 18 | * [constructor](tilelist.tilelist-1.md#constructor) 19 | 20 | ### Methods 21 | 22 | * [containsTile](tilelist.tilelist-1.md#containstile) 23 | * [getTilesToRender](tilelist.tilelist-1.md#gettilestorender) 24 | * [hasOwnProperty](tilelist.tilelist-1.md#hasownproperty) 25 | * [isPrototypeOf](tilelist.tilelist-1.md#isprototypeof) 26 | * [propertyIsEnumerable](tilelist.tilelist-1.md#propertyisenumerable) 27 | * [toLocaleString](tilelist.tilelist-1.md#tolocalestring) 28 | * [toString](tilelist.tilelist-1.md#tostring) 29 | * [valueOf](tilelist.tilelist-1.md#valueof) 30 | 31 | --- 32 | 33 | ## Properties 34 | 35 | 36 | 37 | ### `` Object 38 | 39 | **● Object**: *`ObjectConstructor`* 40 | 41 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:257* 42 | 43 | Provides functionality common to all JavaScript objects. 44 | 45 | ___ 46 | 47 | 48 | ### `` constructor 49 | 50 | **● constructor**: *`Function`* 51 | 52 | *Inherited from Object.constructor* 53 | 54 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:112* 55 | 56 | The initial value of Object.prototype.constructor is the standard built-in Object constructor. 57 | 58 | ___ 59 | 60 | ## Methods 61 | 62 | 63 | 64 | ### containsTile 65 | 66 | ▸ **containsTile**(quadkey: *`string`*): `boolean` 67 | 68 | *Defined in [tilelist.ts:17](https://github.com/areknawo/ThreeMap/blob/master/src/tilelist.ts#L17)* 69 | 70 | Checks if TileList contains specific Tile by Quadkey. 71 | *__example__*: `TileList.containsTile("00003232");` 72 | 73 | **Parameters:** 74 | 75 | | Param | Type | Description | 76 | | ------ | ------ | ------ | 77 | | quadkey | `string` | Tile's quadkey. | 78 | 79 | **Returns:** `boolean` 80 | 81 | ___ 82 | 83 | 84 | ### getTilesToRender 85 | 86 | ▸ **getTilesToRender**(previousTiles?: *[TileList](tilelist.tilelist-1.md)*): [IView](../interfaces/interfaces.iview.md) 87 | 88 | *Defined in [tilelist.ts:28](https://github.com/areknawo/ThreeMap/blob/master/src/tilelist.ts#L28)* 89 | 90 | Get tiles to remove (not seen in current view) and render (actually seen in view). 91 | *__example__*: `TileList.getTilesToRender({...});` 92 | 93 | **Parameters:** 94 | 95 | | Param | Type | Description | 96 | | ------ | ------ | ------ | 97 | | `Optional` previousTiles | [TileList](tilelist.tilelist-1.md) | Collection of currently-in-view tiles. | 98 | 99 | **Returns:** [IView](../interfaces/interfaces.iview.md) 100 | View instance - tiles to be rendered & removed. 101 | 102 | ___ 103 | 104 | 105 | ### `` hasOwnProperty 106 | 107 | ▸ **hasOwnProperty**(v: *`string`*): `boolean` 108 | 109 | *Inherited from Object.hasOwnProperty* 110 | 111 | *Overrides Object.hasOwnProperty* 112 | 113 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:127* 114 | 115 | Determines whether an object has a property with the specified name. 116 | 117 | **Parameters:** 118 | 119 | | Param | Type | Description | 120 | | ------ | ------ | ------ | 121 | | v | `string` | A property name. | 122 | 123 | **Returns:** `boolean` 124 | 125 | ___ 126 | 127 | 128 | ### `` isPrototypeOf 129 | 130 | ▸ **isPrototypeOf**(v: *`Object`*): `boolean` 131 | 132 | *Inherited from Object.isPrototypeOf* 133 | 134 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:133* 135 | 136 | Determines whether an object exists in another object's prototype chain. 137 | 138 | **Parameters:** 139 | 140 | | Param | Type | Description | 141 | | ------ | ------ | ------ | 142 | | v | `Object` | Another object whose prototype chain is to be checked. | 143 | 144 | **Returns:** `boolean` 145 | 146 | ___ 147 | 148 | 149 | ### `` propertyIsEnumerable 150 | 151 | ▸ **propertyIsEnumerable**(v: *`string`*): `boolean` 152 | 153 | *Inherited from Object.propertyIsEnumerable* 154 | 155 | *Overrides Object.propertyIsEnumerable* 156 | 157 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:139* 158 | 159 | Determines whether a specified property is enumerable. 160 | 161 | **Parameters:** 162 | 163 | | Param | Type | Description | 164 | | ------ | ------ | ------ | 165 | | v | `string` | A property name. | 166 | 167 | **Returns:** `boolean` 168 | 169 | ___ 170 | 171 | 172 | ### `` toLocaleString 173 | 174 | ▸ **toLocaleString**(): `string` 175 | 176 | *Inherited from Object.toLocaleString* 177 | 178 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:118* 179 | 180 | Returns a date converted to a string using the current locale. 181 | 182 | **Returns:** `string` 183 | 184 | ___ 185 | 186 | 187 | ### `` toString 188 | 189 | ▸ **toString**(): `string` 190 | 191 | *Inherited from Object.toString* 192 | 193 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:115* 194 | 195 | Returns a string representation of an object. 196 | 197 | **Returns:** `string` 198 | 199 | ___ 200 | 201 | 202 | ### `` valueOf 203 | 204 | ▸ **valueOf**(): `Object` 205 | 206 | *Inherited from Object.valueOf* 207 | 208 | *Defined in /home/arek/Desktop/ThreeMap/node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts:121* 209 | 210 | Returns the primitive value of the specified object. 211 | 212 | **Returns:** `Object` 213 | 214 | ___ 215 | 216 | -------------------------------------------------------------------------------- /docs/API/classes/workerpool.workerpool-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [WorkerPool](../modules/workerpool.md) > [WorkerPool](../classes/workerpool.workerpool-1.md) 2 | 3 | # Class: WorkerPool 4 | 5 | Pool of WebWorkers for handling hard task outside main thread. 6 | 7 | ## Hierarchy 8 | 9 | **WorkerPool** 10 | 11 | ## Index 12 | 13 | ### Constructors 14 | 15 | * [constructor](workerpool.workerpool-1.md#constructor) 16 | 17 | ### Properties 18 | 19 | * [taskList](workerpool.workerpool-1.md#tasklist) 20 | 21 | ### Methods 22 | 23 | * [checkoutTasks](workerpool.workerpool-1.md#checkouttasks) 24 | * [startWorker](workerpool.workerpool-1.md#startworker) 25 | 26 | --- 27 | 28 | ## Constructors 29 | 30 | 31 | 32 | ### constructor 33 | 34 | ⊕ **new WorkerPool**(numOfWorkers: *`number`*, callback: *`function`*): [WorkerPool](workerpool.workerpool-1.md) 35 | 36 | *Defined in [workerpool.ts:16](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L16)* 37 | 38 | *__example__*: `var pool = new WorkerPool(4, (e)=>{...});` 39 | 40 | **Parameters:** 41 | 42 | | Param | Type | Description | 43 | | ------ | ------ | ------ | 44 | | numOfWorkers | `number` | Number of workers to be created in pool. | 45 | | callback | `function` | Function to be called on Worker's job end. | 46 | 47 | **Returns:** [WorkerPool](workerpool.workerpool-1.md) 48 | 49 | ___ 50 | 51 | ## Properties 52 | 53 | 54 | 55 | ### taskList 56 | 57 | **● taskList**: *`object`* 58 | 59 | *Defined in [workerpool.ts:14](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L14)* 60 | 61 | ___ 62 | 63 | ## Methods 64 | 65 | 66 | 67 | ### checkoutTasks 68 | 69 | ▸ **checkoutTasks**(): `void` 70 | 71 | *Defined in [workerpool.ts:48](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L48)* 72 | 73 | Offloads tasks to workers. 74 | *__example__*: `pool.checkoutTasks();` 75 | 76 | **Returns:** `void` 77 | 78 | ___ 79 | 80 | 81 | ### startWorker 82 | 83 | ▸ **startWorker**(message: *[IWorkerMessage](../interfaces/interfaces.iworkermessage.md)*): `void` 84 | 85 | *Defined in [workerpool.ts:67](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L67)* 86 | 87 | Add task to the list for it to be handled by worker. 88 | *__example__*: `pool.startWorker({...});` 89 | 90 | **Parameters:** 91 | 92 | | Param | Type | Description | 93 | | ------ | ------ | ------ | 94 | | message | [IWorkerMessage](../interfaces/interfaces.iworkermessage.md) | Data to be sent to worker. | 95 | 96 | **Returns:** `void` 97 | 98 | ___ 99 | 100 | -------------------------------------------------------------------------------- /docs/API/enums/geometryconstructor.datatypes.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [GeometryConstructor](../modules/geometryconstructor.md) > [DataTypes](../enums/geometryconstructor.datatypes.md) 2 | 3 | # Enumeration: DataTypes 4 | 5 | ## Index 6 | 7 | ### Enumeration members 8 | 9 | * [Linestring](geometryconstructor.datatypes.md#linestring) 10 | * [Polygon](geometryconstructor.datatypes.md#polygon) 11 | 12 | --- 13 | 14 | ## Enumeration members 15 | 16 | 17 | 18 | ### Linestring 19 | 20 | **Linestring**: = 2 21 | 22 | *Defined in [constructor/construct.ts:25](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L25)* 23 | 24 | ___ 25 | 26 | 27 | ### Polygon 28 | 29 | **Polygon**: = 3 30 | 31 | *Defined in [constructor/construct.ts:26](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L26)* 32 | 33 | ___ 34 | 35 | -------------------------------------------------------------------------------- /docs/API/interfaces/extension.ihandlers.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) > [IHandlers](../interfaces/extension.ihandlers.md) 2 | 3 | # Interface: IHandlers 4 | 5 | ## Hierarchy 6 | 7 | **IHandlers** 8 | 9 | ## Index 10 | 11 | ### Methods 12 | 13 | * [onFeature](extension.ihandlers.md#onfeature) 14 | * [onTileCreated](extension.ihandlers.md#ontilecreated) 15 | * [onTileRemoved](extension.ihandlers.md#ontileremoved) 16 | * [onUpdate](extension.ihandlers.md#onupdate) 17 | 18 | --- 19 | 20 | ## Methods 21 | 22 | 23 | 24 | ### onFeature 25 | 26 | ▸ **onFeature**(e: *`object`*): `object` 27 | 28 | *Defined in [Extension.ts:9](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L9)* 29 | 30 | **Parameters:** 31 | 32 | | Param | Type | 33 | | ------ | ------ | 34 | | e | `object` | 35 | 36 | **Returns:** `object` 37 | 38 | ___ 39 | 40 | 41 | ### onTileCreated 42 | 43 | ▸ **onTileCreated**(e: *`object`*): `any` 44 | 45 | *Defined in [Extension.ts:10](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L10)* 46 | 47 | **Parameters:** 48 | 49 | | Param | Type | 50 | | ------ | ------ | 51 | | e | `object` | 52 | 53 | **Returns:** `any` 54 | 55 | ___ 56 | 57 | 58 | ### onTileRemoved 59 | 60 | ▸ **onTileRemoved**(e: *`object`*): `__type` 61 | 62 | *Defined in [Extension.ts:11](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L11)* 63 | 64 | **Parameters:** 65 | 66 | | Param | Type | 67 | | ------ | ------ | 68 | | e | `object` | 69 | 70 | **Returns:** `__type` 71 | 72 | ___ 73 | 74 | 75 | ### onUpdate 76 | 77 | ▸ **onUpdate**(e: *`object`*): `__type` 78 | 79 | *Defined in [Extension.ts:12](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L12)* 80 | 81 | **Parameters:** 82 | 83 | | Param | Type | 84 | | ------ | ------ | 85 | | e | `object` | 86 | 87 | **Returns:** `__type` 88 | 89 | ___ 90 | 91 | -------------------------------------------------------------------------------- /docs/API/interfaces/extension.ionfeatureevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) > [IOnFeatureEvent](../interfaces/extension.ionfeatureevent.md) 2 | 3 | # Interface: IOnFeatureEvent 4 | 5 | ## Hierarchy 6 | 7 | **IOnFeatureEvent** 8 | 9 | ## Index 10 | 11 | ### Properties 12 | 13 | * [feature](extension.ionfeatureevent.md#feature) 14 | * [shown](extension.ionfeatureevent.md#shown) 15 | 16 | --- 17 | 18 | ## Properties 19 | 20 | 21 | 22 | ### feature 23 | 24 | **● feature**: *`any`* 25 | 26 | *Defined in [Extension.ts:19](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L19)* 27 | 28 | Vector tile feature object. 29 | 30 | ___ 31 | 32 | 33 | ### shown 34 | 35 | **● shown**: *`boolean`* 36 | 37 | *Defined in [Extension.ts:23](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L23)* 38 | 39 | If feature is shown in view. 40 | 41 | ___ 42 | 43 | -------------------------------------------------------------------------------- /docs/API/interfaces/extension.iontilecreatedevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) > [IOnTileCreatedEvent](../interfaces/extension.iontilecreatedevent.md) 2 | 3 | # Interface: IOnTileCreatedEvent 4 | 5 | ## Hierarchy 6 | 7 | **IOnTileCreatedEvent** 8 | 9 | ## Index 10 | 11 | ### Properties 12 | 13 | * [tile](extension.iontilecreatedevent.md#tile) 14 | 15 | --- 16 | 17 | ## Properties 18 | 19 | 20 | 21 | ### tile 22 | 23 | **● tile**: *`Mesh`* 24 | 25 | *Defined in [Extension.ts:29](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L29)* 26 | 27 | THREE.JS Mesh of created tile. 28 | 29 | ___ 30 | 31 | -------------------------------------------------------------------------------- /docs/API/interfaces/extension.iontileremovedevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) > [IOnTileRemovedEvent](../interfaces/extension.iontileremovedevent.md) 2 | 3 | # Interface: IOnTileRemovedEvent 4 | 5 | ## Hierarchy 6 | 7 | **IOnTileRemovedEvent** 8 | 9 | ## Index 10 | 11 | ### Properties 12 | 13 | * [tileID](extension.iontileremovedevent.md#tileid) 14 | 15 | --- 16 | 17 | ## Properties 18 | 19 | 20 | 21 | ### tileID 22 | 23 | **● tileID**: *`string`* 24 | 25 | *Defined in [Extension.ts:35](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L35)* 26 | 27 | Quadkey of removed tile. 28 | 29 | ___ 30 | 31 | -------------------------------------------------------------------------------- /docs/API/interfaces/extension.ionupdateevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) > [IOnUpdateEvent](../interfaces/extension.ionupdateevent.md) 2 | 3 | # Interface: IOnUpdateEvent 4 | 5 | ## Hierarchy 6 | 7 | **IOnUpdateEvent** 8 | 9 | ## Index 10 | 11 | ### Properties 12 | 13 | * [tiles](extension.ionupdateevent.md#tiles) 14 | 15 | --- 16 | 17 | ## Properties 18 | 19 | 20 | 21 | ### tiles 22 | 23 | **● tiles**: *[TileList](../classes/tilelist.tilelist-1.md)* 24 | 25 | *Defined in [Extension.ts:41](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L41)* 26 | 27 | List of new tiles in view. 28 | 29 | ___ 30 | 31 | -------------------------------------------------------------------------------- /docs/API/interfaces/geometryconstructor.iresponse.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [GeometryConstructor](../modules/geometryconstructor.md) > [IResponse](../interfaces/geometryconstructor.iresponse.md) 2 | 3 | # Interface: IResponse 4 | 5 | ## Hierarchy 6 | 7 | **IResponse** 8 | 9 | ## Index 10 | 11 | ### Properties 12 | 13 | * [body](geometryconstructor.iresponse.md#body) 14 | * [headers](geometryconstructor.iresponse.md#headers) 15 | * [method](geometryconstructor.iresponse.md#method) 16 | * [rawRequest](geometryconstructor.iresponse.md#rawrequest) 17 | * [statusCode](geometryconstructor.iresponse.md#statuscode) 18 | * [url](geometryconstructor.iresponse.md#url) 19 | 20 | --- 21 | 22 | ## Properties 23 | 24 | 25 | 26 | ### body 27 | 28 | **● body**: * `any` | `string` 29 | * 30 | 31 | *Defined in [constructor/construct.ts:16](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L16)* 32 | 33 | ___ 34 | 35 | 36 | ### headers 37 | 38 | **● headers**: *`__type`* 39 | 40 | *Defined in [constructor/construct.ts:17](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L17)* 41 | 42 | ___ 43 | 44 | 45 | ### method 46 | 47 | **● method**: *`string`* 48 | 49 | *Defined in [constructor/construct.ts:18](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L18)* 50 | 51 | ___ 52 | 53 | 54 | ### rawRequest 55 | 56 | **● rawRequest**: *`XMLHttpRequest`* 57 | 58 | *Defined in [constructor/construct.ts:19](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L19)* 59 | 60 | ___ 61 | 62 | 63 | ### statusCode 64 | 65 | **● statusCode**: *`number`* 66 | 67 | *Defined in [constructor/construct.ts:20](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L20)* 68 | 69 | ___ 70 | 71 | 72 | ### url 73 | 74 | **● url**: *`string`* 75 | 76 | *Defined in [constructor/construct.ts:21](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L21)* 77 | 78 | ___ 79 | 80 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.ilayerstyle.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) 2 | 3 | # Interface: ILayerStyle 4 | 5 | Layer's style configuration. 6 | Each property of style should be of specified type, styleFunction (if allowed) or function string. 7 | 8 | ## Hierarchy 9 | 10 | **ILayerStyle** 11 | 12 | ## Index 13 | 14 | ### Properties 15 | 16 | * [color](interfaces.ilayerstyle.md#color) 17 | * [cups](interfaces.ilayerstyle.md#cups) 18 | * [height](interfaces.ilayerstyle.md#height) 19 | * [min_height](interfaces.ilayerstyle.md#min_height) 20 | * [name](interfaces.ilayerstyle.md#name) 21 | * [show](interfaces.ilayerstyle.md#show) 22 | * [type](interfaces.ilayerstyle.md#type) 23 | * [width](interfaces.ilayerstyle.md#width) 24 | 25 | --- 26 | 27 | ## Properties 28 | 29 | 30 | 31 | ### color 32 | 33 | **● color**: * [styleFunction](../modules/interfaces.md#stylefunction) | `string` | `number`[] 34 | * 35 | 36 | *Defined in [ThreeMap.interfaces.ts:111](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L111)* 37 | 38 | Element's vertices color as hex or in other format. 39 | *__see__*: [color-parse](https://www.npmjs.com/package/color-parse) 40 | 41 | ___ 42 | 43 | 44 | ### `` cups 45 | 46 | **● cups**: *`boolean`* 47 | 48 | *Defined in [ThreeMap.interfaces.ts:134](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L134)* 49 | 50 | If generate cups 51 | *__default__*: `true` 52 | 53 | ___ 54 | 55 | 56 | ### `` height 57 | 58 | **● height**: * [styleFunction](../modules/interfaces.md#stylefunction) | `string` | `number` 59 | * 60 | 61 | *Defined in [ThreeMap.interfaces.ts:115](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L115)* 62 | 63 | Element height - only for polygons. 64 | 65 | ___ 66 | 67 | 68 | ### `` min_height 69 | 70 | **● min_height**: * [styleFunction](../modules/interfaces.md#stylefunction) | `string` | `number` 71 | * 72 | 73 | *Defined in [ThreeMap.interfaces.ts:120](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L120)* 74 | 75 | Element min-height - only for polygons. 76 | *__see__*: [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Key:min_height) 77 | 78 | ___ 79 | 80 | 81 | ### name 82 | 83 | **● name**: *`string`* 84 | 85 | *Defined in [ThreeMap.interfaces.ts:124](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L124)* 86 | 87 | Layer's name e.g. buildings 88 | 89 | ___ 90 | 91 | 92 | ### `` show 93 | 94 | **● show**: * [styleFunction](../modules/interfaces.md#stylefunction) | `string` | `boolean` 95 | * 96 | 97 | *Defined in [ThreeMap.interfaces.ts:129](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L129)* 98 | 99 | If element shall be shown 100 | *__default__*: `true` 101 | 102 | ___ 103 | 104 | 105 | ### `` type 106 | 107 | **● type**: *[GeometryType](../modules/interfaces.md#geometrytype)* 108 | 109 | *Defined in [ThreeMap.interfaces.ts:139](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L139)* 110 | 111 | Accepted geometry type for layer. 112 | *__default__*: `ALL` 113 | 114 | ___ 115 | 116 | 117 | ### `` width 118 | 119 | **● width**: * [styleFunction](../modules/interfaces.md#stylefunction) | `string` | `number` 120 | * 121 | 122 | *Defined in [ThreeMap.interfaces.ts:144](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L144)* 123 | 124 | Line width - only for lineStrings. 125 | *__default__*: `2` 126 | 127 | ___ 128 | 129 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.istyle.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [IStyle](../interfaces/interfaces.istyle.md) 2 | 3 | # Interface: IStyle 4 | 5 | ThreeMap style configuration. 6 | 7 | ## Hierarchy 8 | 9 | **IStyle** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [address](interfaces.istyle.md#address) 16 | * [layers](interfaces.istyle.md#layers) 17 | * [material](interfaces.istyle.md#material) 18 | * [maxZoom](interfaces.istyle.md#maxzoom) 19 | * [minZoom](interfaces.istyle.md#minzoom) 20 | * [tilesExtend](interfaces.istyle.md#tilesextend) 21 | * [workers](interfaces.istyle.md#workers) 22 | 23 | --- 24 | 25 | ## Properties 26 | 27 | 28 | 29 | ### address 30 | 31 | **● address**: *`string`* 32 | 33 | *Defined in [ThreeMap.interfaces.ts:46](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L46)* 34 | 35 | Your MVT tiles address with {x}, {y} and {z} params. 36 | 37 | ___ 38 | 39 | 40 | ### layers 41 | 42 | **● layers**: *[ILayerStyle](interfaces.ilayerstyle.md)[]* 43 | 44 | *Defined in [ThreeMap.interfaces.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L50)* 45 | 46 | Array of layers' styles 47 | 48 | ___ 49 | 50 | 51 | ### material 52 | 53 | **● material**: *`Material`* 54 | 55 | *Defined in [ThreeMap.interfaces.ts:55](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L55)* 56 | 57 | THREE.JS Material for ThreeMap's tiles. Keep in mind that ThreeMap automatically sets vertexColors and side attributes. 58 | 59 | ___ 60 | 61 | 62 | ### `` maxZoom 63 | 64 | **● maxZoom**: *`number`* 65 | 66 | *Defined in [ThreeMap.interfaces.ts:60](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L60)* 67 | 68 | Max value for address' {z} param. 69 | *__default__*: `16` 70 | 71 | ___ 72 | 73 | 74 | ### `` minZoom 75 | 76 | **● minZoom**: *`number`* 77 | 78 | *Defined in [ThreeMap.interfaces.ts:65](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L65)* 79 | 80 | Min value for address' {z} param. 81 | *__default__*: `1` 82 | 83 | ___ 84 | 85 | 86 | ### `` tilesExtend 87 | 88 | **● tilesExtend**: *`number`* 89 | 90 | *Defined in [ThreeMap.interfaces.ts:74](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L74)* 91 | 92 | Value for tiles calculation. 93 | ThreeMap generate tiles for view by generating grid of tiles e.g. 5x5. 94 | Then it checks if these are in camera frustum. 95 | This value sets the tile grid limit in each direction from center tile. 96 | E.g. if value is 3 then the grid is 7x7 which is (3x2+1) x (3x2+1). 97 | *__default__*: `2` 98 | 99 | ___ 100 | 101 | 102 | ### `` workers 103 | 104 | **● workers**: *`number`* 105 | 106 | *Defined in [ThreeMap.interfaces.ts:79](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L79)* 107 | 108 | Number of WebWorkers to be used in WorkerPool instance. 109 | *__default__*: `4` 110 | 111 | ___ 112 | 113 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.itilebuffers.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [ITileBuffers](../interfaces/interfaces.itilebuffers.md) 2 | 3 | # Interface: ITileBuffers 4 | 5 | Buffers for generating geometry. Fruit of WebWorkers' work. 6 | 7 | ## Hierarchy 8 | 9 | **ITileBuffers** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [colorBuffer](interfaces.itilebuffers.md#colorbuffer) 16 | * [id](interfaces.itilebuffers.md#id) 17 | * [normalBuffer](interfaces.itilebuffers.md#normalbuffer) 18 | * [vertexBuffer](interfaces.itilebuffers.md#vertexbuffer) 19 | 20 | --- 21 | 22 | ## Properties 23 | 24 | 25 | 26 | ### colorBuffer 27 | 28 | **● colorBuffer**: *`ArrayBuffer`* 29 | 30 | *Defined in [ThreeMap.interfaces.ts:173](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L173)* 31 | 32 | ___ 33 | 34 | 35 | ### id 36 | 37 | **● id**: *`string`* 38 | 39 | *Defined in [ThreeMap.interfaces.ts:172](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L172)* 40 | 41 | ___ 42 | 43 | 44 | ### normalBuffer 45 | 46 | **● normalBuffer**: *`ArrayBuffer`* 47 | 48 | *Defined in [ThreeMap.interfaces.ts:174](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L174)* 49 | 50 | ___ 51 | 52 | 53 | ### vertexBuffer 54 | 55 | **● vertexBuffer**: *`ArrayBuffer`* 56 | 57 | *Defined in [ThreeMap.interfaces.ts:175](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L175)* 58 | 59 | ___ 60 | 61 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.itileobject.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [ITileObject](../interfaces/interfaces.itileobject.md) 2 | 3 | # Interface: ITileObject 4 | 5 | Alternative to TilePrimitive - tile coordinates & zoom level represented as object properties: x, y, z. 6 | 7 | ## Hierarchy 8 | 9 | **ITileObject** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [x](interfaces.itileobject.md#x) 16 | * [y](interfaces.itileobject.md#y) 17 | * [z](interfaces.itileobject.md#z) 18 | 19 | --- 20 | 21 | ## Properties 22 | 23 | 24 | 25 | ### x 26 | 27 | **● x**: *`number`* 28 | 29 | *Defined in [ThreeMap.interfaces.ts:20](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L20)* 30 | 31 | ___ 32 | 33 | 34 | ### y 35 | 36 | **● y**: *`number`* 37 | 38 | *Defined in [ThreeMap.interfaces.ts:21](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L21)* 39 | 40 | ___ 41 | 42 | 43 | ### z 44 | 45 | **● z**: *`number`* 46 | 47 | *Defined in [ThreeMap.interfaces.ts:22](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L22)* 48 | 49 | ___ 50 | 51 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.iview.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [IView](../interfaces/interfaces.iview.md) 2 | 3 | # Interface: IView 4 | 5 | Object that represents current ThreeMap view - contains 2 Tile arrays. 6 | 7 | ## Hierarchy 8 | 9 | **IView** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [toRemove](interfaces.iview.md#toremove) 16 | * [toRender](interfaces.iview.md#torender) 17 | 18 | --- 19 | 20 | ## Properties 21 | 22 | 23 | 24 | ### toRemove 25 | 26 | **● toRemove**: *[Tile](../classes/tile.tile-1.md)[]* 27 | 28 | *Defined in [ThreeMap.interfaces.ts:32](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L32)* 29 | 30 | List of tiles to be removed. 31 | 32 | ___ 33 | 34 | 35 | ### toRender 36 | 37 | **● toRender**: *[Tile](../classes/tile.tile-1.md)[]* 38 | 39 | *Defined in [ThreeMap.interfaces.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L36)* 40 | 41 | List of tiles to be added. 42 | 43 | ___ 44 | 45 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.iworkerdata.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [IWorkerData](../interfaces/interfaces.iworkerdata.md) 2 | 3 | # Interface: IWorkerData 4 | 5 | Data object used inside WebWorkers for building tiles. 6 | 7 | ## Hierarchy 8 | 9 | **IWorkerData** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [colData](interfaces.iworkerdata.md#coldata) 16 | * [cups](interfaces.iworkerdata.md#cups) 17 | * [feature](interfaces.iworkerdata.md#feature) 18 | * [inxData](interfaces.iworkerdata.md#inxdata) 19 | * [layerOrder](interfaces.iworkerdata.md#layerorder) 20 | * [tile](interfaces.iworkerdata.md#tile) 21 | * [vecData](interfaces.iworkerdata.md#vecdata) 22 | 23 | --- 24 | 25 | ## Properties 26 | 27 | 28 | 29 | ### colData 30 | 31 | **● colData**: *`number`[]* 32 | 33 | *Defined in [ThreeMap.interfaces.ts:198](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L198)* 34 | 35 | ___ 36 | 37 | 38 | ### cups 39 | 40 | **● cups**: *`object`* 41 | 42 | *Defined in [ThreeMap.interfaces.ts:199](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L199)* 43 | 44 | ___ 45 | 46 | 47 | ### feature 48 | 49 | **● feature**: *`VectorTileFeature`* 50 | 51 | *Defined in [ThreeMap.interfaces.ts:200](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L200)* 52 | 53 | ___ 54 | 55 | 56 | ### inxData 57 | 58 | **● inxData**: *`number`[]* 59 | 60 | *Defined in [ThreeMap.interfaces.ts:201](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L201)* 61 | 62 | ___ 63 | 64 | 65 | ### layerOrder 66 | 67 | **● layerOrder**: *`number`* 68 | 69 | *Defined in [ThreeMap.interfaces.ts:202](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L202)* 70 | 71 | ___ 72 | 73 | 74 | ### tile 75 | 76 | **● tile**: *[TilePrimitive](../modules/interfaces.md#tileprimitive)* 77 | 78 | *Defined in [ThreeMap.interfaces.ts:203](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L203)* 79 | 80 | ___ 81 | 82 | 83 | ### vecData 84 | 85 | **● vecData**: *`number`[]* 86 | 87 | *Defined in [ThreeMap.interfaces.ts:204](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L204)* 88 | 89 | ___ 90 | 91 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.iworkerevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [IWorkerEvent](../interfaces/interfaces.iworkerevent.md) 2 | 3 | # Interface: IWorkerEvent 4 | 5 | Event sent from WebWorker. 6 | 7 | ## Hierarchy 8 | 9 | **IWorkerEvent** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [data](interfaces.iworkerevent.md#data) 16 | * [target](interfaces.iworkerevent.md#target) 17 | 18 | --- 19 | 20 | ## Properties 21 | 22 | 23 | 24 | ### data 25 | 26 | **● data**: *[IWorkerEventData](interfaces.iworkereventdata.md)* 27 | 28 | *Defined in [ThreeMap.interfaces.ts:190](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L190)* 29 | 30 | ___ 31 | 32 | 33 | ### target 34 | 35 | **● target**: *`object`* 36 | 37 | *Defined in [ThreeMap.interfaces.ts:191](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L191)* 38 | 39 | ___ 40 | 41 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.iworkereventdata.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [IWorkerEventData](../interfaces/interfaces.iworkereventdata.md) 2 | 3 | # Interface: IWorkerEventData 4 | 5 | Data of event sent from WebWorker. 6 | 7 | ## Hierarchy 8 | 9 | **IWorkerEventData** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [realData](interfaces.iworkereventdata.md#realdata) 16 | * [type](interfaces.iworkereventdata.md#type) 17 | 18 | --- 19 | 20 | ## Properties 21 | 22 | 23 | 24 | ### realData 25 | 26 | **● realData**: *[ITileBuffers](interfaces.itilebuffers.md)* 27 | 28 | *Defined in [ThreeMap.interfaces.ts:182](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L182)* 29 | 30 | ___ 31 | 32 | 33 | ### type 34 | 35 | **● type**: *`string`* 36 | 37 | *Defined in [ThreeMap.interfaces.ts:183](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L183)* 38 | 39 | ___ 40 | 41 | -------------------------------------------------------------------------------- /docs/API/interfaces/interfaces.iworkermessage.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) > [IWorkerMessage](../interfaces/interfaces.iworkermessage.md) 2 | 3 | # Interface: IWorkerMessage 4 | 5 | Message sent to WebWorker 6 | 7 | ## Hierarchy 8 | 9 | **IWorkerMessage** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [id](interfaces.iworkermessage.md#id) 16 | * [style](interfaces.iworkermessage.md#style) 17 | * [url](interfaces.iworkermessage.md#url) 18 | 19 | --- 20 | 21 | ## Properties 22 | 23 | 24 | 25 | ### id 26 | 27 | **● id**: *`string`* 28 | 29 | *Defined in [ThreeMap.interfaces.ts:211](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L211)* 30 | 31 | ___ 32 | 33 | 34 | ### style 35 | 36 | **● style**: *[IStyle](interfaces.istyle.md)* 37 | 38 | *Defined in [ThreeMap.interfaces.ts:212](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L212)* 39 | 40 | ___ 41 | 42 | 43 | ### url 44 | 45 | **● url**: *`string`* 46 | 47 | *Defined in [ThreeMap.interfaces.ts:213](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L213)* 48 | 49 | ___ 50 | 51 | -------------------------------------------------------------------------------- /docs/API/interfaces/linestringconstructor.ilinesegment.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [LineStringConstructor](../modules/linestringconstructor.md) > [ILineSegment](../interfaces/linestringconstructor.ilinesegment.md) 2 | 3 | # Interface: ILineSegment 4 | 5 | ## Hierarchy 6 | 7 | **ILineSegment** 8 | 9 | ## Index 10 | 11 | ### Properties 12 | 13 | * [back](linestringconstructor.ilinesegment.md#back) 14 | * [front](linestringconstructor.ilinesegment.md#front) 15 | 16 | --- 17 | 18 | ## Properties 19 | 20 | 21 | 22 | ### back 23 | 24 | **● back**: *`object`* 25 | 26 | *Defined in [constructor/linestring.ts:7](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L7)* 27 | 28 | #### Type declaration 29 | 30 | left: [Vec3](../modules/interfaces.md#vec3) 31 | 32 | `Optional` normal: [Vec2](../modules/interfaces.md#vec2) 33 | 34 | right: [Vec3](../modules/interfaces.md#vec3) 35 | 36 | ___ 37 | 38 | 39 | ### front 40 | 41 | **● front**: *`object`* 42 | 43 | *Defined in [constructor/linestring.ts:12](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L12)* 44 | 45 | #### Type declaration 46 | 47 | left: [Vec3](../modules/interfaces.md#vec3) 48 | 49 | `Optional` normal: [Vec2](../modules/interfaces.md#vec2) 50 | 51 | right: [Vec3](../modules/interfaces.md#vec3) 52 | 53 | ___ 54 | 55 | -------------------------------------------------------------------------------- /docs/API/interfaces/threemapglobals.ithreemap.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [ThreeMapGlobals](../modules/threemapglobals.md) > [IThreeMap](../interfaces/threemapglobals.ithreemap.md) 2 | 3 | # Interface: IThreeMap 4 | 5 | ThreeMap globally-accessible values. 6 | 7 | ## Hierarchy 8 | 9 | **IThreeMap** 10 | 11 | ## Index 12 | 13 | ### Properties 14 | 15 | * [camera](threemapglobals.ithreemap.md#camera) 16 | * [controls](threemapglobals.ithreemap.md#controls) 17 | * [events](threemapglobals.ithreemap.md#events) 18 | * [frustum](threemapglobals.ithreemap.md#frustum) 19 | * [grid](threemapglobals.ithreemap.md#grid) 20 | * [material](threemapglobals.ithreemap.md#material) 21 | * [scene](threemapglobals.ithreemap.md#scene) 22 | * [style](threemapglobals.ithreemap.md#style) 23 | * [three_map](threemapglobals.ithreemap.md#three_map) 24 | 25 | --- 26 | 27 | ## Properties 28 | 29 | 30 | 31 | ### camera 32 | 33 | **● camera**: *`Camera`* 34 | 35 | *Defined in [ThreeMap.ts:24](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L24)* 36 | 37 | ThreeJS camera. 38 | 39 | ___ 40 | 41 | 42 | ### controls 43 | 44 | **● controls**: *`OrbitControls`* 45 | 46 | *Defined in [ThreeMap.ts:28](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L28)* 47 | 48 | ThreeJS controls. 49 | 50 | ___ 51 | 52 | 53 | ### events 54 | 55 | **● events**: *`Emitter`* 56 | 57 | *Defined in [ThreeMap.ts:32](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L32)* 58 | 59 | ___ 60 | 61 | 62 | ### frustum 63 | 64 | **● frustum**: *`Frustum`* 65 | 66 | *Defined in [ThreeMap.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L36)* 67 | 68 | Camera frustum for tiles calculations. 69 | 70 | ___ 71 | 72 | 73 | ### grid 74 | 75 | **● grid**: *[TileGrid](../classes/tilegrid.tilegrid-1.md)* 76 | 77 | *Defined in [ThreeMap.ts:40](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L40)* 78 | 79 | Tiles grid. 80 | 81 | ___ 82 | 83 | 84 | ### material 85 | 86 | **● material**: *`Material`* 87 | 88 | *Defined in [ThreeMap.ts:44](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L44)* 89 | 90 | ThreeMap's tiles' ThreeJS material. 91 | 92 | ___ 93 | 94 | 95 | ### scene 96 | 97 | **● scene**: *`Scene`* 98 | 99 | *Defined in [ThreeMap.ts:48](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L48)* 100 | 101 | ThreeJS scene. 102 | 103 | ___ 104 | 105 | 106 | ### style 107 | 108 | **● style**: *[IStyle](interfaces.istyle.md)* 109 | 110 | *Defined in [ThreeMap.ts:52](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L52)* 111 | 112 | ThreeMap style configuration. 113 | 114 | ___ 115 | 116 | 117 | ### three_map 118 | 119 | **● three_map**: *`Object3D`* 120 | 121 | *Defined in [ThreeMap.ts:56](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L56)* 122 | 123 | ThreeMap main object 124 | 125 | ___ 126 | 127 | -------------------------------------------------------------------------------- /docs/API/modules/extension.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Extension](../modules/extension.md) 2 | 3 | # External module: Extension 4 | 5 | ## Index 6 | 7 | ### Classes 8 | 9 | * [Extension](../classes/extension.extension-1.md) 10 | 11 | ### Interfaces 12 | 13 | * [IHandlers](../interfaces/extension.ihandlers.md) 14 | * [IOnFeatureEvent](../interfaces/extension.ionfeatureevent.md) 15 | * [IOnTileCreatedEvent](../interfaces/extension.iontilecreatedevent.md) 16 | * [IOnTileRemovedEvent](../interfaces/extension.iontileremovedevent.md) 17 | * [IOnUpdateEvent](../interfaces/extension.ionupdateevent.md) 18 | 19 | --- 20 | 21 | -------------------------------------------------------------------------------- /docs/API/modules/geometryconstructor.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [GeometryConstructor](../modules/geometryconstructor.md) 2 | 3 | # External module: GeometryConstructor 4 | 5 | ## Index 6 | 7 | ### Enumerations 8 | 9 | * [DataTypes](../enums/geometryconstructor.datatypes.md) 10 | 11 | ### Interfaces 12 | 13 | * [IResponse](../interfaces/geometryconstructor.iresponse.md) 14 | 15 | ### Variables 16 | 17 | * [layerOrderLevels](geometryconstructor.md#layerorderlevels) 18 | 19 | ### Functions 20 | 21 | * [cupBuilder](geometryconstructor.md#cupbuilder) 22 | * [readStyleFunction](geometryconstructor.md#readstylefunction) 23 | * [requestTile](geometryconstructor.md#requesttile) 24 | 25 | --- 26 | 27 | ## Variables 28 | 29 | 30 | 31 | ### `` layerOrderLevels 32 | 33 | **● layerOrderLevels**: *`number`[]* = [100, 100, 100, 80, 60, 50, 30, 25, 20, 20, 10, 5, 2, 1, 0.5, 0.1, 0.1] 34 | 35 | *Defined in [constructor/construct.ts:69](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L69)* 36 | 37 | Protection against z-fighting 38 | 39 | ___ 40 | 41 | ## Functions 42 | 43 | 44 | 45 | ### cupBuilder 46 | 47 | ▸ **cupBuilder**(style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*, workerDataBuffers: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*): `void` 48 | 49 | *Defined in [constructor/construct.ts:162](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L162)* 50 | 51 | Generates line's cups. 52 | *__example__*: `cupBuilder({...}, {...});` 53 | 54 | **Parameters:** 55 | 56 | | Param | Type | Description | 57 | | ------ | ------ | ------ | 58 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 59 | | workerDataBuffers | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 60 | 61 | **Returns:** `void` 62 | 63 | ___ 64 | 65 | 66 | ### readStyleFunction 67 | 68 | ▸ **readStyleFunction**(func: *`string`*, feature: *`object`*): `any` 69 | 70 | *Defined in [constructor/construct.ts:40](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L40)* 71 | 72 | Parses function string to function & executes it returning its value. 73 | *__example__*: `readStyleFunction('(feature) => {return feature.height}, {...});` 74 | 75 | **Parameters:** 76 | 77 | | Param | Type | Description | 78 | | ------ | ------ | ------ | 79 | | func | `string` | Function string. | 80 | | feature | `object` | MVT feature properties. | 81 | 82 | **Returns:** `any` 83 | 84 | ___ 85 | 86 | 87 | ### requestTile 88 | 89 | ▸ **requestTile**(url: *`string`*): `Promise`<`any`> 90 | 91 | *Defined in [constructor/construct.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L50)* 92 | 93 | Requests tile from given URL and returns its buffer asynchronously. 94 | *__example__*: `requestTile('https://awesometiles.com/10/15/12');` 95 | 96 | **Parameters:** 97 | 98 | | Param | Type | Description | 99 | | ------ | ------ | ------ | 100 | | url | `string` | Tile's URL. | 101 | 102 | **Returns:** `Promise`<`any`> 103 | 104 | ___ 105 | 106 | -------------------------------------------------------------------------------- /docs/API/modules/interfaces.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Interfaces](../modules/interfaces.md) 2 | 3 | # External module: Interfaces 4 | 5 | ## Index 6 | 7 | ### Interfaces 8 | 9 | * [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) 10 | * [IStyle](../interfaces/interfaces.istyle.md) 11 | * [ITileBuffers](../interfaces/interfaces.itilebuffers.md) 12 | * [ITileObject](../interfaces/interfaces.itileobject.md) 13 | * [IView](../interfaces/interfaces.iview.md) 14 | * [IWorkerData](../interfaces/interfaces.iworkerdata.md) 15 | * [IWorkerEvent](../interfaces/interfaces.iworkerevent.md) 16 | * [IWorkerEventData](../interfaces/interfaces.iworkereventdata.md) 17 | * [IWorkerMessage](../interfaces/interfaces.iworkermessage.md) 18 | 19 | ### Type aliases 20 | 21 | * [GeometryType](interfaces.md#geometrytype) 22 | * [TilePrimitive](interfaces.md#tileprimitive) 23 | * [Vec2](interfaces.md#vec2) 24 | * [Vec3](interfaces.md#vec3) 25 | * [styleFunction](interfaces.md#stylefunction) 26 | 27 | --- 28 | 29 | ## Type aliases 30 | 31 | 32 | 33 | ### GeometryType 34 | 35 | **ΤGeometryType**: * "POLYGON" | "LINESTRING" | "ALL" 36 | * 37 | 38 | *Defined in [ThreeMap.interfaces.ts:82](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L82)* 39 | 40 | ___ 41 | 42 | 43 | ### TilePrimitive 44 | 45 | **ΤTilePrimitive**: *[`number`, `number`, `number`]* 46 | 47 | *Defined in [ThreeMap.interfaces.ts:14](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L14)* 48 | 49 | Tile primitive is an array of tile coordinates & zoom level. 50 | 51 | ___ 52 | 53 | 54 | ### Vec2 55 | 56 | **ΤVec2**: * `number`[] | [`number`, `number`] 57 | * 58 | 59 | *Defined in [ThreeMap.interfaces.ts:87](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L87)* 60 | 61 | 2D Vector - array of x, y coords. 62 | 63 | ___ 64 | 65 | 66 | ### Vec3 67 | 68 | **ΤVec3**: * `number`[] | [`number`, `number`, `number`] 69 | * 70 | 71 | *Defined in [ThreeMap.interfaces.ts:92](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L92)* 72 | 73 | 3D Vector - array of x, y, z coords. 74 | 75 | ___ 76 | 77 | 78 | ### styleFunction 79 | 80 | **ΤstyleFunction**: *`function`* 81 | 82 | *Defined in [ThreeMap.interfaces.ts:100](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L100)* 83 | 84 | Function expression allowed in ThreeMap's style configuration. You get access to currently processed feature's properties. IT MUST RETURN VALUE OF SAME TYPE AS SPECIFIED! IT MUST BE WRITTEN AS FUNCTION EXPRESSION WITH FUNCTION KEYWORD (NO ARROW FUNCTIONS!) 85 | 86 | #### Type declaration 87 | ▸(feature: *`any`*): `number` | `boolean` | `string` 88 | 89 | **Parameters:** 90 | 91 | | Param | Type | 92 | | ------ | ------ | 93 | | feature | `any` | 94 | 95 | **Returns:** `number` | `boolean` | `string` 96 | 97 | ___ 98 | 99 | -------------------------------------------------------------------------------- /docs/API/modules/linestringconstructor.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [LineStringConstructor](../modules/linestringconstructor.md) 2 | 3 | # External module: LineStringConstructor 4 | 5 | ## Index 6 | 7 | ### Interfaces 8 | 9 | * [ILineSegment](../interfaces/linestringconstructor.ilinesegment.md) 10 | 11 | ### Functions 12 | 13 | * [line](linestringconstructor.md#line) 14 | * [lineSegment](linestringconstructor.md#linesegment) 15 | * [lineString](linestringconstructor.md#linestring) 16 | 17 | --- 18 | 19 | ## Functions 20 | 21 | 22 | 23 | ### line 24 | 25 | ▸ **line**(vertices: *`number`[][]*, data: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*, style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*): [IWorkerData](../interfaces/interfaces.iworkerdata.md) 26 | 27 | *Defined in [constructor/linestring.ts:92](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L92)* 28 | 29 | Generates line. 30 | *__example__*: `line([[1,2], [3,4]], {...}, {...});` 31 | 32 | **Parameters:** 33 | 34 | | Param | Type | Description | 35 | | ------ | ------ | ------ | 36 | | vertices | `number`[][] | Preprocessed vertices array. | 37 | | data | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 38 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 39 | 40 | **Returns:** [IWorkerData](../interfaces/interfaces.iworkerdata.md) 41 | 42 | ___ 43 | 44 | 45 | ### lineSegment 46 | 47 | ▸ **lineSegment**(v1: *[Vec2](interfaces.md#vec2)*, v2: *[Vec2](interfaces.md#vec2)*, data: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*, style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*): [ILineSegment](../interfaces/linestringconstructor.ilinesegment.md) 48 | 49 | *Defined in [constructor/linestring.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L50)* 50 | 51 | Generates line segment - line between 2 vectors. 52 | *__example__*: `lineSegment([1,2], [3,4] , {...}, {...});` 53 | 54 | **Parameters:** 55 | 56 | | Param | Type | Description | 57 | | ------ | ------ | ------ | 58 | | v1 | [Vec2](interfaces.md#vec2) | First vector. | 59 | | v2 | [Vec2](interfaces.md#vec2) | Second vector. | 60 | | data | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 61 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 62 | 63 | **Returns:** [ILineSegment](../interfaces/linestringconstructor.ilinesegment.md) 64 | 65 | ___ 66 | 67 | 68 | ### lineString 69 | 70 | ▸ **lineString**(data: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*, style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*): [IWorkerData](../interfaces/interfaces.iworkerdata.md) 71 | 72 | *Defined in [constructor/linestring.ts:25](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L25)* 73 | 74 | Parses data for line generation. 75 | *__example__*: `lineString({...}, {...});` 76 | 77 | **Parameters:** 78 | 79 | | Param | Type | Description | 80 | | ------ | ------ | ------ | 81 | | data | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 82 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 83 | 84 | **Returns:** [IWorkerData](../interfaces/interfaces.iworkerdata.md) 85 | 86 | ___ 87 | 88 | -------------------------------------------------------------------------------- /docs/API/modules/polygonconstructor.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [PolygonConstructor](../modules/polygonconstructor.md) 2 | 3 | # External module: PolygonConstructor 4 | 5 | ## Index 6 | 7 | ### Functions 8 | 9 | * [extrudedPolygon](polygonconstructor.md#extrudedpolygon) 10 | * [flatPolygon](polygonconstructor.md#flatpolygon) 11 | * [polygon](polygonconstructor.md#polygon) 12 | 13 | --- 14 | 15 | ## Functions 16 | 17 | 18 | 19 | ### extrudedPolygon 20 | 21 | ▸ **extrudedPolygon**(vertices: *`number`[][]*, data: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*, style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*): [IWorkerData](../interfaces/interfaces.iworkerdata.md) 22 | 23 | *Defined in [constructor/polygon.ts:64](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/polygon.ts#L64)* 24 | 25 | Generates extruded polygon - 3D Object. 26 | *__example__*: `extrudedPolygon(\[\[1,2\],\[3,4\],\[5,6\],\[1,2\]\], {...}, {...}); 27 | 28 | **Parameters:** 29 | 30 | | Param | Type | Description | 31 | | ------ | ------ | ------ | 32 | | vertices | `number`[][] | Preprocessed vertices array. | 33 | | data | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 34 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 35 | 36 | **Returns:** [IWorkerData](../interfaces/interfaces.iworkerdata.md) 37 | 38 | ___ 39 | 40 | 41 | ### flatPolygon 42 | 43 | ▸ **flatPolygon**(vertices: *`number`[][]*, data: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*, style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*): [IWorkerData](../interfaces/interfaces.iworkerdata.md) 44 | 45 | *Defined in [constructor/polygon.ts:45](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/polygon.ts#L45)* 46 | 47 | Generates flat polygon. 48 | *__example__*: `flatPolygon(\[\[1,2\],\[3,4\],\[5,6\],\[1,2\]\], {...}, {...}); 49 | 50 | **Parameters:** 51 | 52 | | Param | Type | Description | 53 | | ------ | ------ | ------ | 54 | | vertices | `number`[][] | Preprocessed vertices array. | 55 | | data | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 56 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 57 | 58 | **Returns:** [IWorkerData](../interfaces/interfaces.iworkerdata.md) 59 | 60 | ___ 61 | 62 | 63 | ### polygon 64 | 65 | ▸ **polygon**(data: *[IWorkerData](../interfaces/interfaces.iworkerdata.md)*, style: *[ILayerStyle](../interfaces/interfaces.ilayerstyle.md)*): [IWorkerData](../interfaces/interfaces.iworkerdata.md) 66 | 67 | *Defined in [constructor/polygon.ts:14](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/polygon.ts#L14)* 68 | 69 | Parses data for polygon generation. 70 | *__example__*: `polygon({...}, {...});` 71 | 72 | **Parameters:** 73 | 74 | | Param | Type | Description | 75 | | ------ | ------ | ------ | 76 | | data | [IWorkerData](../interfaces/interfaces.iworkerdata.md) | Data used for building tile. | 77 | | style | [ILayerStyle](../interfaces/interfaces.ilayerstyle.md) | Layer's style configuration. | 78 | 79 | **Returns:** [IWorkerData](../interfaces/interfaces.iworkerdata.md) 80 | 81 | ___ 82 | 83 | -------------------------------------------------------------------------------- /docs/API/modules/threemap.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [ThreeMap](../modules/threemap.md) 2 | 3 | # External module: ThreeMap 4 | 5 | ## Index 6 | 7 | ### Classes 8 | 9 | * [Map](../classes/threemap.map.md) 10 | 11 | --- 12 | 13 | -------------------------------------------------------------------------------- /docs/API/modules/threemapglobals.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [ThreeMapGlobals](../modules/threemapglobals.md) 2 | 3 | # External module: ThreeMapGlobals 4 | 5 | ## Index 6 | 7 | ### Interfaces 8 | 9 | * [IThreeMap](../interfaces/threemapglobals.ithreemap.md) 10 | 11 | --- 12 | 13 | -------------------------------------------------------------------------------- /docs/API/modules/tile.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Tile](../modules/tile.md) 2 | 3 | # External module: Tile 4 | 5 | ## Index 6 | 7 | ### Classes 8 | 9 | * [Tile](../classes/tile.tile-1.md) 10 | 11 | --- 12 | 13 | -------------------------------------------------------------------------------- /docs/API/modules/tilegrid.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [TileGrid](../modules/tilegrid.md) 2 | 3 | # External module: TileGrid 4 | 5 | ## Index 6 | 7 | ### Classes 8 | 9 | * [TileGrid](../classes/tilegrid.tilegrid-1.md) 10 | 11 | --- 12 | 13 | -------------------------------------------------------------------------------- /docs/API/modules/tilelist.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [TileList](../modules/tilelist.md) 2 | 3 | # External module: TileList 4 | 5 | ## Index 6 | 7 | ### Classes 8 | 9 | * [TileList](../classes/tilelist.tilelist-1.md) 10 | 11 | --- 12 | 13 | -------------------------------------------------------------------------------- /docs/API/modules/utils.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [Utils](../modules/utils.md) 2 | 3 | # External module: Utils 4 | 5 | ## Index 6 | 7 | ### Variables 8 | 9 | * [merc](utils.md#merc) 10 | * [mercatorExtend](utils.md#mercatorextend) 11 | * [scale](utils.md#scale) 12 | * [tileExtend](utils.md#tileextend) 13 | * [tileRegex](utils.md#tileregex) 14 | 15 | ### Functions 16 | 17 | * [buildFromWorkerData](utils.md#buildfromworkerdata) 18 | * [doesTileExists](utils.md#doestileexists) 19 | * [getCameraPosition](utils.md#getcameraposition) 20 | * [getTileFromMerc](utils.md#gettilefrommerc) 21 | * [getTilePosition](utils.md#gettileposition) 22 | * [getTileScale](utils.md#gettilescale) 23 | * [getURLForTile](utils.md#geturlfortile) 24 | * [getZoom](utils.md#getzoom) 25 | * [getZoomLevel](utils.md#getzoomlevel) 26 | * [intersects](utils.md#intersects) 27 | * [ll2merc](utils.md#ll2merc) 28 | * [merc2ll](utils.md#merc2ll) 29 | * [readStyle](utils.md#readstyle) 30 | * [realTile](utils.md#realtile) 31 | * [removeTile](utils.md#removetile) 32 | * [tileBounds](utils.md#tilebounds) 33 | 34 | --- 35 | 36 | ## Variables 37 | 38 | 39 | 40 | ### `` merc 41 | 42 | **● merc**: *`SphericalMercator`* = new SphericalMercator({ 43 | size: 2048, 44 | }) 45 | 46 | *Defined in [utils.ts:30](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L30)* 47 | 48 | SphericalMercator library instance for latLng to mercator coordinates conversion. 49 | 50 | ___ 51 | 52 | 53 | ### `` mercatorExtend 54 | 55 | **● mercatorExtend**: *`number`* = 20037510 56 | 57 | *Defined in [utils.ts:18](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L18)* 58 | 59 | X and y size of Mercator map. 60 | 61 | ___ 62 | 63 | 64 | ### `` scale 65 | 66 | **● scale**: *`number`* = mercatorExtend / tileExtend 67 | 68 | *Defined in [utils.ts:26](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L26)* 69 | 70 | Pre-calculated scale (tile to mercator size). 71 | 72 | ___ 73 | 74 | 75 | ### `` tileExtend 76 | 77 | **● tileExtend**: *`number`* = 2048 78 | 79 | *Defined in [utils.ts:22](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L22)* 80 | 81 | X and y size of tile. 82 | 83 | ___ 84 | 85 | 86 | ### `` tileRegex 87 | 88 | **● tileRegex**: *`RegExp`* = /{([zxy])}/g 89 | 90 | *Defined in [utils.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L36)* 91 | 92 | Regular expression for matching tile properties in url. 93 | 94 | ___ 95 | 96 | ## Functions 97 | 98 | 99 | 100 | ### buildFromWorkerData 101 | 102 | ▸ **buildFromWorkerData**(data: *[ITileBuffers](../interfaces/interfaces.itilebuffers.md)*): `void` 103 | 104 | *Defined in [utils.ts:230](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L230)* 105 | 106 | Processes data returned from worker & creates tile's mesh. 107 | *__example__*: `buildFromWorkerData({...});` 108 | 109 | **Parameters:** 110 | 111 | | Param | Type | Description | 112 | | ------ | ------ | ------ | 113 | | data | [ITileBuffers](../interfaces/interfaces.itilebuffers.md) | Position, color & normal buffers generated by WebWorker. | 114 | 115 | **Returns:** `void` 116 | 117 | ___ 118 | 119 | 120 | ### doesTileExists 121 | 122 | ▸ **doesTileExists**(quadkey: *`string`*): `boolean` 123 | 124 | *Defined in [utils.ts:156](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L156)* 125 | 126 | Checks if tile exists in grid. 127 | *__example__*: `doesTileExists('0123');` 128 | 129 | **Parameters:** 130 | 131 | | Param | Type | Description | 132 | | ------ | ------ | ------ | 133 | | quadkey | `string` | Tile's quadkey. | 134 | 135 | **Returns:** `boolean` 136 | 137 | ___ 138 | 139 | 140 | ### getCameraPosition 141 | 142 | ▸ **getCameraPosition**(): `number`[] 143 | 144 | *Defined in [utils.ts:212](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L212)* 145 | 146 | Returns camera base plane (x & z) position. 147 | *__example__*: `getCameraPosition()`;` 148 | 149 | **Returns:** `number`[] 150 | 151 | ___ 152 | 153 | 154 | ### getTileFromMerc 155 | 156 | ▸ **getTileFromMerc**(pos: *`number`[]*, z: *`number`*): [TilePrimitive](interfaces.md#tileprimitive) 157 | 158 | *Defined in [utils.ts:130](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L130)* 159 | 160 | Returns tile coordinates for given mercator x & y and zoom level values. 161 | *__example__*: `getTileFromMerc([130533.56363, 106826.5536], 14);` 162 | 163 | **Parameters:** 164 | 165 | | Param | Type | Description | 166 | | ------ | ------ | ------ | 167 | | pos | `number`[] | Array of mercator x & y coordinates. | 168 | | z | `number` | Specified zoom level. | 169 | 170 | **Returns:** [TilePrimitive](interfaces.md#tileprimitive) 171 | 172 | ___ 173 | 174 | 175 | ### getTilePosition 176 | 177 | ▸ **getTilePosition**(id: *`string`*): `number`[] 178 | 179 | *Defined in [utils.ts:177](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L177)* 180 | 181 | Returns given tile's center in mercator coordinates. 182 | *__example__*: `getTilePosition('0123');` 183 | 184 | **Parameters:** 185 | 186 | | Param | Type | Description | 187 | | ------ | ------ | ------ | 188 | | id | `string` | Tile's quadkey. | 189 | 190 | **Returns:** `number`[] 191 | 192 | ___ 193 | 194 | 195 | ### getTileScale 196 | 197 | ▸ **getTileScale**(id: *`string`*): `number` 198 | 199 | *Defined in [utils.ts:197](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L197)* 200 | 201 | Returns number representing x and y scale for resizing tile local coordinates to mercator coordinates. 202 | *__example__*: `getTileScale('0123');` 203 | 204 | **Parameters:** 205 | 206 | | Param | Type | Description | 207 | | ------ | ------ | ------ | 208 | | id | `string` | Tile's quadkey. | 209 | 210 | **Returns:** `number` 211 | 212 | ___ 213 | 214 | 215 | ### getURLForTile 216 | 217 | ▸ **getURLForTile**(tileObject: *[ITileObject](../interfaces/interfaces.itileobject.md)*): `string` 218 | 219 | *Defined in [utils.ts:44](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L44)* 220 | 221 | Get url for tile object. 222 | *__example__*: `getURLForTile({x: 1, y: 3, z: 7);` 223 | 224 | **Parameters:** 225 | 226 | | Param | Type | Description | 227 | | ------ | ------ | ------ | 228 | | tileObject | [ITileObject](../interfaces/interfaces.itileobject.md) | Tile primitive represented as object of x, y, z values. | 229 | 230 | **Returns:** `string` 231 | 232 | ___ 233 | 234 | 235 | ### getZoom 236 | 237 | ▸ **getZoom**(): `number` 238 | 239 | *Defined in [utils.ts:220](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L220)* 240 | 241 | Returns distance from controls' target to camera. 242 | *__example__*: `getZoom();` 243 | 244 | **Returns:** `number` 245 | 246 | ___ 247 | 248 | 249 | ### getZoomLevel 250 | 251 | ▸ **getZoomLevel**(distance: *`number`*): `number` 252 | 253 | *Defined in [utils.ts:142](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L142)* 254 | 255 | Converts distance from camera to controls target into zoom level. 256 | *__example__*: `getZoomLevel(357200);` 257 | 258 | **Parameters:** 259 | 260 | | Param | Type | Description | 261 | | ------ | ------ | ------ | 262 | | distance | `number` | Distance between camera and controls target. | 263 | 264 | **Returns:** `number` 265 | 266 | ___ 267 | 268 | 269 | ### intersects 270 | 271 | ▸ **intersects**(bounds: *`Box3`*): `boolean` 272 | 273 | *Defined in [utils.ts:271](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L271)* 274 | 275 | Checks if bounding box intersects camera's frustum. 276 | *__example__*: `intersects(new THREE.Box3(...));` 277 | 278 | **Parameters:** 279 | 280 | | Param | Type | Description | 281 | | ------ | ------ | ------ | 282 | | bounds | `Box3` | Bounding box. | 283 | 284 | **Returns:** `boolean` 285 | 286 | ___ 287 | 288 | 289 | ### ll2merc 290 | 291 | ▸ **ll2merc**(ll: *`number`[]*): `number`[] 292 | 293 | *Defined in [utils.ts:108](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L108)* 294 | 295 | Convert longitude - latitude coordinates to mercator coordinates. 296 | *__example__*: `ll2merc([77.35262, 40.2525]);` 297 | 298 | **Parameters:** 299 | 300 | | Param | Type | Description | 301 | | ------ | ------ | ------ | 302 | | ll | `number`[] | Array of longitude & latitude coordinates. | 303 | 304 | **Returns:** `number`[] 305 | Array of mercator x & y coordinates. 306 | 307 | ___ 308 | 309 | 310 | ### merc2ll 311 | 312 | ▸ **merc2ll**(xy: *`number`[]*): `number`[] 313 | 314 | *Defined in [utils.ts:119](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L119)* 315 | 316 | Converts mercator coordinates to longitude - latitude coordinates. 317 | *__example__*: `ThreeMap.mercToLonLat([462073.1353, 295052.562]);` 318 | 319 | **Parameters:** 320 | 321 | | Param | Type | Description | 322 | | ------ | ------ | ------ | 323 | | xy | `number`[] | Array of mercator x & y coordinates. | 324 | 325 | **Returns:** `number`[] 326 | Array of longitude & latitude coordinates. 327 | 328 | ___ 329 | 330 | 331 | ### readStyle 332 | 333 | ▸ **readStyle**(style: *[IStyle](../interfaces/interfaces.istyle.md)*): [IStyle](../interfaces/interfaces.istyle.md) 334 | 335 | *Defined in [utils.ts:65](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L65)* 336 | 337 | Parses ThreeMap style configuration and applies default values. 338 | *__example__*: `readStyle({...});` 339 | 340 | **Parameters:** 341 | 342 | | Param | Type | Description | 343 | | ------ | ------ | ------ | 344 | | style | [IStyle](../interfaces/interfaces.istyle.md) | Style configuration. | 345 | 346 | **Returns:** [IStyle](../interfaces/interfaces.istyle.md) 347 | 348 | ___ 349 | 350 | 351 | ### realTile 352 | 353 | ▸ **realTile**(tile: *[TilePrimitive](interfaces.md#tileprimitive)*): `boolean` 354 | 355 | *Defined in [utils.ts:166](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L166)* 356 | 357 | Checks if tile coordinates are in specified bounds (max is 2^zoom level). 358 | *__example__*: `realTile([3,4,4]);` 359 | 360 | **Parameters:** 361 | 362 | | Param | Type | Description | 363 | | ------ | ------ | ------ | 364 | | tile | [TilePrimitive](interfaces.md#tileprimitive) | Tile to be checked. | 365 | 366 | **Returns:** `boolean` 367 | 368 | ___ 369 | 370 | 371 | ### removeTile 372 | 373 | ▸ **removeTile**(quadkey: *`string`*): `void` 374 | 375 | *Defined in [utils.ts:280](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L280)* 376 | 377 | Removes tile from grid & disposes its geometry. 378 | *__example__*: `removeTile('0123');` 379 | 380 | **Parameters:** 381 | 382 | | Param | Type | Description | 383 | | ------ | ------ | ------ | 384 | | quadkey | `string` | Quadkey of tile to remove. | 385 | 386 | **Returns:** `void` 387 | 388 | ___ 389 | 390 | 391 | ### tileBounds 392 | 393 | ▸ **tileBounds**(tile: *`string`*): `Box3` 394 | 395 | *Defined in [utils.ts:255](https://github.com/areknawo/ThreeMap/blob/master/src/utils.ts#L255)* 396 | 397 | Returns bounding box for tile. 398 | *__example__*: `tileBounds('0123');` 399 | 400 | **Parameters:** 401 | 402 | | Param | Type | Description | 403 | | ------ | ------ | ------ | 404 | | tile | `string` | Tile's quadkey to get bounds for. | 405 | 406 | **Returns:** `Box3` 407 | 408 | ___ 409 | 410 | -------------------------------------------------------------------------------- /docs/API/modules/workerpool.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](../README.md) > [WorkerPool](../modules/workerpool.md) 2 | 3 | # External module: WorkerPool 4 | 5 | ## Index 6 | 7 | ### Classes 8 | 9 | * [WorkerPool](../classes/workerpool.workerpool-1.md) 10 | 11 | ### Variables 12 | 13 | * [pool](workerpool.md#pool) 14 | 15 | ### Functions 16 | 17 | * [cancelTask](workerpool.md#canceltask) 18 | * [initWorkerPool](workerpool.md#initworkerpool) 19 | * [startWorker](workerpool.md#startworker) 20 | 21 | --- 22 | 23 | ## Variables 24 | 25 | 26 | 27 | ### `` pool 28 | 29 | **● pool**: *[WorkerPool](../classes/workerpool.workerpool-1.md)* 30 | 31 | *Defined in [workerpool.ts:73](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L73)* 32 | 33 | ___ 34 | 35 | ## Functions 36 | 37 | 38 | 39 | ### cancelTask 40 | 41 | ▸ **cancelTask**(id: *`string`*): `void` 42 | 43 | *Defined in [workerpool.ts:104](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L104)* 44 | 45 | Remove task from WorkerPool's queue. 46 | *__example__*: `cancelTask('0123');` 47 | 48 | **Parameters:** 49 | 50 | | Param | Type | Description | 51 | | ------ | ------ | ------ | 52 | | id | `string` | ID of task to be removed. | 53 | 54 | **Returns:** `void` 55 | 56 | ___ 57 | 58 | 59 | ### initWorkerPool 60 | 61 | ▸ **initWorkerPool**(): `void` 62 | 63 | *Defined in [workerpool.ts:80](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L80)* 64 | 65 | Creates globally-accessible WorkerPool instance. 66 | *__example__*: `initWorkerPool();` 67 | 68 | **Returns:** `void` 69 | 70 | ___ 71 | 72 | 73 | ### startWorker 74 | 75 | ▸ **startWorker**(message: *[IWorkerMessage](../interfaces/interfaces.iworkermessage.md)*): `void` 76 | 77 | *Defined in [workerpool.ts:94](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L94)* 78 | 79 | Sends task to WorkerPool to be handled by worker. 80 | *__example__*: `startWorker({...});` 81 | 82 | **Parameters:** 83 | 84 | | Param | Type | Description | 85 | | ------ | ------ | ------ | 86 | | message | [IWorkerMessage](../interfaces/interfaces.iworkermessage.md) | Message to be sent to worker. | 87 | 88 | **Returns:** `void` 89 | 90 | ___ 91 | 92 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | 2 | # ThreeMap Dev 0.0.1 :earth_americas::earth_africa::earth_asia: 3 | 4 | !> It's highly **Work In Progress** - there is still a lot to be done. 5 | *Do not use it in production!* 6 | If you're willing to help :heartpulse: - checkout **Contribiution guide**. 7 | 8 | Library for high-quality :high_brightness: fully-customizable vector maps 9 | built with THREE.JS for creating stunning :sunglasses: visualizations with ease. 10 | 11 | ## Installation 12 | 13 | Just run:
14 | `npm install three-map`
15 | Or use cdn from [rawgit](https://rawgit.com/areknawo/ThreeMap/master/build/ThreeMap.min.js) 16 | 17 | ## Usage 18 | 19 | As easy as installation:
20 | `new ThreeMap.Map({camera, controls, style})`
21 | camera - THREE.JS camera 22 | controls - THREE.JS controls e.g. OrbitControls 23 | style - ThreeMap style config [(checkout API)](api-interfaces-interfaces.istyle) 24 | 25 | ## Motivation 26 | 27 | I needed to have nice 3D Map in my app. Of course, there are some other libraries, 28 | but each one of them has some disadvantage for my use case: 29 | * [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/) - great library, 30 | but without more advanced visualization features. If you don't have to 31 | use 3D models etc. you should definitely check it out. 32 | * [Vizicities](https://github.com/UDST/vizicities) - almost the same as this library, 33 | but doesn't support map customization as much - you have to load tiles images 34 | for base-map ( roads especially ) and 3D tiles for buildings. 35 | * [Deck GL](http://uber.github.io/deck.gl) - based on Mapbox GL JS with great 36 | support for visualization, almost ideal. Limited only by Mapbox GL 60 degrees 37 | pitch limit, and the fact that use second GL context for its content 38 | (at least at the time of writing, see [this issue](https://github.com/mapbox/mapbox-gl-js/issues/6456) 39 | if you're interested. 40 | 41 | So ThreeMap was created: 42 | * Visualisation is great, as ThreeMap is only a THREE.JS object, so you can use all of THREE.JS goodness. 43 | * Everything is constructed from MVT tiles, no need for textures & images. 44 | * Provides a quite customizable configuration's options. 45 | * **Still in development & buggy - so still a lot of work to do.** 46 | -------------------------------------------------------------------------------- /docs/_coverpage.md: -------------------------------------------------------------------------------- 1 | # ThreeMap Dev 0.0.1 2 | 3 | > THREE.JS visualization library 4 | 5 | * In-development 6 | * Simple and lightweight (~17kB gzipped) 7 | * Customizable 8 | 9 | 10 | [GitHub](https://github.com/areknawo/ThreeMap/) 11 | [Get Started](/README.md) 12 | 13 | 14 | ![color](#3F3F3F) 15 | -------------------------------------------------------------------------------- /docs/_sidebar.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | * ## [Home](README.md) 4 | * ## [Contribute](contribute.md) 5 | * ## [API](api-readme.md) 6 | 7 | * [Extension](api-modules-extension.md) 8 | * [GeometryConstructor](api-modules-geometryconstructor.md) 9 | * [Interfaces](api-modules-interfaces.md) 10 | * [LineStringConstructor](api-modules-linestringconstructor.md) 11 | * [PolygonConstructor](api-modules-polygonconstructor.md) 12 | * [ThreeMap](api-modules-threemap.md) 13 | * [ThreeMapGlobals](api-modules-threemapglobals.md) 14 | * [Tile](api-modules-tile.md) 15 | * [TileGrid](api-modules-tilegrid.md) 16 | * [TileList](api-modules-tilelist.md) 17 | * [Utils](api-modules-utils.md) 18 | * [WorkerPool](api-modules-workerpool.md) 19 | -------------------------------------------------------------------------------- /docs/api-classes-extension.extension-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) > [Extension](api-classes-extension.extension-1.md) 2 | 3 | 4 | 5 | ## Class: Extension 6 | 7 | 8 | Base class provided for creating ThreeMap Extensions 9 | 10 | ### Constructors 11 | 12 | * [constructor](api-classes-extension.extension-1.md#constructor) 13 | 14 | 15 | ### Properties 16 | 17 | * [map](api-classes-extension.extension-1.md#map) 18 | * [onFeature](api-classes-extension.extension-1.md#onfeature) 19 | * [onTileCreated](api-classes-extension.extension-1.md#ontilecreated) 20 | * [onTileRemoved](api-classes-extension.extension-1.md#ontileremoved) 21 | * [onUpdate](api-classes-extension.extension-1.md#onupdate) 22 | * [style](api-classes-extension.extension-1.md#style) 23 | 24 | 25 | 26 | --- 27 | ## Constructors 28 | 29 | 30 | 31 | ### ⊕ **new Extension**(handlers: *[IHandlers](api-interfaces-extension.ihandlers.md)*): [Extension](api-classes-extension.extension-1.md) 32 | 33 | 34 | *Defined in [Extension.ts:70](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L70)* 35 | 36 | 37 | *__example__*: `new Extension({onFeature: ()=>{}, onTileCreated: ()=>{}, onTileRemoved: ()=>{}, onUpdate: ()=>{}});` 38 | 39 | 40 | 41 | **Parameters:** 42 | 43 | | Param | Type | Description | 44 | | ------ | ------ | ------ | 45 | | handlers | [IHandlers](api-interfaces-extension.ihandlers.md) | Functions to apply for ThreeMap's corresponding events. | 46 | 47 | 48 | 49 | 50 | 51 | **Returns:** [Extension](api-classes-extension.extension-1.md) 52 | 53 | --- 54 | 55 | 56 | ## Properties 57 | 58 | 59 | ### map 60 | 61 | **● map**: *`Object3D`* 62 | 63 | *Defined in [Extension.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L50)* 64 | 65 | 66 | 67 | ThreeMap ThreeJS base object - tiles container 68 | 69 | 70 | 71 | 72 | ___ 73 | 74 | 75 | 76 | ### onFeature 77 | 78 | **● onFeature**: *`function`* 79 | 80 | *Defined in [Extension.ts:54](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L54)* 81 | 82 | 83 | 84 | Function to be executed when new tile feature is loaded. 85 | 86 | #### Type declaration 87 | ►(e: *[IOnFeatureEvent](api-interfaces-extension.ionfeatureevent.md)*): `__type` 88 | 89 | 90 | 91 | **Parameters:** 92 | 93 | | Param | Type | Description | 94 | | ------ | ------ | ------ | 95 | | e | [IOnFeatureEvent](api-interfaces-extension.ionfeatureevent.md) | - | 96 | 97 | 98 | 99 | 100 | 101 | **Returns:** `__type` 102 | 103 | 104 | 105 | 106 | 107 | 108 | ___ 109 | 110 | 111 | 112 | ### onTileCreated 113 | 114 | **● onTileCreated**: *`function`* 115 | 116 | *Defined in [Extension.ts:58](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L58)* 117 | 118 | 119 | 120 | Function to be executed when new tile is added to ThreeMap parent element 121 | 122 | #### Type declaration 123 | ►(e: *[IOnTileCreatedEvent](api-interfaces-extension.iontilecreatedevent.md)*): `__type` 124 | 125 | 126 | 127 | **Parameters:** 128 | 129 | | Param | Type | Description | 130 | | ------ | ------ | ------ | 131 | | e | [IOnTileCreatedEvent](api-interfaces-extension.iontilecreatedevent.md) | - | 132 | 133 | 134 | 135 | 136 | 137 | **Returns:** `__type` 138 | 139 | 140 | 141 | 142 | 143 | 144 | ___ 145 | 146 | 147 | 148 | ### onTileRemoved 149 | 150 | **● onTileRemoved**: *`function`* 151 | 152 | *Defined in [Extension.ts:62](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L62)* 153 | 154 | 155 | 156 | Function to be executed when tile is removed from ThreeMap parent element 157 | 158 | #### Type declaration 159 | ►(e: *[IOnTileRemovedEvent](api-interfaces-extension.iontileremovedevent.md)*): `__type` 160 | 161 | 162 | 163 | **Parameters:** 164 | 165 | | Param | Type | Description | 166 | | ------ | ------ | ------ | 167 | | e | [IOnTileRemovedEvent](api-interfaces-extension.iontileremovedevent.md) | - | 168 | 169 | 170 | 171 | 172 | 173 | **Returns:** `__type` 174 | 175 | 176 | 177 | 178 | 179 | 180 | ___ 181 | 182 | 183 | 184 | ### onUpdate 185 | 186 | **● onUpdate**: *`function`* 187 | 188 | *Defined in [Extension.ts:66](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L66)* 189 | 190 | 191 | 192 | Function to be executed on every ThreeJS controls update - e.g. pan, move etc. 193 | 194 | #### Type declaration 195 | ►(e: *[IOnUpdateEvent](api-interfaces-extension.ionupdateevent.md)*): `__type` 196 | 197 | 198 | 199 | **Parameters:** 200 | 201 | | Param | Type | Description | 202 | | ------ | ------ | ------ | 203 | | e | [IOnUpdateEvent](api-interfaces-extension.ionupdateevent.md) | - | 204 | 205 | 206 | 207 | 208 | 209 | **Returns:** `__type` 210 | 211 | 212 | 213 | 214 | 215 | 216 | ___ 217 | 218 | 219 | 220 | ### style 221 | 222 | **● style**: *[IStyle](api-interfaces-interfaces.istyle.md)* 223 | 224 | *Defined in [Extension.ts:70](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L70)* 225 | 226 | 227 | 228 | ThreeMap style configuration object 229 | 230 | 231 | 232 | 233 | ___ 234 | 235 | 236 | -------------------------------------------------------------------------------- /docs/api-classes-tile.tile-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Tile](api-modules-tile.md) > [Tile](api-classes-tile.tile-1.md) 2 | 3 | 4 | 5 | ## Class: Tile 6 | 7 | 8 | Full-fledged tile - used for View instances 9 | 10 | ### Constructors 11 | 12 | * [constructor](api-classes-tile.tile-1.md#constructor) 13 | 14 | 15 | ### Properties 16 | 17 | * [bounds](api-classes-tile.tile-1.md#bounds) 18 | * [id](api-classes-tile.tile-1.md#id) 19 | * [x](api-classes-tile.tile-1.md#x) 20 | * [y](api-classes-tile.tile-1.md#y) 21 | * [z](api-classes-tile.tile-1.md#z) 22 | 23 | 24 | ### Methods 25 | 26 | * [build](api-classes-tile.tile-1.md#build) 27 | * [getBounds](api-classes-tile.tile-1.md#getbounds) 28 | * [remove](api-classes-tile.tile-1.md#remove) 29 | 30 | 31 | 32 | --- 33 | ## Constructors 34 | 35 | 36 | 37 | ### ⊕ **new Tile**(tile: *[TilePrimitive](api-modules-interfaces.md#tileprimitive)*, id?: *`string`*): [Tile](api-classes-tile.tile-1.md) 38 | 39 | 40 | *Defined in [tile.ts:39](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L39)* 41 | 42 | 43 | *__example__*: `new Tile([10, 15, 8], "00003232");` 44 | 45 | 46 | 47 | **Parameters:** 48 | 49 | | Param | Type | Description | 50 | | ------ | ------ | ------ | 51 | | tile | [TilePrimitive](api-modules-interfaces.md#tileprimitive) | Array of tile coordinates [x,y,z]. | 52 | | id | `string` | Optional pre-generated tile's quadkey. | 53 | 54 | 55 | 56 | 57 | 58 | **Returns:** [Tile](api-classes-tile.tile-1.md) 59 | 60 | --- 61 | 62 | 63 | ## Properties 64 | 65 | 66 | ### bounds 67 | 68 | **● bounds**: *`Box3`* 69 | 70 | *Defined in [tile.ts:19](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L19)* 71 | 72 | 73 | 74 | Tile's bounds 75 | 76 | 77 | 78 | 79 | ___ 80 | 81 | 82 | 83 | ### id 84 | 85 | **● id**: *`string`* 86 | 87 | *Defined in [tile.ts:23](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L23)* 88 | 89 | 90 | 91 | Tile's id a.k.a. QuadKey 92 | 93 | 94 | 95 | 96 | ___ 97 | 98 | 99 | 100 | ### x 101 | 102 | **● x**: *`number`* 103 | 104 | *Defined in [tile.ts:27](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L27)* 105 | 106 | 107 | 108 | Tile's x coordinate 109 | 110 | 111 | 112 | 113 | ___ 114 | 115 | 116 | 117 | ### y 118 | 119 | **● y**: *`number`* 120 | 121 | *Defined in [tile.ts:31](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L31)* 122 | 123 | 124 | 125 | Tile's y coordinate 126 | 127 | 128 | 129 | 130 | ___ 131 | 132 | 133 | 134 | ### z 135 | 136 | **● z**: *`number`* 137 | 138 | *Defined in [tile.ts:35](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L35)* 139 | 140 | 141 | 142 | Tile's zoom level 143 | 144 | 145 | 146 | 147 | ___ 148 | 149 | 150 | ## Methods 151 | 152 | 153 | ### build 154 | 155 | ► **build**(): `void` 156 | 157 | 158 | 159 | *Defined in [tile.ts:57](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L57)* 160 | 161 | 162 | 163 | Send task to worker to start creating geometry. 164 | *__example__*: `Tile.build();` 165 | 166 | 167 | 168 | 169 | 170 | **Returns:** `void` 171 | 172 | 173 | 174 | 175 | 176 | ___ 177 | 178 | 179 | 180 | ### getBounds 181 | 182 | ► **getBounds**(): `Box3` 183 | 184 | 185 | 186 | *Defined in [tile.ts:66](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L66)* 187 | 188 | 189 | 190 | Get tile's bounds. 191 | *__example__*: `Tile.getBounds();` 192 | 193 | 194 | 195 | 196 | 197 | **Returns:** `Box3` 198 | ThreeJS bounding box. 199 | 200 | 201 | 202 | 203 | 204 | ___ 205 | 206 | 207 | 208 | ### remove 209 | 210 | ► **remove**(): `void` 211 | 212 | 213 | 214 | *Defined in [tile.ts:74](https://github.com/areknawo/ThreeMap/blob/master/src/tile.ts#L74)* 215 | 216 | 217 | 218 | Remove tile from grid. 219 | *__example__*: `Tile.remove();` 220 | 221 | 222 | 223 | 224 | 225 | **Returns:** `void` 226 | 227 | 228 | 229 | 230 | 231 | ___ 232 | 233 | 234 | -------------------------------------------------------------------------------- /docs/api-classes-tilegrid.tilegrid-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [TileGrid](api-modules-tilegrid.md) > [TileGrid](api-classes-tilegrid.tilegrid-1.md) 2 | 3 | 4 | 5 | ## Class: TileGrid 6 | 7 | 8 | Grid - main tile-grouping unit 9 | 10 | ### Properties 11 | 12 | * [position](api-classes-tilegrid.tilegrid-1.md#position) 13 | * [tiles](api-classes-tilegrid.tilegrid-1.md#tiles) 14 | * [zoom](api-classes-tilegrid.tilegrid-1.md#zoom) 15 | 16 | 17 | ### Methods 18 | 19 | * [getTilesForView](api-classes-tilegrid.tilegrid-1.md#gettilesforview) 20 | * [update](api-classes-tilegrid.tilegrid-1.md#update) 21 | * [render](api-classes-tilegrid.tilegrid-1.md#render) 22 | 23 | 24 | 25 | --- 26 | ## Properties 27 | 28 | 29 | ### position 30 | 31 | **● position**: *`number`[]* 32 | 33 | *Defined in [tilegrid.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L36)* 34 | 35 | 36 | 37 | Current mercator position 38 | 39 | 40 | 41 | 42 | ___ 43 | 44 | 45 | 46 | ### tiles 47 | 48 | **● tiles**: *[TileList](api-classes-tilelist.tilelist-1.md)* 49 | 50 | *Defined in [tilegrid.ts:40](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L40)* 51 | 52 | 53 | 54 | Current tiles in view 55 | 56 | 57 | 58 | 59 | ___ 60 | 61 | 62 | 63 | ### zoom 64 | 65 | **● zoom**: *`number`* 66 | 67 | *Defined in [tilegrid.ts:44](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L44)* 68 | 69 | 70 | 71 | Current zoom level 72 | 73 | 74 | 75 | 76 | ___ 77 | 78 | 79 | ## Methods 80 | 81 | 82 | ### getTilesForView 83 | 84 | ► **getTilesForView**(): [TileList](api-classes-tilelist.tilelist-1.md) 85 | 86 | 87 | 88 | *Defined in [tilegrid.ts:55](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L55)* 89 | 90 | 91 | 92 | Gets tiles inside current view. 93 | *__example__*: var gridInstance = new Grid(); 94 | gridInstance.getTilesForView(); 95 | 96 | 97 | 98 | 99 | 100 | **Returns:** [TileList](api-classes-tilelist.tilelist-1.md) 101 | Tiles in view. 102 | 103 | 104 | 105 | 106 | 107 | ___ 108 | 109 | 110 | 111 | ### update 112 | 113 | ► **update**(): `void` 114 | 115 | 116 | 117 | *Defined in [tilegrid.ts:81](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L81)* 118 | 119 | 120 | 121 | Updates view on change. 122 | *__example__*: `gridInstance.update();` 123 | 124 | 125 | 126 | 127 | 128 | **Returns:** `void` 129 | 130 | 131 | 132 | 133 | 134 | ___ 135 | 136 | 137 | 138 | ### «Static» render 139 | 140 | ► **render**(view: *[IView](api-interfaces-interfaces.iview.md)*): `void` 141 | 142 | 143 | 144 | *Defined in [tilegrid.ts:21](https://github.com/areknawo/ThreeMap/blob/master/src/tilegrid.ts#L21)* 145 | 146 | 147 | 148 | 'Renders' tiles - sends tasks to build & remove them. 149 | *__example__*: `Grid.render({toRender: [...], toRemove: [...]});` 150 | 151 | 152 | 153 | **Parameters:** 154 | 155 | | Param | Type | Description | 156 | | ------ | ------ | ------ | 157 | | view | [IView](api-interfaces-interfaces.iview.md) | List of tiles to render & remove. | 158 | 159 | 160 | 161 | 162 | 163 | **Returns:** `void` 164 | 165 | 166 | 167 | 168 | 169 | ___ 170 | 171 | 172 | -------------------------------------------------------------------------------- /docs/api-classes-workerpool.workerpool-1.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [WorkerPool](api-modules-workerpool.md) > [WorkerPool](api-classes-workerpool.workerpool-1.md) 2 | 3 | 4 | 5 | ## Class: WorkerPool 6 | 7 | 8 | Pool of WebWorkers for handling hard task outside main thread. 9 | 10 | ### Constructors 11 | 12 | * [constructor](api-classes-workerpool.workerpool-1.md#constructor) 13 | 14 | 15 | ### Properties 16 | 17 | * [taskList](api-classes-workerpool.workerpool-1.md#tasklist) 18 | 19 | 20 | ### Methods 21 | 22 | * [checkoutTasks](api-classes-workerpool.workerpool-1.md#checkouttasks) 23 | * [startWorker](api-classes-workerpool.workerpool-1.md#startworker) 24 | 25 | 26 | 27 | --- 28 | ## Constructors 29 | 30 | 31 | 32 | ### ⊕ **new WorkerPool**(numOfWorkers: *`number`*, callback: *`function`*): [WorkerPool](api-classes-workerpool.workerpool-1.md) 33 | 34 | 35 | *Defined in [workerpool.ts:16](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L16)* 36 | 37 | 38 | *__example__*: `var pool = new WorkerPool(4, (e)=>{...});` 39 | 40 | 41 | 42 | **Parameters:** 43 | 44 | | Param | Type | Description | 45 | | ------ | ------ | ------ | 46 | | numOfWorkers | `number` | Number of workers to be created in pool. | 47 | | callback | `function` | Function to be called on Worker's job end. | 48 | 49 | 50 | 51 | 52 | 53 | **Returns:** [WorkerPool](api-classes-workerpool.workerpool-1.md) 54 | 55 | --- 56 | 57 | 58 | ## Properties 59 | 60 | 61 | ### taskList 62 | 63 | **● taskList**: *`any`[]* 64 | 65 | *Defined in [workerpool.ts:14](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L14)* 66 | 67 | 68 | 69 | 70 | 71 | ___ 72 | 73 | 74 | ## Methods 75 | 76 | 77 | ### checkoutTasks 78 | 79 | ► **checkoutTasks**(): `void` 80 | 81 | 82 | 83 | *Defined in [workerpool.ts:48](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L48)* 84 | 85 | 86 | 87 | Offloads tasks to workers. 88 | *__example__*: `pool.checkoutTasks();` 89 | 90 | 91 | 92 | 93 | 94 | **Returns:** `void` 95 | 96 | 97 | 98 | 99 | 100 | ___ 101 | 102 | 103 | 104 | ### startWorker 105 | 106 | ► **startWorker**(message: *[IWorkerMessage](api-interfaces-interfaces.iworkermessage.md)*): `void` 107 | 108 | 109 | 110 | *Defined in [workerpool.ts:62](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L62)* 111 | 112 | 113 | 114 | Add task to the list for it to be handled by worker. 115 | *__example__*: `pool.startWorker({...});` 116 | 117 | 118 | 119 | **Parameters:** 120 | 121 | | Param | Type | Description | 122 | | ------ | ------ | ------ | 123 | | message | [IWorkerMessage](api-interfaces-interfaces.iworkermessage.md) | Data to be sent to worker. | 124 | 125 | 126 | 127 | 128 | 129 | **Returns:** `void` 130 | 131 | 132 | 133 | 134 | 135 | ___ 136 | 137 | 138 | -------------------------------------------------------------------------------- /docs/api-enums-geometryconstructor.datatypes.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [GeometryConstructor](api-modules-geometryconstructor.md) > [DataTypes](api-enums-geometryconstructor.datatypes.md) 2 | 3 | 4 | 5 | ## Enumeration: DataTypes 6 | 7 | ### Enumeration members 8 | 9 | * [Linestring](api-enums-geometryconstructor.datatypes.md#linestring) 10 | * [Polygon](api-enums-geometryconstructor.datatypes.md#polygon) 11 | 12 | 13 | 14 | --- 15 | ## Enumeration members 16 | 17 | 18 | ### Linestring 19 | 20 | ** Linestring**: = 2 21 | 22 | *Defined in [constructor/construct.ts:25](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L25)* 23 | 24 | 25 | 26 | 27 | 28 | ___ 29 | 30 | 31 | 32 | ### Polygon 33 | 34 | ** Polygon**: = 3 35 | 36 | *Defined in [constructor/construct.ts:26](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L26)* 37 | 38 | 39 | 40 | 41 | 42 | ___ 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/api-interfaces-extension.ihandlers.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) > [IHandlers](api-interfaces-extension.ihandlers.md) 2 | 3 | 4 | 5 | ## Interface: IHandlers 6 | 7 | 8 | ## Methods 9 | 10 | 11 | ### onFeature 12 | 13 | ► **onFeature**(e: *`object`*): `object` 14 | 15 | 16 | 17 | *Defined in [Extension.ts:9](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L9)* 18 | 19 | 20 | 21 | **Parameters:** 22 | 23 | | Param | Type | Description | 24 | | ------ | ------ | ------ | 25 | | e | `object` | - | 26 | 27 | 28 | 29 | 30 | 31 | **Returns:** `object` 32 | 33 | 34 | 35 | 36 | 37 | ___ 38 | 39 | 40 | 41 | ### onTileCreated 42 | 43 | ► **onTileCreated**(e: *`object`*): `any` 44 | 45 | 46 | 47 | *Defined in [Extension.ts:10](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L10)* 48 | 49 | 50 | 51 | **Parameters:** 52 | 53 | | Param | Type | Description | 54 | | ------ | ------ | ------ | 55 | | e | `object` | - | 56 | 57 | 58 | 59 | 60 | 61 | **Returns:** `any` 62 | 63 | 64 | 65 | 66 | 67 | ___ 68 | 69 | 70 | 71 | ### onTileRemoved 72 | 73 | ► **onTileRemoved**(e: *`object`*): `__type` 74 | 75 | 76 | 77 | *Defined in [Extension.ts:11](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L11)* 78 | 79 | 80 | 81 | **Parameters:** 82 | 83 | | Param | Type | Description | 84 | | ------ | ------ | ------ | 85 | | e | `object` | - | 86 | 87 | 88 | 89 | 90 | 91 | **Returns:** `__type` 92 | 93 | 94 | 95 | 96 | 97 | ___ 98 | 99 | 100 | 101 | ### onUpdate 102 | 103 | ► **onUpdate**(e: *`object`*): `__type` 104 | 105 | 106 | 107 | *Defined in [Extension.ts:12](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L12)* 108 | 109 | 110 | 111 | **Parameters:** 112 | 113 | | Param | Type | Description | 114 | | ------ | ------ | ------ | 115 | | e | `object` | - | 116 | 117 | 118 | 119 | 120 | 121 | **Returns:** `__type` 122 | 123 | 124 | 125 | 126 | 127 | ___ 128 | 129 | 130 | -------------------------------------------------------------------------------- /docs/api-interfaces-extension.ionfeatureevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) > [IOnFeatureEvent](api-interfaces-extension.ionfeatureevent.md) 2 | 3 | 4 | 5 | ## Interface: IOnFeatureEvent 6 | 7 | 8 | ## Properties 9 | 10 | 11 | ### feature 12 | 13 | **● feature**: *`any`* 14 | 15 | *Defined in [Extension.ts:19](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L19)* 16 | 17 | 18 | 19 | Vector tile feature object. 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### shown 29 | 30 | **● shown**: *`boolean`* 31 | 32 | *Defined in [Extension.ts:23](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L23)* 33 | 34 | 35 | 36 | If feature is shown in view. 37 | 38 | 39 | 40 | 41 | ___ 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/api-interfaces-extension.iontilecreatedevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) > [IOnTileCreatedEvent](api-interfaces-extension.iontilecreatedevent.md) 2 | 3 | 4 | 5 | ## Interface: IOnTileCreatedEvent 6 | 7 | 8 | ## Properties 9 | 10 | 11 | ### tile 12 | 13 | **● tile**: *`Mesh`* 14 | 15 | *Defined in [Extension.ts:29](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L29)* 16 | 17 | 18 | 19 | THREE.JS Mesh of created tile. 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/api-interfaces-extension.iontileremovedevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) > [IOnTileRemovedEvent](api-interfaces-extension.iontileremovedevent.md) 2 | 3 | 4 | 5 | ## Interface: IOnTileRemovedEvent 6 | 7 | 8 | ## Properties 9 | 10 | 11 | ### tileID 12 | 13 | **● tileID**: *`string`* 14 | 15 | *Defined in [Extension.ts:35](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L35)* 16 | 17 | 18 | 19 | Quadkey of removed tile. 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/api-interfaces-extension.ionupdateevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) > [IOnUpdateEvent](api-interfaces-extension.ionupdateevent.md) 2 | 3 | 4 | 5 | ## Interface: IOnUpdateEvent 6 | 7 | 8 | ## Properties 9 | 10 | 11 | ### tiles 12 | 13 | **● tiles**: *[TileList](api-classes-tilelist.tilelist-1.md)* 14 | 15 | *Defined in [Extension.ts:41](https://github.com/areknawo/ThreeMap/blob/master/src/Extension.ts#L41)* 16 | 17 | 18 | 19 | List of new tiles in view. 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/api-interfaces-geometryconstructor.iresponse.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [GeometryConstructor](api-modules-geometryconstructor.md) > [IResponse](api-interfaces-geometryconstructor.iresponse.md) 2 | 3 | 4 | 5 | ## Interface: IResponse 6 | 7 | 8 | ## Properties 9 | 10 | 11 | ### body 12 | 13 | **● body**: *`any`⎮`string`* 14 | 15 | *Defined in [constructor/construct.ts:16](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L16)* 16 | 17 | 18 | 19 | 20 | 21 | ___ 22 | 23 | 24 | 25 | ### headers 26 | 27 | **● headers**: *`__type`* 28 | 29 | *Defined in [constructor/construct.ts:17](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L17)* 30 | 31 | 32 | 33 | 34 | 35 | ___ 36 | 37 | 38 | 39 | ### method 40 | 41 | **● method**: *`string`* 42 | 43 | *Defined in [constructor/construct.ts:18](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L18)* 44 | 45 | 46 | 47 | 48 | 49 | ___ 50 | 51 | 52 | 53 | ### rawRequest 54 | 55 | **● rawRequest**: *`XMLHttpRequest`* 56 | 57 | *Defined in [constructor/construct.ts:19](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L19)* 58 | 59 | 60 | 61 | 62 | 63 | ___ 64 | 65 | 66 | 67 | ### statusCode 68 | 69 | **● statusCode**: *`number`* 70 | 71 | *Defined in [constructor/construct.ts:20](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L20)* 72 | 73 | 74 | 75 | 76 | 77 | ___ 78 | 79 | 80 | 81 | ### url 82 | 83 | **● url**: *`string`* 84 | 85 | *Defined in [constructor/construct.ts:21](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L21)* 86 | 87 | 88 | 89 | 90 | 91 | ___ 92 | 93 | 94 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.ilayerstyle.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) 2 | 3 | 4 | 5 | ## Interface: ILayerStyle 6 | 7 | 8 | Layer's style configuration. 9 | Each property of style should be of specified type, styleFunction (if allowed) or function string. 10 | 11 | 12 | ## Properties 13 | 14 | 15 | ### color 16 | 17 | **● color**: *[styleFunction](api-modules-interfaces.md#stylefunction)⎮`string`⎮`number`[]* 18 | 19 | *Defined in [ThreeMap.interfaces.ts:111](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L111)* 20 | 21 | 22 | 23 | Element's vertices color as hex or in other format. 24 | *__see__*: [color-parse](https://www.npmjs.com/package/color-parse) 25 | 26 | 27 | 28 | 29 | 30 | ___ 31 | 32 | 33 | 34 | ### «Optional» cups 35 | 36 | **● cups**: *`boolean`* 37 | 38 | *Defined in [ThreeMap.interfaces.ts:134](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L134)* 39 | 40 | 41 | 42 | If generate cups 43 | *__default__*: `true` 44 | 45 | 46 | 47 | 48 | 49 | ___ 50 | 51 | 52 | 53 | ### «Optional» height 54 | 55 | **● height**: *[styleFunction](api-modules-interfaces.md#stylefunction)⎮`string`⎮`number`* 56 | 57 | *Defined in [ThreeMap.interfaces.ts:115](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L115)* 58 | 59 | 60 | 61 | Element height - only for polygons. 62 | 63 | 64 | 65 | 66 | ___ 67 | 68 | 69 | 70 | ### «Optional» min_height 71 | 72 | **● min_height**: *[styleFunction](api-modules-interfaces.md#stylefunction)⎮`string`⎮`number`* 73 | 74 | *Defined in [ThreeMap.interfaces.ts:120](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L120)* 75 | 76 | 77 | 78 | Element min-height - only for polygons. 79 | *__see__*: [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Key:min_height) 80 | 81 | 82 | 83 | 84 | 85 | ___ 86 | 87 | 88 | 89 | ### name 90 | 91 | **● name**: *`string`* 92 | 93 | *Defined in [ThreeMap.interfaces.ts:124](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L124)* 94 | 95 | 96 | 97 | Layer's name e.g. buildings 98 | 99 | 100 | 101 | 102 | ___ 103 | 104 | 105 | 106 | ### «Optional» show 107 | 108 | **● show**: *[styleFunction](api-modules-interfaces.md#stylefunction)⎮`string`⎮`boolean`* 109 | 110 | *Defined in [ThreeMap.interfaces.ts:129](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L129)* 111 | 112 | 113 | 114 | If element shall be shown 115 | *__default__*: `true` 116 | 117 | 118 | 119 | 120 | 121 | ___ 122 | 123 | 124 | 125 | ### «Optional» type 126 | 127 | **● type**: *[GeometryType](api-modules-interfaces.md#geometrytype)* 128 | 129 | *Defined in [ThreeMap.interfaces.ts:139](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L139)* 130 | 131 | 132 | 133 | Accepted geometry type for layer. 134 | *__default__*: `ALL` 135 | 136 | 137 | 138 | 139 | 140 | ___ 141 | 142 | 143 | 144 | ### «Optional» width 145 | 146 | **● width**: *[styleFunction](api-modules-interfaces.md#stylefunction)⎮`string`⎮`number`* 147 | 148 | *Defined in [ThreeMap.interfaces.ts:144](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L144)* 149 | 150 | 151 | 152 | Line width - only for lineStrings. 153 | *__default__*: `2` 154 | 155 | 156 | 157 | 158 | 159 | ___ 160 | 161 | 162 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.istyle.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [IStyle](api-interfaces-interfaces.istyle.md) 2 | 3 | 4 | 5 | ## Interface: IStyle 6 | 7 | 8 | ThreeMap style configuration. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### address 15 | 16 | **● address**: *`string`* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:46](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L46)* 19 | 20 | 21 | 22 | Your MVT tiles address with {x}, {y} and {z} params. 23 | 24 | 25 | 26 | 27 | ___ 28 | 29 | 30 | 31 | ### layers 32 | 33 | **● layers**: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)[]* 34 | 35 | *Defined in [ThreeMap.interfaces.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L50)* 36 | 37 | 38 | 39 | Array of layers' styles 40 | 41 | 42 | 43 | 44 | ___ 45 | 46 | 47 | 48 | ### material 49 | 50 | **● material**: *`Material`* 51 | 52 | *Defined in [ThreeMap.interfaces.ts:55](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L55)* 53 | 54 | 55 | 56 | THREE.JS Material for ThreeMap's tiles. Keep in mind that ThreeMap automatically sets vertexColors and side attributes. 57 | 58 | 59 | 60 | 61 | ___ 62 | 63 | 64 | 65 | ### «Optional» maxZoom 66 | 67 | **● maxZoom**: *`number`* 68 | 69 | *Defined in [ThreeMap.interfaces.ts:60](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L60)* 70 | 71 | 72 | 73 | Max value for address' {z} param. 74 | *__default__*: `16` 75 | 76 | 77 | 78 | 79 | 80 | ___ 81 | 82 | 83 | 84 | ### «Optional» minZoom 85 | 86 | **● minZoom**: *`number`* 87 | 88 | *Defined in [ThreeMap.interfaces.ts:65](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L65)* 89 | 90 | 91 | 92 | Min value for address' {z} param. 93 | *__default__*: `1` 94 | 95 | 96 | 97 | 98 | 99 | ___ 100 | 101 | 102 | 103 | ### «Optional» tilesExtend 104 | 105 | **● tilesExtend**: *`number`* 106 | 107 | *Defined in [ThreeMap.interfaces.ts:74](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L74)* 108 | 109 | 110 | 111 | Value for tiles calculation. 112 | ThreeMap generate tiles for view by generating grid of tiles e.g. 5x5\. 113 | Then it checks if these are in camera frustum. 114 | This value sets the tile grid limit in each direction from center tile. 115 | E.g. if value is 3 then the grid is 7x7 which is (3x2+1) x (3x2+1). 116 | *__default__*: `2` 117 | 118 | 119 | 120 | 121 | 122 | ___ 123 | 124 | 125 | 126 | ### «Optional» workers 127 | 128 | **● workers**: *`number`* 129 | 130 | *Defined in [ThreeMap.interfaces.ts:79](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L79)* 131 | 132 | 133 | 134 | Number of WebWorkers to be used in WorkerPool instance. 135 | *__default__*: `4` 136 | 137 | 138 | 139 | 140 | 141 | ___ 142 | 143 | 144 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.itilebuffers.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [ITileBuffers](api-interfaces-interfaces.itilebuffers.md) 2 | 3 | 4 | 5 | ## Interface: ITileBuffers 6 | 7 | 8 | Buffers for generating geometry. Fruit of WebWorkers' work. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### colorBuffer 15 | 16 | **● colorBuffer**: *`ArrayBuffer`* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:173](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L173)* 19 | 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### id 29 | 30 | **● id**: *`string`* 31 | 32 | *Defined in [ThreeMap.interfaces.ts:172](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L172)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | 42 | ### normalBuffer 43 | 44 | **● normalBuffer**: *`ArrayBuffer`* 45 | 46 | *Defined in [ThreeMap.interfaces.ts:174](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L174)* 47 | 48 | 49 | 50 | 51 | 52 | ___ 53 | 54 | 55 | 56 | ### vertexBuffer 57 | 58 | **● vertexBuffer**: *`ArrayBuffer`* 59 | 60 | *Defined in [ThreeMap.interfaces.ts:175](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L175)* 61 | 62 | 63 | 64 | 65 | 66 | ___ 67 | 68 | 69 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.itileobject.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [ITileObject](api-interfaces-interfaces.itileobject.md) 2 | 3 | 4 | 5 | ## Interface: ITileObject 6 | 7 | 8 | Alternative to TilePrimitive - tile coordinates & zoom level represented as object properties: x, y, z. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### x 15 | 16 | **● x**: *`number`* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:20](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L20)* 19 | 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### y 29 | 30 | **● y**: *`number`* 31 | 32 | *Defined in [ThreeMap.interfaces.ts:21](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L21)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | 42 | ### z 43 | 44 | **● z**: *`number`* 45 | 46 | *Defined in [ThreeMap.interfaces.ts:22](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L22)* 47 | 48 | 49 | 50 | 51 | 52 | ___ 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.iview.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [IView](api-interfaces-interfaces.iview.md) 2 | 3 | 4 | 5 | ## Interface: IView 6 | 7 | 8 | Object that represents current ThreeMap view - contains 2 Tile arrays. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### toRemove 15 | 16 | **● toRemove**: *[Tile](api-classes-tile.tile-1.md)[]* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:32](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L32)* 19 | 20 | 21 | 22 | List of tiles to be removed. 23 | 24 | 25 | 26 | 27 | ___ 28 | 29 | 30 | 31 | ### toRender 32 | 33 | **● toRender**: *[Tile](api-classes-tile.tile-1.md)[]* 34 | 35 | *Defined in [ThreeMap.interfaces.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L36)* 36 | 37 | 38 | 39 | List of tiles to be added. 40 | 41 | 42 | 43 | 44 | ___ 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.iworkerdata.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 2 | 3 | 4 | 5 | ## Interface: IWorkerData 6 | 7 | 8 | Data object used inside WebWorkers for building tiles. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### colData 15 | 16 | **● colData**: *`number`[]* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:198](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L198)* 19 | 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### cups 29 | 30 | **● cups**: *`object`* 31 | 32 | *Defined in [ThreeMap.interfaces.ts:199](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L199)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | 42 | ### feature 43 | 44 | **● feature**: *`VectorTileFeature`* 45 | 46 | *Defined in [ThreeMap.interfaces.ts:200](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L200)* 47 | 48 | 49 | 50 | 51 | 52 | ___ 53 | 54 | 55 | 56 | ### inxData 57 | 58 | **● inxData**: *`number`[]* 59 | 60 | *Defined in [ThreeMap.interfaces.ts:201](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L201)* 61 | 62 | 63 | 64 | 65 | 66 | ___ 67 | 68 | 69 | 70 | ### layerOrder 71 | 72 | **● layerOrder**: *`number`* 73 | 74 | *Defined in [ThreeMap.interfaces.ts:202](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L202)* 75 | 76 | 77 | 78 | 79 | 80 | ___ 81 | 82 | 83 | 84 | ### tile 85 | 86 | **● tile**: *[TilePrimitive](api-modules-interfaces.md#tileprimitive)* 87 | 88 | *Defined in [ThreeMap.interfaces.ts:203](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L203)* 89 | 90 | 91 | 92 | 93 | 94 | ___ 95 | 96 | 97 | 98 | ### vecData 99 | 100 | **● vecData**: *`number`[]* 101 | 102 | *Defined in [ThreeMap.interfaces.ts:204](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L204)* 103 | 104 | 105 | 106 | 107 | 108 | ___ 109 | 110 | 111 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.iworkerevent.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [IWorkerEvent](api-interfaces-interfaces.iworkerevent.md) 2 | 3 | 4 | 5 | ## Interface: IWorkerEvent 6 | 7 | 8 | Event sent from WebWorker. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### data 15 | 16 | **● data**: *[IWorkerEventData](api-interfaces-interfaces.iworkereventdata.md)* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:190](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L190)* 19 | 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### target 29 | 30 | **● target**: *`object`* 31 | 32 | *Defined in [ThreeMap.interfaces.ts:191](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L191)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.iworkereventdata.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [IWorkerEventData](api-interfaces-interfaces.iworkereventdata.md) 2 | 3 | 4 | 5 | ## Interface: IWorkerEventData 6 | 7 | 8 | Data of event sent from WebWorker. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### realData 15 | 16 | **● realData**: *[ITileBuffers](api-interfaces-interfaces.itilebuffers.md)* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:182](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L182)* 19 | 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### type 29 | 30 | **● type**: *`string`* 31 | 32 | *Defined in [ThreeMap.interfaces.ts:183](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L183)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/api-interfaces-interfaces.iworkermessage.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) > [IWorkerMessage](api-interfaces-interfaces.iworkermessage.md) 2 | 3 | 4 | 5 | ## Interface: IWorkerMessage 6 | 7 | 8 | Message sent to WebWorker 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### id 15 | 16 | **● id**: *`string`* 17 | 18 | *Defined in [ThreeMap.interfaces.ts:211](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L211)* 19 | 20 | 21 | 22 | 23 | 24 | ___ 25 | 26 | 27 | 28 | ### style 29 | 30 | **● style**: *[IStyle](api-interfaces-interfaces.istyle.md)* 31 | 32 | *Defined in [ThreeMap.interfaces.ts:212](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L212)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | 42 | ### url 43 | 44 | **● url**: *`string`* 45 | 46 | *Defined in [ThreeMap.interfaces.ts:213](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L213)* 47 | 48 | 49 | 50 | 51 | 52 | ___ 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/api-interfaces-linestringconstructor.ilinesegment.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [LineStringConstructor](api-modules-linestringconstructor.md) > [ILineSegment](api-interfaces-linestringconstructor.ilinesegment.md) 2 | 3 | 4 | 5 | ## Interface: ILineSegment 6 | 7 | 8 | ## Properties 9 | 10 | 11 | ### back 12 | 13 | **● back**: *`object`* 14 | 15 | *Defined in [constructor/linestring.ts:7](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L7)* 16 | 17 | 18 | #### Type declaration 19 | 20 | 21 | 22 | 23 | left: [Vec3](api-modules-interfaces.md#vec3) 24 | 25 | 26 | 27 | 28 | 29 | 30 | «Optional» normal: [Vec2](api-modules-interfaces.md#vec2) 31 | 32 | 33 | 34 | 35 | 36 | 37 | right: [Vec3](api-modules-interfaces.md#vec3) 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ___ 46 | 47 | 48 | 49 | ### front 50 | 51 | **● front**: *`object`* 52 | 53 | *Defined in [constructor/linestring.ts:12](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L12)* 54 | 55 | 56 | #### Type declaration 57 | 58 | 59 | 60 | 61 | left: [Vec3](api-modules-interfaces.md#vec3) 62 | 63 | 64 | 65 | 66 | 67 | 68 | «Optional» normal: [Vec2](api-modules-interfaces.md#vec2) 69 | 70 | 71 | 72 | 73 | 74 | 75 | right: [Vec3](api-modules-interfaces.md#vec3) 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | ___ 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/api-interfaces-threemapglobals.ithreemap.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [ThreeMapGlobals](api-modules-threemapglobals.md) > [IThreeMap](api-interfaces-threemapglobals.ithreemap.md) 2 | 3 | 4 | 5 | ## Interface: IThreeMap 6 | 7 | 8 | ThreeMap globally-accessible values. 9 | 10 | 11 | ## Properties 12 | 13 | 14 | ### camera 15 | 16 | **● camera**: *`Camera`* 17 | 18 | *Defined in [ThreeMap.ts:24](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L24)* 19 | 20 | 21 | 22 | ThreeJS camera. 23 | 24 | 25 | 26 | 27 | ___ 28 | 29 | 30 | 31 | ### controls 32 | 33 | **● controls**: *`OrbitControls`* 34 | 35 | *Defined in [ThreeMap.ts:28](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L28)* 36 | 37 | 38 | 39 | ThreeJS controls. 40 | 41 | 42 | 43 | 44 | ___ 45 | 46 | 47 | 48 | ### events 49 | 50 | **● events**: *`Emitter`* 51 | 52 | *Defined in [ThreeMap.ts:32](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L32)* 53 | 54 | 55 | 56 | 57 | 58 | ___ 59 | 60 | 61 | 62 | ### frustum 63 | 64 | **● frustum**: *`Frustum`* 65 | 66 | *Defined in [ThreeMap.ts:36](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L36)* 67 | 68 | 69 | 70 | Camera frustum for tiles calculations. 71 | 72 | 73 | 74 | 75 | ___ 76 | 77 | 78 | 79 | ### grid 80 | 81 | **● grid**: *[TileGrid](api-classes-tilegrid.tilegrid-1.md)* 82 | 83 | *Defined in [ThreeMap.ts:40](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L40)* 84 | 85 | 86 | 87 | Tiles grid. 88 | 89 | 90 | 91 | 92 | ___ 93 | 94 | 95 | 96 | ### material 97 | 98 | **● material**: *`Material`* 99 | 100 | *Defined in [ThreeMap.ts:44](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L44)* 101 | 102 | 103 | 104 | ThreeMap's tiles' ThreeJS material. 105 | 106 | 107 | 108 | 109 | ___ 110 | 111 | 112 | 113 | ### scene 114 | 115 | **● scene**: *`Scene`* 116 | 117 | *Defined in [ThreeMap.ts:48](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L48)* 118 | 119 | 120 | 121 | ThreeJS scene. 122 | 123 | 124 | 125 | 126 | ___ 127 | 128 | 129 | 130 | ### style 131 | 132 | **● style**: *[IStyle](api-interfaces-interfaces.istyle.md)* 133 | 134 | *Defined in [ThreeMap.ts:52](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L52)* 135 | 136 | 137 | 138 | ThreeMap style configuration. 139 | 140 | 141 | 142 | 143 | ___ 144 | 145 | 146 | 147 | ### three_map 148 | 149 | **● three_map**: *`Object3D`* 150 | 151 | *Defined in [ThreeMap.ts:56](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.ts#L56)* 152 | 153 | 154 | 155 | ThreeMap main object 156 | 157 | 158 | 159 | 160 | ___ 161 | 162 | 163 | -------------------------------------------------------------------------------- /docs/api-modules-extension.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Extension](api-modules-extension.md) 2 | 3 | 4 | 5 | ## Module: Extension 6 | 7 | ### Classes 8 | 9 | * [Extension](api-classes-extension.extension-1.md) 10 | 11 | 12 | ### Interfaces 13 | 14 | * [IHandlers](api-interfaces-extension.ihandlers.md) 15 | * [IOnFeatureEvent](api-interfaces-extension.ionfeatureevent.md) 16 | * [IOnTileCreatedEvent](api-interfaces-extension.iontilecreatedevent.md) 17 | * [IOnTileRemovedEvent](api-interfaces-extension.iontileremovedevent.md) 18 | * [IOnUpdateEvent](api-interfaces-extension.ionupdateevent.md) 19 | 20 | 21 | 22 | --- 23 | -------------------------------------------------------------------------------- /docs/api-modules-geometryconstructor.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [GeometryConstructor](api-modules-geometryconstructor.md) 2 | 3 | 4 | 5 | ## Module: GeometryConstructor 6 | 7 | ### Enumerations 8 | 9 | * [DataTypes](api-enums-geometryconstructor.datatypes.md) 10 | 11 | 12 | ### Interfaces 13 | 14 | * [IResponse](api-interfaces-geometryconstructor.iresponse.md) 15 | 16 | 17 | ### Variables 18 | 19 | * [layerOrderLevels](api-modules-geometryconstructor.md#layerorderlevels) 20 | 21 | 22 | ### Functions 23 | 24 | * [cupBuilder](api-modules-geometryconstructor.md#cupbuilder) 25 | * [readStyleFunction](api-modules-geometryconstructor.md#readstylefunction) 26 | 27 | 28 | 29 | --- 30 | ## Variables 31 | 32 | 33 | ### «Const» layerOrderLevels 34 | 35 | **● layerOrderLevels**: *`number`[]* = [100, 100, 100, 80, 60, 50, 30, 25, 20, 20, 10, 5, 2, 1, 0.5, 0.1, 0.1] 36 | 37 | *Defined in [constructor/construct.ts:47](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L47)* 38 | 39 | 40 | 41 | Protection against z-fighting 42 | 43 | 44 | 45 | 46 | ___ 47 | 48 | 49 | ## Functions 50 | 51 | 52 | ### cupBuilder 53 | 54 | ► **cupBuilder**(style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*, workerDataBuffers: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*): `void` 55 | 56 | 57 | 58 | *Defined in [constructor/construct.ts:149](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L149)* 59 | 60 | 61 | 62 | Generates line's cups. 63 | *__example__*: `cupBuilder({...}, {...});` 64 | 65 | 66 | 67 | **Parameters:** 68 | 69 | | Param | Type | Description | 70 | | ------ | ------ | ------ | 71 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 72 | | workerDataBuffers | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 73 | 74 | 75 | 76 | 77 | 78 | **Returns:** `void` 79 | 80 | 81 | 82 | 83 | 84 | ___ 85 | 86 | 87 | 88 | ### readStyleFunction 89 | 90 | ► **readStyleFunction**(func: *`string`*, feature: *`object`*): `any` 91 | 92 | 93 | 94 | *Defined in [constructor/construct.ts:40](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/construct.ts#L40)* 95 | 96 | 97 | 98 | Parses function string to function & executes it returning its value. 99 | *__example__*: `readStyleFunction('(feature) => {return feature.height}, {...});` 100 | 101 | 102 | 103 | **Parameters:** 104 | 105 | | Param | Type | Description | 106 | | ------ | ------ | ------ | 107 | | func | `string` | Function string. | 108 | | feature | `object` | MVT feature properties. | 109 | 110 | 111 | 112 | 113 | 114 | **Returns:** `any` 115 | 116 | 117 | 118 | 119 | 120 | ___ 121 | 122 | 123 | -------------------------------------------------------------------------------- /docs/api-modules-interfaces.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Interfaces](api-modules-interfaces.md) 2 | 3 | 4 | 5 | ## Module: Interfaces 6 | 7 | ### Interfaces 8 | 9 | * [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) 10 | * [IStyle](api-interfaces-interfaces.istyle.md) 11 | * [ITileBuffers](api-interfaces-interfaces.itilebuffers.md) 12 | * [ITileObject](api-interfaces-interfaces.itileobject.md) 13 | * [IView](api-interfaces-interfaces.iview.md) 14 | * [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 15 | * [IWorkerEvent](api-interfaces-interfaces.iworkerevent.md) 16 | * [IWorkerEventData](api-interfaces-interfaces.iworkereventdata.md) 17 | * [IWorkerMessage](api-interfaces-interfaces.iworkermessage.md) 18 | 19 | 20 | ### Type aliases 21 | 22 | * [GeometryType](api-modules-interfaces.md#geometrytype) 23 | * [TilePrimitive](api-modules-interfaces.md#tileprimitive) 24 | * [Vec2](api-modules-interfaces.md#vec2) 25 | * [Vec3](api-modules-interfaces.md#vec3) 26 | * [styleFunction](api-modules-interfaces.md#stylefunction) 27 | 28 | 29 | 30 | --- 31 | ## Type aliases 32 | 33 | 34 | ### GeometryType 35 | 36 | **Τ GeometryType**: *"POLYGON"⎮"LINESTRING"⎮"ALL"* 37 | 38 | *Defined in [ThreeMap.interfaces.ts:82](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L82)* 39 | 40 | 41 | 42 | 43 | 44 | ___ 45 | 46 | 47 | 48 | ### TilePrimitive 49 | 50 | **Τ TilePrimitive**: *[`number`,`number`,`number`]* 51 | 52 | *Defined in [ThreeMap.interfaces.ts:14](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L14)* 53 | 54 | 55 | 56 | Tile primitive is an array of tile coordinates & zoom level. 57 | 58 | 59 | 60 | 61 | ___ 62 | 63 | 64 | 65 | ### Vec2 66 | 67 | **Τ Vec2**: *`number`[]⎮[`number`,`number`]* 68 | 69 | *Defined in [ThreeMap.interfaces.ts:87](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L87)* 70 | 71 | 72 | 73 | 2D Vector - array of x, y coords. 74 | 75 | 76 | 77 | 78 | ___ 79 | 80 | 81 | 82 | ### Vec3 83 | 84 | **Τ Vec3**: *`number`[]⎮[`number`,`number`,`number`]* 85 | 86 | *Defined in [ThreeMap.interfaces.ts:92](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L92)* 87 | 88 | 89 | 90 | 3D Vector - array of x, y, z coords. 91 | 92 | 93 | 94 | 95 | ___ 96 | 97 | 98 | 99 | ### styleFunction 100 | 101 | **Τ styleFunction**: *`function`* 102 | 103 | *Defined in [ThreeMap.interfaces.ts:100](https://github.com/areknawo/ThreeMap/blob/master/src/ThreeMap.interfaces.ts#L100)* 104 | 105 | 106 | 107 | Function expression allowed in ThreeMap's style configuration. You get access to currently processed feature's properties. IT MUST RETURN VALUE OF SAME TYPE AS SPECIFIED! IT MUST BE WRITTEN AS FUNCTION EXPRESSION WITH FUNCTION KEYWORD (NO ARROW FUNCTIONS!) 108 | 109 | #### Type declaration 110 | ►(feature: *`any`*): `number`⎮`boolean`⎮`string` 111 | 112 | 113 | 114 | **Parameters:** 115 | 116 | | Param | Type | Description | 117 | | ------ | ------ | ------ | 118 | | feature | `any` | - | 119 | 120 | 121 | 122 | 123 | 124 | **Returns:** `number`⎮`boolean`⎮`string` 125 | 126 | 127 | 128 | 129 | 130 | 131 | ___ 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/api-modules-linestringconstructor.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [LineStringConstructor](api-modules-linestringconstructor.md) 2 | 3 | 4 | 5 | ## Module: LineStringConstructor 6 | 7 | ### Interfaces 8 | 9 | * [ILineSegment](api-interfaces-linestringconstructor.ilinesegment.md) 10 | 11 | 12 | ### Functions 13 | 14 | * [line](api-modules-linestringconstructor.md#line) 15 | * [lineSegment](api-modules-linestringconstructor.md#linesegment) 16 | * [lineString](api-modules-linestringconstructor.md#linestring) 17 | 18 | 19 | 20 | --- 21 | ## Functions 22 | 23 | 24 | ### line 25 | 26 | ► **line**(vertices: *`number`[][]*, data: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*, style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*): [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 27 | 28 | 29 | 30 | *Defined in [constructor/linestring.ts:92](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L92)* 31 | 32 | 33 | 34 | Generates line. 35 | *__example__*: `line([[1,2], [3,4]], {...}, {...});` 36 | 37 | 38 | 39 | **Parameters:** 40 | 41 | | Param | Type | Description | 42 | | ------ | ------ | ------ | 43 | | vertices | `number`[][] | Preprocessed vertices array. | 44 | | data | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 45 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 46 | 47 | 48 | 49 | 50 | 51 | **Returns:** [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 52 | 53 | 54 | 55 | 56 | 57 | ___ 58 | 59 | 60 | 61 | ### lineSegment 62 | 63 | ► **lineSegment**(v1: *[Vec2](api-modules-interfaces.md#vec2)*, v2: *[Vec2](api-modules-interfaces.md#vec2)*, data: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*, style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*): [ILineSegment](api-interfaces-linestringconstructor.ilinesegment.md) 64 | 65 | 66 | 67 | *Defined in [constructor/linestring.ts:50](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L50)* 68 | 69 | 70 | 71 | Generates line segment - line between 2 vectors. 72 | *__example__*: `lineSegment([1,2], [3,4] , {...}, {...});` 73 | 74 | 75 | 76 | **Parameters:** 77 | 78 | | Param | Type | Description | 79 | | ------ | ------ | ------ | 80 | | v1 | [Vec2](api-modules-interfaces.md#vec2) | First vector. | 81 | | v2 | [Vec2](api-modules-interfaces.md#vec2) | Second vector. | 82 | | data | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 83 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 84 | 85 | 86 | 87 | 88 | 89 | **Returns:** [ILineSegment](api-interfaces-linestringconstructor.ilinesegment.md) 90 | 91 | 92 | 93 | 94 | 95 | ___ 96 | 97 | 98 | 99 | ### lineString 100 | 101 | ► **lineString**(data: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*, style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*): [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 102 | 103 | 104 | 105 | *Defined in [constructor/linestring.ts:25](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/linestring.ts#L25)* 106 | 107 | 108 | 109 | Parses data for line generation. 110 | *__example__*: `lineString({...}, {...});` 111 | 112 | 113 | 114 | **Parameters:** 115 | 116 | | Param | Type | Description | 117 | | ------ | ------ | ------ | 118 | | data | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 119 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 120 | 121 | 122 | 123 | 124 | 125 | **Returns:** [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 126 | 127 | 128 | 129 | 130 | 131 | ___ 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/api-modules-polygonconstructor.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [PolygonConstructor](api-modules-polygonconstructor.md) 2 | 3 | 4 | 5 | ## Module: PolygonConstructor 6 | 7 | ### Functions 8 | 9 | * [extrudedPolygon](api-modules-polygonconstructor.md#extrudedpolygon) 10 | * [flatPolygon](api-modules-polygonconstructor.md#flatpolygon) 11 | * [polygon](api-modules-polygonconstructor.md#polygon) 12 | 13 | 14 | 15 | --- 16 | ## Functions 17 | 18 | 19 | ### extrudedPolygon 20 | 21 | ► **extrudedPolygon**(vertices: *`number`[][]*, data: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*, style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*): [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 22 | 23 | 24 | 25 | *Defined in [constructor/polygon.ts:64](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/polygon.ts#L64)* 26 | 27 | 28 | 29 | Generates extruded polygon - 3D Object. 30 | *__example__*: `extrudedPolygon([[1,2],[3,4],[5,6],[1,2]], {...}, {...}); 31 | 32 | 33 | 34 | **Parameters:** 35 | 36 | | Param | Type | Description | 37 | | ------ | ------ | ------ | 38 | | vertices | `number`[][] | Preprocessed vertices array. | 39 | | data | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 40 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 41 | 42 | 43 | 44 | 45 | 46 | **Returns:** [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 47 | 48 | 49 | 50 | 51 | 52 | ___ 53 | 54 | 55 | 56 | ### flatPolygon 57 | 58 | ► **flatPolygon**(vertices: *`number`[][]*, data: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*, style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*): [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 59 | 60 | 61 | 62 | *Defined in [constructor/polygon.ts:45](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/polygon.ts#L45)* 63 | 64 | 65 | 66 | Generates flat polygon. 67 | *__example__*: `flatPolygon([[1,2],[3,4],[5,6],[1,2]], {...}, {...}); 68 | 69 | 70 | 71 | **Parameters:** 72 | 73 | | Param | Type | Description | 74 | | ------ | ------ | ------ | 75 | | vertices | `number`[][] | Preprocessed vertices array. | 76 | | data | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 77 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 78 | 79 | 80 | 81 | 82 | 83 | **Returns:** [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 84 | 85 | 86 | 87 | 88 | 89 | ___ 90 | 91 | 92 | 93 | ### polygon 94 | 95 | ► **polygon**(data: *[IWorkerData](api-interfaces-interfaces.iworkerdata.md)*, style: *[ILayerStyle](api-interfaces-interfaces.ilayerstyle.md)*): [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 96 | 97 | 98 | 99 | *Defined in [constructor/polygon.ts:14](https://github.com/areknawo/ThreeMap/blob/master/src/constructor/polygon.ts#L14)* 100 | 101 | 102 | 103 | Parses data for polygon generation. 104 | *__example__*: `polygon({...}, {...});` 105 | 106 | 107 | 108 | **Parameters:** 109 | 110 | | Param | Type | Description | 111 | | ------ | ------ | ------ | 112 | | data | [IWorkerData](api-interfaces-interfaces.iworkerdata.md) | Data used for building tile. | 113 | | style | [ILayerStyle](api-interfaces-interfaces.ilayerstyle.md) | Layer's style configuration. | 114 | 115 | 116 | 117 | 118 | 119 | **Returns:** [IWorkerData](api-interfaces-interfaces.iworkerdata.md) 120 | 121 | 122 | 123 | 124 | 125 | ___ 126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/api-modules-threemap.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [ThreeMap](api-modules-threemap.md) 2 | 3 | 4 | 5 | ## Module: ThreeMap 6 | 7 | ### Classes 8 | 9 | * [Map](api-classes-threemap.map.md) 10 | 11 | 12 | 13 | --- 14 | -------------------------------------------------------------------------------- /docs/api-modules-threemapglobals.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [ThreeMapGlobals](api-modules-threemapglobals.md) 2 | 3 | 4 | 5 | ## Module: ThreeMapGlobals 6 | 7 | ### Interfaces 8 | 9 | * [IThreeMap](api-interfaces-threemapglobals.ithreemap.md) 10 | 11 | 12 | 13 | --- 14 | -------------------------------------------------------------------------------- /docs/api-modules-tile.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [Tile](api-modules-tile.md) 2 | 3 | 4 | 5 | ## Module: Tile 6 | 7 | ### Classes 8 | 9 | * [Tile](api-classes-tile.tile-1.md) 10 | 11 | 12 | 13 | --- 14 | -------------------------------------------------------------------------------- /docs/api-modules-tilegrid.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [TileGrid](api-modules-tilegrid.md) 2 | 3 | 4 | 5 | ## Module: TileGrid 6 | 7 | ### Classes 8 | 9 | * [TileGrid](api-classes-tilegrid.tilegrid-1.md) 10 | 11 | 12 | 13 | --- 14 | -------------------------------------------------------------------------------- /docs/api-modules-tilelist.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [TileList](api-modules-tilelist.md) 2 | 3 | 4 | 5 | ## Module: TileList 6 | 7 | ### Classes 8 | 9 | * [TileList](api-classes-tilelist.tilelist-1.md) 10 | 11 | 12 | 13 | --- 14 | -------------------------------------------------------------------------------- /docs/api-modules-workerpool.md: -------------------------------------------------------------------------------- 1 | [ThreeMap](api-readme.md) > [WorkerPool](api-modules-workerpool.md) 2 | 3 | 4 | 5 | ## Module: WorkerPool 6 | 7 | ### Classes 8 | 9 | * [WorkerPool](api-classes-workerpool.workerpool-1.md) 10 | 11 | 12 | ### Variables 13 | 14 | * [pool](api-modules-workerpool.md#pool) 15 | 16 | 17 | ### Functions 18 | 19 | * [initWorkerPool](api-modules-workerpool.md#initworkerpool) 20 | * [startWorker](api-modules-workerpool.md#startworker) 21 | 22 | 23 | 24 | --- 25 | ## Variables 26 | 27 | 28 | ### «Let» pool 29 | 30 | **● pool**: *[WorkerPool](api-classes-workerpool.workerpool-1.md)* 31 | 32 | *Defined in [workerpool.ts:68](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L68)* 33 | 34 | 35 | 36 | 37 | 38 | ___ 39 | 40 | 41 | ## Functions 42 | 43 | 44 | ### initWorkerPool 45 | 46 | ► **initWorkerPool**(): `void` 47 | 48 | 49 | 50 | *Defined in [workerpool.ts:75](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L75)* 51 | 52 | 53 | 54 | Creates globally-accessible WorkerPool instance. 55 | *__example__*: `initWorkerPool();` 56 | 57 | 58 | 59 | 60 | 61 | **Returns:** `void` 62 | 63 | 64 | 65 | 66 | 67 | ___ 68 | 69 | 70 | 71 | ### startWorker 72 | 73 | ► **startWorker**(message: *[IWorkerMessage](api-interfaces-interfaces.iworkermessage.md)*): `void` 74 | 75 | 76 | 77 | *Defined in [workerpool.ts:89](https://github.com/areknawo/ThreeMap/blob/master/src/workerpool.ts#L89)* 78 | 79 | 80 | 81 | Sends task to WorkerPool to be handled by worker. 82 | *__example__*: `startWorker({...});` 83 | 84 | 85 | 86 | **Parameters:** 87 | 88 | | Param | Type | Description | 89 | | ------ | ------ | ------ | 90 | | message | [IWorkerMessage](api-interfaces-interfaces.iworkermessage.md) | Message to be sent to worker. | 91 | 92 | 93 | 94 | 95 | 96 | **Returns:** `void` 97 | 98 | 99 | 100 | 101 | 102 | ___ 103 | 104 | 105 | -------------------------------------------------------------------------------- /docs/api-readme.md: -------------------------------------------------------------------------------- 1 | 2 | # ThreeMap Dev 0.0.1 API 3 | 4 | !> If you're looking for public API checkout **ThreeMap** module. 5 | 6 | 7 | ### Modules: 8 | 9 | * [Extension](api-modules-extension.md) 10 | * [GeometryConstructor](api-modules-geometryconstructor.md) 11 | * [Interfaces](api-modules-interfaces.md) 12 | * [LineStringConstructor](api-modules-linestringconstructor.md) 13 | * [PolygonConstructor](api-modules-polygonconstructor.md) 14 | * [ThreeMap](api-modules-threemap.md) 15 | * [ThreeMapGlobals](api-modules-threemapglobals.md) 16 | * [Tile](api-modules-tile.md) 17 | * [TileGrid](api-modules-tilegrid.md) 18 | * [TileList](api-modules-tilelist.md) 19 | * [Utils](api-modules-utils.md) 20 | * [WorkerPool](api-modules-workerpool.md) 21 | 22 | 23 | 24 | --- 25 | -------------------------------------------------------------------------------- /docs/contribute.md: -------------------------------------------------------------------------------- 1 | # How to contribute? 2 | ThreeMap is in dire need of contributors. Aspects that 3 | `require(most attention)` :smile: are 4 | * Performance - even if ThreeMap uses WebWorkers it's still not enough 5 | * New features & improvements - for example points implementation & roads cups & joins 6 | 7 | ThreeMap is written in Typescript. If you don't know this language then checkout 8 | [this guide](https://www.typescriptlang.org/docs/home.html). 9 | If you don't want to use this and still want to contribute then 10 | in your issues write code in JS and I'll try to port it to TS. 11 | 12 | For better understanding of code, explore [API](api-readme.md). 13 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Three-Map - Library for high-quality vector maps built with ThreeJS 6 | 7 | 8 | 9 | 10 | 11 | 12 |
Please wait...
13 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ThreeMap demo 5 | 15 | 16 | 17 | 18 | 19 | 20 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "MIT", 3 | "name": "three-map", 4 | "version": "0.0.1c", 5 | "description": "Library for high-quality vector maps built with ThreeJS", 6 | "author": "areknawo", 7 | "bugs": { 8 | "url": "https://github.com/areknawo/ThreeMap/issues" 9 | }, 10 | "homepage": "https://github.com/areknawo/ThreeMap/README.md", 11 | "main": "build/ThreeMap.min.js", 12 | "module": "src/index.js", 13 | "source": "src", 14 | "scripts": { 15 | "build": "bili --config './bili.config.worker.js' && bili --config './bili.config.js'", 16 | "docs": "typedoc --options ./tdconfig.json" 17 | }, 18 | "dependencies": { 19 | "@mapbox/sphericalmercator": "^1.0.5", 20 | "@mapbox/tilebelt": "^1.0.1", 21 | "@mapbox/vector-tile": "^1.3.1", 22 | "color-parse": "^1.3.5", 23 | "earcut": "^2.1.3", 24 | "face-normals": "^0.0.0", 25 | "gl-vec2": "^1.2.0", 26 | "mitt": "^1.1.3", 27 | "pbf": "^3.1.0", 28 | "three": "^0.91.0", 29 | "tslint": "^5.10.0", 30 | "xhr": "^2.4.1" 31 | }, 32 | "devDependencies": { 33 | "@types/earcut": "^2.1.0", 34 | "@types/node": "^9.6.6", 35 | "@types/three": "^0.91.13", 36 | "babel-eslint": "^8.2.3", 37 | "bili": "^3.1.1", 38 | "docsify-cli": "^4.2.1", 39 | "eslint": "^4.19.1", 40 | "eslint-plugin-jsdoc": "^3.7.1", 41 | "eslint-plugin-typescript": "^0.12.0", 42 | "rollup-plugin-bundle-worker": "^0.1.0", 43 | "rollup-plugin-typescript2": "^0.13.0", 44 | "typedoc": "^0.11.1", 45 | "typedoc-plugin-external-module-name": "^1.1.1", 46 | "typescript": "^2.8.3", 47 | "typescript-eslint-parser": "^15.0.0" 48 | }, 49 | "repository": { 50 | "type": "git", 51 | "url": "git+https://github.com/areknawo/ThreeMap.git" 52 | }, 53 | "keywords": [ 54 | "Vector", 55 | "Map", 56 | "ThreeJS", 57 | "3D", 58 | "Visualisation" 59 | ] 60 | } 61 | -------------------------------------------------------------------------------- /src/Extension.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module Extension 3 | */ 4 | import { Mesh, Object3D } from "three"; 5 | import { IStyle } from "./ThreeMap.interfaces"; 6 | import { TileList } from "./tilelist"; 7 | 8 | interface IHandlers { 9 | onFeature(e: object): object; 10 | onTileCreated(e: object): any; 11 | onTileRemoved(e: object): {}; 12 | onUpdate(e: object): {}; 13 | } 14 | 15 | interface IOnFeatureEvent { 16 | /** 17 | * Vector tile feature object. 18 | */ 19 | feature: any; 20 | /** 21 | * If feature is shown in view. 22 | */ 23 | shown: boolean; 24 | } 25 | interface IOnTileCreatedEvent { 26 | /** 27 | * THREE.JS Mesh of created tile. 28 | */ 29 | tile: Mesh; 30 | } 31 | interface IOnTileRemovedEvent { 32 | /** 33 | * Quadkey of removed tile. 34 | */ 35 | tileID: string; 36 | } 37 | interface IOnUpdateEvent { 38 | /** 39 | * List of new tiles in view. 40 | */ 41 | tiles: TileList; 42 | } 43 | /** 44 | * Base class provided for creating ThreeMap Extensions 45 | */ 46 | export class Extension { 47 | /** 48 | * ThreeMap ThreeJS base object - tiles container 49 | */ 50 | public map: Object3D; 51 | /** 52 | * Function to be executed when new tile feature is loaded. 53 | */ 54 | public onFeature: (e: IOnFeatureEvent) => {}; 55 | /** 56 | * Function to be executed when new tile is added to ThreeMap parent element 57 | */ 58 | public onTileCreated: (e: IOnTileCreatedEvent) => {}; 59 | /** 60 | * Function to be executed when tile is removed from ThreeMap parent element 61 | */ 62 | public onTileRemoved: (e: IOnTileRemovedEvent) => {}; 63 | /** 64 | * Function to be executed on every ThreeJS controls update - e.g. pan, move etc. 65 | */ 66 | public onUpdate: (e: IOnUpdateEvent) => {}; 67 | /** 68 | * ThreeMap style configuration object 69 | */ 70 | public style: IStyle; 71 | 72 | /** 73 | * @param handlers - Functions to apply for ThreeMap's corresponding events. 74 | * @example `new Extension({onFeature: ()=>{}, onTileCreated: ()=>{}, onTileRemoved: ()=>{}, onUpdate: ()=>{}});` 75 | */ 76 | public constructor(handlers: IHandlers) { 77 | this.onFeature = handlers.onFeature; 78 | this.onTileCreated = handlers.onTileCreated; 79 | this.onTileRemoved = handlers.onTileRemoved; 80 | this.onUpdate = handlers.onUpdate; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/ThreeMap.interfaces.ts: -------------------------------------------------------------------------------- 1 | // TODO: THINK ABOUT DIFFERENT STRUCTURE OF THIS 2 | /** 3 | * @module Interfaces 4 | * 5 | * ThreeMap types & interfaces. 6 | */ 7 | import { VectorTileFeature } from "@mapbox/vector-tile"; 8 | import * as THREE from "three"; 9 | import { Tile } from "./tile"; 10 | 11 | /** 12 | * Tile primitive is an array of tile coordinates & zoom level. 13 | */ 14 | export type TilePrimitive = [number, number, number]; 15 | 16 | /** 17 | * Alternative to TilePrimitive - tile coordinates & zoom level represented as object properties: x, y, z. 18 | */ 19 | export interface ITileObject { 20 | x: number; 21 | y: number; 22 | z: number; 23 | } 24 | 25 | /** 26 | * Object that represents current ThreeMap view - contains 2 Tile arrays. 27 | */ 28 | export interface IView { 29 | /** 30 | * List of tiles to be removed. 31 | */ 32 | toRemove: Tile[]; 33 | /** 34 | * List of tiles to be added. 35 | */ 36 | toRender: Tile[]; 37 | } 38 | 39 | /** 40 | * ThreeMap style configuration. 41 | */ 42 | export interface IStyle { 43 | /** 44 | * Your MVT tiles address with {x}, {y} and {z} params. 45 | */ 46 | address: string; 47 | /** 48 | * Array of layers' styles 49 | */ 50 | layers: ILayerStyle[]; 51 | /** 52 | * THREE.JS Material for ThreeMap's tiles. 53 | * Keep in mind that ThreeMap automatically sets vertexColors and side attributes. 54 | */ 55 | material: THREE.Material; 56 | /** 57 | * Max value for address' {z} param. 58 | * @default `16` 59 | */ 60 | maxZoom?: number; 61 | /** 62 | * Min value for address' {z} param. 63 | * @default `1` 64 | */ 65 | minZoom?: number; 66 | /** 67 | * Value for tiles calculation.
68 | * ThreeMap generate tiles for view by generating grid of tiles e.g. 5x5.
69 | * Then it checks if these are in camera frustum.
70 | * This value sets the tile grid limit in each direction from center tile.
71 | * E.g. if value is 3 then the grid is 7x7 which is (3x2+1) x (3x2+1). 72 | * @default `2` 73 | */ 74 | tilesExtend?: number; 75 | /** 76 | * Number of WebWorkers to be used in WorkerPool instance. 77 | * @default `4` 78 | */ 79 | workers?: number; 80 | } 81 | 82 | export type GeometryType = "POLYGON" | "LINESTRING" | "ALL"; 83 | 84 | /** 85 | * 2D Vector - array of x, y coords. 86 | */ 87 | export type Vec2 = number[] | [number, number]; 88 | 89 | /** 90 | * 3D Vector - array of x, y, z coords. 91 | */ 92 | export type Vec3 = number[] | [number, number, number]; 93 | 94 | /** 95 | * Function expression allowed in ThreeMap's style configuration. 96 | * You get access to currently processed feature's properties. 97 | * IT MUST RETURN VALUE OF SAME TYPE AS SPECIFIED! 98 | * IT MUST BE WRITTEN AS FUNCTION EXPRESSION WITH FUNCTION KEYWORD (NO ARROW FUNCTIONS!) 99 | */ 100 | export type styleFunction = (feature: any) => number | boolean | string; 101 | 102 | /** 103 | * Layer's style configuration.
104 | * Each property of style should be of specified type, styleFunction (if allowed) or function string. 105 | */ 106 | export interface ILayerStyle { 107 | /** 108 | * Element's vertices color as hex or in other format. 109 | * @see [color-parse](https://www.npmjs.com/package/color-parse) 110 | */ 111 | color: styleFunction | string | number[]; 112 | /** 113 | * Element height - only for polygons. 114 | */ 115 | height?: styleFunction | string | number; 116 | /** 117 | * Element min-height - only for polygons. 118 | * @see [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Key:min_height) 119 | */ 120 | min_height?: styleFunction | string | number; 121 | /** 122 | * Layer's name e.g. buildings 123 | */ 124 | name: string; 125 | /** 126 | * If element shall be shown 127 | * @default `true` 128 | */ 129 | show?: styleFunction | string | boolean; 130 | /** 131 | * If generate cups 132 | * @default `true` 133 | */ 134 | cups?: boolean; 135 | /** 136 | * Accepted geometry type for layer. 137 | * @default `ALL` 138 | */ 139 | type?: GeometryType; 140 | /** 141 | * Line width - only for lineStrings. 142 | * @default `2` 143 | */ 144 | width?: styleFunction | string | number; 145 | /** 146 | * @hidden 147 | */ 148 | min_height_tmp?: number; 149 | /** 150 | * @hidden 151 | */ 152 | height_tmp?: number; 153 | /** 154 | * @hidden 155 | */ 156 | width_tmp?: number; 157 | /** 158 | * @hidden 159 | */ 160 | color_tmp?: number[]; 161 | /** 162 | * @hidden 163 | */ 164 | show_tmp?: boolean; 165 | } 166 | 167 | /** 168 | * Buffers for generating geometry. 169 | * Fruit of WebWorkers' work. 170 | */ 171 | export interface ITileBuffers { 172 | id: string; 173 | colorBuffer: ArrayBuffer; 174 | normalBuffer: ArrayBuffer; 175 | vertexBuffer: ArrayBuffer; 176 | } 177 | 178 | /** 179 | * Data of event sent from WebWorker. 180 | */ 181 | export interface IWorkerEventData { 182 | realData: ITileBuffers; 183 | type: string; 184 | } 185 | 186 | /** 187 | * Event sent from WebWorker. 188 | */ 189 | export interface IWorkerEvent { 190 | data: IWorkerEventData; 191 | target: object; 192 | } 193 | 194 | /** 195 | * Data object used inside WebWorkers for building tiles. 196 | */ 197 | export interface IWorkerData { 198 | colData: number[]; 199 | cups: object; 200 | feature: VectorTileFeature; 201 | inxData: number[]; 202 | layerOrder: number; 203 | tile: TilePrimitive; 204 | vecData: number[]; 205 | } 206 | 207 | /** 208 | * Message sent to WebWorker 209 | */ 210 | export interface IWorkerMessage { 211 | id: string; 212 | style: IStyle; 213 | url: string; 214 | } 215 | -------------------------------------------------------------------------------- /src/ThreeMap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module ThreeMapGlobals 3 | * ThreeMap's most important values. 4 | */ 5 | import Emitter = mitt.Emitter; 6 | import { 7 | Camera, 8 | Frustum, 9 | Material, 10 | Object3D, 11 | OrbitControls, 12 | Scene, 13 | } from "three"; 14 | import { IStyle } from "./ThreeMap.interfaces"; 15 | import { TileGrid } from "./tilegrid"; 16 | 17 | /** 18 | * ThreeMap globally-accessible values. 19 | */ 20 | interface IThreeMap { 21 | /** 22 | * ThreeJS camera. 23 | */ 24 | camera: Camera; 25 | /** 26 | * ThreeJS controls. 27 | */ 28 | controls: OrbitControls; 29 | /* 30 | * ThreeMap events. 31 | */ 32 | events: Emitter; 33 | /** 34 | * Camera frustum for tiles calculations. 35 | */ 36 | frustum: Frustum; 37 | /** 38 | * Tiles grid. 39 | */ 40 | grid: TileGrid; 41 | /** 42 | * ThreeMap's tiles' ThreeJS material. 43 | */ 44 | material: Material; 45 | /** 46 | * ThreeJS scene. 47 | */ 48 | scene: Scene; 49 | /** 50 | * ThreeMap style configuration. 51 | */ 52 | style: IStyle; 53 | /** 54 | * ThreeMap main object 55 | */ 56 | three_map: Object3D; 57 | } 58 | 59 | /** 60 | * @hidden 61 | * ThreeMap globals initialization. 62 | */ 63 | export const TM: IThreeMap = { 64 | camera: undefined, 65 | controls: undefined, 66 | events: undefined, 67 | frustum: undefined, 68 | grid: undefined, 69 | material: undefined, 70 | scene: undefined, 71 | style: undefined, 72 | three_map: undefined, 73 | }; 74 | -------------------------------------------------------------------------------- /src/constructor/construct.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module GeometryConstructor 3 | */ 4 | import { quadkeyToTile } from "@mapbox/tilebelt"; 5 | import VT from "@mapbox/vector-tile"; 6 | import colorParse from "color-parse"; 7 | import vertexNormals from "face-normals"; 8 | import { dist, normalize, sub } from "gl-vec2"; 9 | import Protobuf from "pbf"; 10 | import xhr from "xhr"; 11 | import { ILayerStyle, IWorkerData, IWorkerMessage, Vec2, Vec3 } from "../ThreeMap.interfaces"; 12 | import { lineString } from "./linestring"; 13 | import { polygon } from "./polygon"; 14 | 15 | interface IResponse { 16 | body: object | string; 17 | headers: {}; 18 | method: string; 19 | rawRequest: XMLHttpRequest; 20 | statusCode: number; 21 | url: string; 22 | } 23 | 24 | enum DataTypes { 25 | Linestring = 2, 26 | Polygon = 3, 27 | } 28 | 29 | /** 30 | * @hidden 31 | */ 32 | const funcRegex = /function/g; 33 | /** 34 | * Parses function string to function & executes it returning its value. 35 | * 36 | * @param func - Function string. 37 | * @param feature - MVT feature properties. 38 | * @example `readStyleFunction('(feature) => {return feature.height}, {...});` 39 | */ 40 | function readStyleFunction(func: string, feature: object): any { 41 | return Function(`return (${func}(${JSON.stringify(feature)}))`)(); 42 | } 43 | 44 | /** 45 | * Protection against z-fighting 46 | */ 47 | const layerOrderLevels: number[] = [100, 100, 100, 80, 60, 50, 30, 25, 20, 20, 10, 5, 2, 1, 0.5, 0.1, 0.1]; 48 | 49 | self.addEventListener("message", (ev: { data: IWorkerMessage }): void => { 50 | xhr( 51 | { 52 | method: "GET", 53 | responseType: "arraybuffer", 54 | url: ev.data.url, 55 | useXDR: true, 56 | }, 57 | (err: Error, resp: IResponse, data: Protobuf): void => { 58 | const tileData: VT.VectorTile = new VT.VectorTile(new Protobuf(data)); 59 | const workerDataBuffers: IWorkerData = { 60 | colData: [], 61 | cups: [], 62 | feature: undefined, 63 | inxData: [], 64 | layerOrder: 0, 65 | tile: quadkeyToTile(ev.data.id), 66 | vecData: [], 67 | }; 68 | let style: ILayerStyle; 69 | let mapFeature: any; 70 | let shown: boolean; 71 | for (const layer of ev.data.style.layers) { 72 | if (tileData.layers[layer.name]) { 73 | workerDataBuffers.layerOrder += layerOrderLevels[workerDataBuffers.tile[2]]; 74 | style = layer; 75 | for (let i: number = 0; i < tileData.layers[layer.name].length; i++) { 76 | mapFeature = tileData.layers[layer.name].feature(i); 77 | shown = false; 78 | workerDataBuffers.feature = mapFeature; 79 | 80 | if (typeof style.color === "string" && style.color.match(funcRegex)) { 81 | style.color_tmp = colorParse(readStyleFunction(style.color, mapFeature.properties)); 82 | } else { 83 | style.color_tmp = colorParse(style.color).values; 84 | } 85 | 86 | if (typeof style.show === "boolean") { 87 | style.show_tmp = style.show; 88 | } else if (typeof style.show === "string") { 89 | style.show_tmp = readStyleFunction(style.show, mapFeature.properties); 90 | } 91 | if (style.show_tmp) { 92 | shown = true; 93 | if (mapFeature.type === DataTypes.Linestring) { 94 | if (style.type === "LINESTRING" || "ALL") { 95 | 96 | if (typeof style.width === "string") { 97 | style.width_tmp = readStyleFunction(style.width, mapFeature.properties) / 2; 98 | } else if (typeof style.width === "number") { 99 | style.width_tmp = style.width; 100 | } 101 | lineString(workerDataBuffers, style); 102 | if (style.cups) { 103 | cupBuilder(style, workerDataBuffers); 104 | } 105 | } 106 | } else if (mapFeature.type === DataTypes.Polygon) { 107 | if (style.type === "POLYGON" || "ALL") { 108 | 109 | if (typeof style.height === "string") { 110 | style.height_tmp = readStyleFunction(style.height, mapFeature.properties); 111 | } else if (typeof style.height === "number") { 112 | style.height_tmp = style.height; 113 | } 114 | 115 | if (typeof style.min_height === "string") { 116 | style.min_height_tmp = readStyleFunction(style.min_height, mapFeature.properties); 117 | } else if (typeof style.min_height === "number") { 118 | style.min_height_tmp = style.min_height; 119 | } 120 | polygon(workerDataBuffers, style); 121 | } 122 | } 123 | } 124 | // @ts-ignore 125 | self.postMessage({ type: "feature", realData: { feature: mapFeature, shown } }); 126 | } 127 | } 128 | } 129 | const normalBuffer: ArrayBuffer = vertexNormals(workerDataBuffers.vecData, 0).buffer; 130 | const vertexBuffer: ArrayBuffer = new Float32Array(workerDataBuffers.vecData).buffer; 131 | const colorBuffer: ArrayBuffer = new Float32Array(workerDataBuffers.colData).buffer; 132 | self.postMessage( 133 | { type: "onFinish", realData: { vertexBuffer, colorBuffer, normalBuffer, id: ev.data.id } }, 134 | // @ts-ignore 135 | [vertexBuffer, colorBuffer, normalBuffer], 136 | ); 137 | }); 138 | 139 | }); 140 | 141 | /** 142 | * Generates line's cups. 143 | * 144 | * @param style - Layer's style configuration. 145 | * @param workerDataBuffers - Data used for building tile. 146 | * 147 | * @example `cupBuilder({...}, {...});` 148 | */ 149 | function cupBuilder(style: ILayerStyle, workerDataBuffers: IWorkerData): void { 150 | const numOfGenColors: number = 6; 151 | for (const key in workerDataBuffers.cups) { 152 | if (workerDataBuffers.cups.hasOwnProperty(key)) { 153 | if (workerDataBuffers.cups[key].length >= 2) { 154 | workerDataBuffers.vecData.push( 155 | ...workerDataBuffers.cups[key][0].right, 156 | ...workerDataBuffers.cups[key][0].left, 157 | ...workerDataBuffers.cups[key][1].right, 158 | ...workerDataBuffers.cups[key][1].right, 159 | ...workerDataBuffers.cups[key][0].left, 160 | ...workerDataBuffers.cups[key][1].left, 161 | ); 162 | 163 | for (let i: number = 0; i < numOfGenColors; i++) { 164 | workerDataBuffers.colData.push( 165 | style.color_tmp[0] / 255, 166 | style.color_tmp[1] / 255, 167 | style.color_tmp[2] / 255, 168 | ); 169 | } 170 | } 171 | if (workerDataBuffers.cups[key][0].normal) { 172 | const numOfGenVec3: number = 9; 173 | const toThird: number = 3; 174 | const right: Vec2 = workerDataBuffers.cups[key][0].right; 175 | const left: Vec2 = workerDataBuffers.cups[key][0].left; 176 | const rightVec: Vec2 = [workerDataBuffers.cups[key][0].right[0], workerDataBuffers.cups[key][0].right[2]]; 177 | const leftVec: Vec2 = [workerDataBuffers.cups[key][0].left[0], workerDataBuffers.cups[key][0].left[2]]; 178 | let center: Vec2 = sub([], rightVec, leftVec); 179 | const thickness: number = Math.round(dist(rightVec, leftVec)); 180 | center = [leftVec[0] + center[0] / 2, leftVec[1] + center[1] / 2]; 181 | const verticalNormal: Vec2 = workerDataBuffers.cups[key][0].normal; 182 | const horizontalNormal: Vec2 = normalize([], sub([], rightVec, leftVec)); 183 | const topCup: Vec3 = [ 184 | center[0] - thickness / 2 * verticalNormal[0], 185 | workerDataBuffers.layerOrder, 186 | center[1] - thickness / 2 * verticalNormal[1], 187 | ]; 188 | const middleRightCup: Vec3 = [ 189 | center[0] + thickness / toThird * (horizontalNormal[0] - verticalNormal[0]), 190 | workerDataBuffers.layerOrder, 191 | center[1] + thickness / toThird * (horizontalNormal[1] - verticalNormal[1]), 192 | ]; 193 | const middleLeftCup: Vec3 = [ 194 | center[0] - thickness / toThird * (verticalNormal[0] + horizontalNormal[0]), 195 | workerDataBuffers.layerOrder, 196 | center[1] - thickness / toThird * (verticalNormal[1] + horizontalNormal[1]), 197 | ]; 198 | workerDataBuffers.vecData.push(...right, ...topCup, ...middleRightCup); 199 | workerDataBuffers.vecData.push(...right, ...left, ...topCup); 200 | workerDataBuffers.vecData.push(...left, ...middleLeftCup, ...topCup); 201 | for (let i: number = 0; i < numOfGenVec3; i++) { 202 | workerDataBuffers.colData.push( 203 | style.color_tmp[0] / 255, 204 | style.color_tmp[1] / 255, 205 | style.color_tmp[2] / 255, 206 | ); 207 | } 208 | } 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /src/constructor/linestring.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module LineStringConstructor 3 | */ 4 | import { add, scale, normalize, sub } from "gl-vec2"; 5 | import { ILayerStyle, IWorkerData, Vec2, Vec3 } from "../ThreeMap.interfaces"; 6 | interface ILineSegment { 7 | back: { 8 | left: Vec3; 9 | normal?: Vec2; 10 | right: Vec3; 11 | }; 12 | front: { 13 | left: Vec3; 14 | normal?: Vec2; 15 | right: Vec3; 16 | }; 17 | } 18 | /** 19 | * Parses data for line generation. 20 | * 21 | * @param data - Data used for building tile. 22 | * @param style - Layer's style configuration. 23 | * @example `lineString({...}, {...});` 24 | */ 25 | export function lineString(data: IWorkerData, style: ILayerStyle): IWorkerData { 26 | const tileExtend: number = 2048; 27 | const geometry: Array> = data.feature.loadGeometry(); 28 | let vertices: Vec2[]; 29 | 30 | for (const lineSeg of geometry) { 31 | vertices = []; 32 | for (const vec of lineSeg) { 33 | vertices.push([vec.x - tileExtend, vec.y - tileExtend]); 34 | } 35 | line(vertices, data, style); 36 | } 37 | 38 | return data; 39 | } 40 | 41 | /** 42 | * Generates line segment - line between 2 vectors. 43 | * 44 | * @param v1 - First vector. 45 | * @param v2 - Second vector. 46 | * @param data - Data used for building tile. 47 | * @param style - Layer's style configuration. 48 | * @example `lineSegment([1,2], [3,4] , {...}, {...});` 49 | */ 50 | function lineSegment(v1: Vec2, v2: Vec2, data: IWorkerData, style: ILayerStyle): ILineSegment { 51 | const lineVec: Vec2 = sub([], v2, v1); 52 | const normal: Vec2 = normalize([], [-lineVec[1], lineVec[0]]); 53 | const distance: number = scale([], normal, style.width_tmp); 54 | const numOfGenColors: number = 6; 55 | let frontRight: Vec3 = add([], v2, distance); 56 | let frontLeft: Vec3 = sub([], v2, distance); 57 | let backRight: Vec3 = add([], v1, distance); 58 | let backLeft: Vec3 = sub([], v1, distance); 59 | 60 | frontRight = [frontRight[0], data.layerOrder, frontRight[1]]; 61 | frontLeft = [frontLeft[0], data.layerOrder, frontLeft[1]]; 62 | backRight = [backRight[0], data.layerOrder, backRight[1]]; 63 | backLeft = [backLeft[0], data.layerOrder, backLeft[1]]; 64 | 65 | data.vecData.push(...backRight, ...backLeft, ...frontRight); 66 | data.vecData.push(...frontRight, ...backLeft, ...frontLeft); 67 | 68 | for (let i: number = 0; i < numOfGenColors; i++) { 69 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 70 | } 71 | 72 | return { 73 | back: { 74 | left: backLeft, 75 | right: backRight, 76 | }, 77 | front: { 78 | left: frontLeft, 79 | right: frontRight, 80 | }, 81 | }; 82 | } 83 | 84 | /** 85 | * Generates line. 86 | * 87 | * @param vertices - Preprocessed vertices array. 88 | * @param data - Data used for building tile. 89 | * @param style - Layer's style configuration. 90 | * @example `line([[1,2], [3,4]], {...}, {...});` 91 | */ 92 | function line(vertices: number[][], data: IWorkerData, style: ILayerStyle): IWorkerData { 93 | const numOfGenColors: number = 6; 94 | if (vertices.length < 2) { 95 | return; 96 | } 97 | let seg1: ILineSegment; 98 | let seg2: ILineSegment; 99 | for (let i: number = 0; i < vertices.length - 1; i++) { 100 | seg1 = seg2 ? seg2 : lineSegment(vertices[i], vertices[i + 1], data, style); 101 | if (i === 0) { 102 | const vertexKey: string = vertices[i].join("|"); 103 | if (data.cups[vertexKey]) { 104 | delete data.cups[vertexKey].normal; 105 | data.cups[vertexKey].push(seg1.back); 106 | } else { 107 | const lineVec: Vec2 = sub([], vertices[i + 1], vertices[i]); 108 | const normal: Vec2 = normalize([], lineVec); 109 | const cup: ILineSegment["back"] = seg1.back; 110 | cup.normal = normal; 111 | data.cups[vertexKey] = [cup]; 112 | } 113 | } 114 | if (i === vertices.length - 2) { 115 | const vertexKey: string = vertices[i + 1].join("|"); 116 | if (data.cups[vertexKey]) { 117 | delete data.cups[vertexKey].normal; 118 | data.cups[vertexKey].push(seg1.front); 119 | } else { 120 | const lineVec: Vec2 = sub([], vertices[i], vertices[i + 1]); 121 | const normal: Vec2 = normalize([], lineVec); 122 | const cup: ILineSegment["front"] = seg1.front; 123 | cup.normal = normal; 124 | data.cups[vertexKey] = [cup]; 125 | } 126 | } 127 | if (vertices[i + 2]) { 128 | seg2 = lineSegment(vertices[i + 1], vertices[i + 2], data, style); 129 | data.vecData.push(...seg1.front.right, ...seg1.front.left, ...seg2.back.right); 130 | data.vecData.push(...seg1.front.right, ...seg1.front.left, ...seg2.back.left); 131 | for (let k: number = 0; k < numOfGenColors; k++) { 132 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 133 | } 134 | } 135 | } 136 | 137 | return data; 138 | } 139 | -------------------------------------------------------------------------------- /src/constructor/polygon.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module PolygonConstructor 3 | */ 4 | import earcut from "earcut"; 5 | import { ILayerStyle, IWorkerData } from "../ThreeMap.interfaces"; 6 | 7 | /** 8 | * Parses data for polygon generation. 9 | * 10 | * @param data - Data used for building tile. 11 | * @param style - Layer's style configuration. 12 | * @example `polygon({...}, {...});` 13 | */ 14 | export function polygon(data: IWorkerData, style: ILayerStyle): IWorkerData { 15 | const geometry: Array>> = classifyRings(data.feature.loadGeometry()); 16 | let vertices: number[][]; 17 | for (const ring of geometry) { 18 | vertices = [[], []]; 19 | for (let j: number = 0; j < ring.length; j++) { 20 | for (let l: number = 0; l < ring[j].length - 1; l++) { 21 | vertices[0].push(ring[j][l].x - 2048, ring[j][l].y - 2048); 22 | if (j > 0) { 23 | vertices[1].push((vertices[0].length - 2) / 2); 24 | } 25 | } 26 | } 27 | if (style.height === 0) { 28 | flatPolygon(vertices, data, style); 29 | } else { 30 | extrudedPolygon(vertices, data, style); 31 | } 32 | } 33 | 34 | return data; 35 | } 36 | 37 | /** 38 | * Generates flat polygon. 39 | * 40 | * @param vertices - Preprocessed vertices array. 41 | * @param data - Data used for building tile. 42 | * @param style - Layer's style configuration. 43 | * @example `flatPolygon([[1,2],[3,4],[5,6],[1,2]], {...}, {...}); 44 | */ 45 | function flatPolygon(vertices: number[][], data: IWorkerData, style: ILayerStyle): IWorkerData { 46 | const tris: number[] = earcut(vertices[0], vertices[1]); 47 | for (const tri of tris) { 48 | // @ts-ignore 49 | data.vecData.push(vertices[0][tri * 2], style.min_height_tmp + data.layerOrder, vertices[0][tri * 2 + 1]); 50 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 51 | } 52 | 53 | return data; 54 | } 55 | 56 | /** 57 | * Generates extruded polygon - 3D Object. 58 | * 59 | * @param vertices - Preprocessed vertices array. 60 | * @param data - Data used for building tile. 61 | * @param style - Layer's style configuration. 62 | * @example `extrudedPolygon([[1,2],[3,4],[5,6],[1,2]], {...}, {...}); 63 | */ 64 | function extrudedPolygon(vertices: number[][], data: IWorkerData, style: ILayerStyle): IWorkerData { 65 | const numOfGenColors: number = 6; 66 | const tris: number[] = earcut(vertices[0], vertices[1]); 67 | for (const tri of tris) { 68 | // @ts-ignore 69 | data.vecData.push(vertices[0][tri * 2], style.min_height_tmp + data.layerOrder, vertices[0][tri * 2 + 1]); 70 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 71 | } 72 | for (const tri of tris) { 73 | // @ts-ignore 74 | data.vecData.push(vertices[0][tri * 2], style.height_tmp, vertices[0][tri * 2 + 1]); 75 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 76 | } 77 | for (let i: number = 0; i < vertices[0].length / 2; i++) { 78 | if (i + 1 !== vertices[0].length / 2) { 79 | data.vecData.push(vertices[0][i * 2], style.height_tmp, vertices[0][i * 2 + 1]); 80 | data.vecData.push(vertices[0][i * 2], style.min_height_tmp + data.layerOrder, vertices[0][i * 2 + 1]); 81 | data.vecData.push(vertices[0][(i + 1) * 2], style.min_height_tmp + data.layerOrder, vertices[0][(i + 1) * 2 + 1]); 82 | data.vecData.push(vertices[0][(i + 1) * 2], style.min_height_tmp + data.layerOrder, vertices[0][(i + 1) * 2 + 1]); 83 | data.vecData.push(vertices[0][(i + 1) * 2], style.height_tmp, vertices[0][(i + 1) * 2 + 1]); 84 | data.vecData.push(vertices[0][i * 2], style.height_tmp, vertices[0][i * 2 + 1]); 85 | 86 | for (let l: number = 0; l < numOfGenColors; l++) { 87 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 88 | } 89 | } else { 90 | data.vecData.push(vertices[0][i * 2], style.height_tmp, vertices[0][i * 2 + 1]); 91 | data.vecData.push(vertices[0][i * 2], style.min_height_tmp + data.layerOrder, vertices[0][i * 2 + 1]); 92 | data.vecData.push(vertices[0][0], style.min_height_tmp + data.layerOrder, vertices[0][1]); 93 | data.vecData.push(vertices[0][0], style.min_height_tmp + data.layerOrder, vertices[0][1]); 94 | data.vecData.push(vertices[0][0], style.height_tmp, vertices[0][1]); 95 | data.vecData.push(vertices[0][i * 2], style.height_tmp, vertices[0][i * 2 + 1]); 96 | 97 | for (let j: number = 0; j < numOfGenColors; j++) { 98 | data.colData.push(style.color_tmp[0] / 255, style.color_tmp[1] / 255, style.color_tmp[2] / 255); 99 | } 100 | } 101 | } 102 | 103 | return data; 104 | } 105 | /** 106 | * @hidden 107 | * Helps in polygon classification. 108 | * 109 | * @param ring - MVT Polygon data. 110 | * @example `signedArea([{x: 1, y: 2}, ...]); 111 | */ 112 | function signedArea(ring: Array<{ x: number; y: number }>): number { 113 | let sum: number = 0; 114 | const len: number = ring.length; 115 | let j: number = len - 1; 116 | let p1: { x: number; y: number }; 117 | let p2: { x: number; y: number }; 118 | for (let i: number = 0; i < len; j = i++) { 119 | p1 = ring[i]; 120 | p2 = ring[j]; 121 | sum += (p2.x - p1.x) * (p1.y + p2.y); 122 | } 123 | 124 | return sum; 125 | } 126 | 127 | /** 128 | * @hidden 129 | * Sorts vertices for polygons with holes. 130 | * 131 | * @param rings - MVT Geometry data. 132 | * @example `classifyRings([[{x: 1, y: 2}, ...],[...]]);` 133 | */ 134 | function classifyRings(rings: Array>): Array>> { 135 | const len: number = rings.length; 136 | if (len <= 1) { 137 | return [rings]; 138 | } 139 | const polygons: Array>> = []; 140 | let poly: Array>; 141 | let ccw: boolean; 142 | 143 | for (let i: number = 0; i < len; i++) { 144 | const area: number = signedArea(rings[i]); 145 | if (area === 0) { 146 | continue; 147 | } 148 | if (ccw === undefined) { 149 | ccw = area < 0; 150 | } 151 | if (ccw === area < 0) { 152 | if (poly) { 153 | polygons.push(poly); 154 | } 155 | poly = [rings[i]]; 156 | } else { 157 | if (poly) { 158 | poly.push(rings[i]); 159 | } 160 | } 161 | } 162 | if (poly) { 163 | polygons.push(poly); 164 | } 165 | 166 | return polygons; 167 | } 168 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module ThreeMap 3 | * ThreeMap base class - initialize map. 4 | */ 5 | import EventEmitter from "mitt"; 6 | import { Camera, Frustum, Matrix4, Object3D, OrbitControls } from "three"; 7 | import { Extension } from "./Extension"; 8 | import { TM } from "./ThreeMap"; 9 | import { IStyle } from "./ThreeMap.interfaces"; 10 | import { TileGrid } from "./tilegrid"; 11 | import { ll2merc, merc2ll, readStyle } from "./utils"; 12 | import { initWorkerPool } from "./workerpool"; 13 | 14 | /** 15 | * ThreeMap base class 16 | */ 17 | export class Map extends Object3D { 18 | /** 19 | * Convert longitude - latitude coordinates to mercator coordinates. 20 | * 21 | * @param latlng - Array of longitude & latitude coordinates. 22 | * @returns Array of mercator x & y coordinates. 23 | * @example `ThreeMap.lonlatToMerc([77.35262, 40.2525]);` 24 | */ 25 | public static lonLatToMerc(latlng: number[]): number[] { 26 | return ll2merc(latlng); 27 | } 28 | 29 | /** 30 | * Convert mercator coordinates to longitude - latitude coordinates. 31 | * 32 | * @param mercXY - Array of mercator x & y coordinates. 33 | * @returns Array of longitude & latitude coordinates. 34 | * @example `ThreeMap.mercToLonLat([462073.1353, 295052.562]);` 35 | */ 36 | public static mercToLonLat(mercXY: number[]): number[] { 37 | return merc2ll(mercXY); 38 | } 39 | 40 | public events: EventEmitter.Emitter; 41 | 42 | /** 43 | * @param params - Object with ThreeJS camera, controls and ThreeMap style configuration object. 44 | * @example `var map = new ThreeMap({camera: [...], controls: [...], style: [...]});` 45 | */ 46 | public constructor(params: { 47 | camera: Camera; 48 | controls: OrbitControls; 49 | style: IStyle; 50 | }) { 51 | super(); 52 | if (!params.camera || !params.controls || !params.style) { 53 | throw new Error( 54 | "Please provide parameters with ThreeJS camera, controls and ThreeMap style!", 55 | ); 56 | } 57 | this.events = new EventEmitter(); 58 | TM.style = readStyle(params.style); 59 | TM.camera = params.camera; 60 | TM.frustum = new Frustum(); 61 | TM.frustum.setFromMatrix( 62 | new Matrix4().multiplyMatrices( 63 | TM.camera.projectionMatrix, 64 | TM.camera.matrixWorldInverse, 65 | ), 66 | ); 67 | TM.controls = params.controls; 68 | TM.grid = new TileGrid(); 69 | TM.events = this.events; 70 | TM.three_map = this; 71 | TM.material = params.style.material; 72 | initWorkerPool(); 73 | params.style.material = undefined; 74 | 75 | TM.controls.addEventListener("change", () => { 76 | TM.camera.updateMatrix(); 77 | TM.camera.updateMatrixWorld(false); 78 | TM.camera.matrixWorldInverse.getInverse(TM.camera.matrixWorld); 79 | TM.frustum.setFromMatrix( 80 | new Matrix4().multiplyMatrices( 81 | TM.camera.projectionMatrix, 82 | TM.camera.matrixWorldInverse, 83 | ), 84 | ); 85 | TM.grid.update(); 86 | }); 87 | } 88 | 89 | /** 90 | * Unregister ThreeMap's event listener. 91 | * 92 | * @param event - Event's name. 93 | * @param callback - Event's associated callback. 94 | * @example `map.off('tileCreated', (e) => console.log(e));` 95 | */ 96 | public off(event: string, callback: (data: object) => any): void { 97 | this.events.off(event, callback); 98 | } 99 | 100 | /** 101 | * Register ThreeMap's event listener. 102 | * 103 | * @param event - Event's name. 104 | * @param callback - Event's callback. 105 | * @example `map.on('tileCreated', (e) => console.log(e));` 106 | * ``` 107 | */ 108 | public on(event: string, callback: (data: object) => any): void { 109 | this.events.on(event, callback); 110 | } 111 | 112 | /** 113 | * Registers new ThreeMap's extensions. 114 | * 115 | * @param ext - ThreeMap's Extension class instance. 116 | * @example `map.register(new ThreeMap.Extension({...}));` 117 | * ``` 118 | */ 119 | public registerExtension(ext: Extension): void { 120 | this.events.on("update", ext.onUpdate.bind(ext)); 121 | this.events.on("tileCreated", ext.onTileRemoved.bind(ext)); 122 | this.events.on("tileRemoved", ext.onTileCreated.bind(ext)); 123 | this.events.on("feature", ext.onFeature.bind(ext)); 124 | ext.style = TM.style; 125 | ext.map = TM.three_map; 126 | } 127 | } 128 | 129 | export { Extension }; 130 | -------------------------------------------------------------------------------- /src/tile.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module Tile 3 | */ 4 | import { tileToQuadkey } from "@mapbox/tilebelt"; 5 | import { dist } from "gl-vec2"; 6 | import { Box3 } from "three"; 7 | import { TM } from "./ThreeMap"; 8 | import { TilePrimitive } from "./ThreeMap.interfaces"; 9 | import { getURLForTile, removeTile, tileBounds } from "./utils"; 10 | import { startWorker } from "./workerpool"; 11 | 12 | /** 13 | * Full-fledged tile - used for View instances 14 | */ 15 | export class Tile { 16 | /** 17 | * Tile's bounds 18 | */ 19 | public bounds: Box3; 20 | /** 21 | * Tile's id a.k.a. QuadKey 22 | */ 23 | public id: string; 24 | /** 25 | * Tile's x coordinate 26 | */ 27 | public x: number; 28 | /** 29 | * Tile's y coordinate 30 | */ 31 | public y: number; 32 | /** 33 | * Tile's zoom level 34 | */ 35 | public z: number; 36 | /** 37 | * One-time assign url of tile 38 | */ 39 | private readonly url: string; 40 | 41 | /** 42 | * @param tile - Array of tile coordinates [x,y,z]. 43 | * @param id - Optional pre-generated tile's quadkey. 44 | * @example `new Tile([10, 15, 8], "00003232");` 45 | */ 46 | public constructor(tile: TilePrimitive, id?: string) { 47 | this.id = id ? id : tileToQuadkey(tile); 48 | [this.x, this.y, this.z] = tile; 49 | this.url = getURLForTile({ x: this.x, y: this.y, z: this.z }); 50 | this.bounds = tileBounds(this.id); 51 | } 52 | /** 53 | * Send task to worker to start creating geometry. 54 | * 55 | * @example `Tile.build();` 56 | */ 57 | public build(): void { 58 | return startWorker({ url: this.url, id: this.id, style: TM.style }); 59 | } 60 | /** 61 | * Get tile's bounds. 62 | * 63 | * @returns ThreeJS bounding box. 64 | * @example `Tile.getBounds();` 65 | */ 66 | public getBounds(): Box3 { 67 | return this.bounds; 68 | } 69 | /** 70 | * Remove tile from grid. 71 | * 72 | * @example `Tile.remove();` 73 | */ 74 | public remove(): void { 75 | removeTile(this.id); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/tilegrid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module TileGrid 3 | */ 4 | import { getChildren, tileToBBOX, tileToQuadkey } from "@mapbox/tilebelt"; 5 | import { TM } from "./ThreeMap"; 6 | import { IView, TilePrimitive } from "./ThreeMap.interfaces"; 7 | import { Tile } from "./tile"; 8 | import { TileList } from "./tilelist"; 9 | import { getCameraPosition, getTileFromMerc, getZoom, getZoomLevel, intersects, realTile } from "./utils"; 10 | 11 | /** 12 | * Grid - main tile-grouping unit 13 | */ 14 | export class TileGrid { 15 | /** 16 | * 'Renders' tiles - sends tasks to build & remove them. 17 | * 18 | * @param view - List of tiles to render & remove. 19 | * @example `Grid.render({toRender: [...], toRemove: [...]});` 20 | */ 21 | public static render(view: IView): void { 22 | if (view.toRender) { 23 | for (let i = 0; i < view.toRender.length; i++) { 24 | view.toRender[i].build(); 25 | } 26 | } 27 | if (view.toRemove) { 28 | for (let i = 0; i < view.toRemove.length; i++) { 29 | view.toRemove[i].remove(); 30 | } 31 | } 32 | } 33 | /** 34 | * Current mercator position 35 | */ 36 | public position: number[]; 37 | /** 38 | * Current tiles in view 39 | */ 40 | public tiles: TileList; 41 | /** 42 | * Current zoom level 43 | */ 44 | public zoom: number; 45 | 46 | /** 47 | * Gets tiles inside current view. 48 | * 49 | * @returns Tiles in view. 50 | * @example ``` 51 | * var gridInstance = new Grid(); 52 | * gridInstance.getTilesForView(); 53 | * ``` 54 | */ 55 | public getTilesForView(): TileList { 56 | const tiles: TileList = new TileList(); 57 | let tile: TilePrimitive; 58 | let tileObject: Tile; 59 | this.position = getCameraPosition(); 60 | this.zoom = getZoomLevel(getZoom()); 61 | const centerTile: TilePrimitive = getTileFromMerc(this.position, this.zoom); 62 | for (let x: number = -TM.style.tilesExtend; x <= TM.style.tilesExtend; x++) { 63 | for (let y: number = -TM.style.tilesExtend; y <= TM.style.tilesExtend; y++) { 64 | tile = [centerTile[0] + x, centerTile[1] + y, centerTile[2]]; 65 | if (realTile(tile)) { 66 | tileObject = new Tile(tile); 67 | if (intersects(tileObject.bounds)) { 68 | tiles.push(tileObject); 69 | } 70 | } 71 | } 72 | } 73 | 74 | return tiles; 75 | } 76 | /** 77 | * Updates view on change. 78 | * 79 | * @example `gridInstance.update();` 80 | */ 81 | public update(): void { 82 | let view: IView; 83 | if (this.tiles) { 84 | const oldTiles: TileList = this.tiles; 85 | this.tiles = this.getTilesForView(); 86 | view = this.tiles.getTilesToRender(oldTiles); 87 | } else { 88 | this.tiles = this.getTilesForView(); 89 | view = this.tiles.getTilesToRender(); 90 | } 91 | //TM.events.emit("update", { tiles: this.tiles }); 92 | TileGrid.render(view); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/tilelist.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module TileList 3 | */ 4 | import { IView } from "./ThreeMap.interfaces"; 5 | import { Tile } from "./tile"; 6 | 7 | /** 8 | * TileList - collection of tiles 9 | */ 10 | export class TileList extends Array { 11 | /** 12 | * Checks if TileList contains specific Tile by Quadkey. 13 | * 14 | * @param quadkey - Tile's quadkey. 15 | * @example `TileList.containsTile("00003232");` 16 | */ 17 | public containsTile(quadkey: string): boolean { 18 | for (let i = 0; i < this.length; i++) { 19 | if (this[i].id === quadkey) { 20 | return true; 21 | } 22 | } 23 | return false; 24 | } 25 | 26 | /** 27 | * Get tiles to remove (not seen in current view) and render (actually seen in view). 28 | * 29 | * @param previousTiles - Collection of currently-in-view tiles. 30 | * @returns View instance - tiles to be rendered & removed. 31 | * @example `TileList.getTilesToRender({...});` 32 | */ 33 | public getTilesToRender(previousTiles?: TileList): IView { 34 | const toRender: Tile[] = []; 35 | if (!previousTiles) { 36 | for (let i = 0; i < this.length; i++) { 37 | toRender.push(this[i]); 38 | } 39 | 40 | return { toRender, toRemove: undefined }; 41 | } 42 | const toRemove: Tile[] = []; 43 | const toPreserve: TileList = new TileList(); 44 | for (let i = 0; i < this.length; i++) { 45 | if (!previousTiles.containsTile(this[i].id)) { 46 | // @ts-ignore 47 | toRender.push(this[i]); 48 | } else { 49 | // @ts-ignore 50 | toPreserve.push(this[i]); 51 | } 52 | 53 | } 54 | for (let i = 0; i < previousTiles.length; i++) { 55 | if (!toPreserve.containsTile(previousTiles[i].id)) { 56 | toRemove.push(previousTiles[i]); 57 | } 58 | } 59 | 60 | return { toRender, toRemove }; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Collection of util functions used in library. 3 | * 4 | * @format 5 | * @module Utils 6 | */ 7 | 8 | import SphericalMercator from "@mapbox/sphericalmercator"; 9 | import { getChildren, pointToTile, quadkeyToTile, tileToBBOX, tileToQuadkey } from "@mapbox/tilebelt"; 10 | import { Box3, BufferAttribute, BufferGeometry, Mesh, Object3D, Vector3 } from "three"; 11 | import { TM } from "./ThreeMap"; 12 | import { IStyle, ITileBuffers, ITileObject, TilePrimitive } from "./ThreeMap.interfaces"; 13 | 14 | /** 15 | * X and y size of Mercator map. 16 | */ 17 | const mercatorExtend: number = 20037510; 18 | /** 19 | * X and y size of tile. 20 | */ 21 | const tileExtend: number = 2048; 22 | /** 23 | * Pre-calculated scale (tile to mercator size). 24 | */ 25 | const scale: number = mercatorExtend / tileExtend; 26 | /** 27 | * SphericalMercator library instance for latLng to mercator coordinates conversion. 28 | */ 29 | const merc: SphericalMercator = new SphericalMercator({ 30 | size: 2048, 31 | }); 32 | /** 33 | * Regular expression for matching tile properties in url. 34 | */ 35 | const tileRegex: RegExp = /{([zxy])}/g; 36 | 37 | /** 38 | * Get url for tile object. 39 | * 40 | * @param tileObject - Tile primitive represented as object of x, y, z values. 41 | * @example `getURLForTile({x: 1, y: 3, z: 7);` 42 | */ 43 | export function getURLForTile(tileObject: ITileObject): string { 44 | tileRegex.lastIndex = 0; 45 | 46 | return TM.style.address.replace(tileRegex, (match: string, key: string) => tileObject[key]); 47 | } 48 | 49 | /** 50 | * @hidden 51 | * Throws error. 52 | * @param message - Error message. 53 | * @example `throwError('Error');` 54 | */ 55 | export function throwError(message: string): never { 56 | throw new Error(message); 57 | } 58 | /** 59 | * Parses ThreeMap style configuration and applies default values. 60 | * 61 | * @param style - Style configuration. 62 | * @example `readStyle({...});` 63 | */ 64 | export function readStyle(style: IStyle): IStyle { 65 | if (!style.address || !style.layers || !style.material) { 66 | return throwError("Required style properties (address, layers, material) haven't been supplied"); 67 | } 68 | for (const layer of style.layers) { 69 | if (!layer.name || !layer.color) { 70 | return throwError("Required style properties (name, color) haven't been supplied"); 71 | } 72 | if (layer.width && typeof layer.width === "function") { 73 | layer.width = layer.width.toString(); 74 | } 75 | if (layer.height && typeof layer.height === "function") { 76 | layer.height = layer.height.toString(); 77 | } 78 | if (layer.min_height && typeof layer.min_height === "function") { 79 | layer.min_height = layer.min_height.toString(); 80 | } 81 | if (layer.color && typeof layer.color === "function") { 82 | layer.color = layer.color.toString(); 83 | } 84 | layer.height = layer.height ? layer.height : 0; 85 | layer.min_height = layer.min_height ? layer.min_height : 0; 86 | layer.width = layer.width ? layer.width : 2; 87 | layer.show = layer.show ? layer.show : true; 88 | layer.cups = layer.cups ? layer.cups : true; 89 | layer.type = layer.type ? layer.type : "ALL"; 90 | } 91 | 92 | style.maxZoom = style.maxZoom ? style.maxZoom : 16; 93 | style.minZoom = style.minZoom ? style.minZoom : 1; 94 | style.tilesExtend = style.tilesExtend ? style.tilesExtend : 2; 95 | style.workers = style.workers ? style.workers : 4; 96 | 97 | return style; 98 | } 99 | 100 | /** 101 | * Convert longitude - latitude coordinates to mercator coordinates. 102 | * 103 | * @param ll - Array of longitude & latitude coordinates. 104 | * @returns Array of mercator x & y coordinates. 105 | * @example `ll2merc([77.35262, 40.2525]);` 106 | */ 107 | export function ll2merc(ll: number[]): number[] { 108 | const xy: number[] = merc.forward(ll); 109 | return [xy[0], -xy[1]]; 110 | } 111 | 112 | /** 113 | * Converts mercator coordinates to longitude - latitude coordinates. 114 | * 115 | * @param xy - Array of mercator x & y coordinates. 116 | * @returns Array of longitude & latitude coordinates. 117 | * @example `ThreeMap.mercToLonLat([462073.1353, 295052.562]);` 118 | */ 119 | export function merc2ll(xy: number[]): number[] { 120 | return merc.inverse([xy[0], -xy[1]]); 121 | } 122 | 123 | /** 124 | * Returns tile coordinates for given mercator x & y and zoom level values. 125 | * 126 | * @param pos - Array of mercator x & y coordinates. 127 | * @param z - Specified zoom level. 128 | * @example `getTileFromMerc([130533.56363, 106826.5536], 14);` 129 | */ 130 | export function getTileFromMerc(pos: number[], z: number): TilePrimitive { 131 | const mercPos: number[] = merc.inverse(pos); 132 | 133 | return pointToTile(mercPos[0], mercPos[1], z); 134 | } 135 | 136 | /** 137 | * Converts distance from camera to controls target into zoom level. 138 | * 139 | * @param distance - Distance between camera and controls target. 140 | * @example `getZoomLevel(357200);` 141 | */ 142 | export function getZoomLevel(distance: number): number { 143 | const maxZoomLevel: number = 15000000; 144 | 145 | return Math.round( 146 | Math.min(Math.max(Math.log(distance / maxZoomLevel) / Math.log(0.5), TM.style.minZoom), TM.style.maxZoom), 147 | ); 148 | } 149 | 150 | /** 151 | * Checks if tile exists in grid. 152 | * 153 | * @param quadkey - Tile's quadkey. 154 | * @example `doesTileExists('0123');` 155 | */ 156 | export function doesTileExists(quadkey: string): boolean { 157 | return TM.grid.tiles.containsTile(quadkey); 158 | } 159 | 160 | /** 161 | * Checks if tile coordinates are in specified bounds (max is 2^zoom level). 162 | * 163 | * @param tile - Tile to be checked. 164 | * @example `realTile([3,4,4]);` 165 | */ 166 | export function realTile(tile: TilePrimitive): boolean { 167 | const maxTile: number = 2 ** tile[2] - 1; 168 | 169 | return tile[0] >= 0 && tile[1] >= 0 && tile[0] <= maxTile && tile[1] <= maxTile; 170 | } 171 | /** 172 | * Returns given tile's center in mercator coordinates. 173 | * 174 | * @param id - Tile's quadkey. 175 | * @example `getTilePosition('0123');` 176 | */ 177 | export function getTilePosition(id: string): number[] { 178 | const thirdChildIndex: number = 2; 179 | let tile: number[] = quadkeyToTile(id); 180 | tile = getChildren(tile)[thirdChildIndex]; 181 | const n: number = Math.PI - 2 * Math.PI * tile[1] / 2 ** tile[2]; 182 | const halfDegrees: number = 180; 183 | const fullDegrees: number = 360; 184 | 185 | return merc.forward([ 186 | tile[0] / 2 ** tile[2] * fullDegrees - halfDegrees, 187 | halfDegrees / Math.PI * Math.atan(halfDegrees / fullDegrees * (Math.exp(n) - Math.exp(-n))), 188 | ]); 189 | } 190 | 191 | /** 192 | * Returns number representing x and y scale for resizing tile local coordinates to mercator coordinates. 193 | * 194 | * @param id - Tile's quadkey. 195 | * @example `getTileScale('0123');` 196 | */ 197 | export function getTileScale(id: string): number { 198 | const tile: number[] = quadkeyToTile(id); 199 | 200 | return scale / 2 ** tile[2]; 201 | } 202 | 203 | ///////////////////////////// 204 | ///// THREE.JS SECTION ///// 205 | /////////////////////////// 206 | 207 | /** 208 | * Returns camera base plane (x & z) position. 209 | * 210 | * @example `getCameraPosition()`;` 211 | */ 212 | export function getCameraPosition(): number[] { 213 | return [TM.controls.target.x, -TM.controls.target.z]; 214 | } 215 | /** 216 | * Returns distance from controls' target to camera. 217 | * 218 | * @example `getZoom();` 219 | */ 220 | export function getZoom(): number { 221 | return TM.controls.target.distanceTo(TM.camera.position); 222 | } 223 | 224 | /** 225 | * Processes data returned from worker & creates tile's mesh. 226 | * 227 | * @param data - Position, color & normal buffers generated by WebWorker. 228 | * @example `buildFromWorkerData({...});` 229 | */ 230 | export function buildFromWorkerData(data: ITileBuffers): void { 231 | const pos: number[] = getTilePosition(data.id); 232 | const tileScale: number = getTileScale(data.id); 233 | const bufferAttributeSize: number = 3; 234 | const geometry: BufferGeometry = new BufferGeometry(); 235 | geometry.addAttribute("position", new BufferAttribute(new Float32Array(data.vertexBuffer), bufferAttributeSize)); 236 | geometry.addAttribute("color", new BufferAttribute(new Float32Array(data.colorBuffer), bufferAttributeSize)); 237 | geometry.addAttribute("normal", new BufferAttribute(new Float32Array(data.normalBuffer), bufferAttributeSize)); 238 | const tile: Mesh = new Mesh(geometry, TM.material); 239 | tile.name = data.id; 240 | TM.three_map.add(tile); 241 | tile.scale.set(tileScale, 1, tileScale); 242 | tile.position.set(pos[0], 0, -pos[1]); 243 | TM.events.emit("tileCreated", { tile }); 244 | } 245 | 246 | /** 247 | * Returns bounding box for tile. 248 | * 249 | * @param tile - Tile's quadkey to get bounds for. 250 | * @example `tileBounds('0123');` 251 | */ 252 | export function tileBounds(tile: string): Box3 { 253 | const pos: number[] = getTilePosition(tile); 254 | const boundsOffset: number = 0.94; 255 | const tileScale: number = getTileScale(tile) * tileExtend * boundsOffset; 256 | const vec1: Vector3 = new Vector3(pos[0] + tileScale, 0, -pos[1] + tileScale); 257 | const vec2: Vector3 = new Vector3(pos[0] - tileScale, 0, -pos[1] - tileScale); 258 | 259 | return new Box3(vec1, vec2); 260 | } 261 | 262 | /** 263 | * Checks if bounding box intersects camera's frustum. 264 | * 265 | * @param bounds - Bounding box. 266 | * @example `intersects(new THREE.Box3(...));` 267 | */ 268 | export function intersects(bounds: Box3): boolean { 269 | return TM.frustum.intersectsBox(bounds); 270 | } 271 | /** 272 | * Removes tile from grid & disposes its geometry. 273 | * 274 | * @param quadkey - Quadkey of tile to remove. 275 | * @example `removeTile('0123');` 276 | */ 277 | export function removeTile(quadkey: string): void { 278 | const toRemove: Object3D | Mesh = TM.three_map.getObjectByName(quadkey); 279 | if (toRemove && toRemove instanceof Mesh) { 280 | if (toRemove.geometry) { 281 | toRemove.geometry.dispose(); 282 | } 283 | TM.three_map.remove(toRemove); 284 | } 285 | TM.events.emit("tileRemoved", { tileID: quadkey }); 286 | } 287 | -------------------------------------------------------------------------------- /src/workerpool.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module WorkerPool 3 | */ 4 | // @ts-ignore 5 | import TileWorker from "worker!./worker.tmp.min.js"; // tslint:disable-line 6 | import { TM } from "./ThreeMap"; 7 | import { IWorkerEvent, IWorkerEventData, IWorkerMessage } from "./ThreeMap.interfaces"; 8 | import { buildFromWorkerData, doesTileExists } from "./utils"; 9 | 10 | /** 11 | * Pool of WebWorkers for handling hard task outside main thread. 12 | */ 13 | class WorkerPool { 14 | public readonly taskList: object[]; 15 | private readonly availableWorkers: TileWorker[]; 16 | private readonly callback: (e: IWorkerEventData) => void; 17 | 18 | /** 19 | * @param numOfWorkers - Number of workers to be created in pool. 20 | * @param callback - Function to be called on Worker's job end. 21 | * 22 | * @example `var pool = new WorkerPool(4, (e)=>{...});` 23 | */ 24 | public constructor(numOfWorkers: number, callback: (e: IWorkerEventData) => void) { 25 | this.availableWorkers = []; 26 | this.taskList = []; 27 | this.callback = callback; 28 | for (let i: number = 0; i < numOfWorkers; i++) { 29 | this.availableWorkers[i] = new TileWorker(); 30 | this.availableWorkers[i].onmessage = (event: IWorkerEvent): void => { 31 | if (event.data.type === "onFinish") { 32 | this.availableWorkers.push(event.target); 33 | this.callback(event.data); 34 | this.checkoutTasks(); 35 | } else { 36 | this.availableWorkers.push(event.target); 37 | TM.events.emit(event.data.type, event.data.realData); 38 | } 39 | }; 40 | } 41 | } 42 | 43 | /** 44 | * Offloads tasks to workers. 45 | * 46 | * @example `pool.checkoutTasks();` 47 | */ 48 | public checkoutTasks(): void { 49 | if (this.availableWorkers.length > 0 && this.taskList.length > 0) { 50 | const worker: TileWorker = this.availableWorkers.pop(); 51 | const task: object = this.taskList.pop(); 52 | worker.postMessage(task); 53 | } 54 | } 55 | 56 | /** 57 | * Add task to the list for it to be handled by worker. 58 | * 59 | * @param message - Data to be sent to worker. 60 | * @example `pool.startWorker({...});` 61 | */ 62 | public startWorker(message: IWorkerMessage): void { 63 | this.taskList.push(message); 64 | this.checkoutTasks(); 65 | } 66 | } 67 | 68 | let pool: WorkerPool; 69 | 70 | /** 71 | * Creates globally-accessible WorkerPool instance. 72 | * 73 | * @example `initWorkerPool();` 74 | */ 75 | export function initWorkerPool(): void { 76 | pool = new WorkerPool(TM.style.workers, (ev: IWorkerEventData): void => { 77 | if (doesTileExists(ev.realData.id)) { 78 | buildFromWorkerData(ev.realData); 79 | } 80 | }); 81 | } 82 | 83 | /** 84 | * Sends task to WorkerPool to be handled by worker. 85 | * 86 | * @param message - Message to be sent to worker. 87 | * @example `startWorker({...});` 88 | */ 89 | export function startWorker(message: IWorkerMessage): void { 90 | return pool.startWorker(message); 91 | } 92 | -------------------------------------------------------------------------------- /tdconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": "./src", 3 | "out": "./docspage", 4 | "ignoreCompilerErrors": true, 5 | "excludeExternals": true, 6 | "excludeProtected": true, 7 | "excludePrivate":true, 8 | "externalPattern": "**/node_modules/**/*", 9 | "target": "ES6", 10 | "module": "umd", 11 | "hideGenerator": true, 12 | "disableOutputCheck": true, 13 | "mode": "modules", 14 | "name":"ThreeMap", 15 | "exclude": [ 16 | "test", 17 | "src/constructor/", 18 | "src/constructor", 19 | "**src/constructor/*", 20 | "node_modules", 21 | "test/", 22 | "node_modules/", 23 | "**/test", 24 | "**/node_modules", 25 | "**/test/**/*", 26 | "**/node_modules/**/*" 27 | ] 28 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es6", 4 | "target": "es6", 5 | "sourceMap": true, 6 | "moduleResolution": "node", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "exclude": [ 10 | "node_modules" 11 | ] 12 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:latest"], 3 | "rules": { 4 | "prefer-conditional-expression": false, 5 | "prefer-for-of": false 6 | } 7 | } --------------------------------------------------------------------------------