Skip to content

Commit

Permalink
Properly dispose renderer to stop the animation loop when removing th…
Browse files Browse the repository at this point in the history
…e scene from the DOM (#5112)
  • Loading branch information
vincentfretin committed Sep 10, 2022
1 parent 34665ed commit fb67365
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ module.exports.AScene = registerElement('a-scene', {
window.removeEventListener('vrdisplaypointerrestricted', this.pointerRestrictedBound);
window.removeEventListener('vrdisplaypointerunrestricted', this.pointerUnrestrictedBound);
window.removeEventListener('sessionend', this.resize);
this.renderer.xr.dispose();
this.renderer.dispose();
}
},

Expand Down
1 change: 1 addition & 0 deletions tests/__init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ setup(function () {
dispose: function () {},
enabled: false
},
dispose: function () {},
getContext: function () { return undefined; },
setAnimationLoop: function () {},
setSize: function () {},
Expand Down
3 changes: 3 additions & 0 deletions tests/core/scene/a-scene.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ suite('a-scene (without renderer)', function () {
setPoseTarget: function () {},
dispose: function () {}
},
dispose: function () {},
getContext: function () { return undefined; },
setAnimationLoop: function () {},
setPixelRatio: function () {},
Expand Down Expand Up @@ -271,6 +272,7 @@ suite('a-scene (without renderer)', function () {
setPoseTarget: function () {},
dispose: function () {}
},
dispose: function () {},
setAnimationLoop: function () {},
setPixelRatio: function () {},
setSize: function () {},
Expand Down Expand Up @@ -445,6 +447,7 @@ suite('a-scene (without renderer)', function () {
setDevice: function () {},
dispose: function () {}
},
dispose: function () {},
setAnimationLoop: function () {},
setSize: setSizeSpy,
render: function () {}
Expand Down

0 comments on commit fb67365

Please sign in to comment.