itowns 2.44.3-next.8 → 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 (219) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  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/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -615
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -534
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/Tile/Tile.js +0 -219
  100. package/lib/Core/Tile/TileGrid.js +0 -46
  101. package/lib/Core/TileGeometry.js +0 -40
  102. package/lib/Core/TileMesh.js +0 -109
  103. package/lib/Core/View.js +0 -1109
  104. package/lib/Layer/C3DTilesLayer.js +0 -455
  105. package/lib/Layer/ColorLayer.js +0 -128
  106. package/lib/Layer/CopcLayer.js +0 -58
  107. package/lib/Layer/ElevationLayer.js +0 -107
  108. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  109. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  110. package/lib/Layer/GeoidLayer.js +0 -80
  111. package/lib/Layer/GeometryLayer.js +0 -202
  112. package/lib/Layer/InfoLayer.js +0 -64
  113. package/lib/Layer/LabelLayer.js +0 -456
  114. package/lib/Layer/Layer.js +0 -304
  115. package/lib/Layer/LayerUpdateState.js +0 -89
  116. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  117. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  118. package/lib/Layer/OrientedImageLayer.js +0 -222
  119. package/lib/Layer/PointCloudLayer.js +0 -359
  120. package/lib/Layer/Potree2Layer.js +0 -164
  121. package/lib/Layer/PotreeLayer.js +0 -65
  122. package/lib/Layer/RasterLayer.js +0 -27
  123. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  124. package/lib/Layer/TiledGeometryLayer.js +0 -403
  125. package/lib/Loader/LASLoader.js +0 -193
  126. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  127. package/lib/Loader/Potree2Loader.js +0 -207
  128. package/lib/Main.js +0 -115
  129. package/lib/MainBundle.js +0 -4
  130. package/lib/Parser/B3dmParser.js +0 -174
  131. package/lib/Parser/CameraCalibrationParser.js +0 -94
  132. package/lib/Parser/GDFParser.js +0 -72
  133. package/lib/Parser/GTXParser.js +0 -75
  134. package/lib/Parser/GeoJsonParser.js +0 -212
  135. package/lib/Parser/GpxParser.js +0 -25
  136. package/lib/Parser/ISGParser.js +0 -71
  137. package/lib/Parser/KMLParser.js +0 -25
  138. package/lib/Parser/LASParser.js +0 -137
  139. package/lib/Parser/MapBoxUrlParser.js +0 -83
  140. package/lib/Parser/PntsParser.js +0 -131
  141. package/lib/Parser/Potree2BinParser.js +0 -92
  142. package/lib/Parser/PotreeBinParser.js +0 -106
  143. package/lib/Parser/PotreeCinParser.js +0 -29
  144. package/lib/Parser/ShapefileParser.js +0 -78
  145. package/lib/Parser/VectorTileParser.js +0 -202
  146. package/lib/Parser/XbilParser.js +0 -119
  147. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  148. package/lib/Parser/iGLTFLoader.js +0 -168
  149. package/lib/Process/3dTilesProcessing.js +0 -304
  150. package/lib/Process/FeatureProcessing.js +0 -76
  151. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  152. package/lib/Process/ObjectRemovalHelper.js +0 -97
  153. package/lib/Process/handlerNodeError.js +0 -23
  154. package/lib/Provider/3dTilesProvider.js +0 -149
  155. package/lib/Provider/DataSourceProvider.js +0 -8
  156. package/lib/Provider/Fetcher.js +0 -229
  157. package/lib/Provider/PointCloudProvider.js +0 -45
  158. package/lib/Provider/TileProvider.js +0 -16
  159. package/lib/Provider/URLBuilder.js +0 -116
  160. package/lib/Renderer/Camera.js +0 -281
  161. package/lib/Renderer/Color.js +0 -56
  162. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  163. package/lib/Renderer/CommonMaterial.js +0 -31
  164. package/lib/Renderer/Label2DRenderer.js +0 -190
  165. package/lib/Renderer/LayeredMaterial.js +0 -243
  166. package/lib/Renderer/OBB.js +0 -153
  167. package/lib/Renderer/OrientedImageCamera.js +0 -118
  168. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  169. package/lib/Renderer/PointsMaterial.js +0 -485
  170. package/lib/Renderer/RasterTile.js +0 -209
  171. package/lib/Renderer/RenderMode.js +0 -31
  172. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  173. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  174. package/lib/Renderer/SphereHelper.js +0 -23
  175. package/lib/Renderer/WebXR.js +0 -51
  176. package/lib/Renderer/c3DEngine.js +0 -214
  177. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  178. package/lib/Source/C3DTilesIonSource.js +0 -54
  179. package/lib/Source/C3DTilesSource.js +0 -30
  180. package/lib/Source/CopcSource.js +0 -115
  181. package/lib/Source/EntwinePointTileSource.js +0 -62
  182. package/lib/Source/FileSource.js +0 -189
  183. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  184. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  185. package/lib/Source/OGC3DTilesSource.js +0 -21
  186. package/lib/Source/OrientedImageSource.js +0 -59
  187. package/lib/Source/Potree2Source.js +0 -167
  188. package/lib/Source/PotreeSource.js +0 -82
  189. package/lib/Source/Source.js +0 -223
  190. package/lib/Source/TMSSource.js +0 -145
  191. package/lib/Source/VectorTilesSource.js +0 -178
  192. package/lib/Source/WFSSource.js +0 -168
  193. package/lib/Source/WMSSource.js +0 -133
  194. package/lib/Source/WMTSSource.js +0 -86
  195. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  196. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  197. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  198. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  199. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  200. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  201. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  202. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  203. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  204. package/lib/Utils/CameraUtils.js +0 -555
  205. package/lib/Utils/DEMUtils.js +0 -350
  206. package/lib/Utils/FeaturesUtils.js +0 -156
  207. package/lib/Utils/Gradients.js +0 -16
  208. package/lib/Utils/OrientationUtils.js +0 -457
  209. package/lib/Utils/ThreeUtils.js +0 -115
  210. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  211. package/lib/Utils/gui/Main.js +0 -7
  212. package/lib/Utils/gui/Minimap.js +0 -154
  213. package/lib/Utils/gui/Navigation.js +0 -245
  214. package/lib/Utils/gui/Scale.js +0 -107
  215. package/lib/Utils/gui/Searchbar.js +0 -234
  216. package/lib/Utils/gui/Widget.js +0 -80
  217. package/lib/Utils/placeObjectOnGround.js +0 -137
  218. package/lib/Worker/LASLoaderWorker.js +0 -19
  219. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,126 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Itowns - 3d-tiles from Cesium ion example</title>
