Skip to content

Commit

Permalink
Merge pull request #1760 from xeokit/XCD-208-improve-high-DPI-quality
Browse files Browse the repository at this point in the history
XCD-208 Make FastNavPlugin revert to the original canvas resolutionScale on switchToHighQuality
  • Loading branch information
xeolabs authored Dec 9, 2024
2 parents 8a9b50a + b43db8a commit 9432522
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 9432522

Please sign in to comment.