Skip to content
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

Supporting reversed ranges in 3d scenes #1940 #3071

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 19 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@
"es6-promise": "^3.0.2",
"fast-isnumeric": "^1.1.1",
"font-atlas-sdf": "^1.3.3",
"gl-cone3d": "^1.1.0",
"gl-cone3d": "git://github.com/archmoj/gl-cone3d.git#93879d5078596f8ce27ef3d848d4ec0493faa029",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to paste new link whenever you pushed a new commit. The "compare" view on github will update accordingly.

"gl-contour2d": "^1.1.4",
"gl-error3d": "^1.0.7",
"gl-error3d": "git://github.com/archmoj/gl-error3d.git#eccf97514df079aea0eb30fca62dfc13379096b6",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-heatmap2d": "^1.0.4",
"gl-line3d": "^1.1.2",
"gl-line3d": "git://github.com/archmoj/gl-line3d.git#7019b0c682ce39e1016f33813ac0a40a37bcc7a3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.0.0",
"gl-mesh3d": "git://github.com/archmoj/gl-mesh3d.git#ec915f4996a606718a7c2a41f812363faa4db163",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-plot2d": "^1.3.1",
"gl-plot3d": "^1.5.5",
"gl-plot3d": "git://github.com/archmoj/gl-plot3d.git#ce601a50cd3057899f6074f8ea5fcf0ab77f417c",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also changes to gl-axes3d as a dependency of gl-plot3d here: gl-vis/gl-axes3d@master...archmoj:rev-bounds

