@openglobus/og 0.19.3 → 0.20.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.
- package/README.md +3 -3
- package/css/og.css +18 -4
- package/lib/@openglobus/js/Clock.d.ts +106 -0
- package/lib/@openglobus/js/Deferred.d.ts +6 -0
- package/lib/@openglobus/js/Events.d.ts +90 -0
- package/lib/@openglobus/js/Extent.d.ts +145 -0
- package/lib/@openglobus/js/Globe.d.ts +134 -0
- package/lib/@openglobus/js/ImageCanvas.d.ts +128 -0
- package/lib/@openglobus/js/Lock.d.ts +15 -0
- package/lib/@openglobus/js/LonLat.d.ts +128 -0
- package/lib/@openglobus/js/Object3d.d.ts +64 -0
- package/lib/@openglobus/js/Popup.d.ts +46 -0
- package/lib/@openglobus/js/QueueArray.d.ts +16 -0
- package/lib/@openglobus/js/Rectangle.d.ts +76 -0
- package/lib/@openglobus/js/Stack.d.ts +20 -0
- package/lib/@openglobus/js/astro/astro.d.ts +39 -0
- package/lib/@openglobus/js/astro/earth.d.ts +8 -0
- package/lib/@openglobus/js/astro/jd.d.ts +234 -0
- package/lib/@openglobus/js/astro/orbit.d.ts +5 -0
- package/lib/@openglobus/js/astro/rotation.d.ts +2 -0
- package/lib/@openglobus/js/bv/Box.d.ts +32 -0
- package/lib/@openglobus/js/bv/Sphere.d.ts +37 -0
- package/lib/@openglobus/js/bv/index.d.ts +3 -0
- package/lib/@openglobus/js/camera/Camera.d.ts +314 -0
- package/lib/@openglobus/js/camera/Frustum.d.ts +139 -0
- package/lib/@openglobus/js/camera/PlanetCamera.d.ts +234 -0
- package/lib/@openglobus/js/camera/index.d.ts +3 -0
- package/lib/@openglobus/js/cons.d.ts +40 -0
- package/lib/@openglobus/js/control/Atmosphere.d.ts +16 -0
- package/lib/@openglobus/js/control/CompassButton.d.ts +16 -0
- package/lib/@openglobus/js/control/Control.d.ts +100 -0
- package/lib/@openglobus/js/control/DebugInfo.d.ts +25 -0
- package/lib/@openglobus/js/control/DrawingSwitcher.d.ts +13 -0
- package/lib/@openglobus/js/control/EarthCoordinates.d.ts +41 -0
- package/lib/@openglobus/js/control/EarthNavigation.d.ts +50 -0
- package/lib/@openglobus/js/control/GeoImageDragControl.d.ts +22 -0
- package/lib/@openglobus/js/control/KeyboardNavigation.d.ts +28 -0
- package/lib/@openglobus/js/control/LayerAnimation.d.ts +71 -0
- package/lib/@openglobus/js/control/LayerSwitcher.d.ts +36 -0
- package/lib/@openglobus/js/control/Lighting.d.ts +53 -0
- package/lib/@openglobus/js/control/MouseNavigation.d.ts +64 -0
- package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +44 -0
- package/lib/@openglobus/js/control/RulerSwitcher.d.ts +17 -0
- package/lib/@openglobus/js/control/ScaleControl.d.ts +24 -0
- package/lib/@openglobus/js/control/SegmentBoundVisualization.d.ts +12 -0
- package/lib/@openglobus/js/control/ShowFps.d.ts +9 -0
- package/lib/@openglobus/js/control/SimpleNavigation.d.ts +25 -0
- package/lib/@openglobus/js/control/SimpleSkyBackground.d.ts +17 -0
- package/lib/@openglobus/js/control/Sun.d.ts +33 -0
- package/lib/@openglobus/js/control/ToggleWireframe.d.ts +14 -0
- package/lib/@openglobus/js/control/TouchNavigation.d.ts +52 -0
- package/lib/@openglobus/js/control/ZoomControl.d.ts +27 -0
- package/lib/@openglobus/js/control/drawing/DrawingControl.d.ts +12 -0
- package/lib/@openglobus/js/control/drawing/LineStringDrawingScene.d.ts +15 -0
- package/lib/@openglobus/js/control/drawing/PolygonDrawingScene.d.ts +98 -0
- package/lib/@openglobus/js/control/elevationProfile/ElevationProfile.d.ts +77 -0
- package/lib/@openglobus/js/control/elevationProfile/ElevationProfileButtonsView.d.ts +14 -0
- package/lib/@openglobus/js/control/elevationProfile/ElevationProfileControl.d.ts +33 -0
- package/lib/@openglobus/js/control/elevationProfile/ElevationProfileLegend.d.ts +20 -0
- package/lib/@openglobus/js/control/elevationProfile/ElevationProfileScene.d.ts +80 -0
- package/lib/@openglobus/js/control/elevationProfile/ElevationProfileView.d.ts +63 -0
- package/lib/@openglobus/js/control/elevationProfile/PointListDialog.d.ts +12 -0
- package/lib/@openglobus/js/control/heightRuler/HeightRuler.d.ts +7 -0
- package/lib/@openglobus/js/control/heightRuler/HeightRulerScene.d.ts +35 -0
- package/lib/@openglobus/js/control/heightRuler/HeightRulerSwitcher.d.ts +6 -0
- package/lib/@openglobus/js/control/index.d.ts +29 -0
- package/lib/@openglobus/js/control/ruler/Ruler.d.ts +13 -0
- package/lib/@openglobus/js/control/ruler/RulerScene.d.ts +88 -0
- package/lib/@openglobus/js/control/selection/Selection.d.ts +55 -0
- package/lib/@openglobus/js/control/selection/SelectionScene.d.ts +44 -0
- package/lib/@openglobus/js/control/timeline/TimelineControl.d.ts +18 -0
- package/lib/@openglobus/js/control/timeline/TimelineModel.d.ts +41 -0
- package/lib/@openglobus/js/control/timeline/TimelineView.d.ts +85 -0
- package/lib/@openglobus/js/control/timeline/timelineUtils.d.ts +12 -0
- package/lib/@openglobus/js/control/visibleExtent/drawnode.d.ts +7 -0
- package/lib/@openglobus/js/ellipsoid/Ellipsoid.d.ts +193 -0
- package/lib/@openglobus/js/ellipsoid/index.d.ts +3 -0
- package/lib/@openglobus/js/ellipsoid/wgs84.d.ts +6 -0
- package/lib/@openglobus/js/entity/BaseBillboard.d.ts +222 -0
- package/lib/@openglobus/js/entity/BaseBillboardHandler.d.ts +81 -0
- package/lib/@openglobus/js/entity/Billboard.d.ts +113 -0
- package/lib/@openglobus/js/entity/BillboardHandler.d.ts +15 -0
- package/lib/@openglobus/js/entity/Entity.d.ts +354 -0
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +363 -0
- package/lib/@openglobus/js/entity/GeoObject.d.ts +152 -0
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +104 -0
- package/lib/@openglobus/js/entity/Geometry.d.ts +124 -0
- package/lib/@openglobus/js/entity/GeometryHandler.d.ts +84 -0
- package/lib/@openglobus/js/entity/Label.d.ts +214 -0
- package/lib/@openglobus/js/entity/LabelHandler.d.ts +65 -0
- package/lib/@openglobus/js/entity/LabelWorker.d.ts +15 -0
- package/lib/@openglobus/js/entity/PointCloud.d.ts +179 -0
- package/lib/@openglobus/js/entity/PointCloudHandler.d.ts +42 -0
- package/lib/@openglobus/js/entity/Polyline.d.ts +345 -0
- package/lib/@openglobus/js/entity/PolylineHandler.d.ts +22 -0
- package/lib/@openglobus/js/entity/Ray.d.ts +133 -0
- package/lib/@openglobus/js/entity/RayHandler.d.ts +70 -0
- package/lib/@openglobus/js/entity/Strip.d.ts +139 -0
- package/lib/@openglobus/js/entity/StripHandler.d.ts +42 -0
- package/lib/@openglobus/js/entity/index.d.ts +10 -0
- package/lib/@openglobus/js/index.d.ts +33 -0
- package/lib/@openglobus/js/input/KeyboardHandler.d.ts +33 -0
- package/lib/@openglobus/js/input/MouseHandler.d.ts +16 -0
- package/lib/@openglobus/js/input/TouchHandler.d.ts +11 -0
- package/lib/@openglobus/js/input/input.d.ts +3 -0
- package/lib/@openglobus/js/layer/BaseGeoImage.d.ts +145 -0
- package/lib/@openglobus/js/layer/Bing.d.ts +4 -0
- package/lib/@openglobus/js/layer/CanvasTiles.d.ts +103 -0
- package/lib/@openglobus/js/layer/GeoImage.d.ts +61 -0
- package/lib/@openglobus/js/layer/GeoTexture2d.d.ts +17 -0
- package/lib/@openglobus/js/layer/GeoVideo.d.ts +68 -0
- package/lib/@openglobus/js/layer/KML.d.ts +72 -0
- package/lib/@openglobus/js/layer/Layer.d.ts +415 -0
- package/lib/@openglobus/js/layer/Material.d.ts +34 -0
- package/lib/@openglobus/js/layer/OpenStreetMap.d.ts +4 -0
- package/lib/@openglobus/js/layer/Vector.d.ts +246 -0
- package/lib/@openglobus/js/layer/WMS.d.ts +75 -0
- package/lib/@openglobus/js/layer/XYZ.d.ts +148 -0
- package/lib/@openglobus/js/layer/index.d.ts +12 -0
- package/lib/@openglobus/js/light/LightSource.d.ts +174 -0
- package/lib/@openglobus/js/math/Line2.d.ts +11 -0
- package/lib/@openglobus/js/math/Line3.d.ts +28 -0
- package/lib/@openglobus/js/math/Mat3.d.ts +77 -0
- package/lib/@openglobus/js/math/Mat4.d.ts +195 -0
- package/lib/@openglobus/js/math/Plane.d.ts +20 -0
- package/lib/@openglobus/js/math/Quat.d.ts +373 -0
- package/lib/@openglobus/js/math/Ray.d.ts +76 -0
- package/lib/@openglobus/js/math/Vec2.d.ts +310 -0
- package/lib/@openglobus/js/math/Vec3.d.ts +472 -0
- package/lib/@openglobus/js/math/Vec4.d.ts +163 -0
- package/lib/@openglobus/js/math/coder.d.ts +51 -0
- package/lib/@openglobus/js/math/index.d.ts +11 -0
- package/lib/@openglobus/js/math.d.ts +266 -0
- package/lib/@openglobus/js/mercator.d.ts +92 -0
- package/lib/@openglobus/js/proj/EPSG3857.d.ts +9 -0
- package/lib/@openglobus/js/proj/EPSG4326.d.ts +9 -0
- package/lib/@openglobus/js/proj/Proj.d.ts +43 -0
- package/lib/@openglobus/js/quadTree/EPSG4326QuadTreeStrategy.d.ts +6 -0
- package/lib/@openglobus/js/quadTree/EarthQuadTreeStrategy.d.ts +9 -0
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +54 -0
- package/lib/@openglobus/js/quadTree/MarsQuadTreeStrategy.d.ts +11 -0
- package/lib/@openglobus/js/quadTree/Node.d.ts +80 -0
- package/lib/@openglobus/js/quadTree/QuadTreeStrategy.d.ts +28 -0
- package/lib/@openglobus/js/quadTree/Wgs84QuadTreeStrategy.d.ts +6 -0
- package/lib/@openglobus/js/quadTree/index.d.ts +12 -0
- package/lib/@openglobus/js/quadTree/quadTree.d.ts +40 -0
- package/lib/@openglobus/js/renderer/Renderer.d.ts +319 -0
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +240 -0
- package/lib/@openglobus/js/scene/Axes.d.ts +12 -0
- package/lib/@openglobus/js/scene/BaseNode.d.ts +61 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +652 -0
- package/lib/@openglobus/js/scene/RenderNode.d.ts +150 -0
- package/lib/@openglobus/js/scene/SkyBox.d.ts +13 -0
- package/lib/@openglobus/js/scene/index.d.ts +5 -0
- package/lib/@openglobus/js/segment/Segment.d.ts +288 -0
- package/lib/@openglobus/js/segment/SegmentLonLat.d.ts +44 -0
- package/lib/@openglobus/js/segment/SegmentLonLatWgs84.d.ts +10 -0
- package/lib/@openglobus/js/segment/Slice.d.ts +13 -0
- package/lib/@openglobus/js/segment/segmentHelper.d.ts +18 -0
- package/lib/@openglobus/js/shaders/atmos.d.ts +4 -0
- package/lib/@openglobus/js/shaders/billboard.d.ts +3 -0
- package/lib/@openglobus/js/shaders/bloom.d.ts +2 -0
- package/lib/@openglobus/js/shaders/blur.d.ts +3 -0
- package/lib/@openglobus/js/shaders/depth.d.ts +2 -0
- package/lib/@openglobus/js/shaders/drawnode.d.ts +8 -0
- package/lib/@openglobus/js/shaders/geoObject.d.ts +3 -0
- package/lib/@openglobus/js/shaders/label.d.ts +4 -0
- package/lib/@openglobus/js/shaders/lumFilter.d.ts +2 -0
- package/lib/@openglobus/js/shaders/pointCloud.d.ts +2 -0
- package/lib/@openglobus/js/shaders/polyline.d.ts +3 -0
- package/lib/@openglobus/js/shaders/ray.d.ts +2 -0
- package/lib/@openglobus/js/shaders/screenFrame.d.ts +2 -0
- package/lib/@openglobus/js/shaders/skybox.d.ts +2 -0
- package/lib/@openglobus/js/shaders/toneMapping.d.ts +2 -0
- package/lib/@openglobus/js/shaders/utils.d.ts +1 -0
- package/lib/@openglobus/js/terrain/BilTerrain.d.ts +18 -0
- package/lib/@openglobus/js/terrain/EmptyTerrain.d.ts +113 -0
- package/lib/@openglobus/js/terrain/Geoid.d.ts +33 -0
- package/lib/@openglobus/js/terrain/GlobusRgbTerrain.d.ts +6 -0
- package/lib/@openglobus/js/terrain/GlobusTerrain.d.ts +137 -0
- package/lib/{js/terrain/MapboxTerrain.d.ts → @openglobus/js/terrain/RgbTerrain.d.ts} +6 -5
- package/lib/@openglobus/js/terrain/index.d.ts +6 -0
- package/lib/@openglobus/js/ui/Button.d.ts +32 -0
- package/lib/@openglobus/js/ui/ButtonGroup.d.ts +16 -0
- package/lib/@openglobus/js/ui/Color.d.ts +22 -0
- package/lib/@openglobus/js/ui/Dialog.d.ts +55 -0
- package/lib/@openglobus/js/ui/Slider.d.ts +38 -0
- package/lib/@openglobus/js/ui/ToggleButton.d.ts +20 -0
- package/lib/@openglobus/js/ui/View.d.ts +37 -0
- package/lib/@openglobus/js/ui/icons.d.ts +1 -0
- package/lib/@openglobus/js/utils/BaseWorker.d.ts +14 -0
- package/lib/@openglobus/js/utils/FontAtlas.d.ts +82 -0
- package/lib/@openglobus/js/utils/GeoImageCreator.d.ts +34 -0
- package/lib/@openglobus/js/utils/ImagesCacheManager.d.ts +22 -0
- package/lib/@openglobus/js/utils/Loader.d.ts +63 -0
- package/lib/@openglobus/js/utils/NormalMapCreator.d.ts +52 -0
- package/lib/@openglobus/js/utils/PlainSegmentWorker.d.ts +24 -0
- package/lib/@openglobus/js/utils/TerrainWorker.d.ts +28 -0
- package/lib/@openglobus/js/utils/TextureAtlas.d.ts +113 -0
- package/lib/@openglobus/js/utils/VectorTileCreator.d.ts +18 -0
- package/lib/@openglobus/js/utils/colorTable.d.ts +3 -0
- package/lib/@openglobus/js/utils/earcut.d.ts +7 -0
- package/lib/@openglobus/js/utils/objParser.d.ts +24 -0
- package/lib/@openglobus/js/utils/shared.d.ts +263 -0
- package/lib/@openglobus/js/utils/units.d.ts +16 -0
- package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +53 -0
- package/lib/@openglobus/js/webgl/Framebuffer.d.ts +69 -0
- package/lib/@openglobus/js/webgl/Handler.d.ts +473 -0
- package/lib/@openglobus/js/webgl/Multisample.d.ts +27 -0
- package/lib/@openglobus/js/webgl/Program.d.ts +159 -0
- package/lib/@openglobus/js/webgl/ProgramController.d.ts +86 -0
- package/lib/@openglobus/js/webgl/index.d.ts +6 -0
- package/lib/@openglobus/js/webgl/types.d.ts +9 -0
- package/lib/@openglobus/js/webgl/variableHandlers.d.ts +22 -0
- package/lib/@openglobus/og.css +1 -1
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Extent.js +2 -2
- package/lib/js/Globe.d.ts +1 -1
- package/lib/js/Object3d.d.ts +16 -1
- package/lib/js/Object3d.js +66 -1
- package/lib/js/astro/jd.js +26 -26
- package/lib/js/camera/Frustum.d.ts +1 -1
- package/lib/js/camera/Frustum.js +3 -2
- package/lib/js/control/DebugInfo.js +19 -18
- package/lib/js/control/Lighting.d.ts +4 -0
- package/lib/js/control/Lighting.js +51 -12
- package/lib/js/control/SimpleSkyBackground.d.ts +2 -0
- package/lib/js/control/SimpleSkyBackground.js +13 -3
- package/lib/js/control/drawing/PolygonDrawingScene.js +2 -2
- package/lib/js/control/timeline/timelineUtils.js +32 -32
- package/lib/js/control/visibleExtent/drawnode.js +1 -1
- package/lib/js/entity/GeoObject.d.ts +20 -6
- package/lib/js/entity/GeoObject.js +44 -4
- package/lib/js/entity/GeoObjectHandler.d.ts +6 -1
- package/lib/js/entity/GeoObjectHandler.js +58 -6
- package/lib/js/entity/Geometry.d.ts +24 -11
- package/lib/js/entity/Geometry.js +17 -9
- package/lib/js/entity/GeometryHandler.js +5 -5
- package/lib/js/entity/Label.d.ts +7 -0
- package/lib/js/entity/Label.js +11 -0
- package/lib/js/entity/Polyline.d.ts +15 -7
- package/lib/js/entity/Polyline.js +54 -6
- package/lib/js/entity/Strip.d.ts +12 -0
- package/lib/js/entity/Strip.js +16 -0
- package/lib/js/entity/StripHandler.js +1 -1
- package/lib/js/entity/index.d.ts +10 -11
- package/lib/js/entity/index.js +10 -11
- package/lib/js/index.d.ts +5 -5
- package/lib/js/index.js +5 -5
- package/lib/js/layer/Bing.d.ts +4 -0
- package/lib/js/layer/Bing.js +40 -0
- package/lib/js/layer/GeoImage.d.ts +1 -1
- package/lib/js/layer/GeoVideo.d.ts +1 -1
- package/lib/js/layer/Layer.d.ts +1 -1
- package/lib/js/layer/Layer.js +2 -2
- package/lib/js/layer/OpenStreetMap.d.ts +4 -0
- package/lib/js/layer/OpenStreetMap.js +19 -0
- package/lib/js/layer/Vector.d.ts +3 -0
- package/lib/js/layer/Vector.js +3 -3
- package/lib/js/layer/index.d.ts +12 -11
- package/lib/js/layer/index.js +12 -11
- package/lib/js/math/Mat4.js +18 -17
- package/lib/js/mercator.js +2 -1
- package/lib/js/quadTree/EPSG4326QuadTreeStrategy.js +4 -5
- package/lib/js/quadTree/EarthQuadTreeStrategy.d.ts +3 -0
- package/lib/js/quadTree/EarthQuadTreeStrategy.js +40 -5
- package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/js/quadTree/EntityCollectionNode.js +13 -14
- package/lib/js/quadTree/MarsQuadTreeStrategy.d.ts +5 -0
- package/lib/js/quadTree/MarsQuadTreeStrategy.js +31 -5
- package/lib/js/quadTree/Node.d.ts +2 -1
- package/lib/js/quadTree/Node.js +38 -28
- package/lib/js/quadTree/QuadTreeStrategy.d.ts +3 -0
- package/lib/js/quadTree/QuadTreeStrategy.js +17 -0
- package/lib/js/quadTree/Wgs84QuadTreeStrategy.js +3 -3
- package/lib/js/renderer/Renderer.js +1 -0
- package/lib/js/scene/Axes.js +4 -4
- package/lib/js/scene/Planet.js +6 -4
- package/lib/js/segment/Segment.d.ts +12 -9
- package/lib/js/segment/Segment.js +47 -24
- package/lib/js/segment/SegmentLonLat.d.ts +1 -5
- package/lib/js/segment/SegmentLonLat.js +8 -100
- package/lib/js/segment/SegmentLonLatWgs84.js +5 -3
- package/lib/js/shaders/billboard.js +4 -4
- package/lib/js/shaders/drawnode.js +16 -19
- package/lib/js/shaders/geoObject.js +10 -11
- package/lib/js/shaders/ray.js +7 -3
- package/lib/js/terrain/BilTerrain.d.ts +1 -1
- package/lib/js/terrain/BilTerrain.js +7 -6
- package/lib/js/terrain/EmptyTerrain.d.ts +7 -0
- package/lib/js/terrain/EmptyTerrain.js +7 -0
- package/lib/js/terrain/GlobusRgbTerrain.d.ts +6 -0
- package/lib/js/terrain/GlobusRgbTerrain.js +25 -0
- package/lib/js/terrain/GlobusTerrain.d.ts +5 -5
- package/lib/js/terrain/GlobusTerrain.js +35 -30
- package/lib/js/terrain/RgbTerrain.d.ts +22 -0
- package/lib/js/terrain/RgbTerrain.js +415 -0
- package/lib/js/terrain/index.d.ts +3 -2
- package/lib/js/terrain/index.js +3 -2
- package/lib/js/ui/Color.d.ts +22 -0
- package/lib/js/ui/Color.js +58 -0
- package/lib/js/utils/GeoImageCreator.js +1 -1
- package/lib/js/utils/NormalMapCreator.js +1 -1
- package/lib/js/utils/VectorTileCreator.js +3 -3
- package/lib/js/utils/objParser.js +3 -3
- package/lib/js/utils/shared.d.ts +3 -9
- package/lib/js/utils/shared.js +24 -9
- package/package.json +26 -18
- package/lib/js/terrain/MapboxTerrain.js +0 -298
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { View } from './View';
|
|
2
|
+
import { stringTemplate } from '../utils/shared';
|
|
3
|
+
const COLOR_EVENTS = ["input"];
|
|
4
|
+
const TEMPLATE = `<div class="og-color">
|
|
5
|
+
<label for="{id}" class="og-color-label">{label}</label>
|
|
6
|
+
<input type="color" name="{id}" value="{value}"/>
|
|
7
|
+
</div>`;
|
|
8
|
+
let __labelCounter__ = 0;
|
|
9
|
+
class Color extends View {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super({
|
|
12
|
+
template: stringTemplate(TEMPLATE, {
|
|
13
|
+
id: `color-${__labelCounter__++}`,
|
|
14
|
+
label: options.label || ""
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
this._onInput = (e) => {
|
|
18
|
+
//@ts-ignore
|
|
19
|
+
this.value = e.target.value;
|
|
20
|
+
};
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
this.events = this.events.registerNames(COLOR_EVENTS);
|
|
23
|
+
this._value = options.value || "blue";
|
|
24
|
+
this.$label = null;
|
|
25
|
+
this.$input = null;
|
|
26
|
+
}
|
|
27
|
+
render(params) {
|
|
28
|
+
super.render(params);
|
|
29
|
+
this.$label = this.select(".og-color-label");
|
|
30
|
+
if (this.$label.innerHTML === "") {
|
|
31
|
+
this.$label.style.display = "none";
|
|
32
|
+
}
|
|
33
|
+
this.$input = this.select("input");
|
|
34
|
+
this._initEvents();
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
set value(val) {
|
|
38
|
+
if (val !== this._value) {
|
|
39
|
+
this._value = val;
|
|
40
|
+
this.$input.value = this._value;
|
|
41
|
+
this.events.dispatch(this.events.input, this._value, this);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get value() {
|
|
45
|
+
return this._value;
|
|
46
|
+
}
|
|
47
|
+
_initEvents() {
|
|
48
|
+
this.$input.addEventListener("input", this._onInput);
|
|
49
|
+
}
|
|
50
|
+
_clearEvents() {
|
|
51
|
+
this.$input.removeEventListener("input", this._onInput);
|
|
52
|
+
}
|
|
53
|
+
remove() {
|
|
54
|
+
this._clearEvents();
|
|
55
|
+
super.remove();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export { Color };
|
|
@@ -145,7 +145,7 @@ export class GeoImageCreator {
|
|
|
145
145
|
v_texCoords = texCoords;
|
|
146
146
|
vec2 highDiff = cornersHigh - extentParamsHigh.xy;
|
|
147
147
|
vec2 lowDiff = cornersLow - extentParamsLow.xy;
|
|
148
|
-
gl_Position = vec4((-1.0 + (highDiff + lowDiff) * extentParamsHigh.zw) * vec2(1.0, -1.0), 0.0, 1.0);
|
|
148
|
+
gl_Position = vec4((-1.0 + (highDiff * step(1.0, length(highDiff)) + lowDiff) * extentParamsHigh.zw) * vec2(1.0, -1.0), 0.0, 1.0);
|
|
149
149
|
}`,
|
|
150
150
|
fragmentShader: `precision highp float;
|
|
151
151
|
uniform sampler2D sourceTexture;
|
|
@@ -108,7 +108,7 @@ export class NormalMapCreator {
|
|
|
108
108
|
this._normalMapVerticesTexture = this._handler.createEmptyTexture_l(this._width, this._height);
|
|
109
109
|
//create vertices hasharray for different grid size segments from 2^4(16) to 2^7(128)
|
|
110
110
|
for (let p = this._minTabelSize; p <= this._maxTableSize; p++) {
|
|
111
|
-
const gs = Math.pow(2, p);
|
|
111
|
+
const gs = (1 << p); //Math.pow(2, p);
|
|
112
112
|
const gs2 = gs / 2;
|
|
113
113
|
let vertices = new Float32Array((gs + 1) * (gs + 1) * 2);
|
|
114
114
|
for (let i = 0; i <= gs; i++) {
|
|
@@ -55,8 +55,8 @@ export class VectorTileCreator {
|
|
|
55
55
|
|
|
56
56
|
vec2 proj(vec2 coordHigh, vec2 coordLow) {
|
|
57
57
|
vec2 highDiff = coordHigh - extentParamsHigh.xy;
|
|
58
|
-
vec2 lowDiff = coordLow - extentParamsLow.xy;
|
|
59
|
-
return vec2(-1.0 + (highDiff + lowDiff) * extentParamsHigh.zw) * vec2(1.0, -1.0);
|
|
58
|
+
vec2 lowDiff = coordLow - extentParamsLow.xy;
|
|
59
|
+
return vec2(-1.0 + (highDiff * step(1.0, length(highDiff)) + lowDiff) * extentParamsHigh.zw) * vec2(1.0, -1.0);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
void main(){
|
|
@@ -149,7 +149,7 @@ export class VectorTileCreator {
|
|
|
149
149
|
vec2 proj(vec2 coordHigh, vec2 coordLow) {
|
|
150
150
|
vec2 highDiff = coordHigh - extentParamsHigh.xy;
|
|
151
151
|
vec2 lowDiff = coordLow - extentParamsLow.xy;
|
|
152
|
-
return vec2(-1.0 + (highDiff + lowDiff) * extentParamsHigh.zw) * vec2(1.0, -1.0);
|
|
152
|
+
return vec2(-1.0 + (highDiff * step(1.0, length(highDiff)) + lowDiff) * extentParamsHigh.zw) * vec2(1.0, -1.0);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
void main() {
|
|
@@ -10,8 +10,8 @@ export function objParser(text) {
|
|
|
10
10
|
];
|
|
11
11
|
// same order as `f` indices
|
|
12
12
|
let vertexData = [
|
|
13
|
-
[],
|
|
14
|
-
[],
|
|
13
|
+
[], // positions
|
|
14
|
+
[], // texcoords
|
|
15
15
|
[], // normals
|
|
16
16
|
];
|
|
17
17
|
const materialLibs = [];
|
|
@@ -82,7 +82,7 @@ export function objParser(text) {
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
s: () => {
|
|
85
|
-
},
|
|
85
|
+
}, // smoothing group
|
|
86
86
|
mtllib(parts, unparsedArgs) {
|
|
87
87
|
// the spec says there can be multiple filenames here
|
|
88
88
|
// but many exist with spaces in a single filename
|
package/lib/js/utils/shared.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare function isUndef(obj?: any): boolean;
|
|
|
19
19
|
export declare function isUndefExt(obj: any, defVal: any): any;
|
|
20
20
|
export declare function stamp(obj: any): number;
|
|
21
21
|
export declare function isString(s: any): boolean;
|
|
22
|
+
export declare function rgbToStringHTML(rgb: NumberArray3 | Vec3): string;
|
|
22
23
|
/**
|
|
23
24
|
* Convert html color string to the RGBA number vector.
|
|
24
25
|
* @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
|
|
@@ -52,8 +53,9 @@ export declare function stringTemplate(template: string, params?: any): string;
|
|
|
52
53
|
export declare function getHTML(template: string, params?: any): string;
|
|
53
54
|
export declare function parseHTML(htmlStr: string): HTMLElement[];
|
|
54
55
|
export declare function print2d(id: string, text: string, x: number, y: number): void;
|
|
56
|
+
export declare function isNumber(value: any): boolean;
|
|
55
57
|
export declare function defaultString(str?: string, def?: string): string;
|
|
56
|
-
export declare function createVector3(v?: Vec3 | Vec2 | NumberArray3 | NumberArray2 | null, def?: Vec3): Vec3;
|
|
58
|
+
export declare function createVector3(v?: number | Vec3 | Vec2 | NumberArray3 | NumberArray2 | null, def?: Vec3): Vec3;
|
|
57
59
|
export declare function createVector4(v?: Vec4 | NumberArray4 | null, def?: Vec4): Vec4;
|
|
58
60
|
export declare function createColorRGBA(c?: string | NumberArray4 | Vec4 | null, def?: Vec4): Vec4;
|
|
59
61
|
export declare function createColorRGB(c?: string | NumberArray3 | Vec3 | null, def?: Vec3): Vec3;
|
|
@@ -239,14 +241,6 @@ export declare function getMatrixSubArray64(sourceArr: TypedArray | number[], gr
|
|
|
239
241
|
export declare function getMatrixSubArray32(sourceArr: TypedArray | number[], gridSize: number, i0: number, j0: number, size: number): Float32Array;
|
|
240
242
|
/**
|
|
241
243
|
* Returns two float32 triangle coordinate arrays from inside of the source triangle array.
|
|
242
|
-
* @static
|
|
243
|
-
* @param {Array.<number>} sourceArr - Source array
|
|
244
|
-
* @param {number} gridSize - Source array square matrix size
|
|
245
|
-
* @param {number} i0 - First row index source array matrix
|
|
246
|
-
* @param {number} j0 - First column index
|
|
247
|
-
* @param {number} size - Square matrix result size.
|
|
248
|
-
* @param {object} outBounds - Output bounds.
|
|
249
|
-
* @return{Array.<number>} Triangle coordinates array from the source array.
|
|
250
244
|
* @TODO: optimization
|
|
251
245
|
*/
|
|
252
246
|
export declare function getMatrixSubArrayBoundsExt(sourceArr: TypedArray | number[], sourceArrHigh: TypedArray | number[], sourceArrLow: TypedArray | number[], noDataVertices: TypedArray | number[] | undefined, gridSize: number, i0: number, j0: number, size: number, outArr: TypedArray | number[], outArrHigh: TypedArray | number[], outArrLow: TypedArray | number[], outBounds: any, outNoDataVertices: TypedArray | number[]): void;
|
package/lib/js/utils/shared.js
CHANGED
|
@@ -36,6 +36,23 @@ export function stamp(obj) {
|
|
|
36
36
|
export function isString(s) {
|
|
37
37
|
return typeof s === "string" || s instanceof String;
|
|
38
38
|
}
|
|
39
|
+
function d2h(val) {
|
|
40
|
+
return val.toString(16).padStart(2, '0');
|
|
41
|
+
}
|
|
42
|
+
export function rgbToStringHTML(rgb) {
|
|
43
|
+
let r, g, b;
|
|
44
|
+
if (rgb instanceof Array) {
|
|
45
|
+
r = d2h(rgb[0]);
|
|
46
|
+
g = d2h(rgb[1]);
|
|
47
|
+
b = d2h(rgb[2]);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
r = d2h(rgb.x);
|
|
51
|
+
g = d2h(rgb.y);
|
|
52
|
+
b = d2h(rgb.z);
|
|
53
|
+
}
|
|
54
|
+
return `#${r}${g}${b}`;
|
|
55
|
+
}
|
|
39
56
|
/**
|
|
40
57
|
* Convert html color string to the RGBA number vector.
|
|
41
58
|
* @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
|
|
@@ -145,12 +162,18 @@ export function print2d(id, text, x, y) {
|
|
|
145
162
|
el.style.left = `${x}px`;
|
|
146
163
|
el.style.top = `${y}px`;
|
|
147
164
|
}
|
|
165
|
+
export function isNumber(value) {
|
|
166
|
+
return typeof value === 'number';
|
|
167
|
+
}
|
|
148
168
|
export function defaultString(str, def = "") {
|
|
149
169
|
return str ? str.trim() : def;
|
|
150
170
|
}
|
|
151
171
|
export function createVector3(v, def) {
|
|
152
172
|
if (v) {
|
|
153
|
-
if (v
|
|
173
|
+
if (isNumber(v)) {
|
|
174
|
+
return new Vec3(v, v, v);
|
|
175
|
+
}
|
|
176
|
+
else if (v instanceof Vec3) {
|
|
154
177
|
return v.clone();
|
|
155
178
|
}
|
|
156
179
|
else if (v instanceof Array) {
|
|
@@ -797,14 +820,6 @@ export function getMatrixSubArray32(sourceArr, gridSize, i0, j0, size) {
|
|
|
797
820
|
}
|
|
798
821
|
/**
|
|
799
822
|
* Returns two float32 triangle coordinate arrays from inside of the source triangle array.
|
|
800
|
-
* @static
|
|
801
|
-
* @param {Array.<number>} sourceArr - Source array
|
|
802
|
-
* @param {number} gridSize - Source array square matrix size
|
|
803
|
-
* @param {number} i0 - First row index source array matrix
|
|
804
|
-
* @param {number} j0 - First column index
|
|
805
|
-
* @param {number} size - Square matrix result size.
|
|
806
|
-
* @param {object} outBounds - Output bounds.
|
|
807
|
-
* @return{Array.<number>} Triangle coordinates array from the source array.
|
|
808
823
|
* @TODO: optimization
|
|
809
824
|
*/
|
|
810
825
|
export function getMatrixSubArrayBoundsExt(sourceArr, sourceArrHigh, sourceArrLow, noDataVertices, gridSize, i0, j0, size, outArr, outArrHigh, outArrLow, outBounds, outNoDataVertices) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "[openglobus](https://www.openglobus.org/) is a javascript/typescript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers, and 3D objects. It uses the WebGL technology, open source, and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|
|
7
7
|
},
|
|
8
8
|
"main": "./lib/js/index.js",
|
|
9
|
+
"types": "./lib/js/index.d.ts",
|
|
9
10
|
"style": "./css/og.css",
|
|
10
11
|
"scripts": {
|
|
11
12
|
"docs": "jsdoc -r ./src/ -c ./jsdoc.conf.json -d ./docs",
|
|
13
|
+
"serve_docs": "cd docs; ws -p 8088",
|
|
12
14
|
"serve": "ws -p 8080",
|
|
13
15
|
"build": "rollup -c --bundleConfigAsCjs",
|
|
14
16
|
"clean": "rm -rf ./lib ./docs",
|
|
@@ -32,28 +34,34 @@
|
|
|
32
34
|
},
|
|
33
35
|
"homepage": "https://www.openglobus.org",
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"@babel/
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
37
|
+
"@babel/cli": "^7.24.7",
|
|
38
|
+
"@babel/core": "^7.24.7",
|
|
39
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
40
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
41
|
+
"@babel/preset-env": "^7.24.7",
|
|
42
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
43
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
44
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
45
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
46
|
+
"@types/jest": "^29.5.12",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^7.10.0",
|
|
48
|
+
"@typescript-eslint/parser": "^7.10.0",
|
|
49
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
50
|
+
"eslint": "^8.57.0",
|
|
44
51
|
"jest": "^29.7.0",
|
|
45
52
|
"jest-canvas-mock": "^2.5.2",
|
|
46
53
|
"jest-environment-jsdom": "^29.7.0",
|
|
47
|
-
"jsdoc": "^4.0.
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
54
|
+
"jsdoc": "^4.0.3",
|
|
55
|
+
"jsdoc-babel": "^0.5.0",
|
|
56
|
+
"lint-staged": "^15.2.4",
|
|
57
|
+
"local-web-server": "^5.3.3",
|
|
58
|
+
"postcss": "^8.4.38",
|
|
59
|
+
"prettier": "^3.2.5",
|
|
60
|
+
"rollup": "^4.18.0",
|
|
53
61
|
"rollup-plugin-copy": "^3.5.0",
|
|
54
62
|
"rollup-plugin-postcss": "^4.0.2",
|
|
55
|
-
"ts-jest": "^29.1.
|
|
56
|
-
"typescript": "^5.
|
|
63
|
+
"ts-jest": "^29.1.3",
|
|
64
|
+
"typescript": "^5.4.5"
|
|
57
65
|
},
|
|
58
66
|
"lint-staged": {
|
|
59
67
|
"*.{js,ts}": [
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import * as mercator from "../mercator";
|
|
2
|
-
import { getTileExtent } from "../mercator";
|
|
3
|
-
import { GlobusTerrain } from "./GlobusTerrain";
|
|
4
|
-
import { isPowerOfTwo } from "../math";
|
|
5
|
-
import { Layer } from "../layer/Layer";
|
|
6
|
-
/**
|
|
7
|
-
* The key doesn't work; just an example!
|
|
8
|
-
*/
|
|
9
|
-
const KEY = "pk.eyJ1IjoiZm94bXVsZGVyODMiLCJhIjoiY2pqYmR3dG5oM2Z1bzNrczJqYm5pODhuNSJ9.Y4DRmEPhb-XSlCR9CAXACQ";
|
|
10
|
-
const rgb2Height = (r, g, b) => {
|
|
11
|
-
return -10000 + 0.1 * (r * 256 * 256 + g * 256 + b);
|
|
12
|
-
};
|
|
13
|
-
class MapboxTerrain extends GlobusTerrain {
|
|
14
|
-
constructor(name, options = {}) {
|
|
15
|
-
super(name || "MapboxTerrain", {
|
|
16
|
-
equalizeVertices: options.equalizeVertices != undefined ? options.equalizeVertices : true,
|
|
17
|
-
maxZoom: options.maxZoom || 17,
|
|
18
|
-
noDataValues: options.noDataValues || [-65537, -10000],
|
|
19
|
-
plainGridSize: options.plainGridSize || 128,
|
|
20
|
-
url: options.url != undefined
|
|
21
|
-
? options.url
|
|
22
|
-
: `//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${options.key || KEY}`,
|
|
23
|
-
gridSizeByZoom: options.gridSizeByZoom || [
|
|
24
|
-
64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
|
|
25
|
-
],
|
|
26
|
-
...options
|
|
27
|
-
});
|
|
28
|
-
this.equalizeNormals = options.equalizeNormals || false;
|
|
29
|
-
this._dataType = "imageBitmap";
|
|
30
|
-
this._imageSize = options.imageSize || 256;
|
|
31
|
-
this._ctx = this._createTemporalCanvas(this._imageSize);
|
|
32
|
-
this._imageDataCache = {};
|
|
33
|
-
}
|
|
34
|
-
isBlur(segment) {
|
|
35
|
-
return segment.tileZoom >= 16;
|
|
36
|
-
}
|
|
37
|
-
_createTemporalCanvas(size) {
|
|
38
|
-
let canvas = document.createElement("canvas");
|
|
39
|
-
canvas.width = size;
|
|
40
|
-
canvas.height = size;
|
|
41
|
-
return canvas.getContext("2d", {
|
|
42
|
-
willReadFrequently: true
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
_createHeights(data, tileIndex, tileX, tileY, tileZoom, extent, preventChildren) {
|
|
46
|
-
this._ctx.clearRect(0, 0, this._imageSize, this._imageSize);
|
|
47
|
-
this._ctx.drawImage(data, 0, 0);
|
|
48
|
-
let rgbaData = this._ctx.getImageData(0, 0, this._imageSize, this._imageSize).data;
|
|
49
|
-
const SIZE = data.width;
|
|
50
|
-
//
|
|
51
|
-
//Non-power of two images
|
|
52
|
-
//
|
|
53
|
-
if (!isPowerOfTwo(this._imageSize) && SIZE === this._imageSize) {
|
|
54
|
-
let outCurrenElevations = new Float32Array(SIZE * SIZE);
|
|
55
|
-
extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations, this._heightFactor);
|
|
56
|
-
return outCurrenElevations;
|
|
57
|
-
}
|
|
58
|
-
if (this._imageSize === this.plainGridSize) {
|
|
59
|
-
let elevationsSize = (this.plainGridSize + 1) * (this.plainGridSize + 1);
|
|
60
|
-
let outCurrenElevations = new Float32Array(elevationsSize);
|
|
61
|
-
for (let k = 0, len = this._imageSize * this._imageSize; k < len; k++) {
|
|
62
|
-
let j = k % this._imageSize, i = Math.floor(k / this._imageSize);
|
|
63
|
-
let fromInd4 = k * 4;
|
|
64
|
-
let h = this._heightFactor * rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
|
|
65
|
-
outCurrenElevations[i * (this._imageSize + 1) + j] = h;
|
|
66
|
-
}
|
|
67
|
-
for (let i = 0, len = this._imageSize; i < len; i++) {
|
|
68
|
-
let j = this._imageSize - 1;
|
|
69
|
-
let fromInd4 = (i * this._imageSize + j) * 4;
|
|
70
|
-
let h = this._heightFactor * rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
|
|
71
|
-
outCurrenElevations[i * (this._imageSize + 1) + this._imageSize] = h;
|
|
72
|
-
}
|
|
73
|
-
for (let j = 0, len = this._imageSize; j < len; j++) {
|
|
74
|
-
let i = this._imageSize - 1;
|
|
75
|
-
let fromInd4 = (i * this._imageSize + j) * 4;
|
|
76
|
-
let h = this._heightFactor * rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
|
|
77
|
-
outCurrenElevations[this._imageSize * (this._imageSize + 1) + j] = h;
|
|
78
|
-
}
|
|
79
|
-
let h = this._heightFactor * rgb2Height(rgbaData[rgbaData.length - 4], rgbaData[rgbaData.length - 3], rgbaData[rgbaData.length - 2]);
|
|
80
|
-
outCurrenElevations[outCurrenElevations.length - 1] = h;
|
|
81
|
-
return outCurrenElevations;
|
|
82
|
-
}
|
|
83
|
-
//
|
|
84
|
-
// Power of two images
|
|
85
|
-
//
|
|
86
|
-
let elevationsSize = (this.plainGridSize + 1) * (this.plainGridSize + 1);
|
|
87
|
-
let d = SIZE / this.plainGridSize;
|
|
88
|
-
let outCurrenElevations = new Float32Array(elevationsSize);
|
|
89
|
-
let outChildrenElevations = new Array(d);
|
|
90
|
-
for (let i = 0; i < d; i++) {
|
|
91
|
-
outChildrenElevations[i] = [];
|
|
92
|
-
for (let j = 0; j < d; j++) {
|
|
93
|
-
outChildrenElevations[i][j] = new Float32Array(elevationsSize);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (preventChildren) {
|
|
97
|
-
extractElevationTilesMapboxNoChildren(rgbaData, this._heightFactor, this.noDataValues, outCurrenElevations);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
extractElevationTilesMapbox(rgbaData, this._heightFactor, this.noDataValues, outCurrenElevations, outChildrenElevations);
|
|
101
|
-
}
|
|
102
|
-
this._elevationCache[tileIndex] = {
|
|
103
|
-
heights: outCurrenElevations,
|
|
104
|
-
extent: extent //segment.getExtent()
|
|
105
|
-
};
|
|
106
|
-
if (!preventChildren) {
|
|
107
|
-
for (let i = 0; i < d; i++) {
|
|
108
|
-
for (let j = 0; j < d; j++) {
|
|
109
|
-
let x = tileX * 2 + j, y = tileY * 2 + i, z = tileZoom + 1;
|
|
110
|
-
let tileIndex = Layer.getTileIndex(x, y, z);
|
|
111
|
-
this._elevationCache[tileIndex] = {
|
|
112
|
-
heights: outChildrenElevations[i][j],
|
|
113
|
-
extent: getTileExtent(x, y, z)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return outCurrenElevations;
|
|
119
|
-
}
|
|
120
|
-
getHeightAsync(lonLat, callback, zoom) {
|
|
121
|
-
if (!lonLat || lonLat.lat > mercator.MAX_LAT || lonLat.lat < mercator.MIN_LAT) {
|
|
122
|
-
callback(0);
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
let z = zoom || this.maxZoom, size = mercator.POLE2 / Math.pow(2, z), merc = mercator.forward(lonLat), x = Math.floor((mercator.POLE + merc.lon) / size), y = Math.floor((mercator.POLE - merc.lat) / size);
|
|
126
|
-
let tileIndex = Layer.getTileIndex(x, y, z), extent = mercator.getTileExtent(x, y, z);
|
|
127
|
-
let sizeImgW = extent.getWidth() / (this._imageSize - 1), sizeImgH = extent.getHeight() / (this._imageSize - 1);
|
|
128
|
-
let i = this._imageSize - Math.ceil((merc.lat - extent.southWest.lat) / sizeImgH) - 1, j = Math.floor((merc.lon - extent.southWest.lon) / sizeImgW);
|
|
129
|
-
let index = (i * this._imageSize + j) * 4;
|
|
130
|
-
if (this._imageDataCache[tileIndex]) {
|
|
131
|
-
let data = this._imageDataCache[tileIndex];
|
|
132
|
-
callback(this._heightFactor * rgb2Height(data[index], data[index + 1], data[index + 2]));
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
if (!this._fetchCache[tileIndex]) {
|
|
136
|
-
let url = this._buildURL(x, y, z);
|
|
137
|
-
this._fetchCache[tileIndex] = this._loader.fetch({
|
|
138
|
-
src: url,
|
|
139
|
-
type: this._dataType
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
this._fetchCache[tileIndex].then((response) => {
|
|
143
|
-
if (response.status === "ready") {
|
|
144
|
-
this._ctx.clearRect(0, 0, this._imageSize, this._imageSize);
|
|
145
|
-
this._ctx.drawImage(response.data, 0, 0);
|
|
146
|
-
let data = this._ctx.getImageData(0, 0, 256, 256).data;
|
|
147
|
-
this._imageDataCache[tileIndex] = data;
|
|
148
|
-
callback(this._heightFactor * rgb2Height(data[index], data[index + 1], data[index + 2]));
|
|
149
|
-
}
|
|
150
|
-
else if (response.status === "error") {
|
|
151
|
-
callback(0);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
//@ts-ignore
|
|
155
|
-
this._fetchCache[tileIndex] = null;
|
|
156
|
-
delete this._fetchCache[tileIndex];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations, heightFactor = 1) {
|
|
163
|
-
for (let i = 0, len = outCurrenElevations.length; i < len; i++) {
|
|
164
|
-
let i4 = i * 4;
|
|
165
|
-
outCurrenElevations[i] = heightFactor * rgb2Height(rgbaData[i4], rgbaData[i4 + 1], rgbaData[i4 + 2]);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function extractElevationTilesMapbox(rgbaData, heightFactor, noDataValues, outCurrenElevations, outChildrenElevations) {
|
|
169
|
-
let destSize = Math.sqrt(outCurrenElevations.length) - 1;
|
|
170
|
-
let destSizeOne = destSize + 1;
|
|
171
|
-
let sourceSize = Math.sqrt(rgbaData.length / 4);
|
|
172
|
-
let dt = sourceSize / destSize;
|
|
173
|
-
let rightHeight = 0, bottomHeight = 0, sourceSize4 = 0;
|
|
174
|
-
for (let k = 0, currIndex = 0, sourceDataLength = rgbaData.length / 4; k < sourceDataLength; k++) {
|
|
175
|
-
let k4 = k * 4;
|
|
176
|
-
let height = heightFactor * rgb2Height(rgbaData[k4], rgbaData[k4 + 1], rgbaData[k4 + 2]);
|
|
177
|
-
let isNoDataCurrent = MapboxTerrain.checkNoDataValue(noDataValues, height), isNoDataRight = false, isNoDataBottom = false;
|
|
178
|
-
let i = Math.floor(k / sourceSize), j = k % sourceSize;
|
|
179
|
-
let tileX = Math.floor(j / destSize), tileY = Math.floor(i / destSize);
|
|
180
|
-
let destArr = outChildrenElevations[tileY][tileX];
|
|
181
|
-
let ii = i % destSize, jj = j % destSize;
|
|
182
|
-
let destIndex = (ii + tileY) * destSizeOne + jj + tileX;
|
|
183
|
-
destArr[destIndex] = height;
|
|
184
|
-
if ((i + tileY) % dt === 0 && (j + tileX) % dt === 0) {
|
|
185
|
-
outCurrenElevations[currIndex++] = height;
|
|
186
|
-
}
|
|
187
|
-
if ((j + 1) % destSize === 0 && j !== sourceSize - 1) {
|
|
188
|
-
//current tile
|
|
189
|
-
rightHeight = heightFactor * rgb2Height(rgbaData[k4 + 4], rgbaData[k4 + 5], rgbaData[k4 + 6]);
|
|
190
|
-
isNoDataRight = MapboxTerrain.checkNoDataValue(noDataValues, rightHeight);
|
|
191
|
-
let middleHeight = height;
|
|
192
|
-
if (!(isNoDataCurrent || isNoDataRight)) {
|
|
193
|
-
middleHeight = (height + rightHeight) * 0.5;
|
|
194
|
-
}
|
|
195
|
-
destIndex = (ii + tileY) * destSizeOne + jj + 1;
|
|
196
|
-
destArr[destIndex] = middleHeight;
|
|
197
|
-
if ((i + tileY) % dt === 0) {
|
|
198
|
-
outCurrenElevations[currIndex++] = middleHeight;
|
|
199
|
-
}
|
|
200
|
-
//next right tile
|
|
201
|
-
let rightindex = (ii + tileY) * destSizeOne + ((jj + 1) % destSize);
|
|
202
|
-
outChildrenElevations[tileY][tileX + 1][rightindex] = middleHeight;
|
|
203
|
-
}
|
|
204
|
-
if ((i + 1) % destSize === 0 && i !== sourceSize - 1) {
|
|
205
|
-
//current tile
|
|
206
|
-
sourceSize4 = sourceSize * 4;
|
|
207
|
-
bottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4], rgbaData[k4 + sourceSize4 + 1], rgbaData[k4 + sourceSize4 + 2]);
|
|
208
|
-
isNoDataBottom = MapboxTerrain.checkNoDataValue(noDataValues, bottomHeight);
|
|
209
|
-
let middleHeight = (height + bottomHeight) * 0.5;
|
|
210
|
-
if (!(isNoDataCurrent || isNoDataBottom)) {
|
|
211
|
-
middleHeight = (height + bottomHeight) * 0.5;
|
|
212
|
-
}
|
|
213
|
-
destIndex = (ii + 1) * destSizeOne + jj + tileX;
|
|
214
|
-
destArr[destIndex] = middleHeight;
|
|
215
|
-
if ((j + tileX) % dt === 0) {
|
|
216
|
-
outCurrenElevations[currIndex++] = middleHeight;
|
|
217
|
-
}
|
|
218
|
-
//next bottom tile
|
|
219
|
-
let bottomindex = ((ii + 1) % destSize) * destSizeOne + jj + tileX;
|
|
220
|
-
outChildrenElevations[tileY + 1][tileX][bottomindex] = middleHeight;
|
|
221
|
-
}
|
|
222
|
-
if ((j + 1) % destSize === 0 && j !== sourceSize - 1 &&
|
|
223
|
-
(i + 1) % destSize === 0 && i !== sourceSize - 1) {
|
|
224
|
-
//current tile
|
|
225
|
-
let rightBottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4 + 4], rgbaData[k4 + sourceSize4 + 5], rgbaData[k4 + sourceSize4 + 6]);
|
|
226
|
-
let isNoDataRightBottom = MapboxTerrain.checkNoDataValue(noDataValues, rightBottomHeight);
|
|
227
|
-
let middleHeight = height;
|
|
228
|
-
if (!(isNoDataCurrent || isNoDataRight || isNoDataBottom || isNoDataRightBottom)) {
|
|
229
|
-
middleHeight = (height + rightHeight + bottomHeight + rightBottomHeight) * 0.25;
|
|
230
|
-
}
|
|
231
|
-
destIndex = (ii + 1) * destSizeOne + (jj + 1);
|
|
232
|
-
destArr[destIndex] = middleHeight;
|
|
233
|
-
outCurrenElevations[currIndex++] = middleHeight;
|
|
234
|
-
//next right tile
|
|
235
|
-
let rightindex = (ii + 1) * destSizeOne;
|
|
236
|
-
outChildrenElevations[tileY][tileX + 1][rightindex] = middleHeight;
|
|
237
|
-
//next bottom tile
|
|
238
|
-
let bottomindex = destSize;
|
|
239
|
-
outChildrenElevations[tileY + 1][tileX][bottomindex] = middleHeight;
|
|
240
|
-
//next right bottom tile
|
|
241
|
-
let rightBottomindex = 0;
|
|
242
|
-
outChildrenElevations[tileY + 1][tileX + 1][rightBottomindex] = middleHeight;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function extractElevationTilesMapboxNoChildren(rgbaData, heightFactor, noDataValues, outCurrenElevations) {
|
|
247
|
-
let destSize = Math.sqrt(outCurrenElevations.length) - 1;
|
|
248
|
-
let sourceSize = Math.sqrt(rgbaData.length / 4);
|
|
249
|
-
let dt = sourceSize / destSize;
|
|
250
|
-
let rightHeight = 0, bottomHeight = 0, sourceSize4 = 0;
|
|
251
|
-
for (let k = 0, currIndex = 0, sourceDataLength = rgbaData.length / 4; k < sourceDataLength; k++) {
|
|
252
|
-
let k4 = k * 4;
|
|
253
|
-
let height = heightFactor * rgb2Height(rgbaData[k4], rgbaData[k4 + 1], rgbaData[k4 + 2]);
|
|
254
|
-
let isNoDataCurrent = MapboxTerrain.checkNoDataValue(noDataValues, height), isNoDataRight = false, isNoDataBottom = false;
|
|
255
|
-
let i = Math.floor(k / sourceSize), j = k % sourceSize;
|
|
256
|
-
let tileX = Math.floor(j / destSize), tileY = Math.floor(i / destSize);
|
|
257
|
-
if ((i + tileY) % dt === 0 && (j + tileX) % dt === 0) {
|
|
258
|
-
outCurrenElevations[currIndex++] = height;
|
|
259
|
-
}
|
|
260
|
-
if ((j + 1) % destSize === 0 && j !== sourceSize - 1) {
|
|
261
|
-
//current tile
|
|
262
|
-
rightHeight = heightFactor * rgb2Height(rgbaData[k4 + 4], rgbaData[k4 + 5], rgbaData[k4 + 6]);
|
|
263
|
-
isNoDataRight = MapboxTerrain.checkNoDataValue(noDataValues, rightHeight);
|
|
264
|
-
let middleHeight = height;
|
|
265
|
-
if (!(isNoDataCurrent || isNoDataRight)) {
|
|
266
|
-
middleHeight = (height + rightHeight) * 0.5;
|
|
267
|
-
}
|
|
268
|
-
if ((i + tileY) % dt === 0) {
|
|
269
|
-
outCurrenElevations[currIndex++] = middleHeight;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if ((i + 1) % destSize === 0 && i !== sourceSize - 1) {
|
|
273
|
-
//current tile
|
|
274
|
-
sourceSize4 = sourceSize * 4;
|
|
275
|
-
bottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4], rgbaData[k4 + sourceSize4 + 1], rgbaData[k4 + sourceSize4 + 2]);
|
|
276
|
-
isNoDataBottom = MapboxTerrain.checkNoDataValue(noDataValues, bottomHeight);
|
|
277
|
-
let middleHeight = (height + bottomHeight) * 0.5;
|
|
278
|
-
if (!(isNoDataCurrent || isNoDataBottom)) {
|
|
279
|
-
middleHeight = (height + bottomHeight) * 0.5;
|
|
280
|
-
}
|
|
281
|
-
if ((j + tileX) % dt === 0) {
|
|
282
|
-
outCurrenElevations[currIndex++] = middleHeight;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if ((j + 1) % destSize === 0 && j !== sourceSize - 1 &&
|
|
286
|
-
(i + 1) % destSize === 0 && i !== sourceSize - 1) {
|
|
287
|
-
//current tile
|
|
288
|
-
let rightBottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4 + 4], rgbaData[k4 + sourceSize4 + 5], rgbaData[k4 + sourceSize4 + 6]);
|
|
289
|
-
let isNoDataRightBottom = MapboxTerrain.checkNoDataValue(noDataValues, rightBottomHeight);
|
|
290
|
-
let middleHeight = height;
|
|
291
|
-
if (!(isNoDataCurrent || isNoDataRight || isNoDataBottom || isNoDataRightBottom)) {
|
|
292
|
-
middleHeight = (height + rightHeight + bottomHeight + rightBottomHeight) * 0.25;
|
|
293
|
-
}
|
|
294
|
-
outCurrenElevations[currIndex++] = middleHeight;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
export { MapboxTerrain };
|