itowns 2.44.3-next.9 → 2.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +20 -6
  3. package/examples/config.json +1 -0
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/jsm/.eslintrc.cjs +0 -38
  43. package/lib/Controls/FirstPersonControls.js +0 -308
  44. package/lib/Controls/FlyControls.js +0 -175
  45. package/lib/Controls/GlobeControls.js +0 -1162
  46. package/lib/Controls/PlanarControls.js +0 -1025
  47. package/lib/Controls/StateControl.js +0 -429
  48. package/lib/Controls/StreetControls.js +0 -392
  49. package/lib/Converter/Feature2Mesh.js +0 -615
  50. package/lib/Converter/Feature2Texture.js +0 -170
  51. package/lib/Converter/convertToTile.js +0 -75
  52. package/lib/Converter/textureConverter.js +0 -44
  53. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  54. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  55. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  56. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  57. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  58. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  59. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  60. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  61. package/lib/Core/AnimationPlayer.js +0 -142
  62. package/lib/Core/CopcNode.js +0 -174
  63. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  64. package/lib/Core/EntwinePointTileNode.js +0 -126
  65. package/lib/Core/Feature.js +0 -490
  66. package/lib/Core/Geographic/CoordStars.js +0 -80
  67. package/lib/Core/Geographic/Coordinates.js +0 -320
  68. package/lib/Core/Geographic/Crs.js +0 -175
  69. package/lib/Core/Geographic/Extent.js +0 -534
  70. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  71. package/lib/Core/Label.js +0 -222
  72. package/lib/Core/MainLoop.js +0 -211
  73. package/lib/Core/Math/Ellipsoid.js +0 -144
  74. package/lib/Core/Picking.js +0 -255
  75. package/lib/Core/PointCloudNode.js +0 -42
  76. package/lib/Core/Potree2Node.js +0 -206
  77. package/lib/Core/Potree2PointAttributes.js +0 -139
  78. package/lib/Core/PotreeNode.js +0 -101
  79. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  80. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  81. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  82. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  83. package/lib/Core/Prefab/GlobeView.js +0 -161
  84. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  85. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  86. package/lib/Core/Prefab/PlanarView.js +0 -62
  87. package/lib/Core/Prefab/TileBuilder.js +0 -80
  88. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  89. package/lib/Core/Scheduler/Cache.js +0 -256
  90. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  91. package/lib/Core/Scheduler/Scheduler.js +0 -294
  92. package/lib/Core/Style.js +0 -1121
  93. package/lib/Core/System/Capabilities.js +0 -63
  94. package/lib/Core/Tile/Tile.js +0 -219
  95. package/lib/Core/Tile/TileGrid.js +0 -46
  96. package/lib/Core/TileGeometry.js +0 -40
  97. package/lib/Core/TileMesh.js +0 -109
  98. package/lib/Core/View.js +0 -1109
  99. package/lib/Layer/C3DTilesLayer.js +0 -456
  100. package/lib/Layer/ColorLayer.js +0 -128
  101. package/lib/Layer/CopcLayer.js +0 -58
  102. package/lib/Layer/ElevationLayer.js +0 -107
  103. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  104. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  105. package/lib/Layer/GeoidLayer.js +0 -80
  106. package/lib/Layer/GeometryLayer.js +0 -202
  107. package/lib/Layer/InfoLayer.js +0 -64
  108. package/lib/Layer/LabelLayer.js +0 -456
  109. package/lib/Layer/Layer.js +0 -304
  110. package/lib/Layer/LayerUpdateState.js +0 -89
  111. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  112. package/lib/Layer/OGC3DTilesLayer.js +0 -412
  113. package/lib/Layer/OrientedImageLayer.js +0 -222
  114. package/lib/Layer/PointCloudLayer.js +0 -359
  115. package/lib/Layer/Potree2Layer.js +0 -164
  116. package/lib/Layer/PotreeLayer.js +0 -65
  117. package/lib/Layer/RasterLayer.js +0 -27
  118. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  119. package/lib/Layer/TiledGeometryLayer.js +0 -403
  120. package/lib/Loader/LASLoader.js +0 -193
  121. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  122. package/lib/Loader/Potree2Loader.js +0 -207
  123. package/lib/Main.js +0 -115
  124. package/lib/MainBundle.js +0 -4
  125. package/lib/Parser/B3dmParser.js +0 -174
  126. package/lib/Parser/CameraCalibrationParser.js +0 -94
  127. package/lib/Parser/GDFParser.js +0 -72
  128. package/lib/Parser/GTXParser.js +0 -75
  129. package/lib/Parser/GeoJsonParser.js +0 -212
  130. package/lib/Parser/GpxParser.js +0 -25
  131. package/lib/Parser/ISGParser.js +0 -71
  132. package/lib/Parser/KMLParser.js +0 -25
  133. package/lib/Parser/LASParser.js +0 -137
  134. package/lib/Parser/MapBoxUrlParser.js +0 -83
  135. package/lib/Parser/PntsParser.js +0 -131
  136. package/lib/Parser/Potree2BinParser.js +0 -92
  137. package/lib/Parser/PotreeBinParser.js +0 -106
  138. package/lib/Parser/PotreeCinParser.js +0 -29
  139. package/lib/Parser/ShapefileParser.js +0 -78
  140. package/lib/Parser/VectorTileParser.js +0 -202
  141. package/lib/Parser/XbilParser.js +0 -119
  142. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  143. package/lib/Parser/iGLTFLoader.js +0 -168
  144. package/lib/Process/3dTilesProcessing.js +0 -304
  145. package/lib/Process/FeatureProcessing.js +0 -76
  146. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  147. package/lib/Process/ObjectRemovalHelper.js +0 -97
  148. package/lib/Process/handlerNodeError.js +0 -23
  149. package/lib/Provider/3dTilesProvider.js +0 -149
  150. package/lib/Provider/DataSourceProvider.js +0 -8
  151. package/lib/Provider/Fetcher.js +0 -229
  152. package/lib/Provider/PointCloudProvider.js +0 -45
  153. package/lib/Provider/TileProvider.js +0 -16
  154. package/lib/Provider/URLBuilder.js +0 -116
  155. package/lib/Renderer/Camera.js +0 -281
  156. package/lib/Renderer/Color.js +0 -56
  157. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  158. package/lib/Renderer/CommonMaterial.js +0 -31
  159. package/lib/Renderer/Label2DRenderer.js +0 -190
  160. package/lib/Renderer/LayeredMaterial.js +0 -243
  161. package/lib/Renderer/OBB.js +0 -153
  162. package/lib/Renderer/OrientedImageCamera.js +0 -118
  163. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  164. package/lib/Renderer/PointsMaterial.js +0 -485
  165. package/lib/Renderer/RasterTile.js +0 -209
  166. package/lib/Renderer/RenderMode.js +0 -31
  167. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  168. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  169. package/lib/Renderer/SphereHelper.js +0 -23
  170. package/lib/Renderer/WebXR.js +0 -51
  171. package/lib/Renderer/c3DEngine.js +0 -214
  172. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  173. package/lib/Source/C3DTilesIonSource.js +0 -54
  174. package/lib/Source/C3DTilesSource.js +0 -30
  175. package/lib/Source/CopcSource.js +0 -115
  176. package/lib/Source/EntwinePointTileSource.js +0 -62
  177. package/lib/Source/FileSource.js +0 -189
  178. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  179. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  180. package/lib/Source/OGC3DTilesSource.js +0 -21
  181. package/lib/Source/OrientedImageSource.js +0 -59
  182. package/lib/Source/Potree2Source.js +0 -167
  183. package/lib/Source/PotreeSource.js +0 -82
  184. package/lib/Source/Source.js +0 -223
  185. package/lib/Source/TMSSource.js +0 -145
  186. package/lib/Source/VectorTilesSource.js +0 -178
  187. package/lib/Source/WFSSource.js +0 -168
  188. package/lib/Source/WMSSource.js +0 -133
  189. package/lib/Source/WMTSSource.js +0 -86
  190. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  191. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  192. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  193. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  194. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  195. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  196. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  197. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  198. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  199. package/lib/Utils/CameraUtils.js +0 -555
  200. package/lib/Utils/DEMUtils.js +0 -350
  201. package/lib/Utils/FeaturesUtils.js +0 -156
  202. package/lib/Utils/Gradients.js +0 -16
  203. package/lib/Utils/OrientationUtils.js +0 -457
  204. package/lib/Utils/ThreeUtils.js +0 -115
  205. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  206. package/lib/Utils/gui/Main.js +0 -7
  207. package/lib/Utils/gui/Minimap.js +0 -154
  208. package/lib/Utils/gui/Navigation.js +0 -245
  209. package/lib/Utils/gui/Scale.js +0 -107
  210. package/lib/Utils/gui/Searchbar.js +0 -234
  211. package/lib/Utils/gui/Widget.js +0 -80
  212. package/lib/Utils/placeObjectOnGround.js +0 -137
  213. package/lib/Worker/LASLoaderWorker.js +0 -19
  214. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,429 +0,0 @@