"gl-pointcloud2d": "^1.0.1",
"gl-scatter3d": "^1.0.11",
"gl-scatter3d": "git://github.com/archmoj/gl-scatter3d.git#6a4d678e128c3299df082073799387dec04ec8e5",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-select-box": "^1.0.2",
"gl-spikes2d": "^1.0.1",
"gl-streamtube3d": "^1.0.0",
"gl-surface3d": "^1.3.5",
"gl-streamtube3d": "git://github.com/archmoj/gl-streamtube3d.git#5f2cf5e866865d32cc6b9058247c627af27549ac",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-surface3d": "git://github.com/archmoj/gl-surface3d.git#6d16d39cc858215a3df5a6c61dbcc19bd8a043b2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-text": "^1.1.6",
"glslify": "^6.3.1",
"has-hover": "^1.0.1",
Expand Down
16 changes: 9 additions & 7 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,11 @@ proto.plot = function(sceneData, fullLayout, layout) {
}
var dataScale = [1, 1, 1];
for(j = 0; j < 3; ++j) {
if(dataBounds[0][j] > dataBounds[1][j]) {
if(dataBounds[1][j] === dataBounds[0][j]) {
dataScale[j] = 1.0;
}
else {
if(dataBounds[1][j] === dataBounds[0][j]) {
dataScale[j] = 1.0;
}
else {
dataScale[j] = 1.0 / (dataBounds[1][j] - dataBounds[0][j]);
}
dataScale[j] = 1.0 / (dataBounds[1][j] - dataBounds[0][j]);
}
}

Expand Down Expand Up @@ -560,6 +555,13 @@ proto.plot = function(sceneData, fullLayout, layout) {
sceneBounds[0][i] -= d / 32.0;
sceneBounds[1][i] += d / 32.0;
}

if(axis.autorange === 'reversed') {
// swap bounds:
var tmp = sceneBounds[0][i];
sceneBounds[0][i] = sceneBounds[1][i];
sceneBounds[1][i] = tmp;
}
} else {
var range = axis.range;
sceneBounds[0][i] = axis.r2l(range[0]);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/image/mocks/gl3d_cone-newplot_reversed_ranges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data":[{"x":[0.2],"y":[0.4],"z":[-0.6],"u":[1],"v":[1],"w":[0],"type":"cone"},{"x":[0.4],"y":[-0.6],"z":[0.2],"u":[1],"v":[0],"w":[1],"type":"cone"},{"x":[-0.6],"y":[0.2],"z":[0.4],"u":[0],"v":[1],"w":[1],"type":"cone"},{"x":[-0.2],"y":[-0.4],"z":[0.6],"u":[-1],"v":[-1],"w":[0],"type":"cone"},{"x":[-0.4],"y":[0.6],"z":[-0.2],"u":[-1],"v":[0],"w":[-1],"type":"cone"},{"x":[0.6],"y":[-0.2],"z":[-0.4],"u":[0],"v":[-1],"w":[-1],"type":"cone"}],"layout":{"height":758,"width":1310,"title":"Cone objects with Y-axis using autorange: 'reversed'","scene":{"yaxis":{"autorange":"reversed"},"camera":{"eye":{"x":1,"y":-1.5,"z":1.25}}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data":[{"x":[1,1,3,3,1,1,3,3],"y":[21,23,23,21,21,23,23,21],"z":[1e-2,1e-2,1e-2,1e-2,1e+2,1e+2,1e+2,1e+2],"i":[7,0,0,0,4,4,2,6,4,0,3,7],"j":[3,4,1,2,5,6,5,5,0,1,2,2],"k":[0,7,2,3,6,7,1,2,5,5,7,6],"type":"mesh3d"},{"x":[5,-5],"y":[10,15],"z":[[1e-2,1e+2],[1e+3,1e-1],[1e+2,1e-2],[1e-3,1e+1]],"type":"surface","colorscale":[[0.0,"rgb(127,127,255)"],[0.1,"rgb(63,63,255)"],[0.2,"rgb(0,0,255)"],[0.3,"rgb(0,63,191)"],[0.4,"rgb(0,127,127)"],[0.5,"rgb(0,191,63)"],[0.6,"rgb(0,255,0)"],[0.7,"rgb(63,191,0)"],[0.8,"rgb(127,127,0)"],[0.9,"rgb(191,63,0)"],[1.0,"rgb(255,0,0)"]],"cmin":0,"cmax":2},{"x":[-5,-4,-3,-2,-1,0,1,2,3,4,5],"y":[25,16,9,4,1,0,1,4,9,16,25],"z":[1e-5,1e-4,1e-3,1e-2,1e-1,1e0,1e+1,1e+2,1e+3,1e+4,1e+5],"line":{"color":"black","width":5},"text":["A","B","C","D","E","F","G","H","I","J","K"],"type":"scatter3d","mode":"markers+lines+text","error_x":{"type":"sqrt","color":"red"},"error_y":{"type":"sqrt","color":"green"},"error_z":{"type":"sqrt","color":"blue"}}],"layout":{"height":758,"width":1310,"title":"X-axis using autorange:'reversed',Y-axis using range:[30,-5] & Z-axis using range:'reversed' & type:log","scene":{"xaxis":{"autorange":"reversed","showbackground":true,"backgroundcolor":"rgb(127,191,191)","gridcolor":"rgb(255,255,255)","zerolinecolor":"rgb(63,0,0)","zerolinewidth":5},"yaxis":{"range":[30,-5],"showbackground":true,"backgroundcolor":"rgb(191,127,191)","gridcolor":"rgb(255,255,255)","zerolinecolor":"rgb(0,63,0)","zerolinewidth":5},"zaxis":{"autorange":"reversed","type":"log","showbackground":true,"backgroundcolor":"rgb(191,191,127)","gridcolor":"rgb(255,255,255)","zerolinecolor":"rgb(0,0,63)","zerolinewidth":5},"camera":{"eye":{"x":-1.75,"y":-0.75,"z":0.75}}}}}
1 change: 1 addition & 0 deletions test/image/mocks/gl3d_streamtube_reversed_ranges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data":[{"type":"streamtube","x":[0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2],"y":[0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2],"z":[0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2],"u":[1,1,1,0.5,0.5,0.5,0.25,0.25,0.25,1,1,1,0.5,0.5,0.5,0.25,0.25,0.25,1,1,1,0.5,0.5,0.5,0.25,0.25,0.25],"v":[1,1,1,1,1,1,1,1,1,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,2,2,2,2,2,2,2,2,2],"w":[0,0.2,0.4,0,0.2,0.4,0,0.2,0.4,0,0.2,0.4,0,0.2,0.4,0,0.2,0.4,0,0.2,0.4,0,0.2,0.4,0,0.2,0.4],"sizeref":0.5, "cmin":0,"cmax":3}],"layout":{"height":758,"width":1310,"title":"Streamtube, X and Y axes reversed using autorange: reversed, Z-axis reversed using range: [2, -2]","scene":{"camera":{"eye":{"x":0.5,"y":-2.0,"z":1.0}},"xaxis":{"autorange":"reversed"},"yaxis":{"autorange":"reversed"},"zaxis":{"range":[2,-2]}}}}