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 9 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#2f1afdb49bd09e28ea32604b13aea919c0a57330",
"gl-contour2d": "^1.1.4",
"gl-error3d": "^1.0.7",
"gl-error3d": "git://github.com/archmoj/gl-error3d.git#6b5180b0ed024430ccbafb7392dac087bb2c12c4",
"gl-heatmap2d": "^1.0.4",
"gl-line3d": "^1.1.2",
"gl-line3d": "git://github.com/archmoj/gl-line3d.git#3f3e383004309507df9ce42490d85da070effafa",
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.0.0",
"gl-mesh3d": "git://github.com/archmoj/gl-mesh3d.git#b2da71e9cc4719ee5b6a69398651e578cef2f3c0",
"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#da56cdc37d4386261539d5134a5f9a39fe878415",
"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#08ce753c40e2804f33738de987da5c10ec8c67c0",
"gl-surface3d": "git://github.com/archmoj/gl-surface3d.git#cb6ef0af1b3d992112b9bfc83dcf2b4e4736e2d0",
"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}}}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor

Choose a reason for hiding this comment

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

Those new mock are very nice though. Thanks very much!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When try running image tests (on CircleCi) it showed syntax errors. I thought removing the white spaces may help pass the test. But I personally like the version which is human readable. If prefer I could fix the json mocks?

Copy link
Contributor

@etpinard etpinard Oct 9, 2018

Choose a reason for hiding this comment

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

Hmm. The only syntax tests we run on JSON mocks are:

So, I suspect your json files had trailing newlines. You can (and should) run those test locally with npm run test-syntax.


Would you mind reformatting those files? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new json mocks are reformatted.

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 & 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]}}}}