File tree Expand file tree Collapse file tree 2 files changed +37
-7
lines changed Expand file tree Collapse file tree 2 files changed +37
-7
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,17 @@ class ReflectorNode extends TextureNode {
161
161
162
162
}
163
163
164
+ /**
165
+ * Frees internal resources. Should be called when the node is no longer in use.
166
+ */
167
+ dispose ( ) {
168
+
169
+ super . dispose ( ) ;
170
+
171
+ this . _reflectorBaseNode . dispose ( ) ;
172
+
173
+ }
174
+
164
175
}
165
176
166
177
/**
@@ -269,9 +280,9 @@ class ReflectorBaseNode extends Node {
269
280
/**
270
281
* Weak map for managing render targets.
271
282
*
272
- * @type {WeakMap <Camera, RenderTarget> }
283
+ * @type {Map <Camera, RenderTarget> }
273
284
*/
274
- this . renderTargets = new WeakMap ( ) ;
285
+ this . renderTargets = new Map ( ) ;
275
286
276
287
/**
277
288
* Force render even if reflector is facing away from camera.
@@ -308,6 +319,21 @@ class ReflectorBaseNode extends Node {
308
319
309
320
}
310
321
322
+ /**
323
+ * Frees internal resources. Should be called when the node is no longer in use.
324
+ */
325
+ dispose ( ) {
326
+
327
+ super . dispose ( ) ;
328
+
329
+ for ( const renderTarget of this . renderTargets . values ( ) ) {
330
+
331
+ renderTarget . dispose ( ) ;
332
+
333
+ }
334
+
335
+ }
336
+
311
337
/**
312
338
* Returns a virtual camera for the given camera. The virtual camera is used to
313
339
* render the scene from the reflector's view so correct reflections can be produced.
Original file line number Diff line number Diff line change @@ -343,8 +343,6 @@ class Textures extends DataMap {
343
343
344
344
this . _destroyTexture ( texture ) ;
345
345
346
- this . info . memory . textures -- ;
347
-
348
346
} ;
349
347
350
348
texture . addEventListener ( 'dispose' , onDispose ) ;
@@ -445,10 +443,16 @@ class Textures extends DataMap {
445
443
*/
446
444
_destroyTexture ( texture ) {
447
445
448
- this . backend . destroySampler ( texture ) ;
449
- this . backend . destroyTexture ( texture ) ;
446
+ if ( this . has ( texture ) === true ) {
447
+
448
+ this . backend . destroySampler ( texture ) ;
449
+ this . backend . destroyTexture ( texture ) ;
450
+
451
+ this . delete ( texture ) ;
450
452
451
- this . delete ( texture ) ;
453
+ this . info . memory . textures -- ;
454
+
455
+ }
452
456
453
457
}
454
458
You can’t perform that action at this time.
0 commit comments