itowns 2.36.2 → 2.38.1

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 (122) hide show
  1. package/CONTRIBUTING.md +30 -17
  2. package/README.md +12 -1
  3. package/changelog.md +138 -0
  4. package/dist/debug.js +1 -1
  5. package/dist/debug.js.LICENSE.txt +2 -2
  6. package/dist/debug.js.map +1 -1
  7. package/dist/itowns.js +1 -1
  8. package/dist/itowns.js.LICENSE.txt +2 -2
  9. package/dist/itowns.js.map +1 -1
  10. package/dist/itowns_widgets.js +2 -0
  11. package/dist/itowns_widgets.js.map +1 -0
  12. package/examples/config.json +28 -6
  13. package/examples/css/example.css +21 -1
  14. package/examples/css/widgets.css +360 -0
  15. package/examples/geoid_geoidLayer.html +102 -0
  16. package/examples/images/code-logo.svg +43 -0
  17. package/examples/index.html +5 -5
  18. package/examples/itowns-potree.html +252 -0
  19. package/examples/js/GUI/GuiTools.js +17 -0
  20. package/examples/mars.html +0 -1
  21. package/examples/misc_orthographic_camera.html +7 -19
  22. package/examples/source_file_from_fetched_data.html +90 -0
  23. package/examples/source_file_from_format.html +85 -0
  24. package/examples/source_file_from_methods.html +87 -0
  25. package/examples/source_file_from_parsed_data.html +104 -0
  26. package/examples/source_file_geojson_raster.html +21 -45
  27. package/examples/source_file_gpx_raster.html +28 -36
  28. package/examples/source_file_kml_raster.html +1 -4
  29. package/examples/source_file_shapefile.html +39 -34
  30. package/examples/source_stream_wfs_25d.html +21 -13
  31. package/examples/source_stream_wfs_3d.html +21 -12
  32. package/examples/source_stream_wfs_raster.html +20 -20
  33. package/examples/vector_tile_3d_mesh.html +155 -0
  34. package/examples/vector_tile_raster_3d.html +0 -5
  35. package/examples/view_25d_map.html +6 -19
  36. package/examples/view_2d_map.html +6 -19
  37. package/examples/view_3d_map.html +106 -81
  38. package/examples/view_immersive.html +13 -14
  39. package/examples/widgets_minimap.html +124 -0
  40. package/examples/widgets_navigation.html +124 -0
  41. package/examples/widgets_scale.html +96 -0
  42. package/examples/widgets_searchbar.html +124 -0
  43. package/lib/Controls/GlobeControls.js +13 -0
  44. package/lib/Controls/PlanarControls.js +11 -43
  45. package/lib/Converter/Feature2Mesh.js +203 -45
  46. package/lib/Converter/convertToTile.js +13 -4
  47. package/lib/Core/3DTiles/C3DTBoundingVolume.js +4 -1
  48. package/lib/Core/Deprecated/Undeprecator.js +1 -1
  49. package/lib/Core/Feature.js +60 -34
  50. package/lib/Core/Geographic/Extent.js +1 -1
  51. package/lib/Core/Geographic/GeoidGrid.js +143 -0
  52. package/lib/Core/MainLoop.js +137 -63
  53. package/lib/Core/Math/Ellipsoid.js +1 -1
  54. package/lib/Core/Prefab/Globe/SkyShader.js +3 -1
  55. package/lib/Core/Prefab/Planar/PlanarLayer.js +3 -1
  56. package/lib/Core/Style.js +1 -1
  57. package/lib/Core/TileGeometry.js +3 -1
  58. package/lib/Core/TileMesh.js +32 -22
  59. package/lib/Core/View.js +81 -15
  60. package/lib/Layer/ElevationLayer.js +6 -2
  61. package/lib/Layer/FeatureGeometryLayer.js +36 -7
  62. package/lib/Layer/GeoidLayer.js +142 -0
  63. package/lib/Layer/GeometryLayer.js +6 -54
  64. package/lib/Layer/InfoLayer.js +1 -1
  65. package/lib/Layer/Layer.js +1 -1
  66. package/lib/Layer/LayerUpdateStrategy.js +1 -1
  67. package/lib/Layer/OrientedImageLayer.js +1 -0
  68. package/lib/Layer/PotreeLayer.js +3 -1
  69. package/lib/Layer/RasterLayer.js +3 -1
  70. package/lib/Layer/ReferencingLayerProperties.js +50 -0
  71. package/lib/Layer/TiledGeometryLayer.js +3 -1
  72. package/lib/Main.js +214 -174
  73. package/lib/MainBundle.js +1 -1
  74. package/lib/Parser/B3dmParser.js +5 -3
  75. package/lib/Parser/GDFParser.js +118 -0
  76. package/lib/Parser/GTXParser.js +92 -0
  77. package/lib/Parser/GeoJsonParser.js +29 -7
  78. package/lib/Parser/ISGParser.js +121 -0
  79. package/lib/Parser/LASParser.js +3 -1
  80. package/lib/Parser/VectorTileParser.js +4 -3
  81. package/lib/Parser/XbilParser.js +1 -1
  82. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -1
  83. package/lib/Process/3dTilesProcessing.js +2 -2
  84. package/lib/Process/FeatureProcessing.js +38 -86
  85. package/lib/Process/LayeredMaterialNodeProcessing.js +16 -7
  86. package/lib/Process/ObjectRemovalHelper.js +4 -0
  87. package/lib/Provider/3dTilesProvider.js +2 -7
  88. package/lib/Provider/Fetcher.js +4 -1
  89. package/lib/Provider/TileProvider.js +18 -2
  90. package/lib/Provider/URLBuilder.js +1 -1
  91. package/lib/Renderer/Camera.js +33 -12
  92. package/lib/Renderer/ColorLayersOrdering.js +3 -1
  93. package/lib/Renderer/LayeredMaterial.js +34 -9
  94. package/lib/Renderer/OBB.js +22 -25
  95. package/lib/Renderer/OrientedImageMaterial.js +8 -5
  96. package/lib/Renderer/PointsMaterial.js +6 -6
  97. package/lib/Renderer/RasterTile.js +1 -1
  98. package/lib/Renderer/RenderMode.js +3 -1
  99. package/lib/Renderer/Shader/ShaderChunk.js +5 -1
  100. package/lib/Renderer/Shader/ShaderUtils.js +4 -2
  101. package/lib/Renderer/c3DEngine.js +9 -6
  102. package/lib/Source/C3DTilesSource.js +3 -1
  103. package/lib/Source/EntwinePointTileSource.js +3 -1
  104. package/lib/Source/FileSource.js +8 -1
  105. package/lib/Source/PotreeSource.js +3 -1
  106. package/lib/Source/Source.js +15 -10
  107. package/lib/Source/VectorTilesSource.js +5 -0
  108. package/lib/Source/WFSSource.js +9 -3
  109. package/lib/Source/WMTSSource.js +3 -1
  110. package/lib/ThreeExtended/{WebGL.js → capabilities/WebGL.js} +8 -7
  111. package/lib/ThreeExtended/loaders/GLTFLoader.js +88 -39
  112. package/lib/Utils/CameraUtils.js +11 -1
  113. package/lib/Utils/DEMUtils.js +4 -2
  114. package/lib/Utils/FeaturesUtils.js +8 -4
  115. package/lib/Utils/gui/Main.js +39 -0
  116. package/lib/Utils/gui/Minimap.js +197 -0
  117. package/lib/Utils/gui/Navigation.js +322 -0
  118. package/lib/Utils/gui/Scale.js +154 -0
  119. package/lib/Utils/gui/Searchbar.js +299 -0
  120. package/lib/Utils/gui/Widget.js +119 -0
  121. package/package.json +32 -27
  122. package/examples/js/Scale.js +0 -40
