Skip to content

Commit

Permalink
Remove infospots when dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
pchen66 committed Apr 25, 2020
1 parent 4eb69c9 commit d1a10f0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2044,12 +2044,26 @@ Viewer.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype
*/
onPanoramaDispose: function ( panorama ) {

const { scene } = this;
const infospotDisposeMapper = infospot => infospot.toPanorama !== panorama ? infospot : infospot.dispose();

if ( panorama instanceof VideoPanorama ) {

this.hideVideoWidget();

}

// traverse the scene to find association
scene.traverse( object => {

if ( object instanceof Panorama ) {

object.linkedSpots = object.linkedSpots.map( infospotDisposeMapper ).filter( infospot => !!infospot );

}

} );

if ( panorama === this.panorama ) {

this.panorama = null;
Expand Down

0 comments on commit d1a10f0

Please sign in to comment.