Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Preserve gl3d scene aspectratio after orthographic scroll zoom #4578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 12, 2020
Merged
Prev Previous commit
Next Next commit
do not compute axis scale when not needed
  • Loading branch information
archmoj committed Feb 12, 2020
commit ac22cd307ebcf78831f346c160c2b83f33da3696
24 changes: 13 additions & 11 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,24 +726,26 @@ proto.plot = function(sceneData, fullLayout, layout) {
}

var aspectmode = fullSceneLayout.aspectmode;

var axesScaleRatio = [1, 1, 1];

// Compute axis scale per category
for(i = 0; i < 3; ++i) {
axis = fullSceneLayout[axisProperties[i]];
axisType = axis.type;
var axisRatio = axisTypeRatios[axisType];
axesScaleRatio[i] = Math.pow(axisRatio.acc, 1.0 / axisRatio.count) / dataScale[i];
var axesScaleRatio;
if(aspectmode === 'auto' || aspectmode === 'data') {
axesScaleRatio = [1, 1, 1];

// Compute axis scale per category
for(i = 0; i < 3; ++i) {
axis = fullSceneLayout[axisProperties[i]];
axisType = axis.type;
var axisRatio = axisTypeRatios[axisType];
axesScaleRatio[i] = Math.pow(axisRatio.acc, 1.0 / axisRatio.count) / dataScale[i];
}
}

/*
* Dynamically set the aspect ratio depending on the users aspect settings
*/
var axisAutoScaleFactor = 4;
var aspectRatio;

if(aspectmode === 'auto') {
var axisAutoScaleFactor = 4;

if(Math.max.apply(null, axesScaleRatio) / Math.min.apply(null, axesScaleRatio) <= axisAutoScaleFactor) {
/*
* USE DATA MODE WHEN AXIS RANGE DIMENSIONS ARE RELATIVELY EQUAL
Expand Down