diff --git a/js/common/view/DensityBuoyancyScreenView.ts b/js/common/view/DensityBuoyancyScreenView.ts index 54a6bb05..ff6ae3c3 100644 --- a/js/common/view/DensityBuoyancyScreenView.ts +++ b/js/common/view/DensityBuoyancyScreenView.ts @@ -646,27 +646,30 @@ export default class DensityBuoyancyScreenView { - const translation = mass.matrix.translation; - const bbox = mass.getLocalBounds(); + if ( focusablePath.isDisposed ) { + return; + } - const shiftedBbox = bbox.shifted( translation.toVector3() ); + const translation = mass.matrix.translation; + const bbox = mass.getLocalBounds(); - const viewPoints = [ - this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.minZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.maxZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.minZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.maxZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.minZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.maxZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.minZ ) ), - this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.maxZ ) ) - ]; + const shiftedBbox = bbox.shifted( translation.toVector3() ); - focusablePath.shape = Shape.polygon( ConvexHull2.grahamScan( viewPoints, false ) ); + const viewPoints = [ + this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.minZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.maxZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.minZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.maxZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.minZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.maxZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.minZ ) ), + this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.maxZ ) ) + ]; - focusablePath.focusHighlight = focusablePath.shape; - } - ); + focusablePath.shape = Shape.polygon( ConvexHull2.grahamScan( viewPoints, false ) ); + + focusablePath.focusHighlight = focusablePath.shape; + } ); if ( massView instanceof ScaleView ) {