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 {
161161
162162 }
163163
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+
164175}
165176
166177/**
@@ -269,9 +280,9 @@ class ReflectorBaseNode extends Node {
269280 /**
270281 * Weak map for managing render targets.
271282 *
272- * @type {WeakMap <Camera, RenderTarget> }
283+ * @type {Map <Camera, RenderTarget> }
273284 */
274- this . renderTargets = new WeakMap ( ) ;
285+ this . renderTargets = new Map ( ) ;
275286
276287 /**
277288 * Force render even if reflector is facing away from camera.
@@ -308,6 +319,21 @@ class ReflectorBaseNode extends Node {
308319
309320 }
310321
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+
311337 /**
312338 * Returns a virtual camera for the given camera. The virtual camera is used to
313339 * 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 {
343343
344344 this . _destroyTexture ( texture ) ;
345345
346- this . info . memory . textures -- ;
347-
348346 } ;
349347
350348 texture . addEventListener ( 'dispose' , onDispose ) ;
@@ -445,10 +443,16 @@ class Textures extends DataMap {
445443 */
446444 _destroyTexture ( texture ) {
447445
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 ) ;
450452
451- this . delete ( texture ) ;
453+ this . info . memory . textures -- ;
454+
455+ }
452456
453457 }
454458
You can’t perform that action at this time.
0 commit comments