Skip to content

Commit

Permalink
fix(PointCloudLayer): use the User value for ElevationRange (if present)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Feb 7, 2025
1 parent 6d12fde commit 387d64f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
20 changes: 15 additions & 5 deletions examples/copc_simple_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</head>
<body>
<div id="description">Specify the URL of a COPC file to load:
<input type="text" id="url" />
<input type="text" id="copc_url" />
<button onclick="readURL()">Load</button>
<div>
<button onClick="loadAutzen()">Load Autzen Stadium (80mb)</button>
Expand Down Expand Up @@ -71,7 +71,7 @@


function readURL() {
const url = document.getElementById('url').value;
const url = document.getElementById('copc_url').value;

if (url) {
setUrl(url);
Expand All @@ -81,7 +81,7 @@
function setUrl(url) {
if (!url) return;

const input_url = document.getElementById('url');
const input_url = document.getElementById('copc_url');
if (!input_url) return;

uri.searchParams.set('copc', url);
Expand All @@ -93,6 +93,13 @@


function load(url) {
const options = {};
const urlParams = uri.searchParams
urlParams.keys().forEach(key => {
if (key !== 'copc') {
options[key] = parseInt(urlParams.get(key), 10);
}
});
const source = new itowns.CopcSource({ url });

if (layer) {
Expand All @@ -102,12 +109,15 @@
layer.delete();
}

layer = new itowns.CopcLayer('COPC', {
const config = {
source,
crs: view.referenceCrs,
sseThreshold: 2,
pointBudget: 3000000,
});
...options,
};

layer = new itowns.CopcLayer('COPC', config);
view.addLayer(layer).then(onLayerReady);
layer.whenReady
.then(() => debug.PointCloudDebug.initTools(view, layer, gui));
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/CopcLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class CopcLayer extends PointCloudLayer {
this.root.bbox.min.fromArray(cube, 0);
this.root.bbox.max.fromArray(cube, 3);

this.minElevationRange = source.header.min[2];
this.maxElevationRange = source.header.max[2];
this.minElevationRange = this.minElevationRange ?? source.header.min[2];
this.maxElevationRange = this.maxElevationRange ?? source.header.max[2];

this.scale = new THREE.Vector3(1.0, 1.0, 1.0);
this.offset = new THREE.Vector3(0.0, 0.0, 0.0);
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/EntwinePointTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class EntwinePointTileLayer extends PointCloudLayer {
this.root = new EntwinePointTileNode(0, 0, 0, 0, this, -1);
this.root.bbox.min.fromArray(this.source.boundsConforming, 0);
this.root.bbox.max.fromArray(this.source.boundsConforming, 3);
this.minElevationRange = this.source.boundsConforming[2];
this.maxElevationRange = this.source.boundsConforming[5];
this.minElevationRange = this.minElevationRange ?? this.source.boundsConforming[2];
this.maxElevationRange = this.maxElevationRange ?? this.source.boundsConforming[5];

this.extent = Extent.fromBox3(config.crs || 'EPSG:4326', this.root.bbox);
return this.root.loadOctree().then(resolve);
Expand Down
8 changes: 5 additions & 3 deletions src/Layer/PointCloudLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ class PointCloudLayer extends GeometryLayer {
* contains three elements `name, protocol, extent`, these elements will be
* available using `layer.name` or something else depending on the property
* name. See the list of properties to know which one can be specified.
* @param {Source} config.source - Description and options of the source.
* @param {Source} config.source - Description and options of the source See @Layer.
* @param {number} [options.minElevationRange] - Min value for the elevation range (default value will be taken from the source.metadata).
* @param {number} [options.maxElevationRange] - Max value for the elevation range (default value will be taken from the source.metadata).
*/
constructor(id, config = {}) {
const {
Expand All @@ -157,8 +159,8 @@ class PointCloudLayer extends GeometryLayer {
sseThreshold = 2,
minIntensityRange = 1,
maxIntensityRange = 65536,
minElevationRange = 0,
maxElevationRange = 1000,
minElevationRange,
maxElevationRange,
minAngleRange = -90,
maxAngleRange = 90,
material = {},
Expand Down
3 changes: 3 additions & 0 deletions src/Layer/Potree2Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ class Potree2Layer extends PointCloudLayer {
root.bbox = boundingBox;
root.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());

this.minElevationRange = this.minElevationRange ?? metadata.boundingBox.min[2];
this.maxElevationRange = this.maxElevationRange ?? metadata.boundingBox.max[2];

root.id = 'r';
root.depth = 0;
root.nodeType = 2;
Expand Down
3 changes: 3 additions & 0 deletions src/Layer/PotreeLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class PotreeLayer extends PointCloudLayer {
this.root.bbox.min.set(cloud.boundingBox.lx, cloud.boundingBox.ly, cloud.boundingBox.lz);
this.root.bbox.max.set(cloud.boundingBox.ux, cloud.boundingBox.uy, cloud.boundingBox.uz);

this.minElevationRange = this.minElevationRange ?? cloud.boundingBox.lz;
this.maxElevationRange = this.maxElevationRange ?? cloud.boundingBox.uz;

this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', this.root.bbox);
return this.root.loadOctree().then(resolve);
});
Expand Down
7 changes: 4 additions & 3 deletions src/Renderer/PointsMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
* @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
* @param {number} [options.shape=PNTS_SHAPE.CIRCLE] rendered points shape.
* @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
* @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
* @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
* @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
* @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
* @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
* @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
Expand All @@ -171,6 +169,9 @@ class PointsMaterial extends THREE.ShaderMaterial {
* @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 {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range (default value will be [1, 65536] if not defined at Layer level).
* @property {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range (default value will be [0, 1000] if not defined at Layer level).
* @property {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range (default value will be [-90, 90] if not defined at Layer level).
* @property {Scheme} classificationScheme - Color scheme for point classification values.
* @property {Scheme} discreteScheme - Color scheme for all other discrete values.
* @property {object} gradients - Descriptions of all available gradients.
Expand Down

0 comments on commit 387d64f

Please sign in to comment.