Skip to content

Commit 7961810

Browse files
authored
Examples: Fix memory leak in SVG. (#31170)
1 parent 0fce901 commit 7961810

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/webgl_loader_svg.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@
142142

143143
//
144144

145+
if ( scene ) disposeScene( scene );
146+
147+
//
148+
145149
scene = new THREE.Scene();
146150
scene.background = new THREE.Color( 0xb0b0b0 );
147151

@@ -250,6 +254,21 @@
250254

251255
}
252256

257+
function disposeScene( scene ) {
258+
259+
scene.traverse( function ( object ) {
260+
261+
if ( object.isMesh || object.isLine ) {
262+
263+
object.geometry.dispose();
264+
object.material.dispose();
265+
266+
}
267+
268+
} );
269+
270+
}
271+
253272
</script>
254273

255274
</body>

0 commit comments

Comments
 (0)