From cee6cf111b94e80deace3cb7323c2d575923f8ff Mon Sep 17 00:00:00 2001 From: stefano bovio Date: Fri, 27 Oct 2023 14:37:18 +0200 Subject: [PATCH 1/2] Fix #9624 Point cloud shading options (#9666) --- .../TOC/fragments/settings/Display.jsx | 17 +- .../settings/PointCloudShadingSettings.jsx | 140 ++++++++++++ .../settings/ThreeDTilesSettings.jsx | 88 ++++++++ .../PointCloudShadingSettings-test.jsx | 205 ++++++++++++++++++ .../__tests__/ThreeDTilesSettings-test.jsx | 111 ++++++++++ .../map/cesium/plugins/ThreeDTilesLayer.js | 38 +++- web/client/components/styleeditor/Fields.jsx | 3 +- .../components/styleeditor/PropertyField.jsx | 9 +- .../components/styleeditor/config/blocks.js | 3 +- .../components/styleeditor/config/property.js | 5 +- web/client/themes/default/less/common.less | 35 +++ .../themes/default/less/react-select.less | 4 + web/client/themes/default/less/wizard.less | 1 - web/client/translations/data.de-DE.json | 18 +- web/client/translations/data.en-US.json | 18 +- web/client/translations/data.es-ES.json | 18 +- web/client/translations/data.fr-FR.json | 18 +- web/client/translations/data.it-IT.json | 18 +- 18 files changed, 721 insertions(+), 28 deletions(-) create mode 100644 web/client/components/TOC/fragments/settings/PointCloudShadingSettings.jsx create mode 100644 web/client/components/TOC/fragments/settings/ThreeDTilesSettings.jsx create mode 100644 web/client/components/TOC/fragments/settings/__tests__/PointCloudShadingSettings-test.jsx create mode 100644 web/client/components/TOC/fragments/settings/__tests__/ThreeDTilesSettings-test.jsx diff --git a/web/client/components/TOC/fragments/settings/Display.jsx b/web/client/components/TOC/fragments/settings/Display.jsx index d4f93e06e4..acea7b9a83 100644 --- a/web/client/components/TOC/fragments/settings/Display.jsx +++ b/web/client/components/TOC/fragments/settings/Display.jsx @@ -21,6 +21,7 @@ import { ServerTypes } from '../../../../utils/LayersUtils'; import Select from 'react-select'; import { getSupportedFormat } from '../../../../api/WMS'; import WMSCacheOptions from './WMSCacheOptions'; +import ThreeDTilesSettings from './ThreeDTilesSettings'; export default class extends React.Component { static propTypes = { opacityText: PropTypes.node, @@ -206,18 +207,10 @@ export default class extends React.Component { - {this.props.element.type === "3dtiles" && - - - - this.props.onChange("heightOffset", parseFloat(val))}/> - - - } + {this.props.element.type === "wms" && diff --git a/web/client/components/TOC/fragments/settings/PointCloudShadingSettings.jsx b/web/client/components/TOC/fragments/settings/PointCloudShadingSettings.jsx new file mode 100644 index 0000000000..20f3673ca2 --- /dev/null +++ b/web/client/components/TOC/fragments/settings/PointCloudShadingSettings.jsx @@ -0,0 +1,140 @@ +/* + * Copyright 2023, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + + +import React from 'react'; +import PropTypes from 'prop-types'; +import { FormGroup, ControlLabel, InputGroup, Checkbox } from 'react-bootstrap'; +import DebouncedFormControl from '../../../misc/DebouncedFormControl'; +import Message from '../../../I18N/Message'; +import InfoPopover from '../../../widgets/widget/InfoPopover'; + +/** + * PointCloudShadingSettings. This component shows the point cloud shading options available + * @prop {object} layer the layer options + * @prop {object} onChange callback on every on change event + */ +function PointCloudShadingSettings({ + layer, + onChange +}) { + if (!(layer?.type === '3dtiles' && layer?.format === 'pnts')) { + return null; + } + const { pointCloudShading = {} } = layer || {}; + return ( + <> +
+ + onChange('pointCloudShading', { + ...pointCloudShading, + attenuation: event?.target?.checked, + maximumAttenuation: pointCloudShading?.maximumAttenuation ?? 4, + eyeDomeLighting: pointCloudShading?.eyeDomeLighting ?? true + })} + > + + {' '}} /> + + + + + + + + { + onChange('pointCloudShading', { + ...pointCloudShading, + maximumAttenuation: value !== undefined ? parseFloat(value) : undefined + }); + }} + /> + + px + + + + + onChange('pointCloudShading', { + ...pointCloudShading, + eyeDomeLighting: event?.target?.checked + })} + > + + {' '}} /> + + + + + + + + onChange('pointCloudShading', { + ...pointCloudShading, + eyeDomeLightingStrength: value !== undefined ? parseFloat(value) : undefined + })} + /> + + + + + + + + onChange('pointCloudShading', { + ...pointCloudShading, + eyeDomeLightingRadius: value !== undefined ? parseFloat(value) : undefined + })} + /> + + + + ); +} + +PointCloudShadingSettings.propTypes = { + layer: PropTypes.object, + onChange: PropTypes.func +}; + +PointCloudShadingSettings.defaultProps = { + layer: {}, + onChange: () => {} +}; + +export default PointCloudShadingSettings; diff --git a/web/client/components/TOC/fragments/settings/ThreeDTilesSettings.jsx b/web/client/components/TOC/fragments/settings/ThreeDTilesSettings.jsx new file mode 100644 index 0000000000..3f5aa9f99f --- /dev/null +++ b/web/client/components/TOC/fragments/settings/ThreeDTilesSettings.jsx @@ -0,0 +1,88 @@ +/* + * Copyright 2023, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + + +import React from 'react'; +import PropTypes from 'prop-types'; +import { FormGroup, ControlLabel, InputGroup } from 'react-bootstrap'; +import DebouncedFormControl from '../../../misc/DebouncedFormControl'; +import Message from '../../../I18N/Message'; +import PointCloudShadingSettings from './PointCloudShadingSettings'; +import Select from 'react-select'; + +/** + * ThreeDTilesSettings. This component shows the 3d tiles options available + * @prop {object} layer the layer options + * @prop {object} onChange callback on every on change event + */ +function ThreeDTilesSettings({ + layer, + onChange +}) { + if (layer?.type !== '3dtiles') { + return null; + } + return ( +
+ + + +