Skip to content

Commit

Permalink
fix(TiledGeometryLayer): remove subdivision checking code (iTowns#2344)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyGlt authored Sep 19, 2024
1 parent c1409c5 commit e386637
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
4 changes: 0 additions & 4 deletions src/Core/Prefab/Globe/GlobeLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class GlobeLayer extends TiledGeometryLayer {
* level for this tiled layer.
* @param {number} [config.sseSubdivisionThreshold=1] - Threshold level for
* the SSE.
* @param {number} [config.maxDeltaElevationLevel=4] - Maximum delta between
* two elevations tile.
*
* @throws {Error} `object3d` must be a valid `THREE.Object3d`.
*/
Expand All @@ -67,8 +65,6 @@ class GlobeLayer extends TiledGeometryLayer {
this.options.defaultPickingRadius = 5;
this.minSubdivisionLevel = this.minSubdivisionLevel == undefined ? 2 : this.minSubdivisionLevel;
this.maxSubdivisionLevel = this.maxSubdivisionLevel == undefined ? 19 : this.maxSubdivisionLevel;
this.maxDeltaElevationLevel = this.maxDeltaElevationLevel || 4.0;

this.extent = this.schemeTile[0].clone();

for (let i = 1; i < this.schemeTile.length; i++) {
Expand Down
3 changes: 0 additions & 3 deletions src/Core/Prefab/Planar/PlanarLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class PlanarLayer extends TiledGeometryLayer {
* name.
* @param {number} [config.maxSubdivisionLevel=5] - Maximum subdivision
* level for this tiled layer.
* @param {number} [config.maxDeltaElevationLevel=4] - Maximum delta between
* two elevations tile.
*
* @throws {Error} `object3d` must be a valid `THREE.Object3d`.
*/
Expand All @@ -49,7 +47,6 @@ class PlanarLayer extends TiledGeometryLayer {
this.extent = extent;
this.minSubdivisionLevel = this.minSubdivisionLevel == undefined ? 0 : this.minSubdivisionLevel;
this.maxSubdivisionLevel = this.maxSubdivisionLevel == undefined ? 5 : this.maxSubdivisionLevel;
this.maxDeltaElevationLevel = this.maxDeltaElevationLevel || 4.0;
}
}

Expand Down
21 changes: 4 additions & 17 deletions src/Layer/TiledGeometryLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class TiledGeometryLayer extends GeometryLayer {
throw new Error(`Cannot init tiled layer without builder for layer ${this.id}`);
}

if (config.maxDeltaElevationLevel) {
console.warn('Config using maxDeltaElevationLevel is deprecated. The parameter maxDeltaElevationLevel is not longer used');
}

this.level0Nodes = [];
const promises = [];

Expand Down Expand Up @@ -414,23 +418,6 @@ class TiledGeometryLayer extends GeometryLayer {
if (this.maxSubdivisionLevel <= node.level) {
return false;
}

// Prevent to subdivise the node if the current elevation level
// we must avoid a tile, with level 20, inherits a level 3 elevation texture.
// The induced geometric error is much too large and distorts the SSE
const nodeLayer = node.material.getElevationLayer();
if (nodeLayer) {
const currentTexture = nodeLayer.textures[0];
if (currentTexture && currentTexture.extent) {
const offsetScale = nodeLayer.offsetScales[0];
const ratio = offsetScale.z;
// ratio is node size / texture size
if (ratio < 1 / 2 ** this.maxDeltaElevationLevel) {
return false;
}
}
}

subdivisionVector.setFromMatrixScale(node.matrixWorld);
boundingSphereCenter.copy(node.boundingSphere.center).applyMatrix4(node.matrixWorld);
const distance = Math.max(
Expand Down

0 comments on commit e386637

Please sign in to comment.