Skip to content

Commit

Permalink
fix(3dtiles): improve 3D Tiles cache cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
jailln committed Jan 24, 2023
1 parent c53436a commit 284be24
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/Process/3dTilesProcessing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as THREE from 'three';
import Extent from 'Core/Geographic/Extent';
import ObjectRemovalHelper from 'Process/ObjectRemovalHelper';

/** @module 3dTilesProcessing
*/
Expand Down Expand Up @@ -166,7 +167,7 @@ function cleanup3dTileset(layer, n, depth = 0) {
// skip non-tiles elements
if (!n.children[i].content) {
if (canCleanCompletely) {
n.children[i].traverse(_cleanupObject3D);
ObjectRemovalHelper.removeChildrenAndCleanupRecursively(n.children[i].layer, n.children[i]);
}
} else {
cleanup3dTileset(layer, n.children[i], depth + 1);
Expand All @@ -192,31 +193,6 @@ function cleanup3dTileset(layer, n, depth = 0) {
}
}

// This function is used to cleanup a Object3D hierarchy.
// (no 3dtiles spectific code here because this is managed by cleanup3dTileset)
function _cleanupObject3D(n) {
// all children of 'n' are raw Object3D
for (const child of n.children) {
_cleanupObject3D(child);
}
// free resources
if (n.material) {
// material can be either a THREE.Material object, or an array of
// THREE.Material objects
if (Array.isArray(n.material)) {
for (const material of n.material) {
material.dispose();
}
} else {
n.material.dispose();
}
}
if (n.geometry) {
n.geometry.dispose();
}
n.remove(...n.children);
}

// this is a layer
export function pre3dTilesUpdate() {
if (!this.visible) {
Expand Down

0 comments on commit 284be24

Please sign in to comment.