Skip to content

Commit 284be24

Browse files
committed
fix(3dtiles): improve 3D Tiles cache cleaning
1 parent c53436a commit 284be24

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

src/Process/3dTilesProcessing.js

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as THREE from 'three';
22
import Extent from 'Core/Geographic/Extent';
3+
import ObjectRemovalHelper from 'Process/ObjectRemovalHelper';
34

45
/** @module 3dTilesProcessing
56
*/
@@ -166,7 +167,7 @@ function cleanup3dTileset(layer, n, depth = 0) {
166167
// skip non-tiles elements
167168
if (!n.children[i].content) {
168169
if (canCleanCompletely) {
169-
n.children[i].traverse(_cleanupObject3D);
170+
ObjectRemovalHelper.removeChildrenAndCleanupRecursively(n.children[i].layer, n.children[i]);
170171
}
171172
} else {
172173
cleanup3dTileset(layer, n.children[i], depth + 1);
@@ -192,31 +193,6 @@ function cleanup3dTileset(layer, n, depth = 0) {
192193
}
193194
}
194195

195-
// This function is used to cleanup a Object3D hierarchy.
196-
// (no 3dtiles spectific code here because this is managed by cleanup3dTileset)
197-
function _cleanupObject3D(n) {
198-
// all children of 'n' are raw Object3D
199-
for (const child of n.children) {
200-
_cleanupObject3D(child);
201-
}
202-
// free resources
203-
if (n.material) {
204-
// material can be either a THREE.Material object, or an array of
205-
// THREE.Material objects
206-
if (Array.isArray(n.material)) {
207-
for (const material of n.material) {
208-
material.dispose();
209-
}
210-
} else {
211-
n.material.dispose();
212-
}
213-
}
214-
if (n.geometry) {
215-
n.geometry.dispose();
216-
}
217-
n.remove(...n.children);
218-
}
219-
220196
// this is a layer
221197
export function pre3dTilesUpdate() {
222198
if (!this.visible) {

0 commit comments

Comments
 (0)