Skip to content

Commit

Permalink
Engine unmounted first and Engine dispose() disposes of the Scene. Ne…
Browse files Browse the repository at this point in the history
…ed an additional check before disposing the Scene #65
  • Loading branch information
brianzinn committed May 31, 2020
1 parent 8c9aefb commit 08bc7c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Engine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ class Engine extends React.Component<EngineProps, EngineState> {

componentWillUnmount () {
window.removeEventListener('resize', this.onResizeWindow);
if (this.engine != null) {
this.engine?.dispose();

if (this.engine !== null) {
this.engine!.dispose();
this.engine = null;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Scene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ const Scene: React.FC<SceneProps> = (props: SceneProps, context?: any) => {
scene.onPointerObservable.remove(pointerMoveObservable);
}

scene.dispose();
if (scene.isDisposed === false) {
scene.dispose();
}
}
},
[/* no deps, so called only on un/mount */]
Expand Down

0 comments on commit 08bc7c3

Please sign in to comment.