@@ -64,6 +64,10 @@ var GLTFLoader = /*#__PURE__*/function (_Loader) {
64
64
  return new GLTFTextureWebPExtension(parser);
65
65
  });
66
66
 
67
+ _this.register(function (parser) {
68
+ return new GLTFMaterialsSheenExtension(parser);
69
+ });
70
+
67
71
  _this.register(function (parser) {
68
72
  return new GLTFMaterialsTransmissionExtension(parser);
69
73
  });
@@ -270,6 +274,14 @@ var GLTFLoader = /*#__PURE__*/function (_Loader) {
270
274
  parser.setPlugins(plugins);
271
275
  parser.parse(onLoad, onError);
272
276
  }
277
+ }, {
278
+ key: "parseAsync",
279
+ value: function parseAsync(data, path) {
280
+ var scope = this;
281
+ return new Promise(function (resolve, reject) {
282
+ scope.parse(data, path, resolve, reject);
283
+ });
284
+ }
273
285
  }]);
274
286
  return GLTFLoader;
275
287
  }(_three.Loader);
@@ -309,6 +321,7 @@ var EXTENSIONS = {
309
321
  KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
310
322
  KHR_MATERIALS_IOR: 'KHR_materials_ior',
311
323
  KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
324
+ KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
312
325
  KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
313
326
  KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
314
327
  KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
@@ -531,6 +544,65 @@ var GLTFMaterialsClearcoatExtension = /*#__PURE__*/function () {
531
544
  }]);
