From 92d5aafb7db61176e0c3054867c4917eb3d6bd54 Mon Sep 17 00:00:00 2001 From: Kevin ETOURNEAU Date: Wed, 23 Aug 2023 09:20:08 +0200 Subject: [PATCH 1/5] feat(points): Allow custom adaptive points parameters --- CONTRIBUTORS.md | 4 ++++ src/Renderer/PointsMaterial.js | 14 +++++++++++++- src/Renderer/Shader/PointsVS.glsl | 5 ++++- utils/debug/PotreeDebug.js | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 835d010b51..48747ddf04 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -45,6 +45,10 @@ The following people have contributed to iTowns. * [Diginove](http://diginove.com/index.php/fr/diginove-lexpertise-en-traitement-dimages/): * [Michel Benet](https://github.com/mbenevole) +* [Sogelink](https://www.sogelink.com/) + * [Kévin ETOURNEAU](https://github.com/ketourneau) + * [Alexis DELFORGES](https://github.com/pourfex) + The following organizations are the current maintainers of iTowns: * IGN (http://www.ign.fr) * Ciril Group (https://www.cirilgroup.com/) diff --git a/src/Renderer/PointsMaterial.js b/src/Renderer/PointsMaterial.js index 2d9e5f5866..574c4c4e25 100644 --- a/src/Renderer/PointsMaterial.js +++ b/src/Renderer/PointsMaterial.js @@ -53,12 +53,15 @@ class PointsMaterial extends THREE.RawShaderMaterial { /** * @class PointsMaterial * @param {object} [options={}] The options - * @param {number} [options.size=0] size point + * @param {number} [options.size=0] size point (adaptive size mode when size is 0) * @param {number} [options.mode=PNTS_MODE.COLOR] display mode. * @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color. * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(0, 1)] intensity range. * @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode. * @param {Classification} [options.classification] - define points classification. + * @param {number} [options.minAdaptiveSize=3] min adaptive size point (used only when size is 0) + * @param {number} [options.maxAdaptiveSize=10] max adaptive size point (used only when size is 0) + * @param {number} [options.adaptiveScale=1] adaptive scale factor (used only when size is 0) * @property {Classification} classification - points classification. * * @example @@ -74,6 +77,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication; const size = options.size || 0; const mode = options.mode || PNTS_MODE.COLOR; + const minAdaptiveSize = options.minAdaptiveSize || 3; + const maxAdaptiveSize = options.maxAdaptiveSize || 10; + const adaptiveScale = options.adaptiveScale || 1; delete options.orientedImageMaterial; delete options.intensityRange; @@ -81,6 +87,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { delete options.applyOpacityClassication; delete options.size; delete options.mode; + delete options.minAdaptiveSize; + delete options.maxAdaptiveSize; + delete options.adaptiveScale; super(options); @@ -97,6 +106,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { CommonMaterial.setUniformProperty(this, 'overlayColor', options.overlayColor || new THREE.Vector4(0, 0, 0, 0)); CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange); CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication); + CommonMaterial.setUniformProperty(this, 'minAdaptiveSize', minAdaptiveSize); + CommonMaterial.setUniformProperty(this, 'maxAdaptiveSize', maxAdaptiveSize); + CommonMaterial.setUniformProperty(this, 'adaptiveScale', adaptiveScale); // add classification texture to apply classification lut. const data = new Uint8Array(256 * 4); diff --git a/src/Renderer/Shader/PointsVS.glsl b/src/Renderer/Shader/PointsVS.glsl index c36b57ee1d..a70a489023 100644 --- a/src/Renderer/Shader/PointsVS.glsl +++ b/src/Renderer/Shader/PointsVS.glsl @@ -20,6 +20,9 @@ attribute vec4 unique_id; attribute float intensity; attribute float classification; uniform sampler2D classificationLUT; +uniform float minAdaptiveSize; +uniform float maxAdaptiveSize; +uniform float adaptiveScale; #if defined(NORMAL_OCT16) attribute vec2 oct16Normal; @@ -102,7 +105,7 @@ void main() { if (size > 0.) { gl_PointSize = size; } else { - gl_PointSize = clamp(-size / gl_Position.w, 3.0, 10.0); + gl_PointSize = clamp(-size / gl_Position.w, minAdaptiveSize, maxAdaptiveSize) * adaptiveScale; } #if defined(USE_TEXTURES_PROJECTIVE) diff --git a/utils/debug/PotreeDebug.js b/utils/debug/PotreeDebug.js index 40ecdac176..d4f683fcab 100644 --- a/utils/debug/PotreeDebug.js +++ b/utils/debug/PotreeDebug.js @@ -26,6 +26,9 @@ export default { } styleUI.add(layer, 'opacity', 0, 1).name('Layer Opacity').onChange(update); styleUI.add(layer, 'pointSize', 0, 15).name('Point Size').onChange(update); + styleUI.add(layer.material, 'adaptiveScale', 0, 15).name('Adaptive scale').onChange(update); + styleUI.add(layer.material, 'minAdaptiveSize', 0, 15).name('Min adaptive size').onChange(update); + styleUI.add(layer.material, 'maxAdaptiveSize', 0, 15).name('Max adaptive size').onChange(update); if (layer.material.picking != undefined) { styleUI.add(layer.material, 'picking').name('Display picking id').onChange(update); } From d7fdc3db510bbfd2890aea849f548ab8077dca24 Mon Sep 17 00:00:00 2001 From: Kevin ETOURNEAU Date: Fri, 25 Aug 2023 11:07:05 +0200 Subject: [PATCH 2/5] feat(points): Add sizeMode parameter & 3dTiles now also use adaptive parameters --- src/Layer/C3DTilesLayer.js | 15 ++++++++++++-- src/Layer/ReferencingLayerProperties.js | 20 ++++++++++++++++++ src/Provider/3dTilesProvider.js | 10 ++++++++- src/Renderer/PointsMaterial.js | 27 ++++++++++++++++++++----- src/Renderer/Shader/PointsVS.glsl | 7 ++++--- utils/debug/3dTilesDebug.js | 17 ++++++++++++++++ utils/debug/PotreeDebug.js | 10 ++++++++- 7 files changed, 94 insertions(+), 12 deletions(-) diff --git a/src/Layer/C3DTilesLayer.js b/src/Layer/C3DTilesLayer.js index 1d02d0f736..f1a472c27e 100644 --- a/src/Layer/C3DTilesLayer.js +++ b/src/Layer/C3DTilesLayer.js @@ -3,7 +3,7 @@ import GeometryLayer from 'Layer/GeometryLayer'; import { init3dTilesLayer, pre3dTilesUpdate, process3dTilesNode } from 'Process/3dTilesProcessing'; import C3DTileset from 'Core/3DTiles/C3DTileset'; import C3DTExtensions from 'Core/3DTiles/C3DTExtensions'; -import { PNTS_MODE } from 'Renderer/PointsMaterial'; +import { PNTS_MODE, PNTS_SIZE } from 'Renderer/PointsMaterial'; // eslint-disable-next-line no-unused-vars import Style from 'Core/Style'; import C3DTFeature from 'Core/3DTiles/C3DTFeature'; @@ -70,6 +70,10 @@ class C3DTilesLayer extends GeometryLayer { * removed from the scene. * @param {C3DTExtensions} [config.registeredExtensions] 3D Tiles extensions managers registered for this tileset. * @param {String} [config.pntsMode= PNTS_MODE.COLOR] {@link PointsMaterials} Point cloud coloring mode. Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points, CLASSIFICATION uses a classification property of the batch table to color points. + * @param {String} [config.pntsSize= PNTS_SIZE.VALUE] {@link PointsMaterials} Point cloud size mode. Only 'VALUE' or 'ADAPTIVE' are possible. VALUE use constant size, ADAPTIVE compute size depending on distance from point to camera. + * @param {Number} [config.pntsAdaptiveScale=1] Scale factor used by 'ADAPTIVE' size mode + * @param {Number} [config.pntsMinAdaptiveSize=3] Minimum scale used by 'ADAPTIVE' size mode + * @param {Number} [config.pntsMaxAdaptiveSize=10] Maximum scale used by 'ADAPTIVE' size mode * @param {Style} [config.style=null] - style used for this layer * @param {View} view The view */ @@ -84,13 +88,20 @@ class C3DTilesLayer extends GeometryLayer { this.pntsMode = PNTS_MODE.COLOR; this.classification = config.classification; - + this.pntsSize = PNTS_SIZE.VALUE; + this.pntsAdaptiveScale = config.pntsAdaptiveScale || 1; + this.pntsMinAdaptiveSize = config.pntsMinAdaptiveSize || 3; + this.pntsMaxAdaptiveSize = config.pntsMaxAdaptiveSize || 10; if (config.pntsMode) { const exists = Object.values(PNTS_MODE).includes(config.pntsMode); if (!exists) { console.warn("The points cloud mode doesn't exist. Use 'COLOR' or 'CLASSIFICATION' instead."); } else { this.pntsMode = config.pntsMode; } } + if (config.pntsSize) { + const exists = Object.values(PNTS_SIZE).includes(config.pntsSize); + if (!exists) { console.warn("The points cloud size doesn't exist. Use 'VALUE' or 'ADAPTIVE' instead."); } else { this.pntsSize = config.pntsSize; } + } /** @type {Style} */ this._style = config.style || null; diff --git a/src/Layer/ReferencingLayerProperties.js b/src/Layer/ReferencingLayerProperties.js index aa7b73bbdd..cfe8e45a29 100644 --- a/src/Layer/ReferencingLayerProperties.js +++ b/src/Layer/ReferencingLayerProperties.js @@ -21,6 +21,26 @@ function ReferLayerProperties(material, layer) { get: () => material.layer.pntsMode, }); } + if (material.uniforms && material.uniforms.sizeMode != undefined) { + Object.defineProperty(material.uniforms.sizeMode, 'value', { + get: () => material.layer.pntsSize, + }); + } + if (material.uniforms && material.uniforms.minAdaptiveSize != undefined) { + Object.defineProperty(material.uniforms.minAdaptiveSize, 'value', { + get: () => material.layer.pntsMinAdaptiveSize, + }); + } + if (material.uniforms && material.uniforms.maxAdaptiveSize != undefined) { + Object.defineProperty(material.uniforms.maxAdaptiveSize, 'value', { + get: () => material.layer.pntsMaxAdaptiveSize, + }); + } + if (material.uniforms && material.uniforms.adaptiveScale != undefined) { + Object.defineProperty(material.uniforms.adaptiveScale, 'value', { + get: () => material.layer.pntsAdaptiveScale, + }); + } Object.defineProperty(material, 'wireframe', { get: () => material.layer.wireframe, diff --git a/src/Provider/3dTilesProvider.js b/src/Provider/3dTilesProvider.js index 92bdc271bb..787d254963 100644 --- a/src/Provider/3dTilesProvider.js +++ b/src/Provider/3dTilesProvider.js @@ -29,7 +29,15 @@ function pntsParse(data, layer) { return PntsParser.parse(data, layer.registeredExtensions).then((result) => { const material = layer.material ? layer.material.clone() : - new PointsMaterial({ size: 0.05, mode: layer.pntsMode, classification: layer.classification }); + new PointsMaterial({ + size: 0.05, + mode: layer.pntsMode, + classification: layer.classification, + sizeMode: layer.pntsSize, + minAdaptiveSize: layer.pntsMinAdaptiveSize, + maxAdaptiveSize: layer.pntsMaxAdaptiveSize, + adaptiveScale: layer.adaptiveScale, + }); // refer material properties in the layer so when layers opacity and visibility is updated, the material is // automatically updated diff --git a/src/Renderer/PointsMaterial.js b/src/Renderer/PointsMaterial.js index 574c4c4e25..230e187aeb 100644 --- a/src/Renderer/PointsMaterial.js +++ b/src/Renderer/PointsMaterial.js @@ -12,6 +12,11 @@ export const PNTS_MODE = { NORMAL: 3, }; +export const PNTS_SIZE = { + VALUE: 0, + ADAPTIVE: 1, +}; + const white = new THREE.Color(1.0, 1.0, 1.0); /** @@ -53,15 +58,16 @@ class PointsMaterial extends THREE.RawShaderMaterial { /** * @class PointsMaterial * @param {object} [options={}] The options - * @param {number} [options.size=0] size point (adaptive size mode when size is 0) + * @param {number} [options.size=0] size point * @param {number} [options.mode=PNTS_MODE.COLOR] display mode. * @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color. * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(0, 1)] intensity range. * @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode. * @param {Classification} [options.classification] - define points classification. - * @param {number} [options.minAdaptiveSize=3] min adaptive size point (used only when size is 0) - * @param {number} [options.maxAdaptiveSize=10] max adaptive size point (used only when size is 0) - * @param {number} [options.adaptiveScale=1] adaptive scale factor (used only when size is 0) + * @param {number} [options.sizeMode=SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ADAPTIVE' are possible. VALUE use constant size, ADAPTIVE compute size depending on distance from point to camera. + * @param {number} [options.adaptiveScale=1] scale factor used by 'ADAPTIVE' size mode + * @param {number} [options.minAdaptiveSize=3] minimum scale used by 'ADAPTIVE' size mode + * @param {number} [options.maxAdaptiveSize=10] maximum scale used by 'ADAPTIVE' size mode * @property {Classification} classification - points classification. * * @example @@ -75,8 +81,12 @@ class PointsMaterial extends THREE.RawShaderMaterial { const oiMaterial = options.orientedImageMaterial; const classification = options.classification || ClassificationScheme.DEFAULT; const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication; - const size = options.size || 0; + let size = options.size || 0; const mode = options.mode || PNTS_MODE.COLOR; + const sizeMode = size === 0 ? PNTS_SIZE.ADAPTIVE : (options.sizeMode || PNTS_SIZE.VALUE); + if ((sizeMode === PNTS_SIZE.ADAPTIVE) && (size !== 0)) { + size = 0; + } const minAdaptiveSize = options.minAdaptiveSize || 3; const maxAdaptiveSize = options.maxAdaptiveSize || 10; const adaptiveScale = options.adaptiveScale || 1; @@ -87,6 +97,7 @@ class PointsMaterial extends THREE.RawShaderMaterial { delete options.applyOpacityClassication; delete options.size; delete options.mode; + delete options.sizeMode; delete options.minAdaptiveSize; delete options.maxAdaptiveSize; delete options.adaptiveScale; @@ -98,6 +109,7 @@ class PointsMaterial extends THREE.RawShaderMaterial { this.scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE); + CommonMaterial.setDefineMapping(this, 'PNTS_SIZE', PNTS_SIZE); CommonMaterial.setUniformProperty(this, 'size', size); CommonMaterial.setUniformProperty(this, 'mode', mode); @@ -106,6 +118,7 @@ class PointsMaterial extends THREE.RawShaderMaterial { CommonMaterial.setUniformProperty(this, 'overlayColor', options.overlayColor || new THREE.Vector4(0, 0, 0, 0)); CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange); CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication); + CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode); CommonMaterial.setUniformProperty(this, 'minAdaptiveSize', minAdaptiveSize); CommonMaterial.setUniformProperty(this, 'maxAdaptiveSize', maxAdaptiveSize); CommonMaterial.setUniformProperty(this, 'adaptiveScale', adaptiveScale); @@ -226,6 +239,10 @@ class PointsMaterial extends THREE.RawShaderMaterial { this.transparent = source.transparent; this.size = source.size; this.mode = source.mode; + this.sizeMode = source.sizeMode; + this.adaptiveScale = source.adaptiveScale; + this.minAdaptiveSize = source.minAdaptiveSize; + this.maxAdaptiveSize = source.maxAdaptiveSize; this.picking = source.picking; this.scale = source.scale; this.overlayColor.copy(source.overlayColor); diff --git a/src/Renderer/Shader/PointsVS.glsl b/src/Renderer/Shader/PointsVS.glsl index a70a489023..2b14bf9500 100644 --- a/src/Renderer/Shader/PointsVS.glsl +++ b/src/Renderer/Shader/PointsVS.glsl @@ -20,6 +20,7 @@ attribute vec4 unique_id; attribute float intensity; attribute float classification; uniform sampler2D classificationLUT; +uniform int sizeMode; uniform float minAdaptiveSize; uniform float maxAdaptiveSize; uniform float adaptiveScale; @@ -93,7 +94,7 @@ void main() { vColor.rgb = vec3(i, i, i); } else if (mode == PNTS_MODE_NORMAL) { vColor.rgb = abs(normal); - } else if (mode ==PNTS_MODE_COLOR) { + } else if (mode == PNTS_MODE_COLOR) { // default to color mode vColor.rgb = mix(color, overlayColor.rgb, overlayColor.a); } @@ -102,9 +103,9 @@ void main() { #include #include - if (size > 0.) { + if (sizeMode == PNTS_SIZE_VALUE) { gl_PointSize = size; - } else { + } else if (sizeMode == PNTS_SIZE_ADAPTIVE) { gl_PointSize = clamp(-size / gl_Position.w, minAdaptiveSize, maxAdaptiveSize) * adaptiveScale; } diff --git a/utils/debug/3dTilesDebug.js b/utils/debug/3dTilesDebug.js index d9a13a57f7..8c28150bb0 100644 --- a/utils/debug/3dTilesDebug.js +++ b/utils/debug/3dTilesDebug.js @@ -1,6 +1,7 @@ import * as THREE from 'three'; import View from 'Core/View'; import GeometryLayer from 'Layer/GeometryLayer'; +import { PNTS_SIZE } from 'Renderer/PointsMaterial'; import GeometryDebug from './GeometryDebug'; import OBBHelper from './OBBHelper'; @@ -112,4 +113,20 @@ export default function create3dTilesDebugUI(datDebugTool, view, _3dTileslayer) gui.add(_3dTileslayer, 'sseThreshold', 0, 100).name('sseThreshold').onChange(() => { view.notifyChange(view.camera.camera3D); }); + + gui.add(_3dTileslayer, 'pntsSize', PNTS_SIZE).name('Pnts size mode').onChange(() => { + view.notifyChange(view.camera.camera3D); + }); + + gui.add(_3dTileslayer, 'pntsAdaptiveScale', 0, 15).name('Adptive scale').onChange(() => { + view.notifyChange(view.camera.camera3D); + }); + + gui.add(_3dTileslayer, 'pntsMinAdaptiveSize', 0, 15).name('Min adptive size').onChange(() => { + view.notifyChange(view.camera.camera3D); + }); + + gui.add(_3dTileslayer, 'pntsMaxAdaptiveSize', 0, 15).name('Max adptive size').onChange(() => { + view.notifyChange(view.camera.camera3D); + }); } diff --git a/utils/debug/PotreeDebug.js b/utils/debug/PotreeDebug.js index d4f683fcab..92c4994469 100644 --- a/utils/debug/PotreeDebug.js +++ b/utils/debug/PotreeDebug.js @@ -1,4 +1,4 @@ -import { PNTS_MODE } from 'Renderer/PointsMaterial'; +import { PNTS_MODE, PNTS_SIZE } from 'Renderer/PointsMaterial'; export default { initTools(view, layer, datUi) { @@ -26,6 +26,14 @@ export default { } styleUI.add(layer, 'opacity', 0, 1).name('Layer Opacity').onChange(update); styleUI.add(layer, 'pointSize', 0, 15).name('Point Size').onChange(update); + if (layer.material.sizeMode != undefined) { + styleUI.add(layer.material, 'sizeMode', PNTS_SIZE).name('Point size mode').onChange(() => { + if (layer.material.sizeMode == PNTS_SIZE.ADAPTIVE) { + layer.pointSize = 0; + } + update(); + }); + } styleUI.add(layer.material, 'adaptiveScale', 0, 15).name('Adaptive scale').onChange(update); styleUI.add(layer.material, 'minAdaptiveSize', 0, 15).name('Min adaptive size').onChange(update); styleUI.add(layer.material, 'maxAdaptiveSize', 0, 15).name('Max adaptive size').onChange(update); From d698c17b02958cade95da2dfcfe1dc09c970d9e4 Mon Sep 17 00:00:00 2001 From: Kevin ETOURNEAU Date: Fri, 25 Aug 2023 14:20:48 +0200 Subject: [PATCH 3/5] feat(points): Add export PNTS_SIZE --- src/Main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main.js b/src/Main.js index e54a21194f..016fd7613a 100644 --- a/src/Main.js +++ b/src/Main.js @@ -19,7 +19,7 @@ export { VIEW_EVENTS } from 'Core/View'; export { default as FeatureProcessing } from 'Process/FeatureProcessing'; export { updateLayeredMaterialNodeImagery, updateLayeredMaterialNodeElevation } from 'Process/LayeredMaterialNodeProcessing'; export { default as OrientedImageCamera } from 'Renderer/OrientedImageCamera'; -export { default as PointsMaterial, PNTS_MODE, ClassificationScheme } from 'Renderer/PointsMaterial'; +export { default as PointsMaterial, PNTS_MODE, PNTS_SIZE, ClassificationScheme } from 'Renderer/PointsMaterial'; export { default as GlobeControls } from 'Controls/GlobeControls'; export { default as FlyControls } from 'Controls/FlyControls'; export { default as FirstPersonControls } from 'Controls/FirstPersonControls'; From 721b10e97066dbcfe3f2fe07881d173d675d9dca Mon Sep 17 00:00:00 2001 From: Kevin ETOURNEAU Date: Wed, 30 Aug 2023 16:58:01 +0200 Subject: [PATCH 4/5] fix(points): Rename ADAPTIVE to ATTENUATE --- src/Layer/C3DTilesLayer.js | 14 ++++------ src/Layer/PointCloudLayer.js | 1 + src/Layer/ReferencingLayerProperties.js | 17 ++++-------- src/Provider/3dTilesProvider.js | 5 ++-- src/Renderer/PointsMaterial.js | 37 ++++++++++--------------- src/Renderer/Shader/PointsVS.glsl | 12 ++++---- utils/debug/3dTilesDebug.js | 8 ++---- utils/debug/PotreeDebug.js | 8 ++---- 8 files changed, 41 insertions(+), 61 deletions(-) diff --git a/src/Layer/C3DTilesLayer.js b/src/Layer/C3DTilesLayer.js index f1a472c27e..5943dfb946 100644 --- a/src/Layer/C3DTilesLayer.js +++ b/src/Layer/C3DTilesLayer.js @@ -70,10 +70,9 @@ class C3DTilesLayer extends GeometryLayer { * removed from the scene. * @param {C3DTExtensions} [config.registeredExtensions] 3D Tiles extensions managers registered for this tileset. * @param {String} [config.pntsMode= PNTS_MODE.COLOR] {@link PointsMaterials} Point cloud coloring mode. Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points, CLASSIFICATION uses a classification property of the batch table to color points. - * @param {String} [config.pntsSize= PNTS_SIZE.VALUE] {@link PointsMaterials} Point cloud size mode. Only 'VALUE' or 'ADAPTIVE' are possible. VALUE use constant size, ADAPTIVE compute size depending on distance from point to camera. - * @param {Number} [config.pntsAdaptiveScale=1] Scale factor used by 'ADAPTIVE' size mode - * @param {Number} [config.pntsMinAdaptiveSize=3] Minimum scale used by 'ADAPTIVE' size mode - * @param {Number} [config.pntsMaxAdaptiveSize=10] Maximum scale used by 'ADAPTIVE' size mode + * @param {String} [config.pntsSize= PNTS_SIZE.VALUE] {@link PointsMaterials} Point cloud size mode. Only 'VALUE' or 'ATTENUATE' are possible. VALUE use constant size, ATTENUATE compute size depending on distance from point to camera. + * @param {Number} [config.pntsMinAttenuateSize=3] Minimum scale used by 'ADAPTIVE' size mode + * @param {Number} [config.pntsMaxAttenuateSize=10] Maximum scale used by 'ADAPTIVE' size mode * @param {Style} [config.style=null] - style used for this layer * @param {View} view The view */ @@ -89,9 +88,8 @@ class C3DTilesLayer extends GeometryLayer { this.pntsMode = PNTS_MODE.COLOR; this.classification = config.classification; this.pntsSize = PNTS_SIZE.VALUE; - this.pntsAdaptiveScale = config.pntsAdaptiveScale || 1; - this.pntsMinAdaptiveSize = config.pntsMinAdaptiveSize || 3; - this.pntsMaxAdaptiveSize = config.pntsMaxAdaptiveSize || 10; + this.pntsMinAttenuateSize = config.pntsMinAttenuateSize || 3; + this.pntsMaxAttenuateSize = config.pntsMaxAttenuateSize || 10; if (config.pntsMode) { const exists = Object.values(PNTS_MODE).includes(config.pntsMode); @@ -100,7 +98,7 @@ class C3DTilesLayer extends GeometryLayer { if (config.pntsSize) { const exists = Object.values(PNTS_SIZE).includes(config.pntsSize); - if (!exists) { console.warn("The points cloud size doesn't exist. Use 'VALUE' or 'ADAPTIVE' instead."); } else { this.pntsSize = config.pntsSize; } + if (!exists) { console.warn("The points cloud size doesn't exist. Use 'VALUE' or 'ATTENUATE' instead."); } else { this.pntsSize = config.pntsSize; } } /** @type {Style} */ diff --git a/src/Layer/PointCloudLayer.js b/src/Layer/PointCloudLayer.js index 9b15c71f3b..00dfcd563f 100644 --- a/src/Layer/PointCloudLayer.js +++ b/src/Layer/PointCloudLayer.js @@ -160,6 +160,7 @@ class PointCloudLayer extends GeometryLayer { this.material.opacity = this.opacity; this.material.transparent = this.opacity < 1; this.material.size = this.pointSize; + this.material.preSSE = context.camera.preSSE; if (this.material.updateUniforms) { this.material.updateUniforms(); } diff --git a/src/Layer/ReferencingLayerProperties.js b/src/Layer/ReferencingLayerProperties.js index cfe8e45a29..1cf0f5cd2a 100644 --- a/src/Layer/ReferencingLayerProperties.js +++ b/src/Layer/ReferencingLayerProperties.js @@ -26,19 +26,14 @@ function ReferLayerProperties(material, layer) { get: () => material.layer.pntsSize, }); } - if (material.uniforms && material.uniforms.minAdaptiveSize != undefined) { - Object.defineProperty(material.uniforms.minAdaptiveSize, 'value', { - get: () => material.layer.pntsMinAdaptiveSize, + if (material.uniforms && material.uniforms.minAttenuateSize != undefined) { + Object.defineProperty(material.uniforms.minAttenuateSize, 'value', { + get: () => material.layer.pntsMinAttenuateSize, }); } - if (material.uniforms && material.uniforms.maxAdaptiveSize != undefined) { - Object.defineProperty(material.uniforms.maxAdaptiveSize, 'value', { - get: () => material.layer.pntsMaxAdaptiveSize, - }); - } - if (material.uniforms && material.uniforms.adaptiveScale != undefined) { - Object.defineProperty(material.uniforms.adaptiveScale, 'value', { - get: () => material.layer.pntsAdaptiveScale, + if (material.uniforms && material.uniforms.maxAttenuateSize != undefined) { + Object.defineProperty(material.uniforms.maxAttenuateSize, 'value', { + get: () => material.layer.pntsMaxAttenuateSize, }); } diff --git a/src/Provider/3dTilesProvider.js b/src/Provider/3dTilesProvider.js index 787d254963..e58b2ac16c 100644 --- a/src/Provider/3dTilesProvider.js +++ b/src/Provider/3dTilesProvider.js @@ -34,9 +34,8 @@ function pntsParse(data, layer) { mode: layer.pntsMode, classification: layer.classification, sizeMode: layer.pntsSize, - minAdaptiveSize: layer.pntsMinAdaptiveSize, - maxAdaptiveSize: layer.pntsMaxAdaptiveSize, - adaptiveScale: layer.adaptiveScale, + minAttenuateSize: layer.pntsMinAttenuateSize, + maxAttenuateSize: layer.pntsMaxAttenuateSize, }); // refer material properties in the layer so when layers opacity and visibility is updated, the material is diff --git a/src/Renderer/PointsMaterial.js b/src/Renderer/PointsMaterial.js index 230e187aeb..16b27ea26e 100644 --- a/src/Renderer/PointsMaterial.js +++ b/src/Renderer/PointsMaterial.js @@ -14,7 +14,7 @@ export const PNTS_MODE = { export const PNTS_SIZE = { VALUE: 0, - ADAPTIVE: 1, + ATTENUATE: 1, }; const white = new THREE.Color(1.0, 1.0, 1.0); @@ -64,10 +64,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(0, 1)] intensity range. * @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode. * @param {Classification} [options.classification] - define points classification. - * @param {number} [options.sizeMode=SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ADAPTIVE' are possible. VALUE use constant size, ADAPTIVE compute size depending on distance from point to camera. - * @param {number} [options.adaptiveScale=1] scale factor used by 'ADAPTIVE' size mode - * @param {number} [options.minAdaptiveSize=3] minimum scale used by 'ADAPTIVE' size mode - * @param {number} [options.maxAdaptiveSize=10] maximum scale used by 'ADAPTIVE' size mode + * @param {number} [options.sizeMode=SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ATTENUATE' are possible. VALUE use constant size, ATTENUATE compute size depending on distance from point to camera. + * @param {number} [options.minAttenuateSize=3] minimum scale used by 'ATTENUATE' size mode + * @param {number} [options.maxAttenuateSize=10] maximum scale used by 'ATTENUATE' size mode * @property {Classification} classification - points classification. * * @example @@ -81,15 +80,11 @@ class PointsMaterial extends THREE.RawShaderMaterial { const oiMaterial = options.orientedImageMaterial; const classification = options.classification || ClassificationScheme.DEFAULT; const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication; - let size = options.size || 0; + const size = options.size || 0; const mode = options.mode || PNTS_MODE.COLOR; - const sizeMode = size === 0 ? PNTS_SIZE.ADAPTIVE : (options.sizeMode || PNTS_SIZE.VALUE); - if ((sizeMode === PNTS_SIZE.ADAPTIVE) && (size !== 0)) { - size = 0; - } - const minAdaptiveSize = options.minAdaptiveSize || 3; - const maxAdaptiveSize = options.maxAdaptiveSize || 10; - const adaptiveScale = options.adaptiveScale || 1; + const sizeMode = size === 0 ? PNTS_SIZE.ATTENUATE : (options.sizeMode || PNTS_SIZE.VALUE); + const minAttenuateSize = options.minAttenuateSize || 3; + const maxAttenuateSize = options.maxAttenuateSize || 10; delete options.orientedImageMaterial; delete options.intensityRange; @@ -98,9 +93,8 @@ class PointsMaterial extends THREE.RawShaderMaterial { delete options.size; delete options.mode; delete options.sizeMode; - delete options.minAdaptiveSize; - delete options.maxAdaptiveSize; - delete options.adaptiveScale; + delete options.minAttenuateSize; + delete options.maxAttenuateSize; super(options); @@ -119,9 +113,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { CommonMaterial.setUniformProperty(this, 'intensityRange', intensityRange); CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication); CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode); - CommonMaterial.setUniformProperty(this, 'minAdaptiveSize', minAdaptiveSize); - CommonMaterial.setUniformProperty(this, 'maxAdaptiveSize', maxAdaptiveSize); - CommonMaterial.setUniformProperty(this, 'adaptiveScale', adaptiveScale); + CommonMaterial.setUniformProperty(this, 'preSSE', 1.0); + CommonMaterial.setUniformProperty(this, 'minAttenuateSize', minAttenuateSize); + CommonMaterial.setUniformProperty(this, 'maxAttenuateSize', maxAttenuateSize); // add classification texture to apply classification lut. const data = new Uint8Array(256 * 4); @@ -240,9 +234,8 @@ class PointsMaterial extends THREE.RawShaderMaterial { this.size = source.size; this.mode = source.mode; this.sizeMode = source.sizeMode; - this.adaptiveScale = source.adaptiveScale; - this.minAdaptiveSize = source.minAdaptiveSize; - this.maxAdaptiveSize = source.maxAdaptiveSize; + this.minAttenuateSize = source.minAttenuateSize; + this.maxAttenuateSize = source.maxAttenuateSize; this.picking = source.picking; this.scale = source.scale; this.overlayColor.copy(source.overlayColor); diff --git a/src/Renderer/Shader/PointsVS.glsl b/src/Renderer/Shader/PointsVS.glsl index 2b14bf9500..969d37b667 100644 --- a/src/Renderer/Shader/PointsVS.glsl +++ b/src/Renderer/Shader/PointsVS.glsl @@ -8,6 +8,7 @@ #include uniform float size; +uniform float preSSE; uniform bool picking; uniform int mode; @@ -21,9 +22,8 @@ attribute float intensity; attribute float classification; uniform sampler2D classificationLUT; uniform int sizeMode; -uniform float minAdaptiveSize; -uniform float maxAdaptiveSize; -uniform float adaptiveScale; +uniform float minAttenuateSize; +uniform float maxAttenuateSize; #if defined(NORMAL_OCT16) attribute vec2 oct16Normal; @@ -105,8 +105,10 @@ void main() { if (sizeMode == PNTS_SIZE_VALUE) { gl_PointSize = size; - } else if (sizeMode == PNTS_SIZE_ADAPTIVE) { - gl_PointSize = clamp(-size / gl_Position.w, minAdaptiveSize, maxAdaptiveSize) * adaptiveScale; + } else if (sizeMode == PNTS_SIZE_ATTENUATE) { + gl_PointSize = size; + gl_PointSize *= (preSSE / -mvPosition.z); + gl_PointSize = clamp(gl_PointSize, minAttenuateSize, maxAttenuateSize); } #if defined(USE_TEXTURES_PROJECTIVE) diff --git a/utils/debug/3dTilesDebug.js b/utils/debug/3dTilesDebug.js index 8c28150bb0..34122a01e0 100644 --- a/utils/debug/3dTilesDebug.js +++ b/utils/debug/3dTilesDebug.js @@ -118,15 +118,11 @@ export default function create3dTilesDebugUI(datDebugTool, view, _3dTileslayer) view.notifyChange(view.camera.camera3D); }); - gui.add(_3dTileslayer, 'pntsAdaptiveScale', 0, 15).name('Adptive scale').onChange(() => { + gui.add(_3dTileslayer, 'pntsMinAttenuateSize', 0, 15).name('Min attenuate size').onChange(() => { view.notifyChange(view.camera.camera3D); }); - gui.add(_3dTileslayer, 'pntsMinAdaptiveSize', 0, 15).name('Min adptive size').onChange(() => { - view.notifyChange(view.camera.camera3D); - }); - - gui.add(_3dTileslayer, 'pntsMaxAdaptiveSize', 0, 15).name('Max adptive size').onChange(() => { + gui.add(_3dTileslayer, 'pntsMaxAttenuateSize', 0, 15).name('Max attenuate size').onChange(() => { view.notifyChange(view.camera.camera3D); }); } diff --git a/utils/debug/PotreeDebug.js b/utils/debug/PotreeDebug.js index 92c4994469..6975bd4691 100644 --- a/utils/debug/PotreeDebug.js +++ b/utils/debug/PotreeDebug.js @@ -28,15 +28,11 @@ export default { styleUI.add(layer, 'pointSize', 0, 15).name('Point Size').onChange(update); if (layer.material.sizeMode != undefined) { styleUI.add(layer.material, 'sizeMode', PNTS_SIZE).name('Point size mode').onChange(() => { - if (layer.material.sizeMode == PNTS_SIZE.ADAPTIVE) { - layer.pointSize = 0; - } update(); }); } - styleUI.add(layer.material, 'adaptiveScale', 0, 15).name('Adaptive scale').onChange(update); - styleUI.add(layer.material, 'minAdaptiveSize', 0, 15).name('Min adaptive size').onChange(update); - styleUI.add(layer.material, 'maxAdaptiveSize', 0, 15).name('Max adaptive size').onChange(update); + styleUI.add(layer.material, 'minAttenuateSize', 0, 15).name('Min attenuate size').onChange(update); + styleUI.add(layer.material, 'maxAttenuateSize', 0, 15).name('Max attenuate size').onChange(update); if (layer.material.picking != undefined) { styleUI.add(layer.material, 'picking').name('Display picking id').onChange(update); } From 9b457ecb3b4326acb8cd2607d99b42d76a738620 Mon Sep 17 00:00:00 2001 From: Kevin ETOURNEAU Date: Fri, 1 Sep 2023 10:49:00 +0200 Subject: [PATCH 5/5] refactor(points): Rename PNTS_SIZE_MODE and ATTENUATED --- src/Layer/C3DTilesLayer.js | 20 ++++++++--------- src/Layer/ReferencingLayerProperties.js | 14 ++++++------ src/Main.js | 2 +- src/Provider/3dTilesProvider.js | 6 ++--- src/Renderer/PointsMaterial.js | 30 ++++++++++++------------- src/Renderer/Shader/PointsVS.glsl | 10 ++++----- utils/debug/3dTilesDebug.js | 8 +++---- utils/debug/PotreeDebug.js | 8 +++---- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/Layer/C3DTilesLayer.js b/src/Layer/C3DTilesLayer.js index 5943dfb946..28d93578a6 100644 --- a/src/Layer/C3DTilesLayer.js +++ b/src/Layer/C3DTilesLayer.js @@ -3,7 +3,7 @@ import GeometryLayer from 'Layer/GeometryLayer'; import { init3dTilesLayer, pre3dTilesUpdate, process3dTilesNode } from 'Process/3dTilesProcessing'; import C3DTileset from 'Core/3DTiles/C3DTileset'; import C3DTExtensions from 'Core/3DTiles/C3DTExtensions'; -import { PNTS_MODE, PNTS_SIZE } from 'Renderer/PointsMaterial'; +import { PNTS_MODE, PNTS_SIZE_MODE } from 'Renderer/PointsMaterial'; // eslint-disable-next-line no-unused-vars import Style from 'Core/Style'; import C3DTFeature from 'Core/3DTiles/C3DTFeature'; @@ -70,9 +70,9 @@ class C3DTilesLayer extends GeometryLayer { * removed from the scene. * @param {C3DTExtensions} [config.registeredExtensions] 3D Tiles extensions managers registered for this tileset. * @param {String} [config.pntsMode= PNTS_MODE.COLOR] {@link PointsMaterials} Point cloud coloring mode. Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points, CLASSIFICATION uses a classification property of the batch table to color points. - * @param {String} [config.pntsSize= PNTS_SIZE.VALUE] {@link PointsMaterials} Point cloud size mode. Only 'VALUE' or 'ATTENUATE' are possible. VALUE use constant size, ATTENUATE compute size depending on distance from point to camera. - * @param {Number} [config.pntsMinAttenuateSize=3] Minimum scale used by 'ADAPTIVE' size mode - * @param {Number} [config.pntsMaxAttenuateSize=10] Maximum scale used by 'ADAPTIVE' size mode + * @param {String} [config.pntsSizeMode= PNTS_SIZE_MODE.VALUE] {@link PointsMaterials} Point cloud size mode. Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance from point to camera. + * @param {Number} [config.pntsMinAttenuatedSize=3] Minimum scale used by 'ATTENUATED' size mode + * @param {Number} [config.pntsMaxAttenuatedSize=10] Maximum scale used by 'ATTENUATED' size mode * @param {Style} [config.style=null] - style used for this layer * @param {View} view The view */ @@ -87,18 +87,18 @@ class C3DTilesLayer extends GeometryLayer { this.pntsMode = PNTS_MODE.COLOR; this.classification = config.classification; - this.pntsSize = PNTS_SIZE.VALUE; - this.pntsMinAttenuateSize = config.pntsMinAttenuateSize || 3; - this.pntsMaxAttenuateSize = config.pntsMaxAttenuateSize || 10; + this.pntsSizeMode = PNTS_SIZE_MODE.VALUE; + this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize || 3; + this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize || 10; if (config.pntsMode) { const exists = Object.values(PNTS_MODE).includes(config.pntsMode); if (!exists) { console.warn("The points cloud mode doesn't exist. Use 'COLOR' or 'CLASSIFICATION' instead."); } else { this.pntsMode = config.pntsMode; } } - if (config.pntsSize) { - const exists = Object.values(PNTS_SIZE).includes(config.pntsSize); - if (!exists) { console.warn("The points cloud size doesn't exist. Use 'VALUE' or 'ATTENUATE' instead."); } else { this.pntsSize = config.pntsSize; } + if (config.pntsSizeMode) { + const exists = Object.values(PNTS_SIZE_MODE).includes(config.pntsSizeMode); + if (!exists) { console.warn("The points cloud size mode doesn't exist. Use 'VALUE' or 'ATTENUATED' instead."); } else { this.pntsSizeMode = config.pntsSizeMode; } } /** @type {Style} */ diff --git a/src/Layer/ReferencingLayerProperties.js b/src/Layer/ReferencingLayerProperties.js index 1cf0f5cd2a..a750b80e82 100644 --- a/src/Layer/ReferencingLayerProperties.js +++ b/src/Layer/ReferencingLayerProperties.js @@ -23,17 +23,17 @@ function ReferLayerProperties(material, layer) { } if (material.uniforms && material.uniforms.sizeMode != undefined) { Object.defineProperty(material.uniforms.sizeMode, 'value', { - get: () => material.layer.pntsSize, + get: () => material.layer.pntsSizeMode, }); } - if (material.uniforms && material.uniforms.minAttenuateSize != undefined) { - Object.defineProperty(material.uniforms.minAttenuateSize, 'value', { - get: () => material.layer.pntsMinAttenuateSize, + if (material.uniforms && material.uniforms.minAttenuatedSize != undefined) { + Object.defineProperty(material.uniforms.minAttenuatedSize, 'value', { + get: () => material.layer.pntsMinAttenuatedSize, }); } - if (material.uniforms && material.uniforms.maxAttenuateSize != undefined) { - Object.defineProperty(material.uniforms.maxAttenuateSize, 'value', { - get: () => material.layer.pntsMaxAttenuateSize, + if (material.uniforms && material.uniforms.maxAttenuatedSize != undefined) { + Object.defineProperty(material.uniforms.maxAttenuatedSize, 'value', { + get: () => material.layer.pntsMaxAttenuatedSize, }); } diff --git a/src/Main.js b/src/Main.js index 016fd7613a..ba0fa8e66e 100644 --- a/src/Main.js +++ b/src/Main.js @@ -19,7 +19,7 @@ export { VIEW_EVENTS } from 'Core/View'; export { default as FeatureProcessing } from 'Process/FeatureProcessing'; export { updateLayeredMaterialNodeImagery, updateLayeredMaterialNodeElevation } from 'Process/LayeredMaterialNodeProcessing'; export { default as OrientedImageCamera } from 'Renderer/OrientedImageCamera'; -export { default as PointsMaterial, PNTS_MODE, PNTS_SIZE, ClassificationScheme } from 'Renderer/PointsMaterial'; +export { default as PointsMaterial, PNTS_MODE, PNTS_SIZE_MODE, ClassificationScheme } from 'Renderer/PointsMaterial'; export { default as GlobeControls } from 'Controls/GlobeControls'; export { default as FlyControls } from 'Controls/FlyControls'; export { default as FirstPersonControls } from 'Controls/FirstPersonControls'; diff --git a/src/Provider/3dTilesProvider.js b/src/Provider/3dTilesProvider.js index e58b2ac16c..d6cc6f64fb 100644 --- a/src/Provider/3dTilesProvider.js +++ b/src/Provider/3dTilesProvider.js @@ -33,9 +33,9 @@ function pntsParse(data, layer) { size: 0.05, mode: layer.pntsMode, classification: layer.classification, - sizeMode: layer.pntsSize, - minAttenuateSize: layer.pntsMinAttenuateSize, - maxAttenuateSize: layer.pntsMaxAttenuateSize, + sizeMode: layer.pntsSizeMode, + minAttenuatedSize: layer.pntsMinAttenuatedSize, + maxAttenuatedSize: layer.pntsMaxAttenuatedSize, }); // refer material properties in the layer so when layers opacity and visibility is updated, the material is diff --git a/src/Renderer/PointsMaterial.js b/src/Renderer/PointsMaterial.js index 16b27ea26e..3f824f643d 100644 --- a/src/Renderer/PointsMaterial.js +++ b/src/Renderer/PointsMaterial.js @@ -12,9 +12,9 @@ export const PNTS_MODE = { NORMAL: 3, }; -export const PNTS_SIZE = { +export const PNTS_SIZE_MODE = { VALUE: 0, - ATTENUATE: 1, + ATTENUATED: 1, }; const white = new THREE.Color(1.0, 1.0, 1.0); @@ -64,9 +64,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(0, 1)] intensity range. * @param {boolean} [options.applyOpacityClassication=false] apply opacity classification on all display mode. * @param {Classification} [options.classification] - define points classification. - * @param {number} [options.sizeMode=SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ATTENUATE' are possible. VALUE use constant size, ATTENUATE compute size depending on distance from point to camera. - * @param {number} [options.minAttenuateSize=3] minimum scale used by 'ATTENUATE' size mode - * @param {number} [options.maxAttenuateSize=10] maximum scale used by 'ATTENUATE' size mode + * @param {number} [options.sizeMode=PNTS_SIZE_MODE.VALUE] point cloud size mode. Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance from point to camera. + * @param {number} [options.minAttenuatedSize=3] minimum scale used by 'ATTENUATED' size mode + * @param {number} [options.maxAttenuatedSize=10] maximum scale used by 'ATTENUATED' size mode * @property {Classification} classification - points classification. * * @example @@ -82,9 +82,9 @@ class PointsMaterial extends THREE.RawShaderMaterial { const applyOpacityClassication = options.applyOpacityClassication == undefined ? false : options.applyOpacityClassication; const size = options.size || 0; const mode = options.mode || PNTS_MODE.COLOR; - const sizeMode = size === 0 ? PNTS_SIZE.ATTENUATE : (options.sizeMode || PNTS_SIZE.VALUE); - const minAttenuateSize = options.minAttenuateSize || 3; - const maxAttenuateSize = options.maxAttenuateSize || 10; + const sizeMode = size === 0 ? PNTS_SIZE_MODE.ATTENUATED : (options.sizeMode || PNTS_SIZE_MODE.VALUE); + const minAttenuatedSize = options.minAttenuatedSize || 3; + const maxAttenuatedSize = options.maxAttenuatedSize || 10; delete options.orientedImageMaterial; delete options.intensityRange; @@ -93,8 +93,8 @@ class PointsMaterial extends THREE.RawShaderMaterial { delete options.size; delete options.mode; delete options.sizeMode; - delete options.minAttenuateSize; - delete options.maxAttenuateSize; + delete options.minAttenuatedSize; + delete options.maxAttenuatedSize; super(options); @@ -103,7 +103,7 @@ class PointsMaterial extends THREE.RawShaderMaterial { this.scale = options.scale || 0.05 * 0.5 / Math.tan(1.0 / 2.0); // autosizing scale CommonMaterial.setDefineMapping(this, 'PNTS_MODE', PNTS_MODE); - CommonMaterial.setDefineMapping(this, 'PNTS_SIZE', PNTS_SIZE); + CommonMaterial.setDefineMapping(this, 'PNTS_SIZE_MODE', PNTS_SIZE_MODE); CommonMaterial.setUniformProperty(this, 'size', size); CommonMaterial.setUniformProperty(this, 'mode', mode); @@ -114,8 +114,8 @@ class PointsMaterial extends THREE.RawShaderMaterial { CommonMaterial.setUniformProperty(this, 'applyOpacityClassication', applyOpacityClassication); CommonMaterial.setUniformProperty(this, 'sizeMode', sizeMode); CommonMaterial.setUniformProperty(this, 'preSSE', 1.0); - CommonMaterial.setUniformProperty(this, 'minAttenuateSize', minAttenuateSize); - CommonMaterial.setUniformProperty(this, 'maxAttenuateSize', maxAttenuateSize); + CommonMaterial.setUniformProperty(this, 'minAttenuatedSize', minAttenuatedSize); + CommonMaterial.setUniformProperty(this, 'maxAttenuatedSize', maxAttenuatedSize); // add classification texture to apply classification lut. const data = new Uint8Array(256 * 4); @@ -234,8 +234,8 @@ class PointsMaterial extends THREE.RawShaderMaterial { this.size = source.size; this.mode = source.mode; this.sizeMode = source.sizeMode; - this.minAttenuateSize = source.minAttenuateSize; - this.maxAttenuateSize = source.maxAttenuateSize; + this.minAttenuatedSize = source.minAttenuatedSize; + this.maxAttenuatedSize = source.maxAttenuatedSize; this.picking = source.picking; this.scale = source.scale; this.overlayColor.copy(source.overlayColor); diff --git a/src/Renderer/Shader/PointsVS.glsl b/src/Renderer/Shader/PointsVS.glsl index 969d37b667..019541fe6a 100644 --- a/src/Renderer/Shader/PointsVS.glsl +++ b/src/Renderer/Shader/PointsVS.glsl @@ -22,8 +22,8 @@ attribute float intensity; attribute float classification; uniform sampler2D classificationLUT; uniform int sizeMode; -uniform float minAttenuateSize; -uniform float maxAttenuateSize; +uniform float minAttenuatedSize; +uniform float maxAttenuatedSize; #if defined(NORMAL_OCT16) attribute vec2 oct16Normal; @@ -103,12 +103,12 @@ void main() { #include #include - if (sizeMode == PNTS_SIZE_VALUE) { + if (sizeMode == PNTS_SIZE_MODE_VALUE) { gl_PointSize = size; - } else if (sizeMode == PNTS_SIZE_ATTENUATE) { + } else if (sizeMode == PNTS_SIZE_MODE_ATTENUATED) { gl_PointSize = size; gl_PointSize *= (preSSE / -mvPosition.z); - gl_PointSize = clamp(gl_PointSize, minAttenuateSize, maxAttenuateSize); + gl_PointSize = clamp(gl_PointSize, minAttenuatedSize, maxAttenuatedSize); } #if defined(USE_TEXTURES_PROJECTIVE) diff --git a/utils/debug/3dTilesDebug.js b/utils/debug/3dTilesDebug.js index 34122a01e0..d1db7cdc66 100644 --- a/utils/debug/3dTilesDebug.js +++ b/utils/debug/3dTilesDebug.js @@ -1,7 +1,7 @@ import * as THREE from 'three'; import View from 'Core/View'; import GeometryLayer from 'Layer/GeometryLayer'; -import { PNTS_SIZE } from 'Renderer/PointsMaterial'; +import { PNTS_SIZE_MODE } from 'Renderer/PointsMaterial'; import GeometryDebug from './GeometryDebug'; import OBBHelper from './OBBHelper'; @@ -114,15 +114,15 @@ export default function create3dTilesDebugUI(datDebugTool, view, _3dTileslayer) view.notifyChange(view.camera.camera3D); }); - gui.add(_3dTileslayer, 'pntsSize', PNTS_SIZE).name('Pnts size mode').onChange(() => { + gui.add(_3dTileslayer, 'pntsSizeMode', PNTS_SIZE_MODE).name('Pnts size mode').onChange(() => { view.notifyChange(view.camera.camera3D); }); - gui.add(_3dTileslayer, 'pntsMinAttenuateSize', 0, 15).name('Min attenuate size').onChange(() => { + gui.add(_3dTileslayer, 'pntsMinAttenuatedSize', 0, 15).name('Min attenuated size').onChange(() => { view.notifyChange(view.camera.camera3D); }); - gui.add(_3dTileslayer, 'pntsMaxAttenuateSize', 0, 15).name('Max attenuate size').onChange(() => { + gui.add(_3dTileslayer, 'pntsMaxAttenuatedSize', 0, 15).name('Max attenuated size').onChange(() => { view.notifyChange(view.camera.camera3D); }); } diff --git a/utils/debug/PotreeDebug.js b/utils/debug/PotreeDebug.js index 6975bd4691..43f5ad5f2c 100644 --- a/utils/debug/PotreeDebug.js +++ b/utils/debug/PotreeDebug.js @@ -1,4 +1,4 @@ -import { PNTS_MODE, PNTS_SIZE } from 'Renderer/PointsMaterial'; +import { PNTS_MODE, PNTS_SIZE_MODE } from 'Renderer/PointsMaterial'; export default { initTools(view, layer, datUi) { @@ -27,12 +27,12 @@ export default { styleUI.add(layer, 'opacity', 0, 1).name('Layer Opacity').onChange(update); styleUI.add(layer, 'pointSize', 0, 15).name('Point Size').onChange(update); if (layer.material.sizeMode != undefined) { - styleUI.add(layer.material, 'sizeMode', PNTS_SIZE).name('Point size mode').onChange(() => { + styleUI.add(layer.material, 'sizeMode', PNTS_SIZE_MODE).name('Point size mode').onChange(() => { update(); }); } - styleUI.add(layer.material, 'minAttenuateSize', 0, 15).name('Min attenuate size').onChange(update); - styleUI.add(layer.material, 'maxAttenuateSize', 0, 15).name('Max attenuate size').onChange(update); + styleUI.add(layer.material, 'minAttenuatedSize', 0, 15).name('Min attenuated size').onChange(update); + styleUI.add(layer.material, 'maxAttenuatedSize', 0, 15).name('Max attenuated size').onChange(update); if (layer.material.picking != undefined) { styleUI.add(layer.material, 'picking').name('Display picking id').onChange(update); }