From d1a10f03204904a65dfd41a48426f42005d11c8e Mon Sep 17 00:00:00 2001 From: pchen66 Date: Fri, 24 Apr 2020 23:42:57 -0700 Subject: [PATCH] Remove infospots when dispose --- src/viewer/Viewer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/viewer/Viewer.js b/src/viewer/Viewer.js index d36fe08f..f2a721b8 100644 --- a/src/viewer/Viewer.js +++ b/src/viewer/Viewer.js @@ -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;