532
545
  return GLTFMaterialsClearcoatExtension;
533
546
  }();
547
+ /**
548
+ * Sheen Materials Extension
549
+ *
550
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
551
+ */
552
+
553
+
554
+ var GLTFMaterialsSheenExtension = /*#__PURE__*/function () {
555
+ function GLTFMaterialsSheenExtension(parser) {
556
+ (0, _classCallCheck2["default"])(this, GLTFMaterialsSheenExtension);
557
+ this.parser = parser;
558
+ this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
559
+ }
560
+
561
+ (0, _createClass2["default"])(GLTFMaterialsSheenExtension, [{
562
+ key: "getMaterialType",
563
+ value: function getMaterialType(materialIndex) {
564
+ var parser = this.parser;
565
+ var materialDef = parser.json.materials[materialIndex];
566
+ if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
567
+ return _three.MeshPhysicalMaterial;
568
+ }
569
+ }, {
570
+ key: "extendMaterialParams",
571
+ value: function extendMaterialParams(materialIndex, materialParams) {
572
+ var parser = this.parser;
573
+ var materialDef = parser.json.materials[materialIndex];
574
+
575
+ if (!materialDef.extensions || !materialDef.extensions[this.name]) {
576
+ return Promise.resolve();
577
+ }
578
+
579
+ var pending = [];
580
+ materialParams.sheenColor = new _three.Color(0, 0, 0);
581
+ materialParams.sheenRoughness = 0;
582
+ materialParams.sheen = 1;
583
+ var extension = materialDef.extensions[this.name];
584
+
585
+ if (extension.sheenColorFactor !== undefined) {
586
+ materialParams.sheenColor.fromArray(extension.sheenColorFactor);
587
+ }
588
+
589
+ if (extension.sheenRoughnessFactor !== undefined) {
590
+ materialParams.sheenRoughness = extension.sheenRoughnessFactor;
591
+ }
592
+
593
+ if (extension.sheenColorTexture !== undefined) {
594
+ pending.push(parser.assignTexture(materialParams, 'sheenColorMap', extension.sheenColorTexture));
595
+ }
596
+
597
+ if (extension.sheenRoughnessTexture !== undefined) {
598
+ pending.push(parser.assignTexture(materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture));
599
+ }
600
+
601
+ return Promise.all(pending);
602
+ }
603
+ }]);
604
+ return GLTFMaterialsSheenExtension;
605
+ }();
534
606
  /**
535
607
  * Transmission Materials Extension
536
608
  *
@@ -622,7 +694,7 @@ var GLTFMaterialsVolumeExtension = /*#__PURE__*/function () {
622
694
 
623
695
  materialParams.attenuationDistance = extension.attenuationDistance || 0;
624
696
  var colorArray = extension.attenuationColor || [1, 1, 1];
625
- materialParams.attenuationTint = new _three.Color(colorArray[0], colorArray[1], colorArray[2]);
697
+ materialParams.attenuationColor = new _three.Color(colorArray[0], colorArray[1], colorArray[2]);
626
698
  return Promise.all(pending);
627
699
  }
628
700
  }]);
@@ -708,10 +780,10 @@ var GLTFMaterialsSpecularExtension = /*#__PURE__*/function () {
708
780
  }
709
781
 
710
782
  var colorArray = extension.specularColorFactor || [1, 1, 1];
711
- materialParams.specularTint = new _three.Color(colorArray[0], colorArray[1], colorArray[2]);
783
+ materialParams.specularColor = new _three.Color(colorArray[0], colorArray[1], colorArray[2]);
712
784
 
