Skip to content

Commit

Permalink
XCD-208 Make FastNavPlugin revert to the original canvas resolutionSc…
Browse files Browse the repository at this point in the history
…ale on switchToHighQuality
  • Loading branch information
MichalDybizbanskiCreoox committed Dec 9, 2024
1 parent 8a9b50a commit b43db8a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/plugins/FastNavPlugin/FastNavPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class FastNavPlugin extends Plugin {
this._hideEdges = cfg.hideEdges !== false;
this._hideTransparentObjects = !!cfg.hideTransparentObjects;
this._scaleCanvasResolution = !!cfg.scaleCanvasResolution;
this._defaultScaleCanvasResolutionFactor = cfg.defaultScaleCanvasResolutionFactor || 1.0;
this._defaultScaleCanvasResolutionFactor = cfg.defaultScaleCanvasResolutionFactor;
this._scaleCanvasResolutionFactor = cfg.scaleCanvasResolutionFactor || 0.6;
this._delayBeforeRestore = (cfg.delayBeforeRestore !== false);
this._delayBeforeRestoreSeconds = cfg.delayBeforeRestoreSeconds || 0.5;
Expand All @@ -135,6 +135,7 @@ class FastNavPlugin extends Plugin {
viewer.scene._renderer.setSAOEnabled(!this._hideSAO);
viewer.scene._renderer.setTransparentEnabled(!this._hideTransparentObjects);
viewer.scene._renderer.setEdgesEnabled(!this._hideEdges);
this._originalCanvasResolutionScale = viewer.scene.canvas.resolutionScale;
if (this._scaleCanvasResolution) {
viewer.scene.canvas.resolutionScale = this._scaleCanvasResolutionFactor;
} else {
Expand All @@ -145,7 +146,7 @@ class FastNavPlugin extends Plugin {
};

const switchToHighQuality = () => {
viewer.scene.canvas.resolutionScale = this._defaultScaleCanvasResolutionFactor;
viewer.scene.canvas.resolutionScale = this._defaultScaleCanvasResolutionFactor || this._originalCanvasResolutionScale || 1.0;
viewer.scene._renderer.setEdgesEnabled(true);
viewer.scene._renderer.setColorTextureEnabled(true);
viewer.scene._renderer.setPBREnabled(true);
Expand Down Expand Up @@ -350,7 +351,7 @@ class FastNavPlugin extends Plugin {
* @param {Number} defaultScaleCanvasResolutionFactor Factor by scale canvas resolution when we stop interacting with the viewer.
*/
set defaultScaleCanvasResolutionFactor(defaultScaleCanvasResolutionFactor) {
this._defaultScaleCanvasResolutionFactor = defaultScaleCanvasResolutionFactor || 1.0;
this._defaultScaleCanvasResolutionFactor = defaultScaleCanvasResolutionFactor;
}

/**
Expand Down

0 comments on commit b43db8a

Please sign in to comment.