5
-
6
- <meta charset="UTF-8">
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
-
9
- <link rel="stylesheet" type="text/css" href="css/example.css">
10
- <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
11
-
12
- <style type="text/css">
13
- #description {
14
- z-index: 2;
15
- left: 10px;
16
- width: 30%;
17
- }
18
- </style>
19
-
20
-
21
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
22
- </head>
23
- <body>
24
- <div id="description">
25
- <p><b>This example displays a dataset representing extruded OSM buildings from Cesium ion
26
- with Cesium default access token. Zoom to any place in the world to see the buildings. <br>
27
- Buildings may appear to "fly" above the ground in some places, this is due to the combination
28
- of precision errors of this dataset and of the 3D terrain we use in this example. </b>
29
- </p>
30
- </div>
31
- <div id="attribution"></div>
32
- <div id="viewerDiv"></div>
33
-
34
- <!-- Import iTowns source code -->
35
- <script src="../dist/itowns.js"></script>
36
- <!-- Import iTowns LoadingScreen plugin -->
37
- <script src="js/GUI/LoadingScreen.js"></script>
38
-
39
- <script type="text/javascript">
40
-
41
- // ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ----------
42
-
43
- // Define camera initial position
44
- const placement = {
45
- coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
46
- range: 25000000,
47
- }
48
- // `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
49
- var viewerDiv = document.getElementById('viewerDiv');
50
-
51
- // Create a GlobeView
52
- var viewOptions = {
53
- diffuse: new itowns.THREE.Color(0xa0d5fc)
54
- };
55
- var view = new itowns.GlobeView(viewerDiv, placement, viewOptions);
56
-
57
- // Setup loading screen
58
- setupLoadingScreen(viewerDiv, view);
59
-
60
- // ---------- ADD A BASEMAP: ----------
61
-
62
- // Add one imagery layer to the scene. This layer's properties are defined in a json file, but it could be
63
- // defined as a plain js object. See `Layer` documentation for more info.
64
- itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
65
- config.source = new itowns.TMSSource(config.source);
66
- var layer = new itowns.ColorLayer('Ortho', config);
67
- view.addLayer(layer);
68
- });
69
-
70
- // ---------- ADD DIGITAL ELEVATION MODELS : ----------
71
-
72
- // Add two elevation layers, each with a different level of detail. Here again, each layer's properties are
73
- // defined in a json file.
74
- function addElevationLayerFromConfig(config) {
75
- config.source = new itowns.WMTSSource(config.source);
76
- view.addLayer(
77
- new itowns.ElevationLayer(config.id, config),
78
- );
79
- }
80
- itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
81
- itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);
82
-
83
- // ---------- ADD 3D TILES MODEL FROM CESIUM ION SERVER : ----------
84
-
85
- // Enable draco compression (used by this tileset)
86
- itowns.enableDracoLoader('./libs/draco/');
87
-
88
- // Create a new 3D Tiles batch table hierarchy extension manager and add it to the tileset since this tileset
89
- // uses this extension
90
- const extensions = new itowns.C3DTExtensions();
91
- extensions.registerExtension("3DTILES_batch_table_hierarchy",
92
- { [itowns.C3DTilesTypes.batchtable]:
93
- itowns.C3DTBatchTableHierarchyExtension });
94
-
95
- // Create a 3D Tiles layer from Cesium ion server with Cesium default access token and assetId of the
96
- // OSM buildings dataset.
97
- var threeDTilesIonSource = new itowns.C3DTilesIonSource({
98
- accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzOTkxZjY3NS0yNDU4LTQ3MTAtOGQ2NC1lOGI4YmY5ODhhYjQiLCJpZCI6Mzg4OTQsImlhdCI6MTYwNjkyMDkwOH0.aVrPA4xnpbSUlqfJ9RkSWmZtms_hnSRz7m596h1R7ew',
99
- assetId: 96188
100
- });
101
- threeDTilesIonSource.whenReady.then(displayAttributions); // Add attributions returned by cesium ion server
102
- var threeDTilesIonLayer = new itowns.C3DTilesLayer('3d-tiles-cesium-ion', {
103
- name: '3D Tiles from Cesium Ion',
104
- source: threeDTilesIonSource,
105
- registeredExtensions: extensions,
106
- }, view);
107
-
108
- itowns.View.prototype.addLayer.call(view, threeDTilesIonLayer);
109
-
110
- // Automatically convert cesium html attributions into html node elements and append them to the
111
- // attributions div
112
- function displayAttributions() {
113
- var attribDiv = document.getElementById('attribution');
114
- for (attrib of threeDTilesIonSource.attribution) {
115
- var attribElt = document.createElement('template');
116
- attribElt.innerHTML = attrib.html;
117
- attribDiv.appendChild(attribElt.content.firstChild);
118
- }
119
- }
120
-
121
- // ---------- ADD LIGHTS: ----------
122
- var ambLight = new itowns.THREE.AmbientLight(0xffffff, 1);
123
- view.scene.add( ambLight );
124
- </script>
125
- </body>
126
- </html>
@@ -1,95 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Itowns - Pointcloud classification</title>
5
-
6
- <meta charset="UTF-8">
7
- <link rel="stylesheet" type="text/css" href="css/example.css">
8
- <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
9
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
11
- </head>
12
- <body>
13
- <div id="description">
14
- Pointcloud classification
15
- <ul>
16
- <li>Display your pointcloud</li>
17
- <li>Use classification to assign colour to each points</li>
18
- <li>Switch between mode on the left panel</li>
19
- </ul>
20
- </div>
21
- <div id="viewerDiv"></div>
22
- <script src="js/GUI/GuiTools.js"></script>
23
- <script src="../dist/itowns.js"></script>
24
- <script src="js/GUI/LoadingScreen.js"></script>
25
- <script src="../dist/debug.js"></script>
26
- <script src="js/3dTilesHelper.js"></script>
27
- <script type="text/javascript">
28
- /* global itowns,document,GuiTools*/
29
-
30
-
31
- var placement = {
32
- coord: new itowns.Coordinates('EPSG:4326', 3.695885, 43.397379, 0),
33
-
34
- range: 3000,
35
- tilt: 55,
36
- heading: 180
37
- }
38
- // iTowns namespace defined here
39
- var viewerDiv = document.getElementById('viewerDiv');
40
-
41
- var view = new itowns.GlobeView(viewerDiv, placement);
42
- view.camera3D.near = 5;
43
- setupLoadingScreen(viewerDiv, view);
44
-
45
- var menuGlobe = new GuiTools('menuDiv', view, 300);
46
-
47
- itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
48
- config.source = new itowns.TMSSource(config.source);
49
- var layer = new itowns.ColorLayer('Ortho', config);
50
- view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
51
- });
52
- function updatePointCloudSize({tileContent}) {
53
- tileContent.traverse(function (obj) {
54
- if (obj.isPoints) {
55
- obj.material.size = 2.0;
56
- }
57
- });
58
- }
59
- // Create a new Layer 3d-tiles For Pointcloud
60
- // -------------------------------------------
61
- var $3dTilesSource = new itowns.C3DTilesSource({
62
- url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/pnts-sete-2021-0756_6256/tileset.json',
63
- });
64
- var $3dTilesLayerSetePC = new itowns.C3DTilesLayer('3d-tiles-sete', {
65
- name: 'SetePC',
66
- sseThreshold: 5,
67
- pntsMode: itowns.PNTS_MODE.CLASSIFICATION,
68
- pntsShape : itowns.PNTS_SHAPE.CIRCLE,
69
- source: $3dTilesSource,
70
- }, view);
71
-
72
- $3dTilesLayerSetePC.addEventListener(
73
- itowns.C3DTILES_LAYER_EVENTS.ON_TILE_CONTENT_LOADED,
74
- updatePointCloudSize,
75
- );
76
-
77
- itowns.View.prototype.addLayer.call(view, $3dTilesLayerSetePC);
78
- function switchMode(){
79
- let pntsLayer = view.getLayerById("3d-tiles-sete");
80
- if(pntsLayer){
81
- pntsLayer.pntsMode = pntsLayer.pntsMode === itowns.PNTS_MODE.COLOR ? itowns.PNTS_MODE.CLASSIFICATION : itowns.PNTS_MODE.COLOR;
82
- view.notifyChange(view.camera3D);
83
- }
84
- }
85
-
86
- // Add the UI Debug
87
- var d = new debug.Debug(view, menuGlobe.gui);
88
- $3dTilesLayerSetePC.whenReady
89
- .then(() => {
90
- debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer, d);
91
- debug.create3dTilesDebugUI(menuGlobe.gui, view, $3dTilesLayerSetePC);
92
- });
93
- </script>
94
- </body>
95
- </html>
@@ -1,38 +0,0 @@
1
- module.exports = {
2
- extends: [
3
- 'eslint-config-airbnb-base',
4
- 'eslint-config-airbnb-base/rules/strict',
5
- '../.eslintrc.cjs',
6
- ],
7
- parserOptions: {
8
- ecmaVersion: 13,
9
- sourceType: 'module',
10
- ecmaFeatures: {
11
- impliedStrict: true,
12
- },
13
- },
14
- env: {
15
- browser: true,
16
- es6: true,
17
- amd: true,
18
- commonjs: true,
19
- },
20
- globals: {
21
- itowns: true,
22
- },
23
- rules: {
24
- 'prefer-arrow-callback': 'off',
25
- 'object-shorthand': 'off',
26
- 'no-param-reassign': ['error', { props: false }],
27
- 'no-mixed-operators': ['error', { allowSamePrecedence: true }],
28
- 'prefer-template': 'off',
29
- 'prefer-rest-params': 'off',
30
- 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
31
-
32
- // deactivated rules for `examples/`
33
- 'no-console': 'off',
34
- // TODO reactivate all the following rules
35
- 'no-underscore-dangle': 'off',
36
-
37
- },
38
- };
@@ -1,308 +0,0 @@
1
- import * as THREE from 'three';
2
- import { MAIN_LOOP_EVENTS } from "../Core/MainLoop.js";
3
-
4
- // Note: we could use existing three.js controls (like https://github.com/mrdoob/three.js/blob/dev/examples/js/controls/FirstPersonControls.js)
5
- // but including these controls in itowns allows use to integrate them tightly with itowns.
6
- // Especially the existing controls are expecting a continuous update loop while we have a pausable one (so our controls use .notifyChange when needed)
7
-
8
- function limitRotation(camera3D, rot, verticalFOV) {
9
- // Limit vertical rotation (look up/down) to make sure the user cannot see
10
- // outside of the cone defined by verticalFOV
11
- const limit = THREE.MathUtils.degToRad(verticalFOV - camera3D.fov) * 0.5;
12
- return THREE.MathUtils.clamp(rot, -limit, limit);
13
- }
14
- const axisY = new THREE.Vector3(0, 1, 0);
15
- function applyRotation(view, camera3D, state) {
16
- camera3D.quaternion.setFromUnitVectors(axisY, camera3D.up);
17
- camera3D.rotateY(state.rotateY);
18
- camera3D.rotateX(state.rotateX);
19
- view.notifyChange(view.camera3D);
20
- }
21
- const MOVEMENTS = {
22
- 38: {
23
- method: 'translateZ',
24
- sign: -1
25
- },
26
- // FORWARD: up key
27
- 40: {
28
- method: 'translateZ',
29
- sign: 1
30
- },
31
- // BACKWARD: down key
32
- 37: {
33
- method: 'translateX',
34
- sign: -1
35
- },
36
- // STRAFE_LEFT: left key
37
- 39: {
38
- method: 'translateX',
39
- sign: 1
40
- },
41
- // STRAFE_RIGHT: right key
42
- 33: {
43
- method: 'translateY',
44
- sign: 1
45
- },
46
- // UP: PageUp key
47
- 34: {
48
- method: 'translateY',
49
- sign: -1
50
- } // DOWN: PageDown key
51
- };
52
- function moveCameraVerticalPlanar(value) {
53
- this.camera.position.z += value;
54
- }
55
- const normal = new THREE.Vector3();
56
- const q = new THREE.Quaternion();
57
- const e = new THREE.Euler(0, 0, 0, 'YXZ');
58
- function moveCameraVerticalGlobe(value) {
59
- // compute geodesic normale
60
- normal.copy(this.camera.position);
61
- normal.normalize();
62
- this.camera.position.add(normal.multiplyScalar(value));
63
- }
64
- class FirstPersonControls extends THREE.EventDispatcher {
65
- /**
66
- * @param {View} view
67
- * @param {object} options
68
- * @param {boolean} options.focusOnClick - whether or not to focus the renderer domElement on click
69
- * @param {boolean} options.focusOnMouseOver - whether or not to focus when the mouse is over the domElement
70
- * @param {boolean} options.moveSpeed - if > 0, pressing the arrow keys will move the camera
71
- * @param {number} options.verticalFOV - define the max visible vertical angle of the scene in degrees (default 180)
72
- * @param {number} options.panoramaRatio - alternative way to specify the max vertical angle when using a panorama.
73
- * You can specify the panorama width/height ratio and the verticalFOV will be computed automatically
74
- * @param {boolean} options.disableEventListeners - if true, the controls will not self listen to mouse/key events.
75
- * You'll have to manually forward the events to the appropriate functions: onMouseDown, onMouseMove, onMouseUp,
76
- * onKeyUp, onKeyDown and onMouseWheel.
77
- */
78
- constructor(view) {
79
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
80
- super();
81
- this.isFirstPersonControls = true;
82
- this.camera = view.camera3D;
83
- this.view = view;
84
- this.moves = new Set();
85
- if (options.panoramaRatio) {
86
- const radius = options.panoramaRatio * 200 / (2 * Math.PI);
87
- options.verticalFOV = options.panoramaRatio == 2 ? 180 : THREE.MathUtils.radToDeg(2 * Math.atan(200 / (2 * radius)));
88
- }
89
- options.verticalFOV = options.verticalFOV || 180;
90
- options.moveSpeed = options.moveSpeed === undefined ? 10 : options.moveSpeed; // backward or forward move speed in m/s
91
- this.options = options;
92
- this._isMouseDown = false;
93
- this._onMouseDownMouseX = 0;
94
- this._onMouseDownMouseY = 0;
95
- this._state = {
96
- rotateX: 0,
97
- rotateY: 0,
98
- snapshot() {
99
- return {
100
- rotateX: this.rotateX,
101
- rotateY: this.rotateY
102
- };
103
- }
104
- };
105
- this.reset();
106
- this.eventListeners = options.disableEventListeners;
107
- if (!options.disableEventListeners) {
108
- this._onMouseDown = this.onMouseDown.bind(this);
109
- this._onMouseMove = this.onMouseMove.bind(this);
110
- this._onMouseUp = this.onMouseUp.bind(this);
111
- this._onMouseWheel = this.onMouseWheel.bind(this);
112
- this._onKeyUp = this.onKeyUp.bind(this);
113
- this._onKeyDown = this.onKeyDown.bind(this);
114
- this._onContextMenu = this.onContextMenu.bind(this);
115
- view.domElement.addEventListener('mousedown', this._onMouseDown, false);
116
- view.domElement.addEventListener('touchstart', this._onMouseDown, false);
117
- view.domElement.addEventListener('mousemove', this._onMouseMove, false);
118
- view.domElement.addEventListener('touchmove', this._onMouseMove, false);
119
- view.domElement.addEventListener('mouseup', this._onMouseUp, false);
120
- view.domElement.addEventListener('touchend', this._onMouseUp, false);
121
- view.domElement.addEventListener('wheel', this._onMouseWheel, false);
122
- // Disable context menu when right clicking.
123
- view.domElement.addEventListener('contextmenu', this._onContextMenu, false);
124
-
125
- // TODO: Why windows
126
- document.addEventListener('keydown', this._onKeyDown, false);
127
- document.addEventListener('keyup', this._onKeyUp, false);
128
- }
129
- this.view.addFrameRequester(MAIN_LOOP_EVENTS.AFTER_CAMERA_UPDATE, this.update.bind(this));
130
-
131
- // focus policy
132
- this._onFocus = () => view.domElement.focus();
133
- this.focusOnMouseOver = options.focusOnMouseOver;
134
- if (options.focusOnMouseOver) {
135
- view.domElement.addEventListener('mouseover', this._onFocus);
136
- }
137
- this.focusOnClick = options.focusOnClick;
138
- if (options.focusOnClick) {
139
- view.domElement.addEventListener('click', this._onFocus);
140
- }
141
- if (view.referenceCrs == 'EPSG:4978') {
142
- this.moveCameraVertical = moveCameraVerticalGlobe;
143
- } else {
144
- this.moveCameraVertical = moveCameraVerticalPlanar;
145
- }
146
- }
147
- isUserInteracting() {
148
- return this.moves.size !== 0 && !this._isMouseDown;
149
- }
150
-
151
- /**
152
- * Resets the controls internal state to match the camera' state.
153
- * This must be called when manually modifying the camera's position or rotation.
154
- * @param {boolean} preserveRotationOnX - if true, the look up/down rotation will
155
- * not be copied from the camera
156
- */
157
- reset() {
158
- let preserveRotationOnX = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
159
- // Compute the correct init state, given the calculus in applyRotation:
160
- // cam.quaternion = q * r
161
- // => r = invert(q) * cam.quaterion
162
- // q is the quaternion derived from the up vector
163
- q.setFromUnitVectors(axisY, this.camera.up);
164
- q.invert();
165
- q.multiply(this.camera.quaternion);
166
- // tranform it to euler
167
- e.setFromQuaternion(q);
168
- if (!preserveRotationOnX) {
169
- this._state.rotateX = e.x;
170
- }
171
- this._state.rotateY = e.y;
172
- }
173
-
174
- /**
175
- * Updates the camera position / rotation based on occured input events.
176
- * This is done automatically when needed but can also be done if needed.
177
- * @param {number} dt - ellpased time since last update in seconds
178
- * @param {boolean} updateLoopRestarted - true if itowns' update loop just restarted
179
- * @param {boolean} force - set to true if you want to force the update, even if it
180
- * appears unneeded.
181
- */
182
- update(dt, updateLoopRestarted, force) {
183
- if (this.enabled == false) {
184
- return;
185
- }
186
-
187
- // dt will not be relevant when we just started rendering, we consider a 1-frame move in this case
188
- if (updateLoopRestarted) {
189
- dt = 16;
190
- }
191
- for (const move of this.moves) {
192
- if (move.method === 'translateY') {
193
- this.moveCameraVertical(move.sign * this.options.moveSpeed * dt / 1000);
194
- } else {
195
- this.camera[move.method](move.sign * this.options.moveSpeed * dt / 1000);
196
- }
197
- }
198
- if (this._isMouseDown === true || force === true) {
199
- applyRotation(this.view, this.camera, this._state);
200
- }
201
- if (this.moves.size) {
202
- this.view.notifyChange(this.camera);
203
- }
204
- }
205
-
206
- // Event callback functions
207
- // Mouse movement handling
208
- onMouseDown(event) {
209
- if (this.enabled == false) {
210
- return;
211
- }
212
-
213
- // next line is commented because, when I uncomment it, key binding doesn't work any more.
214
- // event.preventDefault();
215
-
216
- this._isMouseDown = true;
217
- const coords = this.view.eventToViewCoords(event);
218
- this._onMouseDownMouseX = coords.x;
219
- this._onMouseDownMouseY = coords.y;
220
- this._stateOnMouseDown = this._state.snapshot();
221
- }
222
- onMouseUp() {
223
- if (this.enabled == false) {
224
- return;
225
- }
226
- this._isMouseDown = false;
227
- }
228
- onMouseMove(event) {
229
- if (this.enabled == false) {
230
- return;
231
- }
232
- if (this._isMouseDown === true) {
233
- // in rigor we have tan(theta) = tan(cameraFOV) * deltaH / H
234
- // (where deltaH is the vertical amount we moved, and H the renderer height)
235
- // we loosely approximate tan(x) by x
236
- const pxToAngleRatio = THREE.MathUtils.degToRad(this.camera.fov) / this.view.mainLoop.gfxEngine.height;
237
- const coords = this.view.eventToViewCoords(event);
238
-
239
- // update state based on pointer movement
240
- this._state.rotateY = (coords.x - this._onMouseDownMouseX) * pxToAngleRatio + this._stateOnMouseDown.rotateY;
241
- this._state.rotateX = limitRotation(this.camera, (coords.y - this._onMouseDownMouseY) * pxToAngleRatio + this._stateOnMouseDown.rotateX, this.options.verticalFOV);
242
- applyRotation(this.view, this.camera, this._state);
243
- }
244
- }
245
-
246
- // Mouse wheel
247
- onMouseWheel(event) {
248
- if (this.enabled == false) {
249
- return;
250
- }
251
- const delta = event.deltaY;
252
- this.camera.fov = THREE.MathUtils.clamp(this.camera.fov + Math.sign(delta), 10, Math.min(100, this.options.verticalFOV));
253
- this.camera.updateProjectionMatrix();
254
- this._state.rotateX = limitRotation(this.camera, this._state.rotateX, this.options.verticalFOV);
255
- applyRotation(this.view, this.camera, this._state);
256
- }
257
-
258
- // Keyboard handling
259
- onKeyUp(e) {
260
- if (this.enabled == false) {
261
- return;
262
- }
263
- const move = MOVEMENTS[e.keyCode];
264
- if (move) {
265
- this.moves.delete(move);
266
- this.view.notifyChange(undefined, false);
267
- e.preventDefault();
268
- }
269
- }
270
- onKeyDown(e) {
271
- if (this.enabled == false) {
272
- return;
273
- }
274
- const move = MOVEMENTS[e.keyCode];
275
- if (move) {
276
- this.moves.add(move);
277
- this.view.notifyChange(undefined, false);
278
- e.preventDefault();
279
- }
280
- }
281
- onContextMenu(event) {
282
- event.preventDefault();
283
- }
284
- dispose() {
285
- if (!this.eventListeners) {
286
- this.view.domElement.removeEventListener('mousedown', this._onMouseDown, false);
287
- this.view.domElement.removeEventListener('touchstart', this._onMouseDown, false);
288
- this.view.domElement.removeEventListener('mousemove', this._onMouseMove, false);
289
- this.view.domElement.removeEventListener('touchmove', this._onMouseMove, false);
290
- this.view.domElement.removeEventListener('mouseup', this._onMouseUp, false);
291
- this.view.domElement.removeEventListener('touchend', this._onMouseUp, false);
292
- this.view.domElement.removeEventListener('wheel', this._onMouseWheel, false);
293
- this.view.domElement.removeEventListener('contextmenu', this._onContextMenu, false);
294
- document.removeEventListener('keydown', this._onKeyDown, false);
295
- document.removeEventListener('keyup', this._onKeyUp, false);
296
- }
297
- if (this.focusOnMouseOver) {
298
- this.view.domElement.removeEventListener('mouseover', this._onFocus);
299
- }
300
- if (this.focusOnClick) {
301
- this.view.domElement.removeEventListener('click', this._onFocus);
302
- }
303
- this.dispatchEvent({
304
- type: 'dispose'
305
- });
306
- }
307
- }
308
- export default FirstPersonControls;