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,11 +1,558 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
5
|
+
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); } }
|
|
6
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
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); }
|
|
9
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
12
|
+
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); }
|
|
13
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
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); }
|
|
17
|
+
/**
|
|
2
18
|
* Copyright 2024 Sourcepole AG
|
|
3
19
|
* All rights reserved.
|
|
4
20
|
*
|
|
5
21
|
* This source code is licensed under the BSD-style license found in the
|
|
6
22
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/import React from"react";import Sun from"@giro3d/giro3d/core/geographic/Sun.js";import{MapLightingMode}from"@giro3d/giro3d/entities/MapLightingOptions";import PropTypes from"prop-types";import suncalc from"suncalc";import{AmbientLight,BasicShadowMap,CameraHelper,DirectionalLight,DirectionalLightHelper,PCFShadowMap,PCFSoftShadowMap,VSMShadowMap}from"three";import Icon from"../../components/Icon";import SideBar from"../../components/SideBar";import Input from"../../components/widgets/Input";import NumberInput from"../../components/widgets/NumberInput";import ToggleSwitch from"../../components/widgets/ToggleSwitch";import CoordinatesUtils from"../../utils/CoordinatesUtils";import LocaleUtils from"../../utils/LocaleUtils";import"./style/MapLight3D.css";var MapLight3D=/*#__PURE__*/function(_React$Component){function MapLight3D(props){var _this;_classCallCheck(this,MapLight3D);_this=_callSuper(this,MapLight3D,[props]);_defineProperty(_this,"state",{showAdvanced:false,lightParams:{day:182,time:720,helpersVisible:false,moonLightIntensity:0.02,sunLightIntensity:3.5,zFactor:1,lightElevationLayersOnly:false,shadowsEnabled:true,shadowType:PCFShadowMap,shadowMapSize:4096,shadowBias:-0.0001,sunDistance:80000,normalBias:0,shadowIntensity:1,shadowVolumeNear:60000,shadowVolumeFar:100000},dayAnimation:false,dayAnimationSettings:false,dayStep:30,timeAnimation:false,timeAnimationSettings:false,timeStep:30});_defineProperty(_this,"onHide",function(){clearInterval(_this.animationInterval);_this.setState({dayAnimation:false,timeAnimation:false})});_defineProperty(_this,"renderBody",function(){var lightParams=_this.state.lightParams;var dateValue=new Date(new Date().getFullYear(),0,1+lightParams.day).toISOString().split("T")[0];var dateToDay=function dateToDay(date){var d=new Date(date);return 1+(d-new Date(Date.UTC(d.getUTCFullYear(),0,1)))/(1000*60*60*24)};var isLeapYear=function isLeapYear(year){return new Date(year,1,29).getDate()===29};var timeValue="".concat(String(Math.trunc(lightParams.time/60)).padStart(2,"0"),":").concat(String(Math.floor(lightParams.time%60)).padStart(2,"0"));var timeToMin=function timeToMin(time){var parts=time.split(":");return parseInt(parts[0],10)*60+parseInt(parts[1],10)};return/*#__PURE__*/React.createElement("div",{className:"maplight3d-body"},/*#__PURE__*/React.createElement("table",null,/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.date")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("div",{className:"map3d-animation-slider"},/*#__PURE__*/React.createElement(Icon,{icon:_this.state.dayAnimation?"square":"triangle-right",onClick:_this.toggleDayAnimation}),/*#__PURE__*/React.createElement("div",{className:"maplight3d-slider"},/*#__PURE__*/React.createElement("input",{max:365+isLeapYear(),min:1,onChange:function onChange(ev){return _this.updateLightParams("day",parseInt(ev.target.value,10))},step:1,type:"range",value:lightParams.day}),/*#__PURE__*/React.createElement(Input,{allowEmpty:false,onChange:function onChange(value){return _this.updateLightParams("day",dateToDay(value))},type:"date",value:dateValue})),/*#__PURE__*/React.createElement(Icon,{className:_this.state.dayAnimationSettings?"map3d-animation-settings-active":"",icon:"cog",onClick:function onClick(){return _this.setState(function(state){return{dayAnimationSettings:!state.dayAnimationSettings}})}})))),_this.state.dayAnimationSettings?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("div",{className:"maplight3d-animation-settings"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("maplight3d.animationstep"),":"),/*#__PURE__*/React.createElement(NumberInput,{max:60,min:1,onChange:function onChange(dayStep){return _this.setState({dayStep:dayStep})},suffix:" "+LocaleUtils.tr("maplight3d.dayspersec"),value:_this.state.dayStep})))):null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.time")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("div",{className:"map3d-animation-slider"},/*#__PURE__*/React.createElement(Icon,{icon:_this.state.timeAnimation?"square":"triangle-right",onClick:_this.toggleTimeAnimation}),/*#__PURE__*/React.createElement("div",{className:"maplight3d-slider"},/*#__PURE__*/React.createElement("input",{max:1439,min:0,onChange:function onChange(ev){return _this.updateLightParams("time",parseInt(ev.target.value,10))},step:1,type:"range",value:lightParams.time}),/*#__PURE__*/React.createElement(Input,{allowEmpty:false,onChange:function onChange(value){return _this.updateLightParams("time",timeToMin(value))},type:"time",value:timeValue})),/*#__PURE__*/React.createElement(Icon,{className:_this.state.timeAnimationSettings?"map3d-animation-settings-active":"",icon:"cog",onClick:function onClick(){return _this.setState(function(state){return{timeAnimationSettings:!state.timeAnimationSettings}})}})))),_this.state.timeAnimationSettings?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("div",{className:"maplight3d-animation-settings"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("maplight3d.animationstep"),":"),/*#__PURE__*/React.createElement(NumberInput,{max:60,min:1,onChange:function onChange(timeStep){return _this.setState({timeStep:timeStep})},suffix:" "+LocaleUtils.tr("maplight3d.minspersec"),value:_this.state.timeStep})))):null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.sunLightIntensity")),/*#__PURE__*/React.createElement("td",null,_this.renderSlider("sunLightIntensity",0,10,0.1))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.moonLightIntensity")),/*#__PURE__*/React.createElement("td",null,_this.renderSlider("moonLightIntensity",0,0.5,0.01))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadows")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:lightParams.shadowsEnabled,onChange:function onChange(value){return _this.updateLightParams("shadowsEnabled",value)}}))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadowintensity")),/*#__PURE__*/React.createElement("td",null,_this.renderSlider("shadowIntensity",0,2,0.1))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",{className:"maplight3d-advanced",colSpan:"2"},/*#__PURE__*/React.createElement("label",null,/*#__PURE__*/React.createElement("input",{checked:_this.state.showAdvanced,onChange:function onChange(ev){return _this.setState(function(state){return{showAdvanced:!state.showAdvanced}})},type:"checkbox"})," ",LocaleUtils.tr("maplight3d.showadvanced")))),_this.state.showAdvanced?[/*#__PURE__*/React.createElement("tr",{key:"helpersVisible"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.helpersVisible")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:lightParams.helpersVisible,onChange:function onChange(value){return _this.updateLightParams("helpersVisible",value)}}))),/*#__PURE__*/React.createElement("tr",{key:"zFactor"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.zFactor")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("input",{max:10,min:0,onChange:function onChange(ev){return _this.updateLightParams("zFactor",ev.target.value)},step:0.1,type:"range",value:lightParams.zFactor}))),/*#__PURE__*/React.createElement("tr",{key:"shadowType"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadowType")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.updateLightParams("shadowType",parseInt(ev.target.value,10))},value:lightParams.shadowType},/*#__PURE__*/React.createElement("option",{value:BasicShadowMap},"BasicShadowMap"),/*#__PURE__*/React.createElement("option",{value:PCFShadowMap},"PCFShadowMap"),/*#__PURE__*/React.createElement("option",{value:PCFSoftShadowMap},"PCFSoftShadowMap"),/*#__PURE__*/React.createElement("option",{value:VSMShadowMap},"VSMShadowMap")))),/*#__PURE__*/React.createElement("tr",{key:"shadowMapSize"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadowMapSize")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{decimals:0,max:8192,min:64,onChange:function onChange(value){return _this.updateLightParams("shadowMapSize",value)},value:lightParams.shadowMapSize}))),/*#__PURE__*/React.createElement("tr",{key:"shadowBias"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadowBias")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{decimals:5,max:0.01,min:-0.01,onChange:function onChange(value){return _this.updateLightParams("shadowBias",value)},value:lightParams.shadowBias}))),/*#__PURE__*/React.createElement("tr",{key:"normalBias"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.normalBias")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{decimals:1,max:10,min:-10,onChange:function onChange(value){return _this.updateLightParams("normalBias",value)},value:lightParams.normalBias}))),/*#__PURE__*/React.createElement("tr",{key:"shadowVolumeNear"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadowVolumeNear")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{decimals:0,max:100000,min:100,onChange:function onChange(value){return _this.updateLightParams("shadowVolumeNear",value)},value:lightParams.shadowVolumeNear}))),/*#__PURE__*/React.createElement("tr",{key:"shadowVolumeFar"},/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("maplight3d.shadowVolumeFar")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(NumberInput,{decimals:0,max:100000,min:100,onChange:function onChange(value){return _this.updateLightParams("shadowVolumeFar",value)},value:lightParams.shadowVolumeFar})))]:null)))});_defineProperty(_this,"toggleDayAnimation",function(){_this.setState(function(state){return{dayAnimation:!state.dayAnimation,timeAnimation:false}},function(){clearInterval(_this.animationInterval);if(_this.state.dayAnimation){_this.animationInterval=setInterval(function(){_this.updateLightParams("day",(_this.state.lightParams.day+_this.state.dayStep/10)%365)},100)}})});_defineProperty(_this,"toggleTimeAnimation",function(){_this.setState(function(state){return{timeAnimation:!state.timeAnimation,dayAnimation:false}},function(){clearInterval(_this.animationInterval);if(_this.state.timeAnimation){_this.animationInterval=setInterval(function(){_this.updateLightParams("time",(_this.state.lightParams.time+_this.state.timeStep/10)%1440)},100)}})});_defineProperty(_this,"renderSlider",function(key,min,max,step){var labelFormatter=arguments.length>4&&arguments[4]!==undefined?arguments[4]:undefined;var value=_this.state.lightParams[key];var parseValue=function parseValue(x){return Number.isInteger(step)?parseInt(x,10):parseFloat(x)};labelFormatter=labelFormatter!==null&&labelFormatter!==void 0?labelFormatter:function(x){return x.toFixed(-Math.log10(step))};return/*#__PURE__*/React.createElement("div",{className:"maplight3d-slider"},/*#__PURE__*/React.createElement("input",{max:max,min:min,onChange:function onChange(ev){return _this.updateLightParams(key,parseValue(ev.target.value))},step:step,type:"range",value:value}),/*#__PURE__*/React.createElement("div",{className:"maplight3d-slider-label"},/*#__PURE__*/React.createElement("span",{style:{left:(value-min)*100/(max-min)+"%"}},labelFormatter(value))))});_defineProperty(_this,"updateLightParams",function(key,value){_this.setState(function(state){return{lightParams:_objectSpread(_objectSpread({},state.lightParams),{},_defineProperty({},key,value))}})});_defineProperty(_this,"configureShadows",function(sunLight,lightParams,shadowIntensityK){if(!lightParams.shadowsEnabled){_this.props.sceneContext.scene.renderer.shadowMap.enabled=false;sunLight.castShadow=false;return}var cameraHeight=_this.props.sceneContext.scene.view.camera.position.z;var targetHeight=_this.props.sceneContext.scene.view.controls.target.z;var volumeSize=Math.min(20000,Math.max(1000,cameraHeight-targetHeight));sunLight.shadow.camera.top=volumeSize;sunLight.shadow.camera.bottom=-volumeSize;sunLight.shadow.camera.left=-volumeSize;sunLight.shadow.camera.right=volumeSize;sunLight.shadow.camera.near=lightParams.shadowVolumeNear;sunLight.shadow.camera.far=lightParams.shadowVolumeFar;sunLight.shadow.camera.updateProjectionMatrix();sunLight.shadow.mapSize.set(lightParams.shadowMapSize,lightParams.shadowMapSize);sunLight.shadow.bias=lightParams.shadowBias;sunLight.shadow.normalBias=lightParams.normalBias;sunLight.shadow.intensity=lightParams.shadowIntensity*shadowIntensityK;_this.props.sceneContext.scene.renderer.shadowMap.enabled=true;sunLight.castShadow=true});_defineProperty(_this,"setLighting",function(){var sceneContext=_this.props.sceneContext;var lightParams=_this.state.lightParams;var ambientLight=sceneContext.getSceneObject("__ambientLight");var sunLight=sceneContext.getSceneObject("__sunLight");var moonLight=sceneContext.getSceneObject("__moonLight");var lightTarget=sceneContext.scene.view.controls.target.clone();lightTarget.z=0;// Compute azimuth / zenith and sun position
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import Sun from '@giro3d/giro3d/core/geographic/Sun.js';
|
|
27
|
+
import { MapLightingMode } from '@giro3d/giro3d/entities/MapLightingOptions';
|
|
28
|
+
import PropTypes from 'prop-types';
|
|
29
|
+
import suncalc from 'suncalc';
|
|
30
|
+
import { AmbientLight, BasicShadowMap, CameraHelper, DirectionalLight, DirectionalLightHelper, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap } from 'three';
|
|
31
|
+
import Icon from '../../components/Icon';
|
|
32
|
+
import SideBar from '../../components/SideBar';
|
|
33
|
+
import Input from '../../components/widgets/Input';
|
|
34
|
+
import NumberInput from '../../components/widgets/NumberInput';
|
|
35
|
+
import ToggleSwitch from '../../components/widgets/ToggleSwitch';
|
|
36
|
+
import CoordinatesUtils from '../../utils/CoordinatesUtils';
|
|
37
|
+
import LocaleUtils from '../../utils/LocaleUtils';
|
|
38
|
+
import './style/MapLight3D.css';
|
|
39
|
+
var MapLight3D = /*#__PURE__*/function (_React$Component) {
|
|
40
|
+
function MapLight3D(props) {
|
|
41
|
+
var _this;
|
|
42
|
+
_classCallCheck(this, MapLight3D);
|
|
43
|
+
_this = _callSuper(this, MapLight3D, [props]);
|
|
44
|
+
_defineProperty(_this, "state", {
|
|
45
|
+
showAdvanced: false,
|
|
46
|
+
lightParams: {
|
|
47
|
+
day: 182,
|
|
48
|
+
time: 720,
|
|
49
|
+
helpersVisible: false,
|
|
50
|
+
moonLightIntensity: 0.02,
|
|
51
|
+
sunLightIntensity: 3.5,
|
|
52
|
+
zFactor: 1,
|
|
53
|
+
lightElevationLayersOnly: false,
|
|
54
|
+
shadowsEnabled: true,
|
|
55
|
+
shadowType: PCFShadowMap,
|
|
56
|
+
shadowMapSize: 4096,
|
|
57
|
+
shadowBias: -0.0001,
|
|
58
|
+
sunDistance: 80000,
|
|
59
|
+
normalBias: 0,
|
|
60
|
+
shadowIntensity: 1.0,
|
|
61
|
+
shadowVolumeNear: 60000,
|
|
62
|
+
shadowVolumeFar: 100000
|
|
63
|
+
},
|
|
64
|
+
dayAnimation: false,
|
|
65
|
+
dayAnimationSettings: false,
|
|
66
|
+
dayStep: 30,
|
|
67
|
+
timeAnimation: false,
|
|
68
|
+
timeAnimationSettings: false,
|
|
69
|
+
timeStep: 30
|
|
70
|
+
});
|
|
71
|
+
_defineProperty(_this, "onHide", function () {
|
|
72
|
+
clearInterval(_this.animationInterval);
|
|
73
|
+
_this.setState({
|
|
74
|
+
dayAnimation: false,
|
|
75
|
+
timeAnimation: false
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
_defineProperty(_this, "renderBody", function () {
|
|
79
|
+
var lightParams = _this.state.lightParams;
|
|
80
|
+
var dateValue = new Date(new Date().getFullYear(), 0, 1 + lightParams.day).toISOString().split("T")[0];
|
|
81
|
+
var dateToDay = function dateToDay(date) {
|
|
82
|
+
var d = new Date(date);
|
|
83
|
+
return 1 + (d - new Date(Date.UTC(d.getUTCFullYear(), 0, 1))) / (1000 * 60 * 60 * 24);
|
|
84
|
+
};
|
|
85
|
+
var isLeapYear = function isLeapYear(year) {
|
|
86
|
+
return new Date(year, 1, 29).getDate() === 29;
|
|
87
|
+
};
|
|
88
|
+
var timeValue = "".concat(String(Math.trunc(lightParams.time / 60)).padStart(2, '0'), ":").concat(String(Math.floor(lightParams.time % 60)).padStart(2, '0'));
|
|
89
|
+
var timeToMin = function timeToMin(time) {
|
|
90
|
+
var parts = time.split(":");
|
|
91
|
+
return parseInt(parts[0], 10) * 60 + parseInt(parts[1], 10);
|
|
92
|
+
};
|
|
93
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "maplight3d-body"
|
|
95
|
+
}, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.date")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: "map3d-animation-slider"
|
|
97
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
98
|
+
icon: _this.state.dayAnimation ? "square" : "triangle-right",
|
|
99
|
+
onClick: _this.toggleDayAnimation
|
|
100
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
className: "maplight3d-slider"
|
|
102
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
103
|
+
max: 365 + isLeapYear(),
|
|
104
|
+
min: 1,
|
|
105
|
+
onChange: function onChange(ev) {
|
|
106
|
+
return _this.updateLightParams("day", parseInt(ev.target.value, 10));
|
|
107
|
+
},
|
|
108
|
+
step: 1,
|
|
109
|
+
type: "range",
|
|
110
|
+
value: lightParams.day
|
|
111
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
112
|
+
allowEmpty: false,
|
|
113
|
+
onChange: function onChange(value) {
|
|
114
|
+
return _this.updateLightParams("day", dateToDay(value));
|
|
115
|
+
},
|
|
116
|
+
type: "date",
|
|
117
|
+
value: dateValue
|
|
118
|
+
})), /*#__PURE__*/React.createElement(Icon, {
|
|
119
|
+
className: _this.state.dayAnimationSettings ? "map3d-animation-settings-active" : "",
|
|
120
|
+
icon: "cog",
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
return _this.setState(function (state) {
|
|
123
|
+
return {
|
|
124
|
+
dayAnimationSettings: !state.dayAnimationSettings
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
})))), _this.state.dayAnimationSettings ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
129
|
+
colSpan: "2"
|
|
130
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: "maplight3d-animation-settings"
|
|
132
|
+
}, /*#__PURE__*/React.createElement("span", null, LocaleUtils.tr("maplight3d.animationstep"), ":"), /*#__PURE__*/React.createElement(NumberInput, {
|
|
133
|
+
max: 60,
|
|
134
|
+
min: 1,
|
|
135
|
+
onChange: function onChange(dayStep) {
|
|
136
|
+
return _this.setState({
|
|
137
|
+
dayStep: dayStep
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
suffix: " " + LocaleUtils.tr("maplight3d.dayspersec"),
|
|
141
|
+
value: _this.state.dayStep
|
|
142
|
+
})))) : null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.time")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
className: "map3d-animation-slider"
|
|
144
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
145
|
+
icon: _this.state.timeAnimation ? "square" : "triangle-right",
|
|
146
|
+
onClick: _this.toggleTimeAnimation
|
|
147
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
148
|
+
className: "maplight3d-slider"
|
|
149
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
150
|
+
max: 1439,
|
|
151
|
+
min: 0,
|
|
152
|
+
onChange: function onChange(ev) {
|
|
153
|
+
return _this.updateLightParams("time", parseInt(ev.target.value, 10));
|
|
154
|
+
},
|
|
155
|
+
step: 1,
|
|
156
|
+
type: "range",
|
|
157
|
+
value: lightParams.time
|
|
158
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
159
|
+
allowEmpty: false,
|
|
160
|
+
onChange: function onChange(value) {
|
|
161
|
+
return _this.updateLightParams("time", timeToMin(value));
|
|
162
|
+
},
|
|
163
|
+
type: "time",
|
|
164
|
+
value: timeValue
|
|
165
|
+
})), /*#__PURE__*/React.createElement(Icon, {
|
|
166
|
+
className: _this.state.timeAnimationSettings ? "map3d-animation-settings-active" : "",
|
|
167
|
+
icon: "cog",
|
|
168
|
+
onClick: function onClick() {
|
|
169
|
+
return _this.setState(function (state) {
|
|
170
|
+
return {
|
|
171
|
+
timeAnimationSettings: !state.timeAnimationSettings
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
})))), _this.state.timeAnimationSettings ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
176
|
+
colSpan: "2"
|
|
177
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: "maplight3d-animation-settings"
|
|
179
|
+
}, /*#__PURE__*/React.createElement("span", null, LocaleUtils.tr("maplight3d.animationstep"), ":"), /*#__PURE__*/React.createElement(NumberInput, {
|
|
180
|
+
max: 60,
|
|
181
|
+
min: 1,
|
|
182
|
+
onChange: function onChange(timeStep) {
|
|
183
|
+
return _this.setState({
|
|
184
|
+
timeStep: timeStep
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
suffix: " " + LocaleUtils.tr("maplight3d.minspersec"),
|
|
188
|
+
value: _this.state.timeStep
|
|
189
|
+
})))) : null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.sunLightIntensity")), /*#__PURE__*/React.createElement("td", null, _this.renderSlider('sunLightIntensity', 0, 10, 0.1))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.moonLightIntensity")), /*#__PURE__*/React.createElement("td", null, _this.renderSlider('moonLightIntensity', 0, 0.5, 0.01))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadows")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
190
|
+
active: lightParams.shadowsEnabled,
|
|
191
|
+
onChange: function onChange(value) {
|
|
192
|
+
return _this.updateLightParams('shadowsEnabled', value);
|
|
193
|
+
}
|
|
194
|
+
}))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadowintensity")), /*#__PURE__*/React.createElement("td", null, _this.renderSlider('shadowIntensity', 0, 2, 0.1))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
195
|
+
className: "maplight3d-advanced",
|
|
196
|
+
colSpan: "2"
|
|
197
|
+
}, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
|
|
198
|
+
checked: _this.state.showAdvanced,
|
|
199
|
+
onChange: function onChange(ev) {
|
|
200
|
+
return _this.setState(function (state) {
|
|
201
|
+
return {
|
|
202
|
+
showAdvanced: !state.showAdvanced
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
type: "checkbox"
|
|
207
|
+
}), " ", LocaleUtils.tr("maplight3d.showadvanced")))), _this.state.showAdvanced ? [/*#__PURE__*/React.createElement("tr", {
|
|
208
|
+
key: "helpersVisible"
|
|
209
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.helpersVisible")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
210
|
+
active: lightParams.helpersVisible,
|
|
211
|
+
onChange: function onChange(value) {
|
|
212
|
+
return _this.updateLightParams('helpersVisible', value);
|
|
213
|
+
}
|
|
214
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
215
|
+
key: "zFactor"
|
|
216
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.zFactor")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", {
|
|
217
|
+
max: 10,
|
|
218
|
+
min: 0,
|
|
219
|
+
onChange: function onChange(ev) {
|
|
220
|
+
return _this.updateLightParams('zFactor', ev.target.value);
|
|
221
|
+
},
|
|
222
|
+
step: 0.1,
|
|
223
|
+
type: "range",
|
|
224
|
+
value: lightParams.zFactor
|
|
225
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
226
|
+
key: "shadowType"
|
|
227
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadowType")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", {
|
|
228
|
+
onChange: function onChange(ev) {
|
|
229
|
+
return _this.updateLightParams('shadowType', parseInt(ev.target.value, 10));
|
|
230
|
+
},
|
|
231
|
+
value: lightParams.shadowType
|
|
232
|
+
}, /*#__PURE__*/React.createElement("option", {
|
|
233
|
+
value: BasicShadowMap
|
|
234
|
+
}, "BasicShadowMap"), /*#__PURE__*/React.createElement("option", {
|
|
235
|
+
value: PCFShadowMap
|
|
236
|
+
}, "PCFShadowMap"), /*#__PURE__*/React.createElement("option", {
|
|
237
|
+
value: PCFSoftShadowMap
|
|
238
|
+
}, "PCFSoftShadowMap"), /*#__PURE__*/React.createElement("option", {
|
|
239
|
+
value: VSMShadowMap
|
|
240
|
+
}, "VSMShadowMap")))), /*#__PURE__*/React.createElement("tr", {
|
|
241
|
+
key: "shadowMapSize"
|
|
242
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadowMapSize")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(NumberInput, {
|
|
243
|
+
decimals: 0,
|
|
244
|
+
max: 8192,
|
|
245
|
+
min: 64,
|
|
246
|
+
onChange: function onChange(value) {
|
|
247
|
+
return _this.updateLightParams('shadowMapSize', value);
|
|
248
|
+
},
|
|
249
|
+
value: lightParams.shadowMapSize
|
|
250
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
251
|
+
key: "shadowBias"
|
|
252
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadowBias")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(NumberInput, {
|
|
253
|
+
decimals: 5,
|
|
254
|
+
max: 0.01,
|
|
255
|
+
min: -0.01,
|
|
256
|
+
onChange: function onChange(value) {
|
|
257
|
+
return _this.updateLightParams('shadowBias', value);
|
|
258
|
+
},
|
|
259
|
+
value: lightParams.shadowBias
|
|
260
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
261
|
+
key: "normalBias"
|
|
262
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.normalBias")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(NumberInput, {
|
|
263
|
+
decimals: 1,
|
|
264
|
+
max: 10,
|
|
265
|
+
min: -10,
|
|
266
|
+
onChange: function onChange(value) {
|
|
267
|
+
return _this.updateLightParams('normalBias', value);
|
|
268
|
+
},
|
|
269
|
+
value: lightParams.normalBias
|
|
270
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
271
|
+
key: "shadowVolumeNear"
|
|
272
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadowVolumeNear")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(NumberInput, {
|
|
273
|
+
decimals: 0,
|
|
274
|
+
max: 100000,
|
|
275
|
+
min: 100,
|
|
276
|
+
onChange: function onChange(value) {
|
|
277
|
+
return _this.updateLightParams('shadowVolumeNear', value);
|
|
278
|
+
},
|
|
279
|
+
value: lightParams.shadowVolumeNear
|
|
280
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
281
|
+
key: "shadowVolumeFar"
|
|
282
|
+
}, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("maplight3d.shadowVolumeFar")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(NumberInput, {
|
|
283
|
+
decimals: 0,
|
|
284
|
+
max: 100000,
|
|
285
|
+
min: 100,
|
|
286
|
+
onChange: function onChange(value) {
|
|
287
|
+
return _this.updateLightParams('shadowVolumeFar', value);
|
|
288
|
+
},
|
|
289
|
+
value: lightParams.shadowVolumeFar
|
|
290
|
+
})))] : null)));
|
|
291
|
+
});
|
|
292
|
+
_defineProperty(_this, "toggleDayAnimation", function () {
|
|
293
|
+
_this.setState(function (state) {
|
|
294
|
+
return {
|
|
295
|
+
dayAnimation: !state.dayAnimation,
|
|
296
|
+
timeAnimation: false
|
|
297
|
+
};
|
|
298
|
+
}, function () {
|
|
299
|
+
clearInterval(_this.animationInterval);
|
|
300
|
+
if (_this.state.dayAnimation) {
|
|
301
|
+
_this.animationInterval = setInterval(function () {
|
|
302
|
+
_this.updateLightParams('day', (_this.state.lightParams.day + _this.state.dayStep / 10) % 365);
|
|
303
|
+
}, 100);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
_defineProperty(_this, "toggleTimeAnimation", function () {
|
|
308
|
+
_this.setState(function (state) {
|
|
309
|
+
return {
|
|
310
|
+
timeAnimation: !state.timeAnimation,
|
|
311
|
+
dayAnimation: false
|
|
312
|
+
};
|
|
313
|
+
}, function () {
|
|
314
|
+
clearInterval(_this.animationInterval);
|
|
315
|
+
if (_this.state.timeAnimation) {
|
|
316
|
+
_this.animationInterval = setInterval(function () {
|
|
317
|
+
_this.updateLightParams('time', (_this.state.lightParams.time + _this.state.timeStep / 10) % 1440);
|
|
318
|
+
}, 100);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
_defineProperty(_this, "renderSlider", function (key, min, max, step) {
|
|
323
|
+
var labelFormatter = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
324
|
+
var value = _this.state.lightParams[key];
|
|
325
|
+
var parseValue = function parseValue(x) {
|
|
326
|
+
return Number.isInteger(step) ? parseInt(x, 10) : parseFloat(x);
|
|
327
|
+
};
|
|
328
|
+
labelFormatter = labelFormatter !== null && labelFormatter !== void 0 ? labelFormatter : function (x) {
|
|
329
|
+
return x.toFixed(-Math.log10(step));
|
|
330
|
+
};
|
|
331
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
332
|
+
className: "maplight3d-slider"
|
|
333
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
334
|
+
max: max,
|
|
335
|
+
min: min,
|
|
336
|
+
onChange: function onChange(ev) {
|
|
337
|
+
return _this.updateLightParams(key, parseValue(ev.target.value));
|
|
338
|
+
},
|
|
339
|
+
step: step,
|
|
340
|
+
type: "range",
|
|
341
|
+
value: value
|
|
342
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
343
|
+
className: "maplight3d-slider-label"
|
|
344
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
345
|
+
style: {
|
|
346
|
+
left: (value - min) * 100 / (max - min) + "%"
|
|
347
|
+
}
|
|
348
|
+
}, labelFormatter(value))));
|
|
349
|
+
});
|
|
350
|
+
_defineProperty(_this, "updateLightParams", function (key, value) {
|
|
351
|
+
_this.setState(function (state) {
|
|
352
|
+
return {
|
|
353
|
+
lightParams: _objectSpread(_objectSpread({}, state.lightParams), {}, _defineProperty({}, key, value))
|
|
354
|
+
};
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
_defineProperty(_this, "configureShadows", function (sunLight, lightParams, shadowIntensityK) {
|
|
358
|
+
if (!lightParams.shadowsEnabled) {
|
|
359
|
+
_this.props.sceneContext.scene.renderer.shadowMap.enabled = false;
|
|
360
|
+
sunLight.castShadow = false;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
var cameraHeight = _this.props.sceneContext.scene.view.camera.position.z;
|
|
364
|
+
var targetHeight = _this.props.sceneContext.scene.view.controls.target.z;
|
|
365
|
+
var volumeSize = Math.min(20000, Math.max(1000, cameraHeight - targetHeight));
|
|
366
|
+
sunLight.shadow.camera.top = volumeSize;
|
|
367
|
+
sunLight.shadow.camera.bottom = -volumeSize;
|
|
368
|
+
sunLight.shadow.camera.left = -volumeSize;
|
|
369
|
+
sunLight.shadow.camera.right = volumeSize;
|
|
370
|
+
sunLight.shadow.camera.near = lightParams.shadowVolumeNear;
|
|
371
|
+
sunLight.shadow.camera.far = lightParams.shadowVolumeFar;
|
|
372
|
+
sunLight.shadow.camera.updateProjectionMatrix();
|
|
373
|
+
sunLight.shadow.mapSize.set(lightParams.shadowMapSize, lightParams.shadowMapSize);
|
|
374
|
+
sunLight.shadow.bias = lightParams.shadowBias;
|
|
375
|
+
sunLight.shadow.normalBias = lightParams.normalBias;
|
|
376
|
+
sunLight.shadow.intensity = lightParams.shadowIntensity * shadowIntensityK;
|
|
377
|
+
_this.props.sceneContext.scene.renderer.shadowMap.enabled = true;
|
|
378
|
+
sunLight.castShadow = true;
|
|
379
|
+
});
|
|
380
|
+
_defineProperty(_this, "setLighting", function () {
|
|
381
|
+
var sceneContext = _this.props.sceneContext;
|
|
382
|
+
var lightParams = _this.state.lightParams;
|
|
383
|
+
var ambientLight = sceneContext.getSceneObject("__ambientLight");
|
|
384
|
+
var sunLight = sceneContext.getSceneObject("__sunLight");
|
|
385
|
+
var moonLight = sceneContext.getSceneObject("__moonLight");
|
|
386
|
+
var lightTarget = sceneContext.scene.view.controls.target.clone();
|
|
387
|
+
lightTarget.z = 0;
|
|
388
|
+
|
|
389
|
+
// Compute azimuth / zenith and sun position
|
|
390
|
+
var date = new Date(new Date().getFullYear(), 0, lightParams.day, Math.trunc(lightParams.time / 60), lightParams.time % 60);
|
|
391
|
+
var latlon = CoordinatesUtils.reproject([lightTarget.x, lightTarget.y], sceneContext.mapCrs, 'EPSG:4326');
|
|
392
|
+
var sunPos = suncalc.getPosition(date, latlon[1], latlon[0]);
|
|
393
|
+
var zenith = 90 - sunPos.altitude / Math.PI * 180;
|
|
394
|
+
var azimuth = 180 + sunPos.azimuth / Math.PI * 180;
|
|
395
|
+
var sunLocalPos = Sun.getLocalPosition({
|
|
396
|
+
point: lightTarget,
|
|
397
|
+
zenith: Math.min(90, zenith),
|
|
398
|
+
azimuth: azimuth,
|
|
399
|
+
distance: lightParams.sunDistance
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// Compute dynamic params
|
|
403
|
+
var noonColor = {
|
|
404
|
+
r: 1.0,
|
|
405
|
+
g: 0.98,
|
|
406
|
+
b: 0.98
|
|
407
|
+
};
|
|
408
|
+
var horizonColor = {
|
|
409
|
+
r: 1.0,
|
|
410
|
+
g: 0.5,
|
|
411
|
+
b: 0.3
|
|
412
|
+
};
|
|
413
|
+
var duskColor = {
|
|
414
|
+
r: 0.15,
|
|
415
|
+
g: 0.22,
|
|
416
|
+
b: 0.35
|
|
417
|
+
};
|
|
418
|
+
var lerpColor = function lerpColor(a, b, t) {
|
|
419
|
+
return {
|
|
420
|
+
r: (1 - t) * a.r + t * b.r,
|
|
421
|
+
g: (1 - t) * a.g + t * b.g,
|
|
422
|
+
b: (1 - t) * a.b + t * b.b
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
var sunColor = noonColor;
|
|
426
|
+
var ambientIntensity = 0;
|
|
427
|
+
var shadowIntensityK = 0;
|
|
428
|
+
var sunLightIntensityK = Math.min(1, (98 - Math.min(98, zenith)) / 16);
|
|
429
|
+
var moonLightIntensityK = 1 - Math.min(1, (90 - Math.min(90, zenith)) / 16);
|
|
430
|
+
if (zenith < 90) {
|
|
431
|
+
var k = Math.pow(zenith / 90, 3);
|
|
432
|
+
sunColor = lerpColor(noonColor, horizonColor, k);
|
|
433
|
+
ambientIntensity = (1 - zenith / 90) * 1.5;
|
|
434
|
+
shadowIntensityK = (1 - k) * 0.9 + 0.2 * k;
|
|
435
|
+
} else if (zenith < 102) {
|
|
436
|
+
var _k = (zenith - 90) / 12;
|
|
437
|
+
sunColor = lerpColor(horizonColor, duskColor, _k);
|
|
438
|
+
shadowIntensityK = 0.2 * (1 - _k);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Set lighting params
|
|
442
|
+
sceneContext.map.lighting.enabled = true;
|
|
443
|
+
sceneContext.map.lighting.mode = lightParams.shadowsEnabled ? MapLightingMode.LightBased : MapLightingMode.Hillshade;
|
|
444
|
+
sceneContext.map.lighting.elevationLayersOnly = lightParams.lightElevationLayersOnly;
|
|
445
|
+
sceneContext.map.lighting.hillshadeAzimuth = azimuth;
|
|
446
|
+
sceneContext.map.lighting.hillshadeZenith = Math.min(90, zenith);
|
|
447
|
+
sceneContext.map.lighting.zFactor = lightParams.zFactor;
|
|
448
|
+
sceneContext.scene.notifyChange(sceneContext.map);
|
|
449
|
+
sceneContext.scene.renderer.shadowMap.type = lightParams.shadowType;
|
|
450
|
+
ambientLight.intensity = ambientIntensity;
|
|
451
|
+
sunLight.position.copy(sunLocalPos);
|
|
452
|
+
sunLight.intensity = lightParams.sunLightIntensity * sunLightIntensityK;
|
|
453
|
+
sunLight.color = sunColor;
|
|
454
|
+
sunLight.target.position.copy(lightTarget);
|
|
455
|
+
sunLight.updateMatrixWorld(true);
|
|
456
|
+
sunLight.target.updateMatrixWorld(true);
|
|
457
|
+
_this.configureShadows(sunLight, lightParams, shadowIntensityK);
|
|
458
|
+
|
|
459
|
+
// NOTE: just a top-down light
|
|
460
|
+
moonLight.position.set(lightTarget.x, lightTarget.y, 8000);
|
|
461
|
+
moonLight.intensity = lightParams.moonLightIntensity * moonLightIntensityK;
|
|
462
|
+
moonLight.target.position.copy(lightTarget);
|
|
463
|
+
moonLight.updateMatrixWorld(true);
|
|
464
|
+
moonLight.target.updateMatrixWorld(true);
|
|
465
|
+
if (lightParams.helpersVisible) {
|
|
466
|
+
var sunLightHelper = sceneContext.getSceneObject("__sunLightHelper");
|
|
467
|
+
sunLightHelper.update();
|
|
468
|
+
sunLightHelper.updateMatrixWorld(true);
|
|
469
|
+
var shadowCameraHelper = sceneContext.getSceneObject("__shadowCameraHelper");
|
|
470
|
+
shadowCameraHelper.update();
|
|
471
|
+
shadowCameraHelper.updateMatrixWorld(true);
|
|
472
|
+
}
|
|
473
|
+
sceneContext.scene.notifyChange();
|
|
474
|
+
});
|
|
475
|
+
_this.state.lightParams.day = props.defaultDay;
|
|
476
|
+
var _parts = props.defaultTime.split(":").slice(0, 2).map(Number);
|
|
477
|
+
_this.state.lightParams.time = _parts[0] * 60 + _parts[1];
|
|
478
|
+
return _this;
|
|
479
|
+
}
|
|
480
|
+
_inherits(MapLight3D, _React$Component);
|
|
481
|
+
return _createClass(MapLight3D, [{
|
|
482
|
+
key: "componentDidMount",
|
|
483
|
+
value: function componentDidMount() {
|
|
484
|
+
this.animationInterval = null;
|
|
485
|
+
this.componentDidUpdate({});
|
|
486
|
+
}
|
|
487
|
+
}, {
|
|
488
|
+
key: "componentDidUpdate",
|
|
489
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
490
|
+
var _prevProps$sceneConte;
|
|
491
|
+
if (this.props.sceneContext.scene !== ((_prevProps$sceneConte = prevProps.sceneContext) === null || _prevProps$sceneConte === void 0 ? void 0 : _prevProps$sceneConte.scene)) {
|
|
492
|
+
var ambientLight = new AmbientLight(0xffffff, 1);
|
|
493
|
+
this.props.sceneContext.addSceneObject("__ambientLight", ambientLight);
|
|
494
|
+
var sunLight = new DirectionalLight(0xffffff, this.state.sunLightIntensity);
|
|
495
|
+
this.props.sceneContext.addSceneObject("__sunLight", sunLight);
|
|
496
|
+
var moonLight = new DirectionalLight(0xffffff, this.state.moonLightIntensity);
|
|
497
|
+
this.props.sceneContext.addSceneObject("__moonLight", moonLight);
|
|
498
|
+
if (this.state.lightParams.helpersVisible) {
|
|
499
|
+
var sunLightHelper = new DirectionalLightHelper(sunLight, 200, 'white');
|
|
500
|
+
this.props.sceneContext.addSceneObject("__sunLightHelper", sunLightHelper);
|
|
501
|
+
var shadowCameraHelper = new CameraHelper(sunLight.shadow.camera);
|
|
502
|
+
this.props.sceneContext.addSceneObject("__shadowCameraHelper", shadowCameraHelper);
|
|
503
|
+
}
|
|
504
|
+
this.props.sceneContext.scene.view.controls.addEventListener('change', this.setLighting);
|
|
505
|
+
this.setLighting();
|
|
506
|
+
} else if (this.state.lightParams !== prevState.lightParams) {
|
|
507
|
+
if (this.state.lightParams.helpersVisible && !prevState.lightParams.helpersVisible) {
|
|
508
|
+
var _sunLight = this.props.sceneContext.getSceneObject("__sunLight");
|
|
509
|
+
var _sunLightHelper = new DirectionalLightHelper(_sunLight, 200, 'white');
|
|
510
|
+
this.props.sceneContext.addSceneObject("__sunLightHelper", _sunLightHelper);
|
|
511
|
+
var _shadowCameraHelper = new CameraHelper(_sunLight.shadow.camera);
|
|
512
|
+
this.props.sceneContext.addSceneObject("__shadowCameraHelper", _shadowCameraHelper);
|
|
513
|
+
} else if (prevState.lightParams.helpersVisible && !this.state.lightParams.helpersVisible) {
|
|
514
|
+
this.props.sceneContext.removeSceneObject("__sunLightHelper");
|
|
515
|
+
this.props.sceneContext.removeSceneObject("__shadowCameraHelper");
|
|
516
|
+
}
|
|
517
|
+
this.setLighting();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}, {
|
|
521
|
+
key: "componentWillUnmount",
|
|
522
|
+
value: function componentWillUnmount() {
|
|
523
|
+
clearInterval(this.lightPositionInterval);
|
|
524
|
+
this.props.sceneContext.removeSceneObject("__sunLight");
|
|
525
|
+
this.props.sceneContext.removeSceneObject("__moonLight");
|
|
526
|
+
this.props.sceneContext.removeSceneObject("__sunLightHelper");
|
|
527
|
+
this.props.sceneContext.removeSceneObject("__shadowCameraHelper");
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
key: "render",
|
|
531
|
+
value: function render() {
|
|
532
|
+
var _this2 = this;
|
|
533
|
+
return /*#__PURE__*/React.createElement(SideBar, {
|
|
534
|
+
icon: "light",
|
|
535
|
+
id: "MapLight3D",
|
|
536
|
+
onHide: this.onHide,
|
|
537
|
+
title: LocaleUtils.tr("appmenu.items.MapLight3D"),
|
|
538
|
+
width: "25em"
|
|
539
|
+
}, function () {
|
|
540
|
+
return {
|
|
541
|
+
body: _this2.renderBody()
|
|
542
|
+
};
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}]);
|
|
546
|
+
}(React.Component);
|
|
547
|
+
_defineProperty(MapLight3D, "propTypes", {
|
|
548
|
+
/** Default viewer day (1-365) */
|
|
549
|
+
defaultDay: PropTypes.number,
|
|
550
|
+
/** Default viewer time (00:00-23:59) */
|
|
551
|
+
defaultTime: PropTypes.string,
|
|
552
|
+
sceneContext: PropTypes.object
|
|
553
|
+
});
|
|
554
|
+
_defineProperty(MapLight3D, "defaultProps", {
|
|
555
|
+
defaultDay: 182,
|
|
556
|
+
defaultTime: '12:00'
|
|
557
|
+
});
|
|
558
|
+
export { MapLight3D as default };
|