Commit 7618da3 1 parent cc47d56 commit 7618da3 Copy full SHA for 7618da3
File tree 1 file changed +13
-3
lines changed
web-ifc-three/src/IFC/components
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -197,9 +197,19 @@ export class IFCManager {
197
197
* @scene Scene where the model is (if it's located in a scene).
198
198
*/
199
199
close ( modelID : number , scene ?: Scene ) {
200
- this . state . api . CloseModel ( modelID ) ;
201
- if ( scene ) scene . remove ( this . state . models [ modelID ] . mesh ) ;
202
- delete this . state . models [ modelID ] ;
200
+ try {
201
+ this . state . api . CloseModel ( modelID ) ;
202
+ const mesh = this . state . models [ modelID ] . mesh ;
203
+ const { geometry, material } = mesh ;
204
+ if ( scene ) scene . remove ( mesh ) ;
205
+ geometry ?. dispose ( ) ;
206
+ geometry = null ;
207
+ Array . isArray ( material ) ? material . forEach ( m => m . dispose ( ) ) : material ?. dispose ( ) ;
208
+ material = null ;
209
+ delete this . state . models [ modelID ] ;
210
+ } catch ( e ) {
211
+ console . warn ( `Close IFCModel ${ modelID } failed` ) ;
212
+ }
203
213
}
204
214
205
215
/**
You can’t perform that action at this time.
0 commit comments