713
785
  if (extension.specularColorTexture !== undefined) {
714
- pending.push(parser.assignTexture(materialParams, 'specularTintMap', extension.specularColorTexture).then(function (texture) {
786
+ pending.push(parser.assignTexture(materialParams, 'specularColorMap', extension.specularColorTexture).then(function (texture) {
715
787
  texture.encoding = _three.sRGBEncoding;
716
788
  }));
717
789
  }
@@ -892,8 +964,7 @@ var BINARY_EXTENSION_CHUNK_TYPES = {
892
964
  JSON: 0x4E4F534A,
893
965
  BIN: 0x004E4942
894
966
  };
895
-
896
- var GLTFBinaryExtension = function GLTFBinaryExtension(data) {
967
+ var GLTFBinaryExtension = /*#__PURE__*/(0, _createClass2["default"])(function GLTFBinaryExtension(data) {
897
968
  (0, _classCallCheck2["default"])(this, GLTFBinaryExtension);
898
969
  this.name = EXTENSIONS.KHR_BINARY_GLTF;
899
970
  this.content = null;
@@ -936,14 +1007,13 @@ var GLTFBinaryExtension = function GLTFBinaryExtension(data) {
936
1007
  if (this.content === null) {
937
1008
  throw new Error('THREE.GLTFLoader: JSON content not found.');
938
1009
  }
939
- };
1010
+ });
940
1011
  /**
941
1012
  * DRACO Mesh Compression Extension
942
1013
  *
943
1014
  * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
944
1015
  */
945
1016
 
946
-
947
1017
  var GLTFDracoMeshCompressionExtension = /*#__PURE__*/function () {
948
1018
  function GLTFDracoMeshCompressionExtension(json, dracoLoader) {
949
1019
  (0, _classCallCheck2["default"])(this, GLTFDracoMeshCompressionExtension);
@@ -1050,7 +1120,7 @@ var GLTFTextureTransformExtension = /*#__PURE__*/function () {
1050
1120
  /**
1051
1121
  * Specular-Glossiness Extension
1052
1122
  *
1053
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
1123
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness
1054
1124
  */
1055
1125
 
1056
1126
  /**
@@ -1074,7 +1144,7 @@ var GLTFMeshStandardSGMaterial = /*#__PURE__*/function (_MeshStandardMaterial) {
1074
1144
 
1075
1145
  var specularMapParsFragmentChunk = ['#ifdef USE_SPECULARMAP', ' uniform sampler2D specularMap;', '#endif'].join('\n');
1076
1146
  var glossinessMapParsFragmentChunk = ['#ifdef USE_GLOSSINESSMAP', ' uniform sampler2D glossinessMap;', '#endif'].join('\n');
1077
- var specularMapFragmentChunk = ['vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', ' vec4 texelSpecular = texture2D( specularMap, vUv );', ' texelSpecular = sRGBToLinear( texelSpecular );', ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', ' specularFactor *= texelSpecular.rgb;', '#endif'].join('\n');
1147
+ var specularMapFragmentChunk = ['vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', ' vec4 texelSpecular = texture2D( specularMap, vUv );', ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', ' specularFactor *= texelSpecular.rgb;', '#endif'].join('\n');
1078
1148
  var glossinessMapFragmentChunk = ['float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );', ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', ' glossinessFactor *= texelGlossiness.a;', '#endif'].join('\n');
1079
1149
  var lightPhysicalFragmentChunk = ['PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', 'material.roughness += geometryRoughness;', 'material.roughness = min( material.roughness, 1.0 );', 'material.specularColor = specularFactor;'].join('\n');
1080
1150
  var uniforms = {
@@ -1265,10 +1335,10 @@ var GLTFMaterialsPbrSpecularGlossinessExtension = /*#__PURE__*/function () {
1265
1335
  */
1266
1336
 
1267
1337
 
1268
- var GLTFMeshQuantizationExtension = function GLTFMeshQuantizationExtension() {
1338
+ var GLTFMeshQuantizationExtension = /*#__PURE__*/(0, _createClass2["default"])(function GLTFMeshQuantizationExtension() {
1269
1339
  (0, _classCallCheck2["default"])(this, GLTFMeshQuantizationExtension);
1270
1340
  this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
1271
- };
1341
+ });
1272
1342
  /*********************************/
1273
1343
 
1274
1344
  /********** INTERPOLATION ********/
@@ -1277,7 +1347,6 @@ var GLTFMeshQuantizationExtension = function GLTFMeshQuantizationExtension() {
1277
1347
  // Spline Interpolation
1278
1348
  // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
1279
1349
 
1280
-
1281
1350
  var GLTFCubicSplineInterpolant = /*#__PURE__*/function (_Interpolant) {
1282
1351
  (0, _inherits2["default"])(GLTFCubicSplineInterpolant, _Interpolant);
1283
1352
 
@@ -1454,30 +1523,10 @@ var ALPHA_MODES = {
1454
1523
  MASK: 'MASK',
1455
1524
  BLEND: 'BLEND'
1456
1525
  };
1457
- /* UTILITY FUNCTIONS */
1458
-
1459
- function resolveURL(url, path) {
1460
- // Invalid URL
1461
- if (typeof url !== 'string' || url === '') return ''; // Host Relative URL
1462
-
1463
- if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
1464
- path = path.replace(/(^https?:\/\/[^\/]+).*/i, '$1');
1465
- } // Absolute URL http://,https://,//
1466
-
1467
-
1468
- if (/^(https?:)?\/\//i.test(url)) return url; // Data URI
1469
-
1470
- if (/^data:.*,.*$/i.test(url)) return url; // Blob URL
1471
-
1472
- if (/^blob:.*$/i.test(url)) return url; // Relative URL
1473
-
1474
- return path + url;
1475
- }
1476
1526
  /**
1477
1527
  * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
1478
1528
  */
1479
1529
 
1480
-
1481
1530
  function createDefaultMaterial(cache) {
1482
1531
  if (cache['DefaultMaterial'] === undefined) {
1483
1532
  cache['DefaultMaterial'] = new _three.MeshStandardMaterial({
@@ -1678,7 +1727,7 @@ var GLTFParser = /*#__PURE__*/function () {
1678
1727
  this.nodeNamesUsed = {}; // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
1679
1728
  // expensive work of uploading a texture to the GPU off the main thread.
1680
1729
 
1681
- if (typeof createImageBitmap !== 'undefined' && /Firefox/.test(navigator.userAgent) === false) {
1730
+ if (typeof createImageBitmap !== 'undefined' && /Firefox|^((?!chrome|android).)*safari/i.test(navigator.userAgent) === false) {
1682
1731
  this.textureLoader = new _three.ImageBitmapLoader(this.options.manager);
1683
1732
  } else {
1684
1733
  this.textureLoader = new _three.TextureLoader(this.options.manager);
@@ -1990,7 +2039,7 @@ var GLTFParser = /*#__PURE__*/function () {
1990
2039
 
1991
2040
  var options = this.options;
1992
2041
  return new Promise(function (resolve, reject) {
1993
- loader.load(resolveURL(bufferDef.uri, options.path), resolve, undefined, function () {
2042
+ loader.load(_three.LoaderUtils.resolveURL(bufferDef.uri, options.path), resolve, undefined, function () {
1994
2043
  reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
1995
2044
  });
1996
2045
  });
@@ -2173,7 +2222,7 @@ var GLTFParser = /*#__PURE__*/function () {
2173
2222
  };
2174
2223
  }
2175
2224
 
2176
- loader.load(resolveURL(sourceURI, options.path), onLoad, undefined, reject);
2225
+ loader.load(_three.LoaderUtils.resolveURL(sourceURI, options.path), onLoad, undefined, reject);
2177
2226
  });
2178
2227
  }).then(function (texture) {
2179
2228
  // Clean up resources and configure Texture.
@@ -2322,7 +2371,9 @@ var GLTFParser = /*#__PURE__*/function () {
2322
2371
  }
2323
2372
  }, {
2324
2373
  key: "getMaterialType",
2325
- value: function getMaterialType() {
2374
+ value: function
2375
+ /* materialIndex */
2376
+ getMaterialType() {
2326
2377
  return _three.MeshStandardMaterial;
2327
2378
  }
2328
2379
  /**
@@ -2395,7 +2446,6 @@ var GLTFParser = /*#__PURE__*/function () {
2395
2446
 
2396
2447
  materialParams.depthWrite = false;
2397
2448
  } else {
2398
- materialParams.format = _three.RGBFormat;
2399
2449
  materialParams.transparent = false;
2400
2450
 
2401
2451
  if (alphaMode === ALPHA_MODES.MASK) {
@@ -2739,9 +2789,8 @@ var GLTFParser = /*#__PURE__*/function () {
2739
2789
  var targetNames = [];
2740
2790
 
2741
2791
  if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {
2742
- // Node may be a Group (glTF mesh with several primitives) or a Mesh.
2743
2792
  node.traverse(function (object) {
2744
- if (object.isMesh === true && object.morphTargetInfluences) {
2793
+ if (object.morphTargetInfluences) {
2745
2794
  targetNames.push(object.name ? object.name : object.uuid);
2746
2795
  }
2747
2796
  });
@@ -7,9 +7,9 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
+ exports["default"] = void 0;
10
11
  exports.getLookAtFromMath = getLookAtFromMath;
11
12
  exports.getRig = getRig;
12
- exports["default"] = void 0;
13
13
 
14
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
15
 
@@ -35,6 +35,8 @@ var _Ellipsoid = _interopRequireDefault(require("../Core/Math/Ellipsoid"));
35
35
 
36
36
  var _OBB = _interopRequireDefault(require("../Renderer/OBB"));
37
37
 
38
+ var _View = require("../Core/View");
39
+
38
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
41
 
40
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -173,6 +175,14 @@ var CameraRig = /*#__PURE__*/function (_THREE$Object3D) {
173
175
  } else {
174
176
  this.camera.matrixWorld.decompose(camera.position, camera.quaternion, camera.scale);
175
177
  }
178
+
179
+ view.dispatchEvent({
180
+ type: _View.VIEW_EVENTS.CAMERA_MOVED,
181
+ coord: this.coord,
182
+ range: this.range,
183
+ heading: this.heading,
184
+ tilt: this.tilt
185
+ });
176
186
  }
177
187
  }, {
178
188
  key: "setProxy",
@@ -7,8 +7,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.readTextureValueWithBilinearFiltering = readTextureValueWithBilinearFiltering;
11
10
  exports["default"] = void 0;
11
+ exports.readTextureValueWithBilinearFiltering = readTextureValueWithBilinearFiltering;
12
12
 
13
13
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
14
14
 
@@ -352,10 +352,12 @@ function offsetInExtent(point, extent) {
352
352
  }
353
353
 
354
354
  function _readZ(layer, method, coord, nodes, cache) {
355
+ var _cache$tile;
356
+
355
357
  var pt = coord.as(layer.extent.crs, temp.coord1);
356
358
  var tileWithValidElevationTexture = null; // first check in cache
357
359
 
358
- if (cache && cache.tile && cache.tile.material) {
360
+ if (cache !== null && cache !== void 0 && (_cache$tile = cache.tile) !== null && _cache$tile !== void 0 && _cache$tile.material) {
359
361
  tileWithValidElevationTexture = tileAt(pt, cache.tile);
360
362
  }
361
363
 
@@ -81,20 +81,24 @@ function getClosestPoint(point, points, epsilon, offset, count, size) {
81
81
  return closestPoint;
82
82
  }
83
83
 
84
- function pointIsInsidePolygon(point, polygonPoints, offset, count, size) {
84
+ function pointIsInsidePolygon(point, polygonPoints, epsilon, offset, count, size) {
85
85
  // ray-casting algorithm based on
86
86
  // http://wrf.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
87
87
  var x = point.x;
88
88
  var y = point.y;
89
89
  var inside = false; // in first j is last point of polygon
90
90
  // for each segment of the polygon (j is i -1)
91
- // debugger;
92
91
 
93
92
  for (var i = offset, j = offset + count - size; i < offset + count; j = i, i += size) {
94
93
  var xi = polygonPoints[i];
95
94
  var yi = polygonPoints[i + 1];
96
95
  var xj = polygonPoints[j];
97
- var yj = polygonPoints[j + 1]; // isIntersect semi-infinite ray horizontally with polygon's edge
96
+ var yj = polygonPoints[j + 1];
97
+
98
+ if (pointIsOverLine(point, [xi, yi, xj, yj], epsilon, 0, 4, 2)) {
99
+ return true;
100
+ } // isIntersect semi-infinite ray horizontally with polygon's edge
101
+
98
102
 
99
103
  if (yi > y != yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
100
104
  inside = !inside;
@@ -107,7 +111,7 @@ function pointIsInsidePolygon(point, polygonPoints, offset, count, size) {
107
111
  function isFeatureSingleGeometryUnderCoordinate(coordinate, type, coordinates, epsilon, offset, count, size) {
108
112
  if (type == _Feature.FEATURE_TYPES.LINE && pointIsOverLine(coordinate, coordinates, epsilon, offset, count, size)) {
109
113
  return true;
110
- } else if (type == _Feature.FEATURE_TYPES.POLYGON && pointIsInsidePolygon(coordinate, coordinates, offset, count, size)) {
114
+ } else if (type == _Feature.FEATURE_TYPES.POLYGON && pointIsInsidePolygon(coordinate, coordinates, epsilon, offset, count, size)) {
111
115
  return true;
112
116
  } else if (type == _Feature.FEATURE_TYPES.POINT) {
113
117
  var closestPoint = getClosestPoint(coordinate, coordinates, epsilon, offset, count, size);
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "Minimap", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _Minimap["default"];
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "Navigation", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _Navigation["default"];
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "Scale", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _Scale["default"];
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "Searchbar", {
27
+ enumerable: true,
28
+ get: function get() {
29
+ return _Searchbar["default"];
30
+ }
31
+ });
32
+
33
+ var _Navigation = _interopRequireDefault(require("./Navigation"));
34
+
35
+ var _Minimap = _interopRequireDefault(require("./Minimap"));
36
+
37
+ var _Scale = _interopRequireDefault(require("./Scale"));
38
+
39
+ var _Searchbar = _interopRequireDefault(require("./Searchbar"));
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _Coordinates = _interopRequireDefault(require("../../Core/Geographic/Coordinates"));
21
+
22
+ var _MainLoop = require("../../Core/MainLoop");
23
+
24
+ var _PlanarView = _interopRequireDefault(require("../../Core/Prefab/PlanarView"));
25
+
26
+ var _Camera = require("../../Renderer/Camera");
27
+
28
+ var _Widget2 = _interopRequireDefault(require("./Widget"));
29
+
30
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
31
+
32
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
+
34
+ var DEFAULT_OPTIONS = {
35
+ minScale: 1 / 500000,
36
+ maxScale: 1 / 5E8,
37
+ zoomRatio: 1 / 30,
38
+ width: 150,
39
+ height: 150,
40
+ position: 'bottom-left'
41
+ };
42
+ /**
43
+ * A widget for minimap
44
+ *
45
+ * To use it, you need to link the widgets' stylesheet to your html webpage. This stylesheet is included in
46
+ * [itowns bundles](https://github.com/iTowns/itowns/releases) if you downloaded them, or it can be found in
47
+ * `node_modules/itowns/examples/css` if you installed iTowns with npm. Otherwise, it can be found at
48
+ * [this link](https://raw.githubusercontent.com/iTowns/itowns/master/examples/css/widgets.css). See
49
+ * [this example](http://www.itowns-project.org/itowns/examples/#widgets_minimap) for more details.
50
+ *
51
+ * @extends Widget
52
+ *
53
+ * @property {HTMLElement} domElement An html div containing the minimap.
54
+ * @property {HTMLElement} parentElement The parent HTML container of `this.domElement`.
55
+ */
56
+
57
+ var Minimap = /*#__PURE__*/function (_Widget) {
58
+ (0, _inherits2["default"])(Minimap, _Widget);
59
+
60
+ var _super = _createSuper(Minimap);
61
+
62
+ /**
63
+ * @param {GlobeView} view The iTowns view the minimap should be
64
+ * linked to. Only {@link GlobeView} is
65
+ * supported at the moment.
66
+ * @param {ColorLayer} layer The {@link ColorLayer} that should be
67
+ * displayed on the minimap.
68
+ * @param {Object} [options] The minimap optional configuration.
69
+ * @param {HTMLElement} [options.parentElement=view.domElement] The parent HTML container of the div
70
+ * which contains minimap widgets.
71
+ * @param {number} [options.size] The size of the minimap. It is a number
72
+ * that describes both width and height
73
+ * in pixels of the minimap.
74
+ * @param {number} [options.width=150] The width in pixels of the minimap.
75
+ * @param {number} [options.height=150] The height in pixels of the minimap.
76
+ * @param {string} [options.position='bottom-left'] Defines which position within the
77
+ * `parentElement` the minimap should be
78
+ * displayed to. Possible values are
79
+ * `top`, `bottom`, `left`, `right`,
80
+ * `top-left`, `top-right`, `bottom-left`
81
+ * and `bottom-right`. If the input value
82
+ * does not match one of these, it will
83
+ * be defaulted to `bottom-left`.
84
+ * @param {Object} [options.translate] An optional translation of the minimap.
85
+ * @param {number} [options.translate.x=0] The minimap translation along the page
86
+ * x-axis.
87
+ * @param {number} [options.translate.y=0] The minimap translation along the page
88
+ * y-axis.
89
+ * @param {HTMLElement|string} [options.cursor] An html element or an HTML string
90
+ * describing a cursor showing minimap
91
+ * view camera target position at the
92
+ * center of the minimap.
93
+ * @param {number} [options.minScale=1/2000] The minimal scale the minimap can reach.
94
+ * @param {number} [options.maxScale=1/1_250_000] The maximal scale the minimap can reach.
95
+ * @param {number} [options.zoomRatio=1/30] The ratio between minimap camera zoom
96
+ * and view camera zoom.
97
+ * @param {number} [options.pitch=0.28] The screen pixel pitch, used to compute
98
+ * view and minimap scale.
99
+ */
100
+ function Minimap(view, layer) {
101
+ var _this;
102
+
103
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
104
+ (0, _classCallCheck2["default"])(this, Minimap);
105
+
106
+ // ---------- BUILD PROPERTIES ACCORDING TO DEFAULT OPTIONS AND OPTIONS PASSED IN PARAMETERS : ----------
107
+ if (!view.isGlobeView) {
108
+ throw new Error('\'Minimap\' plugin only supports \'GlobeView\'. Therefore, the \'view\' parameter must be a ' + '\'GlobeView\'.');
109
+ }
110
+
111
+ if (!layer.isColorLayer) {
112
+ throw new Error('\'layer\' parameter form \'Minimap\' constructor should be a \'ColorLayer\'.');
113
+ }
114
+
115
+ _this = _super.call(this, view, options, DEFAULT_OPTIONS);
116
+ _this.minScale = options.minScale || DEFAULT_OPTIONS.minScale;
117
+ _this.maxScale = options.maxScale || DEFAULT_OPTIONS.maxScale; // TODO : it could be interesting to be able to specify a method as zoomRatio parameter. This method could
118
+ // return a zoom ratio from the scale of the minimap.
119
+
120
+ _this.zoomRatio = options.zoomRatio || DEFAULT_OPTIONS.zoomRatio; // ---------- this.domElement SETTINGS SPECIFIC TO MINIMAP : ----------
121
+
122
+ _this.domElement.id = 'widgets-minimap'; // Display a cursor at the center of the minimap, if requested.
123
+
124
+ if (options.cursor) {
125
+ // Wrap cursor domElement inside a div to center it in minimap.
126
+ var cursorWrapper = document.createElement('div');
127
+ cursorWrapper.id = 'cursor-wrapper';
128
+
129
+ _this.domElement.appendChild(cursorWrapper); // Add specified cursor to its wrapper.
130
+
131
+
132
+ if (typeof options.cursor === 'string') {
133
+ cursorWrapper.innerHTML = options.cursor;
134
+ } else if (options.cursor instanceof HTMLElement) {
135
+ cursorWrapper.appendChild(options.cursor);
136
+ }
137
+ } // ---------- CREATE A MINIMAP View AND DISPLAY DATA PASSED IN Layer PARAMETER : ----------
138
+
139
+
140
+ _this.view = new _PlanarView["default"](_this.domElement, layer.source.extent, {
141
+ camera: {
142
+ type: _Camera.CAMERA_TYPE.ORTHOGRAPHIC
143
+ },
144
+ placement: layer.source.extent,
145
+ // TODO : the default placement should be the view extent for ortho camera
146
+ noControls: true,
147
+ maxSubdivisionLevel: view.tileLayer.maxSubdivisionLevel
148
+ });
149
+
150
+ _this.view.addLayer(layer); // TODO : should this promise be returned by constructor so that user can use it ?
151
+ // Give the focus back to the main view. Indeed, `View` constructor takes the focus, and we don't want the focus
152
+ // on the latest created `View`, which is the minimap view.
153
+
154
+
155
+ view.domElement.focus(); // Prevent the minimap domElement to get focus when clicked, and prevent click event to be propagated to the
156
+ // main view controls.
157
+
158
+ _this.domElement.addEventListener('pointerdown', function (event) {
159
+ event.preventDefault();
160
+ }); // Store minimap view camera3D in constant for code convenience.
161
+
162
+
163
+ var camera3D = _this.view.camera.camera3D; // ---------- UPDATE MINIMAP VIEW WHEN UPDATING THE MAIN VIEW : ----------
164
+ // The minimal and maximal value the minimap camera3D zoom can reach in order to stay in the scale limits.
165
+
166
+ var initialScale = _this.view.getScale(options.pitch);
167
+
168
+ var minZoom = camera3D.zoom * _this.maxScale / initialScale;
169
+ var maxZoom = camera3D.zoom * _this.minScale / initialScale; // Coordinates used to transform position vectors from the main view CRS to the minimap view CRS.
170
+
171
+ var mainViewCoordinates = new _Coordinates["default"](view.referenceCrs);
172
+ var viewCoordinates = new _Coordinates["default"](_this.view.referenceCrs);
173
+ var targetPosition = view.controls.getCameraTargetPosition();
174
+ view.addFrameRequester(_MainLoop.MAIN_LOOP_EVENTS.AFTER_RENDER, function () {
175
+ // Update minimap camera zoom
176
+ var distance = view.camera.camera3D.position.distanceTo(targetPosition);
177
+ var scale = view.getScaleFromDistance(options.pitch, distance);
178
+ camera3D.zoom = _this.zoomRatio * maxZoom * scale / _this.minScale;
179
+ camera3D.zoom = Math.min(Math.max(camera3D.zoom, minZoom), maxZoom);
180
+ camera3D.updateProjectionMatrix(); // Update minimap camera position.
181
+
182
+ mainViewCoordinates.setFromVector3(view.controls.getCameraTargetPosition());
183
+ mainViewCoordinates.as(_this.view.referenceCrs, viewCoordinates);
184
+ camera3D.position.x = viewCoordinates.x;
185
+ camera3D.position.y = viewCoordinates.y;
186
+ camera3D.updateMatrixWorld(true);
187
+
188
+ _this.view.notifyChange(camera3D);
189
+ });
190
+ return _this;
191
+ }
192
+
193
+ return (0, _createClass2["default"])(Minimap);
194
+ }(_Widget2["default"]);
195
+
196
+ var _default = Minimap;
197
+ exports["default"] = _default;