1
- import * as THREE from 'three';
2
- const CONTROL_KEYS = {
3
- LEFT: 37,
4
- UP: 38,
5
- RIGHT: 39,
6
- BOTTOM: 40,
7
- SPACE: 32,
8
- SHIFT: 16,
9
- CTRL: 17,
10
- META: 91,
11
- S: 83
12
- };
13
-
14
- // TODO : a class should be made for `State`, and the properties marked with `_` prefix should be made private
15
- const DEFAULT_STATES = {
16
- ORBIT: {
17
- enable: true,
18
- mouseButton: THREE.MOUSE.LEFT,
19
- double: false,
20
- keyboard: CONTROL_KEYS.CTRL,
21
- finger: 2,
22
- _event: 'rotate'
23
- },
24
- MOVE_GLOBE: {
25
- enable: true,
26
- mouseButton: THREE.MOUSE.LEFT,
27
- double: false,
28
- finger: 1,
29
- _event: 'drag'
30
- },
31
- DOLLY: {
32
- enable: true,
33
- mouseButton: THREE.MOUSE.MIDDLE,
34
- double: false,
35
- finger: 2,
36
- _event: 'dolly'
37
- },
38
- PAN: {
39
- enable: true,
40
- mouseButton: THREE.MOUSE.RIGHT,
41
- double: false,
42
- finger: 3,
43
- _event: 'pan'
44
- },
45
- PANORAMIC: {
46
- enable: true,
47
- mouseButton: THREE.MOUSE.LEFT,
48
- double: false,
49
- keyboard: CONTROL_KEYS.SHIFT,
50
- _event: 'panoramic'
51
- },
52
- TRAVEL_IN: {
53
- enable: true,
54
- mouseButton: THREE.MOUSE.LEFT,
55
- double: true,
56
- _event: 'travel_in',
57
- _trigger: true,
58
- _direction: 'in'
59
- },
60
- TRAVEL_OUT: {
61
- enable: false,
62
- double: false,
63
- _event: 'travel_out',
64
- _trigger: true,
65
- _direction: 'out'
66
- },
67
- ZOOM: {
68
- enable: true,
69
- _event: 'zoom',
70
- _trigger: true
71
- },
72
- PAN_UP: {
73
- enable: true,
74
- keyboard: CONTROL_KEYS.UP,
75
- double: false,
76
- _event: 'pan',
77
- _trigger: true,
78
- _direction: 'up'
79
- },
80
- PAN_BOTTOM: {
81
- enable: true,
82
- keyboard: CONTROL_KEYS.BOTTOM,
83
- double: false,
84
- _event: 'pan',
85
- _trigger: true,
86
- _direction: 'bottom'
87
- },
88
- PAN_LEFT: {
89
- enable: true,
90
- keyboard: CONTROL_KEYS.LEFT,
91
- double: false,
92
- _event: 'pan',
93
- _trigger: true,
94
- _direction: 'left'
95
- },
96
- PAN_RIGHT: {
97
- enable: true,
98
- keyboard: CONTROL_KEYS.RIGHT,
99
- double: false,
100
- _event: 'pan',
101
- _trigger: true,
102
- _direction: 'right'
103
- }
104
- };
105
- const viewCoords = new THREE.Vector2();
106
-
107
- /**
108
- * @typedef {Object} StateControl~State
109
- * @property {boolean} enable=true Indicate whether the state is enabled or not.
110
- * @property {Number} [mouseButton] The mouse button bound to this state.
111
- * @property {Number} [keyboard] The keyCode of the keyboard input bound to this state.
112
- * @property {Number} [finger] The number of fingers on the pad bound to this state.
113
- * @property {boolean} [double] True if the mouse button bound to this state must be pressed twice. For
114
- * example, if `double` is set to true with a `mouseButton` set to left click,
115
- * the State will be bound to a double click mouse button.
116
- */
117
-
118
- /**
119
- * It represents the control's states.
120
- * Each {@link State} is a control mode of the camera and how to interact with
121
- * the interface to activate this mode.
122
- * @class StateControl
123
- *
124
- * @property {State} NONE {@link State} when camera is idle.
125
- * @property {State} ORBIT {@link State} describing camera orbiting movement : the camera moves around its
126
- * target at a constant distance from it.
127
- * @property {State} DOLLY {@link State} describing camera dolly movement : the camera moves forward or
128
- * backward from its target.
129
- * @property {State} PAN {@link State} describing camera pan movement : the camera moves parallel to the
130
- * current view plane.
131
- * @property {State} MOVE_GLOBE {@link State} describing camera drag movement : the camera is moved around the view
132
- * to give the feeling that the view is dragged under a static camera.
133
- * @property {State} PANORAMIC {@link State} describing camera panoramic movement : the camera is rotated around
134
- * its own position.
135
- * @property {State} TRAVEL_IN {@link State} describing camera travel in movement : the camera is zoomed in toward
136
- * a given position. The target position depends on the key/mouse binding of this
137
- * state. If bound to a mouse button, the target position is the mouse position.
138
- * Otherwise, it is the center of the screen.
139
- * @property {State} TRAVEL_OUT {@link State} describing camera travel out movement : the camera is zoomed out from
140
- * a given position. The target position depends on the key/mouse binding of this
141
- * state. If bound to a mouse button, the target position is the mouse position.
142
- * Otherwise, it is the center of the screen. It is disabled by default.
143
- * @property {State} ZOOM {@link State} describing camera zoom in and out movement.
144
- * @property {boolean} enable Defines whether all input will be communicated to the associated `Controls` or not.
145
- * Default is true.
146
- * @property {boolean} enableKeys Defines whether keyboard input will be communicated to the associated `Controls` or
147
- * not. Default is true.
148
- */
149
- class StateControl extends THREE.EventDispatcher {
150
- constructor(view) {
151
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
152
- super();
153
- this._view = view;
154
- this._domElement = view.domElement;
155
- let enabled = true;
156
- Object.defineProperty(this, 'enabled', {
157
- get: () => enabled,
158
- set: value => {
159
- if (!value) {
160
- this.onKeyUp();
161
- this.onPointerUp();
162
- }
163
- enabled = value;
164
- }
165
- });
166
-
167
- // Set to true to disable use of the keys
168
- let enableKeys = true;
169
- Object.defineProperty(this, 'enableKeys', {
170
- get: () => enableKeys,
171
- set: value => {
172
- if (!value) {
173
- this.onKeyUp();
174
- }
175
- enableKeys = value;
176
- }
177
- });
178
- this.NONE = {};
179
- let currentState = this.NONE;
180
- Object.defineProperty(this, 'currentState', {
181
- get: () => currentState,
182
- set: newState => {
183
- if (currentState !== newState) {
184
- const previous = currentState;
185
- currentState = newState;
186
- this.dispatchEvent({
187
- type: 'state-changed',
188
- viewCoords,
189
- previous
190
- });
191
- }
192
- }
193
- });
194
-
195
- // TODO : the 4 next properties should be made private when ES6 allows it
196
- this._clickTimeStamp = 0;
197
- this._lastMousePressed = {
198
- viewCoords: new THREE.Vector2()
199
- };
200
- this._currentMousePressed = undefined;
201
- this._currentKeyPressed = undefined;
202
- this._onPointerDown = this.onPointerDown.bind(this);
203
- this._onPointerMove = this.onPointerMove.bind(this);
204
- this._onPointerUp = this.onPointerUp.bind(this);
205
- this._onMouseWheel = this.onMouseWheel.bind(this);
206
- this._onKeyDown = this.onKeyDown.bind(this);
207
- this._onKeyUp = this.onKeyUp.bind(this);
208
- this._onBlur = this.onBlur.bind(this);
209
- this._onContextMenu = this.onContextMenu.bind(this);
210
- this._domElement.addEventListener('pointerdown', this._onPointerDown, false);
211
- this._domElement.addEventListener('wheel', this._onMouseWheel, false);
212
- this._domElement.addEventListener('keydown', this._onKeyDown, false);
213
- this._domElement.addEventListener('keyup', this._onKeyUp, false);
214
-
215
- // Reset key/mouse when window loose focus
216
- this._domElement.addEventListener('blur', this._onBlur);
217
- // disable context menu when right-clicking
218
- this._domElement.addEventListener('contextmenu', this._onContextMenu, false);
219
- this.setFromOptions(options);
220
- }
221
-
222
- /**
223
- * get the state corresponding to the mouse button and the keyboard key. If the input relates to a trigger - a
224
- * single event which triggers movement, without the move of the mouse for instance -, dispatch a relevant event.
225
- * @param {Number} mouseButton The mouse button
226
- * @param {Number} keyboard The keyboard
227
- * @param {Boolean} [double] Value of the searched state `double` property
228
- * @return {State} the state corresponding
229
- */
230
- inputToState(mouseButton, keyboard) {
231
- let double = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
232
- for (const key of Object.keys(DEFAULT_STATES)) {
233
- const state = this[key];
234
- if (state.enable && state.mouseButton === mouseButton && state.keyboard === keyboard && state.double === double) {
235
- // If the input relates to a state, returns it
236
- if (!state._trigger) {
237
- return state;
238
- }
239
- // If the input relates to a trigger (TRAVEL_IN, TRAVEL_OUT), dispatch a relevant event.
240
- this.dispatchEvent({
241
- type: state._event,
242
- // Dont pass viewCoords if the input is only a keyboard input.
243
- viewCoords: mouseButton !== undefined && viewCoords,
244
- direction: state._direction
245
- });
246
- }
247
- }
248
- return this.NONE;
249
- }
250
-
251
- /**
252
- * get the state corresponding to the number of finger on the pad
253
- *
254
- * @param {Number} finger The number of finger
255
- * @return {state} the state corresponding
256
- */
257
- touchToState(finger) {
258
- for (const key of Object.keys(DEFAULT_STATES)) {
259
- const state = this[key];
260
- if (state.enable && finger == state.finger) {
261
- return state;
262
- }
263
- }
264
- return this.NONE;
265
- }
266
-
267
- /**
268
- * Set the current StateControl {@link State} properties to given values.
269
- * @param {Object} options Object containing the `State` values to set current `StateControl` properties to.
270
- * The `enable` property do not necessarily need to be specified. In that case, the
271
- * previous value of this property will be kept for the new {@link State}.
272
- *
273
- * @example
274
- * // Switch bindings for PAN and MOVE_GLOBE actions, and disabling PANORAMIC movement :
275
- * view.controls.states.setFromOptions({
276
- * PAN: {
277
- * mouseButton: itowns.THREE.MOUSE.LEFT,
278
- * },
279
- * MOVE_GLOBE: {
280
- * mouseButton: itowns.THREE.MOUSE.RIGHT,
281
- * },
282
- * PANORAMIC: {
283
- * enable: false,
284
- * },
285
- * };
286
- */
287
- setFromOptions(options) {
288
- for (const state in DEFAULT_STATES) {
289
- if ({}.hasOwnProperty.call(DEFAULT_STATES, state)) {
290
- let newState = {};
291
- newState = options[state] || this[state] || Object.assign(newState, DEFAULT_STATES[state]);
292
-
293
- // Copy the previous value of `enable` property if not defined in options
294
- if (options[state] && options[state].enable === undefined) {
295
- newState.enable = this[state].enable;
296
- }
297
- // If no value is provided for the `double` property,
298
- // defaults it to `false` instead of leaving it undefined
299
- newState.double = !!newState.double;
300
-
301
- // Copy the `_event` and `_trigger` properties
302
- newState._event = DEFAULT_STATES[state]._event;
303
- newState._trigger = DEFAULT_STATES[state]._trigger;
304
- newState._direction = DEFAULT_STATES[state]._direction;
305
- this[state] = newState;
306
- }
307
- }
308
- }
309
-
310
- // ---------- POINTER EVENTS : ----------
311
-
312
- onPointerDown(event) {
313
- if (!this.enabled) {
314
- return;
315
- }
316
- viewCoords.copy(this._view.eventToViewCoords(event));
317
- switch (event.pointerType) {
318
- case 'mouse':
319
- {
320
- this._currentMousePressed = event.button;
321
- if (this._currentKeyPressed === undefined) {
322
- if (event.ctrlKey) {
323
- this._currentKeyPressed = CONTROL_KEYS.CTRL;
324
- } else if (event.shiftKey) {
325
- this._currentKeyPressed = CONTROL_KEYS.SHIFT;
326
- } else if (event.metaKey) {
327
- this._currentKeyPressed = CONTROL_KEYS.META;
328
- }
329
- }
330
- this.currentState = this.inputToState(this._currentMousePressed, this._currentKeyPressed,
331
- // Detect if the mouse button was pressed less than 500 ms before, and if the cursor has not moved two much
332
- // since previous click. If so, set dblclick to true.
333
- event.timeStamp - this._clickTimeStamp < 500 && this._lastMousePressed.button === this._currentMousePressed && this._lastMousePressed.viewCoords.distanceTo(viewCoords) < 5);
334
- this._clickTimeStamp = event.timeStamp;
335
- this._lastMousePressed.button = this._currentMousePressed;
336
- this._lastMousePressed.viewCoords.copy(viewCoords);
337
- break;
338
- }
339
- // TODO : add touch event management
340
- default:
341
- }
342
- this._domElement.addEventListener('pointermove', this._onPointerMove, false);
343
- this._domElement.addEventListener('pointerup', this._onPointerUp, false);
344
- this._domElement.addEventListener('mouseleave', this._onPointerUp, false);
345
- }
346
- onPointerMove(event) {
347
- event.preventDefault();
348
- if (!this.enabled) {
349
- return;
350
- }
351
- viewCoords.copy(this._view.eventToViewCoords(event));
352
- switch (event.pointerType) {
353
- case 'mouse':
354
- this.dispatchEvent({
355
- type: this.currentState._event,
356
- viewCoords
357
- });
358
- break;
359
- // TODO : add touch event management
360
- default:
361
- }
362
- }
363
- onPointerUp() {
364
- if (!this.enabled) {
365
- return;
366
- }
367
- this._currentMousePressed = undefined;
368
- this._domElement.removeEventListener('pointermove', this._onPointerMove, false);
369
- this._domElement.removeEventListener('pointerup', this._onPointerUp, false);
370
- this._domElement.removeEventListener('mouseleave', this._onPointerUp, false);
371
- this.currentState = this.NONE;
372
- }
373
-
374
- // ---------- WHEEL EVENT : ----------
375
-
376
- onMouseWheel(event) {
377
- event.preventDefault();
378
- if (this.enabled && this.ZOOM.enable) {
379
- this.dispatchEvent({
380
- type: this.ZOOM._event,
381
- delta: event.deltaY
382
- });
383
- }
384
- }
385
-
386
- // ---------- KEYBOARD EVENTS : ----------
387
-
388
- onKeyDown(event) {
389
- if (!this.enabled || !this.enableKeys) {
390
- return;
391
- }
392
- this._currentKeyPressed = event.keyCode;
393
- this.inputToState(this._currentMousePressed, this._currentKeyPressed);
394
- }
395
- onKeyUp() {
396
- if (!this.enabled || !this.enableKeys) {
397
- return;
398
- }
399
- this._currentKeyPressed = undefined;
400
- if (this._currentMousePressed === undefined) {
401
- this.currentState = this.NONE;
402
- }
403
- }
404
- onBlur() {
405
- this.onKeyUp();
406
- this.onPointerUp();
407
- }
408
- onContextMenu(event) {
409
- event.preventDefault();
410
- }
411
-
412
- /**
413
- * Remove all event listeners created within this instance of `StateControl`
414
- */
415
- dispose() {
416
- this._clickTimeStamp = 0;
417
- this._lastMousePressed = undefined;
418
- this._currentKeyPressed = undefined;
419
- this._domElement.removeEventListener('pointerdown', this._onPointerDown, false);
420
- this._domElement.removeEventListener('pointermove', this._onPointerMove, false);
421
- this._domElement.removeEventListener('pointerup', this._onPointerUp, false);
422
- this._domElement.removeEventListener('wheel', this._onMouseWheel, false);
423
- this._domElement.removeEventListener('keydown', this._onKeyDown, false);
424
- this._domElement.removeEventListener('keyup', this._onKeyUp, false);
425
- this._domElement.removeEventListener('blur', this._onBlur);
426
- this._domElement.removeEventListener('contextmenu', this._onContextMenu, false);
427
- }
428
- }
429
- export default StateControl;