qwc2 2025.10.9 → 2025.10.14
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/actions/display.js +30 -1
- package/actions/editing.js +22 -1
- package/actions/layerinfo.js +13 -1
- package/actions/layers.js +213 -3
- package/actions/localConfig.js +58 -1
- package/actions/locale.js +21 -1
- package/actions/locate.js +26 -1
- package/actions/logging.js +10 -1
- package/actions/map.js +105 -2
- package/actions/measurement.js +12 -1
- package/actions/processNotifications.js +37 -1
- package/actions/redlining.js +18 -1
- package/actions/redliningPick.js +12 -1
- package/actions/search.js +12 -1
- package/actions/serviceinfo.js +12 -1
- package/actions/task.js +55 -3
- package/actions/theme.js +339 -19
- package/actions/windows.js +164 -5
- package/components/AppMenu.js +435 -3
- package/components/AttributeForm.js +928 -32
- package/components/AttributeTableWidget.js +1105 -13
- package/components/AutoEditForm.js +189 -3
- package/components/CoordinateDisplayer.js +78 -2
- package/components/EditComboField.js +190 -6
- package/components/EditUploadField.js +315 -3
- package/components/ExportSelection.js +203 -2
- package/components/FullscreenSwitcher.js +90 -3
- package/components/Icon.js +81 -2
- package/components/IdentifyViewer.js +1161 -6
- package/components/ImportLayer.js +718 -20
- package/components/LayerInfoWindow.js +145 -2
- package/components/LinkFeatureForm.js +246 -5
- package/components/MapButton.js +88 -2
- package/components/MapSelection.js +287 -8
- package/components/MessageBar.js +68 -2
- package/components/NumericInputWindow.js +359 -2
- package/components/PickFeature.js +266 -2
- package/components/PluginsContainer.js +227 -8
- package/components/PrintSelection.js +620 -49
- package/components/ProcessNotifications.js +104 -2
- package/components/QtDesignerForm.js +1137 -18
- package/components/ResizeableWindow.js +591 -8
- package/components/SearchBox.js +1307 -20
- package/components/ServiceInfoWindow.js +107 -2
- package/components/SideBar.js +204 -4
- package/components/StandardApp.js +381 -20
- package/components/Swipeable.js +15 -1
- package/components/TaskBar.js +85 -2
- package/components/ThemeLayersListWindow.js +216 -4
- package/components/ThemeList.js +381 -7
- package/components/Toolbar.js +106 -2
- package/components/WindowManager.js +178 -2
- package/components/map/OlLayer.js +257 -6
- package/components/map/OlMap.js +405 -5
- package/components/map/layers/BingLayer.js +31 -2
- package/components/map/layers/GoogleLayer.js +222 -19
- package/components/map/layers/GraticuleLayer.js +21 -1
- package/components/map/layers/ImageLayer.js +15 -1
- package/components/map/layers/MVTLayer.js +52 -2
- package/components/map/layers/OSMLayer.js +24 -2
- package/components/map/layers/OverlayLayer.js +55 -3
- package/components/map/layers/VectorLayer.js +173 -8
- package/components/map/layers/WFSLayer.js +220 -6
- package/components/map/layers/WMSLayer.js +180 -6
- package/components/map/layers/WMTSLayer.js +67 -3
- package/components/map/layers/XYZLayer.js +24 -2
- package/components/map/layers/index.js +28 -1
- package/components/map3d/EditDataset3D.js +190 -3
- package/components/map3d/HeightProfile3D.js +402 -3
- package/components/map3d/ImportObjects3D.js +162 -2
- package/components/map3d/Map3D.js +1304 -38
- package/components/map3d/MapControls3D.js +392 -7
- package/components/map3d/SearchField3D.js +183 -11
- package/components/map3d/View3DSwitcher.js +98 -2
- package/components/map3d/drawtool/CreateTool3D.js +174 -4
- package/components/map3d/drawtool/EditTool3D.js +590 -6
- package/components/map3d/drawtool/NumericInput3D.js +336 -4
- package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
- package/components/map3d/layers/VectorLayer3D.js +53 -2
- package/components/map3d/layers/WFSLayer3D.js +109 -3
- package/components/map3d/layers/WMSLayer3D.js +70 -2
- package/components/map3d/layers/WMTSLayer3D.js +27 -3
- package/components/map3d/layers/index.js +14 -1
- package/components/map3d/utils/FirstPersonControls3D.js +423 -16
- package/components/map3d/utils/MiscUtils3D.js +221 -13
- package/components/map3d/utils/OrbitControls3D.js +176 -5
- package/components/map3d/utils/Tiles3DStyle.js +238 -9
- package/components/share/ShareLink.js +54 -2
- package/components/share/ShareQRCode.js +62 -2
- package/components/share/ShareSocials.js +125 -3
- package/components/timeline/FixedTimeline.js +236 -5
- package/components/timeline/InfiniteTimeline.js +347 -8
- package/components/timeline/TimelineFeaturesSlider.js +439 -5
- package/components/widgets/AccordeonWidget.js +96 -2
- package/components/widgets/ButtonBar.js +124 -2
- package/components/widgets/ColorButton.js +201 -3
- package/components/widgets/ComboBox.js +166 -2
- package/components/widgets/CopyButton.js +110 -2
- package/components/widgets/DateTimeInput.js +100 -3
- package/components/widgets/EditableSelect.js +230 -3
- package/components/widgets/FileSelector.js +128 -4
- package/components/widgets/Input.js +124 -2
- package/components/widgets/InputContainer.js +96 -2
- package/components/widgets/LayerCatalogWidget.js +219 -3
- package/components/widgets/MenuButton.js +157 -1
- package/components/widgets/ModalDialog.js +64 -2
- package/components/widgets/NavBar.js +119 -2
- package/components/widgets/NumberInput.js +226 -4
- package/components/widgets/PopupMenu.js +72 -1
- package/components/widgets/Primitives.js +6 -1
- package/components/widgets/ReCaptchaWidget.js +55 -1
- package/components/widgets/SearchWidget.js +255 -2
- package/components/widgets/Spinner.js +44 -2
- package/components/widgets/SuggestionInput.js +77 -2
- package/components/widgets/TextInput.js +308 -2
- package/components/widgets/ToggleSwitch.js +85 -2
- package/components/widgets/VectorLayerPicker.js +85 -3
- package/libs/openlayers.js +225 -5
- package/package.json +1 -1
- package/plugins/API.js +358 -15
- package/plugins/AttributeTable.js +109 -3
- package/plugins/Authentication.js +130 -5
- package/plugins/BackgroundSwitcher.js +218 -4
- package/plugins/Bookmark.js +289 -3
- package/plugins/BottomBar.js +298 -4
- package/plugins/CookiePopup.js +67 -3
- package/plugins/Cyclomedia.js +442 -5
- package/plugins/Editing.js +497 -9
- package/plugins/FeatureForm.js +366 -4
- package/plugins/FeatureSearch.js +458 -3
- package/plugins/GeometryDigitizer.js +664 -7
- package/plugins/HeightProfile.js +763 -15
- package/plugins/Help.js +102 -3
- package/plugins/HomeButton.js +80 -3
- package/plugins/Identify.js +543 -5
- package/plugins/LayerCatalog.js +215 -4
- package/plugins/LayerTree.js +1194 -6
- package/plugins/LocateButton.js +94 -3
- package/plugins/Map.js +320 -16
- package/plugins/MapCompare.js +94 -3
- package/plugins/MapCopyright.js +127 -5
- package/plugins/MapExport.js +613 -20
- package/plugins/MapFilter.js +868 -12
- package/plugins/MapInfoTooltip.js +277 -3
- package/plugins/MapLegend.js +253 -4
- package/plugins/MapTip.js +290 -4
- package/plugins/Measure.js +220 -4
- package/plugins/NewsPopup.js +137 -3
- package/plugins/OverviewMap.js +167 -7
- package/plugins/Panoramax.js +340 -2
- package/plugins/Portal.js +199 -4
- package/plugins/Print.js +1231 -15
- package/plugins/Redlining.js +750 -6
- package/plugins/Reports.js +332 -3
- package/plugins/Routing.js +1278 -15
- package/plugins/ScratchDrawing.js +173 -5
- package/plugins/Settings.js +241 -4
- package/plugins/Share.js +198 -3
- package/plugins/StartupMarker.js +84 -4
- package/plugins/TaskButton.js +88 -3
- package/plugins/ThemeSwitcher.js +164 -4
- package/plugins/TimeManager.js +971 -10
- package/plugins/TopBar.js +300 -7
- package/plugins/TourGuide.js +213 -2
- package/plugins/ValueTool.js +419 -4
- package/plugins/View3D.js +519 -14
- package/plugins/ZoomButtons.js +165 -3
- package/plugins/map/EditingSupport.js +199 -7
- package/plugins/map/LocateSupport.js +260 -4
- package/plugins/map/MeasurementSupport.js +216 -8
- package/plugins/map/RedliningPickSupport.js +201 -7
- package/plugins/map/RedliningSupport.js +726 -17
- package/plugins/map/SnapInteraction.js +101 -1
- package/plugins/map/SnapSupport.js +210 -2
- package/plugins/map/SnappingSupport.js +356 -17
- package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
- package/plugins/map3d/BottomBar3D.js +118 -3
- package/plugins/map3d/Compare3D.js +422 -8
- package/plugins/map3d/Draw3D.js +353 -6
- package/plugins/map3d/ExportObjects3D.js +393 -18
- package/plugins/map3d/HideObjects3D.js +313 -12
- package/plugins/map3d/Identify3D.js +283 -12
- package/plugins/map3d/LayerTree3D.js +323 -3
- package/plugins/map3d/MapCopyright3D.js +128 -5
- package/plugins/map3d/MapExport3D.js +590 -10
- package/plugins/map3d/MapLight3D.js +553 -6
- package/plugins/map3d/Measure3D.js +571 -20
- package/plugins/map3d/OverviewMap3D.js +169 -3
- package/plugins/map3d/Settings3D.js +73 -3
- package/plugins/map3d/TopBar3D.js +207 -9
- package/plugins/redlining/RedliningBufferSupport.js +206 -3
- package/reducers/display.js +34 -2
- package/reducers/editing.js +68 -3
- package/reducers/index.js +9 -1
- package/reducers/layerinfo.js +26 -2
- package/reducers/layers.js +456 -9
- package/reducers/localConfig.js +122 -2
- package/reducers/locale.js +38 -2
- package/reducers/locate.js +40 -2
- package/reducers/map.js +176 -5
- package/reducers/measurement.js +42 -2
- package/reducers/processNotifications.js +49 -2
- package/reducers/redlining.js +50 -2
- package/reducers/redliningPick.js +27 -2
- package/reducers/search.js +20 -1
- package/reducers/serviceinfo.js +25 -2
- package/reducers/task.js +45 -2
- package/reducers/theme.js +51 -2
- package/reducers/windows.js +203 -2
- package/scripts/dist.sh +1 -1
- package/scripts/gen-plugin-docs.js +152 -2
- package/scripts/makeIconkit.js +85 -6
- package/scripts/themesConfig.js +742 -40
- package/scripts/updateTranslations.js +251 -10
- package/selectors/searchproviders.js +44 -2
- package/stores/StandardStore.js +42 -2
- package/utils/ConfigUtils.js +84 -3
- package/utils/CoordinatesUtils.js +234 -23
- package/utils/DxfUtils.js +237 -11
- package/utils/EditingInterface.js +421 -87
- package/utils/EditingUtils.js +357 -13
- package/utils/ElevationInterface.js +83 -22
- package/utils/FeatureStyles.js +429 -5
- package/utils/IdentifyUtils.js +443 -7
- package/utils/ImageEditor.js +79 -9
- package/utils/LayerUtils.js +1516 -50
- package/utils/LocaleUtils.js +117 -7
- package/utils/MapUtils.js +241 -59
- package/utils/MeasureUtils.js +323 -2
- package/utils/MiscUtils.js +189 -11
- package/utils/PermaLinkUtils.js +429 -6
- package/utils/PluginStore.js +27 -1
- package/utils/ResourceRegistry.js +15 -1
- package/utils/RoutingInterface.js +307 -7
- package/utils/SearchProviders.js +722 -19
- package/utils/ServiceLayerUtils.js +669 -14
- package/utils/Signal.js +32 -2
- package/utils/ThemeUtils.js +341 -7
- package/utils/VectorLayerUtils.js +589 -15
- package/utils/expr_grammar/grammar.js +2239 -2
- package/utils/expr_grammar/test.js +65 -3
|
@@ -1,43 +1,1309 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
16
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
17
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
18
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
20
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
24
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
27
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
|
+
/**
|
|
2
29
|
* Copyright 2024 Sourcepole AG
|
|
3
30
|
* All rights reserved.
|
|
4
31
|
*
|
|
5
32
|
* This source code is licensed under the BSD-style license found in the
|
|
6
33
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import React, { Suspense } from 'react';
|
|
37
|
+
import ReactDOM from 'react-dom';
|
|
38
|
+
import { connect } from 'react-redux';
|
|
39
|
+
import Instance from '@giro3d/giro3d/core/Instance.js';
|
|
40
|
+
import Coordinates from '@giro3d/giro3d/core/geographic/Coordinates';
|
|
41
|
+
import Extent from '@giro3d/giro3d/core/geographic/Extent.js';
|
|
42
|
+
import ElevationLayer from '@giro3d/giro3d/core/layer/ElevationLayer.js';
|
|
43
|
+
import FeatureCollection from "@giro3d/giro3d/entities/FeatureCollection.js";
|
|
44
|
+
import Map from '@giro3d/giro3d/entities/Map.js';
|
|
45
|
+
import Tiles3D from "@giro3d/giro3d/entities/Tiles3D.js";
|
|
46
|
+
import Inspector from "@giro3d/giro3d/gui/Inspector.js";
|
|
47
|
+
import GeoTIFFSource from "@giro3d/giro3d/sources/GeoTIFFSource.js";
|
|
48
|
+
import axios from 'axios';
|
|
49
|
+
import { fromUrl } from "geotiff";
|
|
50
|
+
import isEmpty from 'lodash.isempty';
|
|
51
|
+
import PropTypes from 'prop-types';
|
|
52
|
+
import { Vector2, CubeTextureLoader, Group, Raycaster, Mesh, Box3, Vector3, Matrix4 } from 'three';
|
|
53
|
+
import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
|
|
54
|
+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader';
|
|
55
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
56
|
+
import { LayerRole } from '../../actions/layers';
|
|
57
|
+
import { setCurrentTask } from '../../actions/task';
|
|
58
|
+
import ConfigUtils from '../../utils/ConfigUtils';
|
|
59
|
+
import CoordinatesUtils from '../../utils/CoordinatesUtils';
|
|
60
|
+
import LayerUtils from '../../utils/LayerUtils';
|
|
61
|
+
import MiscUtils from '../../utils/MiscUtils';
|
|
62
|
+
import { registerPermalinkDataStoreHook, unregisterPermalinkDataStoreHook, UrlParams } from '../../utils/PermaLinkUtils';
|
|
63
|
+
import ServiceLayerUtils from '../../utils/ServiceLayerUtils';
|
|
64
|
+
import ThemeUtils from '../../utils/ThemeUtils';
|
|
65
|
+
import { MapContainerPortalContext } from '../PluginsContainer';
|
|
66
|
+
import EditDataset3D from './EditDataset3D';
|
|
67
|
+
import MapControls3D from './MapControls3D';
|
|
68
|
+
import View3DSwitcher from './View3DSwitcher';
|
|
69
|
+
import LayerRegistry from './layers/index';
|
|
70
|
+
import { importGltf, updateObjectLabel } from './utils/MiscUtils3D';
|
|
71
|
+
import Tiles3DStyle from './utils/Tiles3DStyle';
|
|
72
|
+
import './style/Map3D.css';
|
|
73
|
+
|
|
74
|
+
// Ensures unUnload is called *after* all other children have unmounted
|
|
75
|
+
var UnloadWrapper = /*#__PURE__*/function (_React$Component) {
|
|
76
|
+
function UnloadWrapper() {
|
|
77
|
+
var _this;
|
|
78
|
+
_classCallCheck(this, UnloadWrapper);
|
|
79
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
80
|
+
args[_key] = arguments[_key];
|
|
81
|
+
}
|
|
82
|
+
_this = _callSuper(this, UnloadWrapper, [].concat(args));
|
|
83
|
+
_defineProperty(_this, "onUnload", function (el) {
|
|
84
|
+
if (!el) {
|
|
85
|
+
_this.props.onUnload(_this.props.sceneId);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return _this;
|
|
89
|
+
}
|
|
90
|
+
_inherits(UnloadWrapper, _React$Component);
|
|
91
|
+
return _createClass(UnloadWrapper, [{
|
|
92
|
+
key: "render",
|
|
93
|
+
value: function render() {
|
|
94
|
+
return /*#__PURE__*/React.createElement("div", null, this.props.children, /*#__PURE__*/React.createElement("span", {
|
|
95
|
+
ref: this.onUnload
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
}]);
|
|
99
|
+
}(React.Component);
|
|
100
|
+
_defineProperty(UnloadWrapper, "propTypes", {
|
|
101
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
102
|
+
onUnload: PropTypes.func,
|
|
103
|
+
sceneId: PropTypes.string
|
|
104
|
+
});
|
|
105
|
+
var Map3D = /*#__PURE__*/function (_React$Component2) {
|
|
106
|
+
function Map3D(props) {
|
|
107
|
+
var _this2;
|
|
108
|
+
_classCallCheck(this, Map3D);
|
|
109
|
+
_this2 = _callSuper(this, Map3D, [props]);
|
|
110
|
+
_defineProperty(_this2, "state", {
|
|
111
|
+
sceneContext: _objectSpread(_objectSpread({}, Map3D.defaultSceneState), {}, {
|
|
112
|
+
addLayer: function addLayer(layer) {},
|
|
113
|
+
getLayer: function getLayer(layerId) {},
|
|
114
|
+
removeLayer: function removeLayer(layerId) {},
|
|
115
|
+
updateColorLayer: function updateColorLayer(layerId, options, path) {},
|
|
116
|
+
setBaseLayer: function setBaseLayer(layer, visibility) {},
|
|
117
|
+
add3dTiles: function add3dTiles(url, options) {},
|
|
118
|
+
addSceneObject: function addSceneObject(objectId, object) {
|
|
119
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
120
|
+
var showEditTool = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
121
|
+
},
|
|
122
|
+
getSceneObject: function getSceneObject(objectId) {},
|
|
123
|
+
removeSceneObject: function removeSceneObject(objectId) {},
|
|
124
|
+
updateSceneObject: function updateSceneObject(objectId, options) {},
|
|
125
|
+
zoomToObject: function zoomToObject(objectId) {},
|
|
126
|
+
getMap: function getMap() {},
|
|
127
|
+
setViewToExtent: function setViewToExtent(bounds, angle) {},
|
|
128
|
+
getTerrainHeightFromDTM: function getTerrainHeightFromDTM(scenePos) {},
|
|
129
|
+
getTerrainHeightFromMap: function getTerrainHeightFromMap(scenePos) {},
|
|
130
|
+
getSceneIntersection: function getSceneIntersection(x, y, objects) {},
|
|
131
|
+
getSetting: function getSetting(key) {},
|
|
132
|
+
setSetting: function setSetting(key, value) {}
|
|
133
|
+
}),
|
|
134
|
+
sceneId: null
|
|
135
|
+
});
|
|
136
|
+
_defineProperty(_this2, "applyBaseLayer", function () {
|
|
137
|
+
var _baseLayer$name;
|
|
138
|
+
var baseLayer = _this2.state.sceneContext.baseLayers.find(function (e) {
|
|
139
|
+
return e.visibility === true;
|
|
140
|
+
});
|
|
141
|
+
_this2.removeLayer("__baselayer");
|
|
142
|
+
UrlParams.updateParams({
|
|
143
|
+
bl3d: (_baseLayer$name = baseLayer === null || baseLayer === void 0 ? void 0 : baseLayer.name) !== null && _baseLayer$name !== void 0 ? _baseLayer$name : ''
|
|
144
|
+
});
|
|
145
|
+
if (!baseLayer) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
var layerCreator = LayerRegistry[baseLayer.type];
|
|
149
|
+
if (layerCreator !== null && layerCreator !== void 0 && layerCreator.create3d) {
|
|
150
|
+
var layer3d = layerCreator.create3d(baseLayer, _this2.state.sceneContext.mapCrs);
|
|
151
|
+
_this2.addLayer("__baselayer", layer3d);
|
|
152
|
+
_this2.map.insertLayerAfter(layer3d, null);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
_defineProperty(_this2, "setBaseLayer", function (layer, visibility) {
|
|
156
|
+
var _this2$state$sceneCon;
|
|
157
|
+
var currentBaseLayer = ((_this2$state$sceneCon = _this2.state.sceneContext.baseLayers.find(function (l) {
|
|
158
|
+
return l.visibility === true;
|
|
159
|
+
})) === null || _this2$state$sceneCon === void 0 ? void 0 : _this2$state$sceneCon.name) || "";
|
|
160
|
+
if (visibility && (layer === null || layer === void 0 ? void 0 : layer.name) === currentBaseLayer) {
|
|
161
|
+
// Nothing changed
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
_this2.setState(function (state) {
|
|
165
|
+
return {
|
|
166
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
167
|
+
baseLayers: state.sceneContext.baseLayers.map(function (entry) {
|
|
168
|
+
return _objectSpread(_objectSpread({}, entry), {}, {
|
|
169
|
+
visibility: entry.name === layer.name ? visibility : false
|
|
170
|
+
});
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
_defineProperty(_this2, "collectColorLayers", function (prevColorLayers, prevLayers) {
|
|
177
|
+
var prevLayerMap = prevLayers.reduce(function (res, layer) {
|
|
178
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, layer.id, layer));
|
|
179
|
+
}, {});
|
|
180
|
+
return _this2.props.layers.reduce(function (colorLayers, layer) {
|
|
181
|
+
var _prevOptions$visibili, _prevOptions$opacity, _prevOptions$extrusio, _prevOptions$fields;
|
|
182
|
+
if (layer.role !== LayerRole.THEME && layer.role !== LayerRole.USERLAYER) {
|
|
183
|
+
return colorLayers;
|
|
184
|
+
}
|
|
185
|
+
var prevOptions = prevColorLayers[layer.id];
|
|
186
|
+
if (prevOptions && layer === prevLayerMap[layer.id]) {
|
|
187
|
+
colorLayers[layer.id] = prevOptions;
|
|
188
|
+
return colorLayers;
|
|
189
|
+
}
|
|
190
|
+
var layerCreator = LayerRegistry[layer.type];
|
|
191
|
+
if (!layerCreator || !layerCreator.create3d) {
|
|
192
|
+
return colorLayers;
|
|
193
|
+
}
|
|
194
|
+
var _preserveSublayerOptions = function preserveSublayerOptions(entry, prevEntry) {
|
|
195
|
+
var _entry$sublayers, _entry$sublayers$map;
|
|
196
|
+
return (_entry$sublayers = entry.sublayers) === null || _entry$sublayers === void 0 || (_entry$sublayers$map = _entry$sublayers.map) === null || _entry$sublayers$map === void 0 ? void 0 : _entry$sublayers$map.call(_entry$sublayers, function (child) {
|
|
197
|
+
var _prevEntry$sublayers, _prevEntry$sublayers$;
|
|
198
|
+
var prevChild = prevEntry === null || prevEntry === void 0 || (_prevEntry$sublayers = prevEntry.sublayers) === null || _prevEntry$sublayers === void 0 || (_prevEntry$sublayers$ = _prevEntry$sublayers.find) === null || _prevEntry$sublayers$ === void 0 ? void 0 : _prevEntry$sublayers$.call(_prevEntry$sublayers, function (x) {
|
|
199
|
+
return x.name === child.name;
|
|
200
|
+
});
|
|
201
|
+
if ((prevChild === null || prevChild === void 0 ? void 0 : prevChild.name) === child.name) {
|
|
202
|
+
return _objectSpread(_objectSpread({}, child), {}, {
|
|
203
|
+
visibility: prevChild.visibility,
|
|
204
|
+
opacity: prevChild.opacity,
|
|
205
|
+
sublayers: _preserveSublayerOptions(child, prevChild)
|
|
206
|
+
});
|
|
207
|
+
} else {
|
|
208
|
+
return child;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
colorLayers[layer.id] = _objectSpread(_objectSpread({}, layer), {}, {
|
|
213
|
+
visibility: (_prevOptions$visibili = prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.visibility) !== null && _prevOptions$visibili !== void 0 ? _prevOptions$visibili : false,
|
|
214
|
+
opacity: (_prevOptions$opacity = prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.opacity) !== null && _prevOptions$opacity !== void 0 ? _prevOptions$opacity : 255,
|
|
215
|
+
extrusionHeight: (_prevOptions$extrusio = prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.extrusionHeight) !== null && _prevOptions$extrusio !== void 0 ? _prevOptions$extrusio : ['vector', 'wfs'].includes(layer.type) ? 0 : undefined,
|
|
216
|
+
fields: (_prevOptions$fields = prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.fields) !== null && _prevOptions$fields !== void 0 ? _prevOptions$fields : undefined,
|
|
217
|
+
sublayers: _preserveSublayerOptions(layer, prevOptions)
|
|
218
|
+
});
|
|
219
|
+
Object.assign(colorLayers[layer.id], LayerUtils.buildWMSLayerParams(colorLayers[layer.id]));
|
|
220
|
+
if (colorLayers[layer.id].fields === undefined && layerCreator.getFields) {
|
|
221
|
+
layerCreator.getFields(layer).then(function (fields) {
|
|
222
|
+
_this2.updateColorLayer(layer.id, {
|
|
223
|
+
fields: fields
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return colorLayers;
|
|
228
|
+
}, {});
|
|
229
|
+
});
|
|
230
|
+
_defineProperty(_this2, "applyColorLayerUpdates", function (colorLayers, prevColorLayers) {
|
|
231
|
+
// Add-update new layers
|
|
232
|
+
var layerBelow = _this2.getLayer("__baselayer");
|
|
233
|
+
Object.entries(colorLayers).reverse().forEach(function (_ref) {
|
|
234
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
235
|
+
layerId = _ref2[0],
|
|
236
|
+
options = _ref2[1];
|
|
237
|
+
var prevOptions = prevColorLayers[layerId];
|
|
238
|
+
if (options === prevOptions) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
var layerCreator = LayerRegistry[options.type];
|
|
242
|
+
var mapLayer = _this2.getLayer(layerId);
|
|
243
|
+
if (mapLayer) {
|
|
244
|
+
layerCreator.update3d(mapLayer.source, options, prevOptions, _this2.state.sceneContext.mapCrs);
|
|
245
|
+
} else {
|
|
246
|
+
mapLayer = layerCreator.create3d(options, _this2.state.sceneContext.mapCrs);
|
|
247
|
+
_this2.addLayer(layerId, mapLayer);
|
|
248
|
+
}
|
|
249
|
+
_this2.map.insertLayerAfter(mapLayer, layerBelow);
|
|
250
|
+
mapLayer.visible = options.visibility;
|
|
251
|
+
mapLayer.opacity = options.opacity / 255;
|
|
252
|
+
layerBelow = mapLayer;
|
|
253
|
+
if (options.extrusionHeight !== 0) {
|
|
254
|
+
_this2.createUpdateExtrudedLayer(mapLayer, options, options.features !== (prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.features));
|
|
255
|
+
} else if ((prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.extrusionHeight) !== 0) {
|
|
256
|
+
_this2.removeExtrudedLayer(options.id);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
// Remove old layers
|
|
260
|
+
Object.entries(prevColorLayers).forEach(function (_ref3) {
|
|
261
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
262
|
+
layerId = _ref4[0],
|
|
263
|
+
options = _ref4[1];
|
|
264
|
+
if (!(layerId in colorLayers)) {
|
|
265
|
+
if (options.extrusionHeight !== 0) {
|
|
266
|
+
_this2.removeExtrudedLayer(options.id);
|
|
267
|
+
}
|
|
268
|
+
_this2.removeLayer(layerId);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
_this2.instance.notifyChange(_this2.map);
|
|
272
|
+
});
|
|
273
|
+
_defineProperty(_this2, "createUpdateExtrudedLayer", function (mapLayer, options) {
|
|
274
|
+
var _options$features, _options$features$red;
|
|
275
|
+
var forceCreate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
276
|
+
var bounds = options.bbox.bounds;
|
|
277
|
+
var extent = new Extent(options.bbox.crs, bounds[0], bounds[2], bounds[1], bounds[3]);
|
|
278
|
+
var objId = options.id + ":extruded";
|
|
279
|
+
var makeColor = function makeColor(c) {
|
|
280
|
+
if (Array.isArray(c)) {
|
|
281
|
+
return c[0] << 16 | c[1] << 8 | c[2];
|
|
282
|
+
} else if (typeof c === "string") {
|
|
283
|
+
return parseInt(c.replace("#", ""), 16);
|
|
284
|
+
} else {
|
|
285
|
+
return c;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var obj = _this2.objectMap[objId];
|
|
289
|
+
if (!obj || forceCreate) {
|
|
290
|
+
var _options$color;
|
|
291
|
+
if (obj) {
|
|
292
|
+
_this2.instance.remove(obj);
|
|
293
|
+
}
|
|
294
|
+
var layercolor = makeColor((_options$color = options.color) !== null && _options$color !== void 0 ? _options$color : "#FF0000");
|
|
295
|
+
obj = new FeatureCollection({
|
|
296
|
+
source: mapLayer.source.source,
|
|
297
|
+
extent: extent,
|
|
298
|
+
minLevel: 1,
|
|
299
|
+
maxLevel: 1,
|
|
300
|
+
ignoreZ: true,
|
|
301
|
+
elevation: function elevation(feature) {
|
|
302
|
+
var _this2$getTerrainHeig;
|
|
303
|
+
var coordinates = feature.getGeometry().getCoordinates();
|
|
304
|
+
while (Array.isArray(coordinates[0])) {
|
|
305
|
+
coordinates = coordinates[0];
|
|
306
|
+
}
|
|
307
|
+
return (_this2$getTerrainHeig = _this2.getTerrainHeightFromMap(coordinates)) !== null && _this2$getTerrainHeig !== void 0 ? _this2$getTerrainHeig : 0;
|
|
308
|
+
},
|
|
309
|
+
extrusionOffset: function extrusionOffset(feature) {
|
|
310
|
+
if (typeof obj.userData.extrusionHeight === "string") {
|
|
311
|
+
return parseFloat(feature.getProperties()[obj.userData.extrusionHeight]) || 0;
|
|
312
|
+
} else {
|
|
313
|
+
return obj.userData.extrusionHeight;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
style: function style(feature) {
|
|
317
|
+
var _obj$userData$feature, _obj$userData$feature2;
|
|
318
|
+
return (_obj$userData$feature = (_obj$userData$feature2 = obj.userData.featureStyles) === null || _obj$userData$feature2 === void 0 ? void 0 : _obj$userData$feature2[feature.getId()]) !== null && _obj$userData$feature !== void 0 ? _obj$userData$feature : {
|
|
319
|
+
fill: {
|
|
320
|
+
color: layercolor,
|
|
321
|
+
shading: true
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
obj.castShadow = true;
|
|
327
|
+
obj.receiveShadow = true;
|
|
328
|
+
_this2.instance.add(obj);
|
|
329
|
+
_this2.objectMap[objId] = obj;
|
|
330
|
+
}
|
|
331
|
+
obj.userData.extrusionHeight = options.extrusionHeight;
|
|
332
|
+
obj.userData.featureStyles = (_options$features = options.features) === null || _options$features === void 0 || (_options$features$red = _options$features.reduce) === null || _options$features$red === void 0 ? void 0 : _options$features$red.call(_options$features, function (res, feature) {
|
|
333
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, feature.id, {
|
|
334
|
+
fill: {
|
|
335
|
+
color: makeColor(feature.styleOptions.fillColor),
|
|
336
|
+
shading: true
|
|
337
|
+
}
|
|
338
|
+
}));
|
|
339
|
+
}, {});
|
|
340
|
+
obj.opacity = mapLayer.opacity;
|
|
341
|
+
obj.visible = mapLayer.visible;
|
|
342
|
+
obj.updateStyles();
|
|
343
|
+
});
|
|
344
|
+
_defineProperty(_this2, "removeExtrudedLayer", function (layerId) {
|
|
345
|
+
var objId = layerId + ":extruded";
|
|
346
|
+
if (_this2.objectMap[objId]) {
|
|
347
|
+
_this2.instance.remove(_this2.objectMap[objId]);
|
|
348
|
+
delete _this2.objectMap[objId];
|
|
349
|
+
}
|
|
350
|
+
_this2.instance.notifyChange();
|
|
351
|
+
});
|
|
352
|
+
_defineProperty(_this2, "applySceneObjectUpdates", function (sceneObjects, prevSceneObjects) {
|
|
353
|
+
Object.entries(sceneObjects).forEach(function (_ref5) {
|
|
354
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
355
|
+
objectId = _ref6[0],
|
|
356
|
+
options = _ref6[1];
|
|
357
|
+
var prevOptions = prevSceneObjects === null || prevSceneObjects === void 0 ? void 0 : prevSceneObjects[objectId];
|
|
358
|
+
var object = _this2.objectMap[objectId];
|
|
359
|
+
if (options.opacity !== (prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.opacity) || options.visibility !== (prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.visibility)) {
|
|
360
|
+
object.visible = options.visibility && options.opacity > 0;
|
|
361
|
+
if (object.opacity !== undefined) {
|
|
362
|
+
object.opacity = options.opacity / 255;
|
|
363
|
+
} else {
|
|
364
|
+
object.traverse(function (child) {
|
|
365
|
+
if (child instanceof Mesh) {
|
|
366
|
+
child.material.transparent = options.opacity < 255;
|
|
367
|
+
child.material.opacity = options.opacity / 255;
|
|
368
|
+
child.material.needsUpdate = true;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
_this2.instance.notifyChange(object);
|
|
373
|
+
}
|
|
374
|
+
if (options.style !== (prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.style)) {
|
|
375
|
+
_this2.loadTilesetStyle(objectId, options);
|
|
376
|
+
}
|
|
377
|
+
if (options.tilesetStyle !== (prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.tilesetStyle)) {
|
|
378
|
+
object.tiles.group.children.forEach(function (group) {
|
|
379
|
+
Tiles3DStyle.applyTileStyle(group, options, _this2.state.sceneContext);
|
|
380
|
+
});
|
|
381
|
+
_this2.instance.notifyChange(object);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
_defineProperty(_this2, "addLayer", function (layerId, layer) {
|
|
386
|
+
layer.userData.layerId = layerId;
|
|
387
|
+
_this2.map.addLayer(layer);
|
|
388
|
+
});
|
|
389
|
+
_defineProperty(_this2, "getLayer", function (layerId) {
|
|
390
|
+
var _this2$map$getLayers$;
|
|
391
|
+
return (_this2$map$getLayers$ = _this2.map.getLayers(function (l) {
|
|
392
|
+
return l.userData.layerId === layerId;
|
|
393
|
+
})[0]) !== null && _this2$map$getLayers$ !== void 0 ? _this2$map$getLayers$ : null;
|
|
394
|
+
});
|
|
395
|
+
_defineProperty(_this2, "removeLayer", function (layerId) {
|
|
396
|
+
_this2.map.getLayers(function (l) {
|
|
397
|
+
return l.userData.layerId === layerId;
|
|
398
|
+
}).forEach(function (layer) {
|
|
399
|
+
_this2.map.removeLayer(layer, {
|
|
400
|
+
dispose: true
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
_defineProperty(_this2, "updateColorLayer", function (layerId, options) {
|
|
405
|
+
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
406
|
+
_this2.setState(function (state) {
|
|
407
|
+
var entry = _objectSpread({}, state.sceneContext.colorLayers[layerId]);
|
|
408
|
+
var subentry = entry;
|
|
409
|
+
path.forEach(function (idx) {
|
|
410
|
+
subentry.sublayers = _toConsumableArray(subentry.sublayers);
|
|
411
|
+
subentry.sublayers[idx] = _objectSpread({}, subentry.sublayers[idx]);
|
|
412
|
+
subentry = subentry.sublayers[idx];
|
|
413
|
+
});
|
|
414
|
+
Object.assign(subentry, options);
|
|
415
|
+
Object.assign(entry, LayerUtils.buildWMSLayerParams(entry));
|
|
416
|
+
return {
|
|
417
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
418
|
+
colorLayers: _objectSpread(_objectSpread({}, state.sceneContext.colorLayers), {}, _defineProperty({}, layerId, entry))
|
|
419
|
+
})
|
|
420
|
+
};
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
_defineProperty(_this2, "add3dTiles", function (url, name) {
|
|
424
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
425
|
+
var showEditTool = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
426
|
+
var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
427
|
+
var label = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
428
|
+
var tiles = new Tiles3D({
|
|
429
|
+
url: MiscUtils.resolveAssetsPath(url)
|
|
430
|
+
});
|
|
431
|
+
// Recenter tile group
|
|
432
|
+
tiles.tiles.addEventListener('load-tile-set', function (_ref7) {
|
|
433
|
+
var tileSet = _ref7.tileSet;
|
|
434
|
+
if (tileSet.root.parent === null) {
|
|
435
|
+
var bbox = new Box3();
|
|
436
|
+
tiles.tiles.getBoundingBox(bbox);
|
|
437
|
+
var center = bbox.getCenter(new Vector3());
|
|
438
|
+
tiles.tiles.group.position.sub(center);
|
|
439
|
+
if (matrix) {
|
|
440
|
+
tiles.tiles.group.parent.applyMatrix4(matrix);
|
|
441
|
+
} else {
|
|
442
|
+
tiles.tiles.group.parent.position.copy(center);
|
|
443
|
+
}
|
|
444
|
+
tiles.tiles.group.parent.updateMatrixWorld(true);
|
|
445
|
+
if (label) {
|
|
446
|
+
tiles.tiles.group.parent.userData.label = label;
|
|
447
|
+
updateObjectLabel(tiles.tiles.group.parent, _this2.state.sceneContext);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
_this2.instance.notifyChange(tiles);
|
|
451
|
+
if (showEditTool) {
|
|
452
|
+
_this2.props.setCurrentTask("EditDataset3D", null, null, {
|
|
453
|
+
objectId: name
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
tiles.tiles.addEventListener('needs-update', function () {
|
|
458
|
+
_this2.instance.notifyChange(tiles);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Apply style when loading tile
|
|
462
|
+
tiles.tiles.addEventListener('load-model', function (_ref8) {
|
|
463
|
+
var scene = _ref8.scene;
|
|
464
|
+
scene.userData.tilesetName = name;
|
|
465
|
+
scene.userData.featureIdAttr = "id";
|
|
466
|
+
Tiles3DStyle.applyTileStyle(scene, _this2.state.sceneContext.sceneObjects[name], _this2.state.sceneContext);
|
|
467
|
+
_this2.instance.notifyChange(tiles);
|
|
468
|
+
});
|
|
469
|
+
// Show/hide labels when tile visibility changes
|
|
470
|
+
tiles.tiles.addEventListener('tile-visibility-change', function (_ref9) {
|
|
471
|
+
var _scene$userData$tileL, _scene$userData;
|
|
472
|
+
var scene = _ref9.scene,
|
|
473
|
+
visible = _ref9.visible;
|
|
474
|
+
Object.values((_scene$userData$tileL = scene === null || scene === void 0 || (_scene$userData = scene.userData) === null || _scene$userData === void 0 ? void 0 : _scene$userData.tileLabels) !== null && _scene$userData$tileL !== void 0 ? _scene$userData$tileL : {}).forEach(function (l) {
|
|
475
|
+
l.labelObject.visible = visible;
|
|
476
|
+
l.labelObject.element.style.display = visible ? 'initial' : 'none';
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
tiles.castShadow = true;
|
|
480
|
+
tiles.receiveShadow = true;
|
|
481
|
+
tiles.userData.layertree = true;
|
|
482
|
+
_this2.instance.add(tiles);
|
|
483
|
+
_this2.objectMap[name] = tiles;
|
|
484
|
+
_this2.setState(function (state) {
|
|
485
|
+
var objectState = _objectSpread({
|
|
486
|
+
imported: true,
|
|
487
|
+
visibility: true,
|
|
488
|
+
opacity: 255,
|
|
489
|
+
layertree: true,
|
|
490
|
+
title: name
|
|
491
|
+
}, options);
|
|
492
|
+
return {
|
|
493
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
494
|
+
sceneObjects: _objectSpread(_objectSpread({}, state.sceneContext.sceneObjects), {}, _defineProperty({}, name, objectState))
|
|
495
|
+
})
|
|
496
|
+
};
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
_defineProperty(_this2, "addSceneObject", function (objectId, object) {
|
|
500
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
501
|
+
var showEditTool = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
502
|
+
_this2.sceneObjectGroup.add(object);
|
|
503
|
+
_this2.objectMap[objectId] = object;
|
|
504
|
+
_this2.instance.notifyChange(object);
|
|
505
|
+
_this2.setState(function (state) {
|
|
506
|
+
var objectState = _objectSpread({
|
|
507
|
+
visibility: true,
|
|
508
|
+
opacity: 255,
|
|
509
|
+
layertree: false
|
|
510
|
+
}, options);
|
|
511
|
+
return {
|
|
512
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
513
|
+
sceneObjects: _objectSpread(_objectSpread({}, state.sceneContext.sceneObjects), {}, _defineProperty({}, objectId, objectState))
|
|
514
|
+
})
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
if (showEditTool) {
|
|
518
|
+
_this2.props.setCurrentTask("EditDataset3D", null, null, {
|
|
519
|
+
objectId: objectId
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
_defineProperty(_this2, "getSceneObject", function (objectId) {
|
|
524
|
+
return _this2.objectMap[objectId];
|
|
525
|
+
});
|
|
526
|
+
_defineProperty(_this2, "removeSceneObject", function (objectId) {
|
|
527
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
528
|
+
var object = _this2.objectMap[objectId];
|
|
529
|
+
if (!object) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
// Ensure labels are removed
|
|
533
|
+
object.traverse(function (c) {
|
|
534
|
+
if (c.isCSS2DObject) {
|
|
535
|
+
c.element.parentNode.removeChild(c.element);
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
if (object.tiles) {
|
|
539
|
+
_this2.instance.remove(object);
|
|
540
|
+
} else {
|
|
541
|
+
_this2.sceneObjectGroup.remove(object);
|
|
542
|
+
}
|
|
543
|
+
delete _this2.objectMap[objectId];
|
|
544
|
+
_this2.instance.notifyChange();
|
|
545
|
+
_this2.setState(function (state) {
|
|
546
|
+
var newSceneObjects = _objectSpread({}, state.sceneContext.sceneObjects);
|
|
547
|
+
delete newSceneObjects[objectId];
|
|
548
|
+
return {
|
|
549
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
550
|
+
sceneObjects: newSceneObjects
|
|
551
|
+
})
|
|
552
|
+
};
|
|
553
|
+
}, callback);
|
|
554
|
+
});
|
|
555
|
+
_defineProperty(_this2, "updateSceneObject", function (objectId, options) {
|
|
556
|
+
_this2.setState(function (state) {
|
|
557
|
+
return {
|
|
558
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
559
|
+
sceneObjects: _objectSpread(_objectSpread({}, state.sceneContext.sceneObjects), {}, _defineProperty({}, objectId, _objectSpread(_objectSpread({}, state.sceneContext.sceneObjects[objectId]), options)))
|
|
560
|
+
})
|
|
561
|
+
};
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
_defineProperty(_this2, "zoomToObject", function (objectId) {
|
|
565
|
+
var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
|
|
566
|
+
var obj = _this2.state.sceneContext.getSceneObject(objectId);
|
|
567
|
+
var bbox = new Box3();
|
|
568
|
+
if (obj !== null && obj !== void 0 && obj.tiles) {
|
|
569
|
+
obj.tiles.getBoundingBox(bbox);
|
|
570
|
+
} else {
|
|
571
|
+
bbox.setFromObject(obj);
|
|
572
|
+
}
|
|
573
|
+
if (!bbox.isEmpty()) {
|
|
574
|
+
var bounds = [bbox.min.x - margin, bbox.min.y - margin, bbox.max.x + margin, bbox.max.y + margin];
|
|
575
|
+
_this2.state.sceneContext.setViewToExtent(bounds, 0);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
_defineProperty(_this2, "getMap", function () {
|
|
579
|
+
return _this2.map;
|
|
580
|
+
});
|
|
581
|
+
_defineProperty(_this2, "setupContainer", function (el) {
|
|
582
|
+
if (el) {
|
|
583
|
+
_this2.container = el;
|
|
584
|
+
el.resizeObserver = new ResizeObserver(function (entries) {
|
|
585
|
+
var rect = entries[0].contentRect;
|
|
586
|
+
_this2.state.sceneContext.scene.view.dispatchEvent({
|
|
587
|
+
type: 'view-resized',
|
|
588
|
+
width: rect.width,
|
|
589
|
+
height: rect.height
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
el.resizeObserver.observe(el);
|
|
593
|
+
_this2.setupInstance();
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
_defineProperty(_this2, "setupInstance", function () {
|
|
597
|
+
var _this2$props$theme$ma, _this2$props$theme$ma2, _this2$props$theme$ma3, _this2$props$theme$ma4, _this2$props$theme$ma5, _this2$props$theme$ma8, _this2$props$theme$ma9, _this2$props$theme$ma10;
|
|
598
|
+
if (_this2.instance) {
|
|
599
|
+
_this2.disposeInstance();
|
|
600
|
+
}
|
|
601
|
+
if (!_this2.props.theme) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
var projection = _this2.props.theme.mapCrs;
|
|
605
|
+
|
|
606
|
+
// Setup instance
|
|
607
|
+
_this2.instance = new Instance({
|
|
608
|
+
target: _this2.container,
|
|
609
|
+
crs: projection,
|
|
610
|
+
renderer: {
|
|
611
|
+
clearColor: 0x000000,
|
|
612
|
+
preserveDrawingBuffer: true
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
_this2.sceneObjectGroup = new Group();
|
|
616
|
+
_this2.instance.add(_this2.sceneObjectGroup);
|
|
617
|
+
|
|
618
|
+
// Setup map
|
|
619
|
+
var initialBbox = (_this2$props$theme$ma = (_this2$props$theme$ma2 = _this2.props.theme.map3d) === null || _this2$props$theme$ma2 === void 0 ? void 0 : _this2$props$theme$ma2.extent) !== null && _this2$props$theme$ma !== void 0 ? _this2$props$theme$ma : _this2.props.theme.initialBbox;
|
|
620
|
+
var bounds = CoordinatesUtils.reprojectBbox(initialBbox.bounds, initialBbox.crs, projection);
|
|
621
|
+
var extent = new Extent(crs, bounds[0], bounds[2], bounds[1], bounds[3]);
|
|
622
|
+
_this2.map = new Map({
|
|
623
|
+
extent: extent,
|
|
624
|
+
backgroundColor: "white"
|
|
625
|
+
});
|
|
626
|
+
_this2.instance.add(_this2.map);
|
|
627
|
+
|
|
628
|
+
// Setup camera
|
|
629
|
+
var center = extent.center();
|
|
630
|
+
_this2.instance.view.camera.position.set(center.x, center.y, 0.5 * (extent.east - extent.west));
|
|
631
|
+
|
|
632
|
+
// Skybox
|
|
633
|
+
var cubeTextureLoader = new CubeTextureLoader();
|
|
634
|
+
cubeTextureLoader.setPath(ConfigUtils.getAssetsPath() + "/3d/skybox/");
|
|
635
|
+
var cubeTexture = cubeTextureLoader.load(["px.jpg", "nx.jpg", "py.jpg", "ny.jpg", "pz.jpg", "nz.jpg"]);
|
|
636
|
+
_this2.instance.scene.background = cubeTexture;
|
|
637
|
+
|
|
638
|
+
// Setup elevation
|
|
639
|
+
var demUrl = MiscUtils.resolveAssetsPath((_this2$props$theme$ma3 = (_this2$props$theme$ma4 = _this2.props.theme.map3d) === null || _this2$props$theme$ma4 === void 0 || (_this2$props$theme$ma4 = _this2$props$theme$ma4.dtm) === null || _this2$props$theme$ma4 === void 0 ? void 0 : _this2$props$theme$ma4.url) !== null && _this2$props$theme$ma3 !== void 0 ? _this2$props$theme$ma3 : "");
|
|
640
|
+
var demCrs = ((_this2$props$theme$ma5 = _this2.props.theme.map3d) === null || _this2$props$theme$ma5 === void 0 || (_this2$props$theme$ma5 = _this2$props$theme$ma5.dtm) === null || _this2$props$theme$ma5 === void 0 ? void 0 : _this2$props$theme$ma5.crs) || "EPSG:3857";
|
|
641
|
+
if (demUrl) {
|
|
642
|
+
var _this2$props$theme$ma6, _this2$props$theme$ma7;
|
|
643
|
+
var demSource = new GeoTIFFSource({
|
|
644
|
+
url: demUrl,
|
|
645
|
+
crs: demCrs
|
|
646
|
+
});
|
|
647
|
+
var demMin = (_this2$props$theme$ma6 = _this2.props.theme.map3d.dtm.min) !== null && _this2$props$theme$ma6 !== void 0 ? _this2$props$theme$ma6 : undefined;
|
|
648
|
+
var demMax = (_this2$props$theme$ma7 = _this2.props.theme.map3d.dtm.max) !== null && _this2$props$theme$ma7 !== void 0 ? _this2$props$theme$ma7 : undefined;
|
|
649
|
+
var elevationLayer = new ElevationLayer({
|
|
650
|
+
name: 'dem',
|
|
651
|
+
extent: extent,
|
|
652
|
+
source: demSource,
|
|
653
|
+
minmax: demMin !== undefined && demMax !== undefined ? {
|
|
654
|
+
demMin: demMin,
|
|
655
|
+
demMax: demMax
|
|
656
|
+
} : undefined
|
|
657
|
+
});
|
|
658
|
+
_this2.addLayer("__dtm", elevationLayer);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Collect baselayers
|
|
662
|
+
var externalLayers = {};
|
|
663
|
+
var baseLayers = ThemeUtils.createThemeBackgroundLayers(((_this2$props$theme$ma8 = _this2.props.theme.map3d) === null || _this2$props$theme$ma8 === void 0 ? void 0 : _this2$props$theme$ma8.basemaps) || [], _this2.props.themes, null, externalLayers);
|
|
664
|
+
for (var _i = 0, _Object$keys = Object.keys(externalLayers); _i < _Object$keys.length; _i++) {
|
|
665
|
+
var key = _Object$keys[_i];
|
|
666
|
+
var idx = key.indexOf(":");
|
|
667
|
+
var service = key.slice(0, idx);
|
|
668
|
+
var serviceUrl = key.slice(idx + 1);
|
|
669
|
+
ServiceLayerUtils.findLayers(service, serviceUrl, externalLayers[key], projection, function (id, layer) {
|
|
670
|
+
// Don't expose sublayers
|
|
671
|
+
if (layer) {
|
|
672
|
+
layer.sublayers = null;
|
|
673
|
+
}
|
|
674
|
+
_this2.setState(function (state) {
|
|
675
|
+
return {
|
|
676
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
677
|
+
baseLayers: LayerUtils.replacePlaceholderLayer(state.sceneContext.baseLayers, id, layer)
|
|
678
|
+
})
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// Collect color layers
|
|
685
|
+
var colorLayers = _this2.collectColorLayers([], []);
|
|
686
|
+
var sceneObjects = {};
|
|
687
|
+
_this2.objectMap = {};
|
|
688
|
+
// Add 3d tiles
|
|
689
|
+
(((_this2$props$theme$ma9 = _this2.props.theme.map3d) === null || _this2$props$theme$ma9 === void 0 ? void 0 : _this2$props$theme$ma9.tiles3d) || []).forEach(function (entry) {
|
|
690
|
+
var _entry$title;
|
|
691
|
+
var tiles = new Tiles3D({
|
|
692
|
+
url: MiscUtils.resolveAssetsPath(entry.url),
|
|
693
|
+
errorTarget: 32
|
|
694
|
+
});
|
|
695
|
+
tiles.tiles.addEventListener('load-tile-set', function () {
|
|
696
|
+
_this2.instance.notifyChange(tiles);
|
|
697
|
+
});
|
|
698
|
+
tiles.tiles.addEventListener('needs-update', function () {
|
|
699
|
+
_this2.instance.notifyChange(tiles);
|
|
700
|
+
});
|
|
701
|
+
// Apply style when loading tile
|
|
702
|
+
tiles.tiles.addEventListener('load-model', function (_ref10) {
|
|
703
|
+
var _entry$idAttr;
|
|
704
|
+
var scene = _ref10.scene;
|
|
705
|
+
scene.userData.tilesetName = entry.name;
|
|
706
|
+
scene.userData.featureIdAttr = (_entry$idAttr = entry.idAttr) !== null && _entry$idAttr !== void 0 ? _entry$idAttr : "id";
|
|
707
|
+
Tiles3DStyle.applyTileStyle(scene, _this2.state.sceneContext.sceneObjects[entry.name], _this2.state.sceneContext);
|
|
708
|
+
_this2.instance.notifyChange(tiles);
|
|
709
|
+
});
|
|
710
|
+
// Show/hide labels when tile visibility changes
|
|
711
|
+
tiles.tiles.addEventListener('tile-visibility-change', function (_ref11) {
|
|
712
|
+
var _scene$userData$tileL2, _scene$userData2;
|
|
713
|
+
var scene = _ref11.scene,
|
|
714
|
+
visible = _ref11.visible;
|
|
715
|
+
Object.values((_scene$userData$tileL2 = scene === null || scene === void 0 || (_scene$userData2 = scene.userData) === null || _scene$userData2 === void 0 ? void 0 : _scene$userData2.tileLabels) !== null && _scene$userData$tileL2 !== void 0 ? _scene$userData$tileL2 : {}).forEach(function (label) {
|
|
716
|
+
label.labelObject.visible = visible;
|
|
717
|
+
label.labelObject.element.style.display = visible ? 'initial' : 'none';
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
tiles.castShadow = true;
|
|
721
|
+
tiles.receiveShadow = true;
|
|
722
|
+
tiles.userData.layertree = true;
|
|
723
|
+
_this2.instance.add(tiles);
|
|
724
|
+
_this2.objectMap[entry.name] = tiles;
|
|
725
|
+
sceneObjects[entry.name] = {
|
|
726
|
+
visibility: true,
|
|
727
|
+
opacity: 255,
|
|
728
|
+
layertree: true,
|
|
729
|
+
title: (_entry$title = entry.title) !== null && _entry$title !== void 0 ? _entry$title : entry.name,
|
|
730
|
+
baseColor: entry.baseColor,
|
|
731
|
+
styles: entry.styles,
|
|
732
|
+
style: entry.style || Object.keys(entry.styles || {})[0] || null,
|
|
733
|
+
tilesetStyle: null,
|
|
734
|
+
idAttr: entry.idAttr,
|
|
735
|
+
colorAttr: entry.colorAttr,
|
|
736
|
+
alphaAttr: entry.alphaAttr,
|
|
737
|
+
labelAttr: entry.labelAttr
|
|
738
|
+
};
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// Add other objects
|
|
742
|
+
(((_this2$props$theme$ma10 = _this2.props.theme.map3d) === null || _this2$props$theme$ma10 === void 0 ? void 0 : _this2$props$theme$ma10.objects3d) || []).forEach(function (entry) {
|
|
743
|
+
importGltf(MiscUtils.resolveAssetsPath(entry.url), entry.name, _this2.state.sceneContext);
|
|
744
|
+
});
|
|
745
|
+
_this2.setState(function (state) {
|
|
746
|
+
return {
|
|
747
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
748
|
+
scene: _this2.instance,
|
|
749
|
+
map: _this2.map,
|
|
750
|
+
mapCrs: projection,
|
|
751
|
+
dtmUrl: demUrl,
|
|
752
|
+
dtmCrs: demCrs,
|
|
753
|
+
baseLayers: baseLayers,
|
|
754
|
+
colorLayers: colorLayers,
|
|
755
|
+
sceneObjects: sceneObjects
|
|
756
|
+
}),
|
|
757
|
+
sceneId: uuidv4()
|
|
758
|
+
};
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
// Inspector
|
|
762
|
+
if (["1", "true"].includes((UrlParams.getParam("inspector") || "").toLowerCase())) {
|
|
763
|
+
var inspectorContainer = document.createElement("div");
|
|
764
|
+
inspectorContainer.className = 'map3d-inspector';
|
|
765
|
+
_this2.container.appendChild(inspectorContainer);
|
|
766
|
+
_this2.inspector = new Inspector(inspectorContainer, _this2.instance);
|
|
767
|
+
}
|
|
768
|
+
_this2.instance.addEventListener('update-start', _this2.instanceOnUpdateStart);
|
|
769
|
+
_this2.instance.addEventListener('update-end', _this2.instanceOnUpdateEnd);
|
|
770
|
+
_this2.instance.addEventListener('before-entity-update', _this2.instanceOnBeforeEntityUpdate);
|
|
771
|
+
_this2.instance.addEventListener('after-entity-update', _this2.instanceOnAfterEntityUpdate);
|
|
772
|
+
});
|
|
773
|
+
_defineProperty(_this2, "instanceOnUpdateStart", function () {
|
|
774
|
+
var camera = _this2.instance.view.camera;
|
|
775
|
+
var quality = _this2.state.sceneContext.settings.sceneQuality;
|
|
776
|
+
var isFirstPerson = _this2.state.sceneContext.scene.view.controls.isFirstPerson;
|
|
777
|
+
var maxDistance = isFirstPerson ? 200 + 20 * quality : 500 + quality * quality;
|
|
778
|
+
// Hide scene objects according to scene quality
|
|
779
|
+
Object.entries(_this2.state.sceneContext.sceneObjects).forEach(function (_ref12) {
|
|
780
|
+
var _ref13 = _slicedToArray(_ref12, 2),
|
|
781
|
+
objId = _ref13[0],
|
|
782
|
+
options = _ref13[1];
|
|
783
|
+
var object = _this2.objectMap[objId];
|
|
784
|
+
if (options.layertree && object.isObject3D && object.visible) {
|
|
785
|
+
object.children.forEach(function (child) {
|
|
786
|
+
if (child.geometry) {
|
|
787
|
+
if (!child.geometry.boundingBox) {
|
|
788
|
+
child.geometry.computeBoundingBox();
|
|
789
|
+
}
|
|
790
|
+
var localCenter = child.geometry.boundingBox.getCenter(new Vector3());
|
|
791
|
+
var worldCenter = localCenter.applyMatrix4(child.matrixWorld);
|
|
792
|
+
var distance = camera.position.distanceTo(worldCenter);
|
|
793
|
+
child.userData.__wasVisible = child.visible;
|
|
794
|
+
if (distance > maxDistance) {
|
|
795
|
+
child.visible = false;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
_defineProperty(_this2, "instanceOnUpdateEnd", function () {
|
|
803
|
+
Object.entries(_this2.state.sceneContext.sceneObjects).forEach(function (_ref14) {
|
|
804
|
+
var _ref15 = _slicedToArray(_ref14, 2),
|
|
805
|
+
objId = _ref15[0],
|
|
806
|
+
options = _ref15[1];
|
|
807
|
+
var object = _this2.objectMap[objId];
|
|
808
|
+
if (options.layertree && object.isObject3D) {
|
|
809
|
+
object.children.forEach(function (child) {
|
|
810
|
+
child.visible = child.userData.__wasVisible;
|
|
811
|
+
delete child.userData.__wasVisible;
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
_defineProperty(_this2, "instanceOnBeforeEntityUpdate", function (_ref16) {
|
|
817
|
+
var entity = _ref16.entity;
|
|
818
|
+
if (entity !== _this2.map) {
|
|
819
|
+
_this2.instance.view.camera.userData.__previousFar = _this2.instance.view.camera.far;
|
|
820
|
+
var quality = _this2.state.sceneContext.settings.sceneQuality;
|
|
821
|
+
var isFirstPerson = _this2.state.sceneContext.scene.view.controls.isFirstPerson;
|
|
822
|
+
_this2.instance.view.camera.far = isFirstPerson ? 200 + 20 * quality : 500 + quality * quality;
|
|
823
|
+
_this2.instance.view.camera.updateProjectionMatrix();
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
_defineProperty(_this2, "instanceOnAfterEntityUpdate", function (_ref17) {
|
|
827
|
+
var entity = _ref17.entity;
|
|
828
|
+
if (entity !== _this2.map) {
|
|
829
|
+
_this2.instance.view.camera.far = _this2.instance.view.camera.userData.__previousFar;
|
|
830
|
+
delete _this2.instance.view.camera.userData.__previousFar;
|
|
831
|
+
_this2.instance.view.camera.updateProjectionMatrix();
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
_defineProperty(_this2, "loadTilesetStyle", function (objectId, options) {
|
|
835
|
+
var _options$styles;
|
|
836
|
+
var url = (_options$styles = options.styles) === null || _options$styles === void 0 ? void 0 : _options$styles[options.style];
|
|
837
|
+
if (_this2.tilesetStyles[url]) {
|
|
838
|
+
_this2.updateSceneObject(objectId, {
|
|
839
|
+
tilesetStyle: _this2.tilesetStyles[url]
|
|
840
|
+
});
|
|
841
|
+
} else if (url) {
|
|
842
|
+
var fullUrl = MiscUtils.resolveAssetsPath(url);
|
|
843
|
+
axios.get(fullUrl).then(function (response) {
|
|
844
|
+
_this2.tilesetStyles[url] = response.data;
|
|
845
|
+
_this2.updateSceneObject(objectId, {
|
|
846
|
+
tilesetStyle: _this2.tilesetStyles[url]
|
|
847
|
+
});
|
|
848
|
+
})["catch"](function () {
|
|
849
|
+
_this2.tilesetStyles[url] = {};
|
|
850
|
+
_this2.updateSceneObject(objectId, {
|
|
851
|
+
tilesetStyle: _this2.tilesetStyles[url]
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
} else {
|
|
855
|
+
_this2.tilesetStyles[url] = null;
|
|
856
|
+
_this2.updateSceneObject(objectId, {
|
|
857
|
+
tilesetStyle: _this2.tilesetStyles[url]
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
_defineProperty(_this2, "disposeInstance", function () {
|
|
862
|
+
_this2.instance.removeEventListener('update-start', _this2.instanceOnUpdateStart);
|
|
863
|
+
_this2.instance.removeEventListener('update-end', _this2.instanceOnUpdateEnd);
|
|
864
|
+
_this2.instance.removeEventListener('before-entity-update', _this2.instanceOnBeforeEntityUpdate);
|
|
865
|
+
_this2.instance.removeEventListener('after-entity-update', _this2.instanceOnAfterEntityUpdate);
|
|
866
|
+
if (_this2.inspector) {
|
|
867
|
+
_this2.inspector.detach();
|
|
868
|
+
}
|
|
869
|
+
_this2.map.dispose({
|
|
870
|
+
disposeLayers: true
|
|
871
|
+
});
|
|
872
|
+
Object.values(_this2.objectMap).forEach(function (object) {
|
|
873
|
+
_this2.instance.remove(object);
|
|
874
|
+
});
|
|
875
|
+
_this2.instance.dispose();
|
|
876
|
+
_this2.inspector = null;
|
|
877
|
+
_this2.map = null;
|
|
878
|
+
_this2.objectMap = {};
|
|
879
|
+
_this2.sceneObjectGroup = null;
|
|
880
|
+
_this2.instance = null;
|
|
881
|
+
_this2.setState(function (state) {
|
|
882
|
+
return {
|
|
883
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), Map3D.defaultSceneState)
|
|
884
|
+
};
|
|
885
|
+
});
|
|
886
|
+
_this2.props.setCurrentTask(null);
|
|
887
|
+
});
|
|
888
|
+
_defineProperty(_this2, "onUnload", function (key) {
|
|
889
|
+
// Ensure scene has not already been disposed
|
|
890
|
+
if (_this2.state.sceneId === key) {
|
|
891
|
+
_this2.disposeInstance();
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
_defineProperty(_this2, "setupControls", function (instance) {
|
|
895
|
+
_this2.setState(function (state) {
|
|
896
|
+
return {
|
|
897
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
898
|
+
setViewToExtent: instance === null || instance === void 0 ? void 0 : instance.setViewToExtent,
|
|
899
|
+
restoreView: instance === null || instance === void 0 ? void 0 : instance.restoreView
|
|
900
|
+
})
|
|
901
|
+
};
|
|
902
|
+
}, _this2.props.onMapInitialized);
|
|
903
|
+
});
|
|
904
|
+
_defineProperty(_this2, "getTerrainHeightFromDTM", function (scenePos) {
|
|
905
|
+
var returnArray = true;
|
|
906
|
+
if (!Array.isArray(scenePos[0])) {
|
|
907
|
+
returnArray = false;
|
|
908
|
+
scenePos = [scenePos];
|
|
909
|
+
}
|
|
910
|
+
var dtmPos = scenePos.map(function (p) {
|
|
911
|
+
return CoordinatesUtils.reproject(p, _this2.state.sceneContext.mapCrs, _this2.state.sceneContext.dtmCrs);
|
|
912
|
+
});
|
|
913
|
+
var dtmExt = [Infinity, Infinity, -Infinity, -Infinity];
|
|
914
|
+
dtmPos.forEach(function (p) {
|
|
915
|
+
dtmExt[0] = Math.min(dtmExt[0], p[0]);
|
|
916
|
+
dtmExt[1] = Math.min(dtmExt[1], p[1]);
|
|
917
|
+
dtmExt[2] = Math.max(dtmExt[2], p[0]);
|
|
918
|
+
dtmExt[3] = Math.max(dtmExt[3], p[1]);
|
|
919
|
+
});
|
|
920
|
+
return new Promise(function (resolve) {
|
|
921
|
+
if (!_this2.state.sceneContext.dtmUrl) {
|
|
922
|
+
resolve(returnArray ? scenePos.map(function (x) {
|
|
923
|
+
return 0;
|
|
924
|
+
}) : 0);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
fromUrl(_this2.state.sceneContext.dtmUrl).then(function (tiff) {
|
|
928
|
+
tiff.getImage().then(function (image) {
|
|
929
|
+
var _image$fileDirectory = image.fileDirectory,
|
|
930
|
+
ModelTiepoint = _image$fileDirectory.ModelTiepoint,
|
|
931
|
+
ModelPixelScale = _image$fileDirectory.ModelPixelScale;
|
|
932
|
+
|
|
933
|
+
// Extract scale and tiepoint values
|
|
934
|
+
var _ref18 = [ModelPixelScale[0], ModelPixelScale[1]],
|
|
935
|
+
scaleX = _ref18[0],
|
|
936
|
+
scaleY = _ref18[1];
|
|
937
|
+
var _ref19 = [ModelTiepoint[3], ModelTiepoint[4]],
|
|
938
|
+
tiepointX = _ref19[0],
|
|
939
|
+
tiepointY = _ref19[1]; // Tiepoint world coordinates
|
|
940
|
+
|
|
941
|
+
// Calculate pixel indices (rounded to nearest integers)
|
|
942
|
+
var minPixelX = Math.round((dtmExt[0] - tiepointX) / scaleX);
|
|
943
|
+
var minPixelY = Math.round((tiepointY - dtmExt[3]) / scaleY); // Inverted Y-axis in image
|
|
944
|
+
var maxPixelY = Math.round((tiepointY - dtmExt[1]) / scaleY) + 1; // Inverted Y-axis in image
|
|
945
|
+
var maxPixelX = Math.round((dtmExt[2] - tiepointX) / scaleX) + 1;
|
|
946
|
+
var width = maxPixelX - minPixelX;
|
|
947
|
+
var height = maxPixelY - minPixelY;
|
|
948
|
+
image.readRasters({
|
|
949
|
+
window: [minPixelX, minPixelY, maxPixelX, maxPixelY]
|
|
950
|
+
}).then(function (raster) {
|
|
951
|
+
if (!returnArray) {
|
|
952
|
+
resolve(raster[0][0]);
|
|
953
|
+
} else {
|
|
954
|
+
var h = dtmPos.map(function (p) {
|
|
955
|
+
var x = Math.round((p[0] - dtmExt[0]) / (dtmExt[2] - dtmExt[0]) * (width - 1));
|
|
956
|
+
var y = Math.round((1 - (p[1] - dtmExt[1]) / (dtmExt[3] - dtmExt[1])) * (height - 1));
|
|
957
|
+
return raster[0][x + y * width];
|
|
958
|
+
});
|
|
959
|
+
resolve(h);
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
_defineProperty(_this2, "getTerrainHeightFromMap", function (scenePos) {
|
|
967
|
+
var _elevationResult$samp;
|
|
968
|
+
var coordinates = new Coordinates(_this2.state.sceneContext.mapCrs, scenePos[0], scenePos[1], 0);
|
|
969
|
+
var elevationResult = _this2.state.sceneContext.map.getElevation({
|
|
970
|
+
coordinates: coordinates
|
|
971
|
+
});
|
|
972
|
+
// const raycaster = new Raycaster(new Vector3(scenePos[0], scenePos[1], 10000));
|
|
973
|
+
// const terrInter = raycaster.intersectObjects([this.map.object3d]).filter(result => result.object.children.length === 0)[0];
|
|
974
|
+
elevationResult.samples.sort(function (a, b) {
|
|
975
|
+
return a.resolution - b.resolution;
|
|
976
|
+
});
|
|
977
|
+
return (_elevationResult$samp = elevationResult.samples[0]) === null || _elevationResult$samp === void 0 ? void 0 : _elevationResult$samp.elevation;
|
|
978
|
+
});
|
|
979
|
+
_defineProperty(_this2, "getSceneIntersection", function (x, y) {
|
|
980
|
+
var objects = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
981
|
+
var raycaster = new Raycaster();
|
|
982
|
+
var camera = _this2.instance.view.camera;
|
|
983
|
+
raycaster.setFromCamera(new Vector2(x, y), camera);
|
|
984
|
+
// Query object intersection
|
|
985
|
+
var objInter = objects ? raycaster.intersectObjects(_this2.state.sceneContext.collisionObjects, true)[0] : undefined;
|
|
986
|
+
// Query highest resolution terrain tile (i.e. tile with no children)
|
|
987
|
+
var terrInter = raycaster.intersectObjects([_this2.map.object3d]).filter(function (result) {
|
|
988
|
+
return result.object.children.length === 0;
|
|
989
|
+
})[0];
|
|
990
|
+
// Return closest result
|
|
991
|
+
if (objInter && terrInter) {
|
|
992
|
+
return objInter.distance < terrInter.distance ? objInter : terrInter;
|
|
993
|
+
}
|
|
994
|
+
return objInter !== null && objInter !== void 0 ? objInter : terrInter;
|
|
995
|
+
});
|
|
996
|
+
_defineProperty(_this2, "getSetting", function (key) {
|
|
997
|
+
return _this2.state.sceneContext.settings[key];
|
|
998
|
+
});
|
|
999
|
+
_defineProperty(_this2, "setSetting", function (key, value) {
|
|
1000
|
+
_this2.setState(function (state) {
|
|
1001
|
+
return {
|
|
1002
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
1003
|
+
settings: _objectSpread(_objectSpread({}, state.sceneContext.settings), {}, _defineProperty({}, key, value))
|
|
1004
|
+
})
|
|
1005
|
+
};
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
_defineProperty(_this2, "redrawScene", function (ev) {
|
|
1009
|
+
var width = ev.target.innerWidth;
|
|
1010
|
+
var height = ev.target.innerHeight;
|
|
1011
|
+
_this2.instance.renderer.setSize(width, height);
|
|
1012
|
+
_this2.instance.view.camera.aspect = width / height;
|
|
1013
|
+
_this2.instance.view.camera.updateProjectionMatrix();
|
|
1014
|
+
_this2.instance.renderer.render(_this2.instance.scene, _this2.instance.view.camera);
|
|
1015
|
+
});
|
|
1016
|
+
_defineProperty(_this2, "setViewToExtent", function (bounds, rotation) {
|
|
1017
|
+
_this2.state.sceneContext.setViewToExtent(bounds, rotation);
|
|
1018
|
+
});
|
|
1019
|
+
_defineProperty(_this2, "store3dState", function () {
|
|
1020
|
+
var promises = Object.entries(_this2.state.sceneContext.sceneObjects).map(function (_ref20) {
|
|
1021
|
+
var _ref21 = _slicedToArray(_ref20, 2),
|
|
1022
|
+
objectId = _ref21[0],
|
|
1023
|
+
entry = _ref21[1];
|
|
1024
|
+
if (!entry.layertree) {
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
return new Promise(function (resolve) {
|
|
1028
|
+
var object = _this2.state.sceneContext.getSceneObject(objectId);
|
|
1029
|
+
if (entry.drawGroup) {
|
|
1030
|
+
var exporter = new GLTFExporter();
|
|
1031
|
+
exporter.parse(object, function (result) {
|
|
1032
|
+
resolve({
|
|
1033
|
+
id: objectId,
|
|
1034
|
+
options: entry,
|
|
1035
|
+
data: result
|
|
1036
|
+
});
|
|
1037
|
+
});
|
|
1038
|
+
} else if (entry.imported && object.tiles) {
|
|
1039
|
+
var container = object.tiles.group.parent;
|
|
1040
|
+
var tileset = {
|
|
1041
|
+
matrix: container.matrix.elements,
|
|
1042
|
+
label: container.userData.label,
|
|
1043
|
+
url: object.tiles.rootURL
|
|
1044
|
+
};
|
|
1045
|
+
resolve({
|
|
1046
|
+
id: objectId,
|
|
1047
|
+
options: entry,
|
|
1048
|
+
tileset: tileset
|
|
1049
|
+
});
|
|
1050
|
+
} else {
|
|
1051
|
+
resolve({
|
|
1052
|
+
id: objectId,
|
|
1053
|
+
options: entry
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
}).filter(Boolean);
|
|
1058
|
+
return new Promise(function (resolve) {
|
|
1059
|
+
Promise.all(promises).then(function (objects) {
|
|
1060
|
+
var _this2$state$sceneCon2, _this2$state$sceneCon3;
|
|
1061
|
+
var camera = _this2.state.sceneContext.scene.view.camera.position;
|
|
1062
|
+
var target = _this2.state.sceneContext.scene.view.controls.target;
|
|
1063
|
+
var layers = Object.entries(_this2.state.sceneContext.colorLayers).map(function (_ref22) {
|
|
1064
|
+
var _ref23 = _slicedToArray(_ref22, 2),
|
|
1065
|
+
layerId = _ref23[0],
|
|
1066
|
+
options = _ref23[1];
|
|
1067
|
+
return {
|
|
1068
|
+
id: layerId,
|
|
1069
|
+
options: {
|
|
1070
|
+
visibility: options.visibility,
|
|
1071
|
+
opacity: options.opacity,
|
|
1072
|
+
extrusionHeight: options.extrusionHeight
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
});
|
|
1076
|
+
resolve({
|
|
1077
|
+
objects: objects,
|
|
1078
|
+
colorLayers: layers,
|
|
1079
|
+
baseLayer: ((_this2$state$sceneCon2 = _this2.state.sceneContext.baseLayers.find(function (layer) {
|
|
1080
|
+
return layer.visibility === true;
|
|
1081
|
+
})) === null || _this2$state$sceneCon2 === void 0 ? void 0 : _this2$state$sceneCon2.name) || "",
|
|
1082
|
+
personHeight: (_this2$state$sceneCon3 = _this2.state.sceneContext.scene.view.controls.personHeight) !== null && _this2$state$sceneCon3 !== void 0 ? _this2$state$sceneCon3 : 0,
|
|
1083
|
+
camera: [camera.x, camera.y, camera.z],
|
|
1084
|
+
target: [target.x, target.y, target.z]
|
|
1085
|
+
});
|
|
1086
|
+
});
|
|
1087
|
+
});
|
|
1088
|
+
});
|
|
1089
|
+
_defineProperty(_this2, "restore3dState", function (data) {
|
|
1090
|
+
if (isEmpty(data)) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
(data.objects || []).forEach(function (item) {
|
|
1094
|
+
if (item.data) {
|
|
1095
|
+
var loader = new GLTFLoader();
|
|
1096
|
+
loader.parse(item.data, ConfigUtils.getAssetsPath(), function (gltf) {
|
|
1097
|
+
gltf.scene.traverse(function (c) {
|
|
1098
|
+
if (c.isMesh) {
|
|
1099
|
+
c.castShadow = true;
|
|
1100
|
+
c.receiveShadow = true;
|
|
1101
|
+
}
|
|
1102
|
+
updateObjectLabel(c, _this2.state.sceneContext);
|
|
1103
|
+
});
|
|
1104
|
+
_this2.state.sceneContext.addSceneObject(item.id, gltf.scene, item.options);
|
|
1105
|
+
});
|
|
1106
|
+
} else if (item.tileset) {
|
|
1107
|
+
_this2.add3dTiles(item.tileset.url, item.id, item.options, false, new Matrix4().fromArray(item.tileset.matrix), item.tileset.label);
|
|
1108
|
+
} else if (item.id in _this2.state.sceneContext.sceneObjects) {
|
|
1109
|
+
_this2.state.sceneContext.updateSceneObject(item.id, item.options);
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
(data.colorLayers || []).forEach(function (item) {
|
|
1113
|
+
if (item.id in _this2.state.sceneContext.colorLayers) {
|
|
1114
|
+
_this2.state.sceneContext.updateColorLayer(item.id, item.options);
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
_this2.state.sceneContext.restoreView(data);
|
|
1118
|
+
if (data.baseLayer !== undefined) {
|
|
1119
|
+
_this2.setState(function (state) {
|
|
1120
|
+
return {
|
|
1121
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
1122
|
+
baseLayers: state.sceneContext.baseLayers.map(function (l) {
|
|
1123
|
+
return _objectSpread(_objectSpread({}, l), {}, {
|
|
1124
|
+
visibility: l.name === data.baseLayer
|
|
1125
|
+
});
|
|
1126
|
+
})
|
|
1127
|
+
})
|
|
1128
|
+
};
|
|
1129
|
+
});
|
|
1130
|
+
UrlParams.updateParams({
|
|
1131
|
+
bl3d: data.baseLayer
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
_this2.state.sceneContext.scene.notifyChange();
|
|
1135
|
+
});
|
|
1136
|
+
_this2.container = null;
|
|
1137
|
+
_this2.inspector = null;
|
|
1138
|
+
_this2.instance = null;
|
|
1139
|
+
_this2.map = null;
|
|
1140
|
+
_this2.sceneObjectGroup = null;
|
|
1141
|
+
_this2.objectMap = {};
|
|
1142
|
+
_this2.tilesetStyles = {};
|
|
1143
|
+
_this2.state.sceneContext.addLayer = _this2.addLayer;
|
|
1144
|
+
_this2.state.sceneContext.getLayer = _this2.getLayer;
|
|
1145
|
+
_this2.state.sceneContext.removeLayer = _this2.removeLayer;
|
|
1146
|
+
_this2.state.sceneContext.updateColorLayer = _this2.updateColorLayer;
|
|
1147
|
+
_this2.state.sceneContext.setBaseLayer = _this2.setBaseLayer;
|
|
1148
|
+
_this2.state.sceneContext.add3dTiles = _this2.add3dTiles;
|
|
1149
|
+
_this2.state.sceneContext.addSceneObject = _this2.addSceneObject;
|
|
1150
|
+
_this2.state.sceneContext.getSceneObject = _this2.getSceneObject;
|
|
1151
|
+
_this2.state.sceneContext.removeSceneObject = _this2.removeSceneObject;
|
|
1152
|
+
_this2.state.sceneContext.updateSceneObject = _this2.updateSceneObject;
|
|
1153
|
+
_this2.state.sceneContext.zoomToObject = _this2.zoomToObject;
|
|
1154
|
+
_this2.state.sceneContext.getMap = _this2.getMap;
|
|
1155
|
+
_this2.state.sceneContext.getTerrainHeightFromDTM = _this2.getTerrainHeightFromDTM;
|
|
1156
|
+
_this2.state.sceneContext.getTerrainHeightFromMap = _this2.getTerrainHeightFromMap;
|
|
1157
|
+
_this2.state.sceneContext.getSceneIntersection = _this2.getSceneIntersection;
|
|
1158
|
+
_this2.state.sceneContext.getSetting = _this2.getSetting;
|
|
1159
|
+
_this2.state.sceneContext.setSetting = _this2.setSetting;
|
|
1160
|
+
_this2.state.sceneContext.settings.sceneQuality = props.defaultSceneQuality;
|
|
1161
|
+
registerPermalinkDataStoreHook("map3d", _this2.store3dState);
|
|
1162
|
+
return _this2;
|
|
1163
|
+
}
|
|
1164
|
+
_inherits(Map3D, _React$Component2);
|
|
1165
|
+
return _createClass(Map3D, [{
|
|
1166
|
+
key: "componentDidMount",
|
|
1167
|
+
value: function componentDidMount() {
|
|
1168
|
+
this.props.innerRef(this);
|
|
1169
|
+
}
|
|
1170
|
+
}, {
|
|
1171
|
+
key: "componentWillUnmount",
|
|
1172
|
+
value: function componentWillUnmount() {
|
|
1173
|
+
unregisterPermalinkDataStoreHook("map3d");
|
|
1174
|
+
}
|
|
1175
|
+
}, {
|
|
1176
|
+
key: "componentDidUpdate",
|
|
1177
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
1178
|
+
var _this3 = this;
|
|
1179
|
+
if (this.props.theme !== prevProps.theme) {
|
|
1180
|
+
this.setupInstance();
|
|
1181
|
+
} else if (this.props.layers !== prevProps.layers) {
|
|
1182
|
+
this.setState(function (state) {
|
|
1183
|
+
return {
|
|
1184
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
1185
|
+
colorLayers: _this3.collectColorLayers(state.sceneContext.colorLayers, prevProps.layers)
|
|
1186
|
+
})
|
|
1187
|
+
};
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
// Update map layers
|
|
1192
|
+
if (this.state.sceneContext.baseLayers !== prevState.sceneContext.baseLayers) {
|
|
1193
|
+
this.applyBaseLayer();
|
|
1194
|
+
}
|
|
1195
|
+
if (this.state.sceneContext.colorLayers !== prevState.sceneContext.colorLayers) {
|
|
1196
|
+
this.applyColorLayerUpdates(this.state.sceneContext.colorLayers, prevState.sceneContext.colorLayers);
|
|
1197
|
+
}
|
|
1198
|
+
// Update scene objects
|
|
1199
|
+
if (this.state.sceneContext.sceneObjects !== prevState.sceneContext.sceneObjects) {
|
|
1200
|
+
this.applySceneObjectUpdates(this.state.sceneContext.sceneObjects, prevState.sceneContext.sceneObjects);
|
|
1201
|
+
|
|
1202
|
+
// Update collision objects
|
|
1203
|
+
this.setState(function (state) {
|
|
1204
|
+
return {
|
|
1205
|
+
sceneContext: _objectSpread(_objectSpread({}, state.sceneContext), {}, {
|
|
1206
|
+
collisionObjects: Object.entries(state.sceneContext.sceneObjects).map(function (_ref24) {
|
|
1207
|
+
var _ref25 = _slicedToArray(_ref24, 2),
|
|
1208
|
+
objId = _ref25[0],
|
|
1209
|
+
options = _ref25[1];
|
|
1210
|
+
if (options.layertree && options.visibility) {
|
|
1211
|
+
var _obj$tiles$group, _obj$tiles;
|
|
1212
|
+
var obj = _this3.objectMap[objId];
|
|
1213
|
+
return (_obj$tiles$group = (_obj$tiles = obj.tiles) === null || _obj$tiles === void 0 ? void 0 : _obj$tiles.group) !== null && _obj$tiles$group !== void 0 ? _obj$tiles$group : obj;
|
|
1214
|
+
}
|
|
1215
|
+
return null;
|
|
1216
|
+
}).filter(Boolean)
|
|
1217
|
+
})
|
|
1218
|
+
};
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
if (this.state.sceneContext.settings.sceneQuality !== prevState.sceneContext.settings.sceneQuality) {
|
|
1222
|
+
var quality = Math.max(20, this.state.sceneContext.settings.sceneQuality);
|
|
1223
|
+
this.map.segments = Math.pow(2, Math.floor(quality / 20));
|
|
1224
|
+
this.instance.notifyChange(this.instance.view.camera);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}, {
|
|
1228
|
+
key: "render",
|
|
1229
|
+
value: function render() {
|
|
1230
|
+
var _this4 = this;
|
|
1231
|
+
return [/*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement("div", {
|
|
1232
|
+
className: "map3d-map",
|
|
1233
|
+
id: "map3d",
|
|
1234
|
+
key: "Map3D",
|
|
1235
|
+
ref: this.setupContainer
|
|
1236
|
+
}), this.context), this.state.sceneContext.scene ? /*#__PURE__*/React.createElement(UnloadWrapper, {
|
|
1237
|
+
key: this.state.sceneId,
|
|
1238
|
+
onUnload: this.onUnload,
|
|
1239
|
+
sceneId: this.state.sceneId
|
|
1240
|
+
}, /*#__PURE__*/React.createElement(MapControls3D, {
|
|
1241
|
+
controlsPosition: this.props.controlsPosition,
|
|
1242
|
+
mouseButtons: this.props.mouseButtons,
|
|
1243
|
+
onCameraChanged: this.props.onCameraChanged,
|
|
1244
|
+
onControlsSet: this.setupControls,
|
|
1245
|
+
sceneContext: this.state.sceneContext
|
|
1246
|
+
}, /*#__PURE__*/React.createElement(EditDataset3D, {
|
|
1247
|
+
sceneContext: this.state.sceneContext
|
|
1248
|
+
}), /*#__PURE__*/React.createElement(View3DSwitcher, {
|
|
1249
|
+
position: 1
|
|
1250
|
+
}), Object.entries(this.props.plugins3d).map(function (_ref26) {
|
|
1251
|
+
var _ref27 = _slicedToArray(_ref26, 2),
|
|
1252
|
+
name = _ref27[0],
|
|
1253
|
+
Component = _ref27[1];
|
|
1254
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
1255
|
+
key: name
|
|
1256
|
+
}, /*#__PURE__*/React.createElement(Component, _extends({
|
|
1257
|
+
sceneContext: _this4.state.sceneContext
|
|
1258
|
+
}, _this4.props.pluginOptions[name])));
|
|
1259
|
+
}))) : null];
|
|
1260
|
+
}
|
|
1261
|
+
}]);
|
|
1262
|
+
}(React.Component);
|
|
1263
|
+
_defineProperty(Map3D, "contextType", MapContainerPortalContext);
|
|
1264
|
+
_defineProperty(Map3D, "propTypes", {
|
|
1265
|
+
controlsPosition: PropTypes.string,
|
|
1266
|
+
defaultSceneQuality: PropTypes.number,
|
|
1267
|
+
innerRef: PropTypes.func,
|
|
1268
|
+
layers: PropTypes.array,
|
|
1269
|
+
mouseButtons: PropTypes.object,
|
|
1270
|
+
onCameraChanged: PropTypes.func,
|
|
1271
|
+
onMapInitialized: PropTypes.func,
|
|
1272
|
+
pluginOptions: PropTypes.object,
|
|
1273
|
+
plugins3d: PropTypes.object,
|
|
1274
|
+
setCurrentTask: PropTypes.func,
|
|
1275
|
+
theme: PropTypes.object,
|
|
1276
|
+
themes: PropTypes.object
|
|
1277
|
+
});
|
|
1278
|
+
_defineProperty(Map3D, "defaultProps", {
|
|
1279
|
+
geometry: {
|
|
1280
|
+
initialWidth: 600,
|
|
1281
|
+
initialHeight: 800,
|
|
1282
|
+
initialX: 0,
|
|
1283
|
+
initialY: 0,
|
|
1284
|
+
initiallyDocked: true
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
_defineProperty(Map3D, "defaultSceneState", {
|
|
1288
|
+
scene: null,
|
|
1289
|
+
map: null,
|
|
1290
|
+
mapCrs: null,
|
|
1291
|
+
dtmUrl: null,
|
|
1292
|
+
dtmCrs: null,
|
|
1293
|
+
baseLayers: [],
|
|
1294
|
+
colorLayers: {},
|
|
1295
|
+
sceneObjects: {},
|
|
1296
|
+
collisionObjects: [],
|
|
1297
|
+
settings: {
|
|
1298
|
+
sceneQuality: 100
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
export default connect(function (state) {
|
|
1302
|
+
return {
|
|
1303
|
+
theme: state.theme.current,
|
|
1304
|
+
themes: state.theme.themes,
|
|
1305
|
+
layers: state.layers.flat
|
|
1306
|
+
};
|
|
1307
|
+
}, {
|
|
1308
|
+
setCurrentTask: setCurrentTask
|
|
1309
|
+
})(Map3D);
|