1
1
import * as THREE from 'three' ;
2
2
import Extent from 'Core/Geographic/Extent' ;
3
+ import ObjectRemovalHelper from 'Process/ObjectRemovalHelper' ;
3
4
4
5
/** @module 3dTilesProcessing
5
6
*/
@@ -166,7 +167,7 @@ function cleanup3dTileset(layer, n, depth = 0) {
166
167
// skip non-tiles elements
167
168
if ( ! n . children [ i ] . content ) {
168
169
if ( canCleanCompletely ) {
169
- n . children [ i ] . traverse ( _cleanupObject3D ) ;
170
+ ObjectRemovalHelper . removeChildrenAndCleanupRecursively ( n . children [ i ] . layer , n . children [ i ] ) ;
170
171
}
171
172
} else {
172
173
cleanup3dTileset ( layer , n . children [ i ] , depth + 1 ) ;
@@ -192,31 +193,6 @@ function cleanup3dTileset(layer, n, depth = 0) {
192
193
}
193
194
}
194
195
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
-
220
196
// this is a layer
221
197
export function pre3dTilesUpdate ( ) {
222
198
if ( ! this . visible ) {
0 commit comments