-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
package.json
Outdated
"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#f4f5a63ffb19704a1ab1cadcc7aa848d7b68f7bf", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-plot2d": "^1.3.1", | ||
"gl-plot3d": "^1.5.5", | ||
"gl-plot3d": "git://github.com/archmoj/gl-plot3d.git#ce601a50cd3057899f6074f8ea5fcf0ab77f417c", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
@archmoj Nice job! That's a lot of work for a first PR 💪 Now, would you mind sharing links (like I started doing above) to the patches you made in the |
package.json
Outdated
@@ -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#823cabfbb19d8b457730320010cb58df748ff9ee", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only the pick shaders here? Does triangle-fragment.glsl
need to same discard
statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. In the previous version the checks for ranges were commented. When I added the checks similar to the other shaders the cones did not show up. Also for backward compatibility I thought there may be no need for them. But as you mentioned on another comment the are other issues with cones. So I will investigate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added discard logic for cone triangle-fragment.glsl as well as streamtubes.
package.json
Outdated
"gl-heatmap2d": "^1.0.4", | ||
"gl-line3d": "^1.1.2", | ||
"gl-line3d": "git://github.com/archmoj/gl-line3d.git#681398a5477f64cfd92ff7494215d5b6854e834b", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outOfBound function is now located in a separate glsl file (in the local path) which is included in the shaders by glslify. Thanks for the hint : )
package.json
Outdated
"gl-contour2d": "^1.1.4", | ||
"gl-error3d": "^1.0.7", | ||
"gl-error3d": "git://github.com/archmoj/gl-error3d.git#d09c224fe25671fcd588a8c803fe83129156fbab", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I remember Mikola telling me that if-statements in shaders can be slow on some hardware. It might be worth combining these 3 if-statements into one with 2 OR operator ||
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the checks are performed with 2 OR operator ||.
package.json
Outdated
"gl-mat4": "^1.2.0", | ||
"gl-mesh3d": "^2.0.0", | ||
"gl-mesh3d": "git://github.com/archmoj/gl-mesh3d.git#5828f6255d8c5360631d5feec65801bb104a88e8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-pointcloud2d": "^1.0.1", | ||
"gl-scatter3d": "^1.0.11", | ||
"gl-scatter3d": "git://github.com/archmoj/gl-scatter3d.git#b649f8fb619242525b64ccf1def62cb2ed3f224f", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-streamtube3d": "^1.0.0", | ||
"gl-surface3d": "^1.3.5", | ||
"gl-streamtube3d": "git://github.com/archmoj/gl-streamtube3d.git#f4f5a63ffb19704a1ab1cadcc7aa848d7b68f7bf", | ||
"gl-surface3d": "git://github.com/archmoj/gl-surface3d.git#2455aad56d3727b940fad8d02727806abca0fdf4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
@@ -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#823cabfbb19d8b457730320010cb58df748ff9ee", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/plots/gl3d/scene.js
Outdated
@@ -383,6 +383,13 @@ function computeTraceBounds(scene, trace, bounds) { | |||
} | |||
} | |||
|
|||
function isCloseToZero(a) { | |||
if(Math.abs(a) > Number.MIN_VALUE) { // the smallest positive numeric value representable in JavaScript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that's a looser condition than if(a !== 0)
but the numbers you're subtracting need to already be extremely small in order for their difference to be exactly Number.MIN_VALUE
. I suspect we actually want to be substantially looser than that.
Exactly how that should happen I'm not sure, but I think the criterion should be something that depends on the magnitude of the numbers, to the effect of "there should be at least N representable numbers between a and b" where N is maybe 100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@archmoj did adding this isCloseToZero
fix a particular bug? If so, could you provide the problematic "data"
and "layout"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your detailed review and great input.
Because this PR touched on many shader programs, in the reviewed version of this PR, I decided to discard closeToZero range checking. This way it would be easier to investigate if other modifications may have any side effect.
Though we can consider this info in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way it would be easier to investigate if other modifications may have any side effect.
Great thinking. Thanks!
I just made @archmoj and @antoinerg members of https://github.com/gl-vis. No need to push to forks ever again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@archmoj Very solid work! I didn't think you would have to patch every 3D gl-vis module to get this done, but yeah, this is great!
Next stop,
- provide three "data" / "layout" JSON mocks. As your work touches every gl3d trace type, we'll need to make sure to test reversed axes for all those trace types, so I'm thinking we should add:
- one mock with reversed x/y/z range axes and 4 traces: 1 scatter3d with
mode: 'markers+lines+text'
, 1 surface, 1 mesh3d and 1 streamtube trace - one mock with x/y/z axes with
autorange: 'reversed'
(but no set ranges) - one mock with reversed x/y/z axes and 1 cone trace. Cone traces don't behave well in our "old" image test container, so they are skipped during our "normal" test runs here.
- one mock with reversed x/y/z range axes and 4 traces: 1 scatter3d with
Since, you can't run the image test locally (nor generate baseline images), you should commit the JSON mocks and collect the CI artefacts.
Let me know if you have any questions!
package.json
Outdated
"gl-contour2d": "^1.1.4", | ||
"gl-error3d": "^1.0.7", | ||
"gl-error3d": "git://github.com/archmoj/gl-error3d.git#d09c224fe25671fcd588a8c803fe83129156fbab", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I remember Mikola telling me that if-statements in shaders can be slow on some hardware. It might be worth combining these 3 if-statements into one with 2 OR operator ||
.
package.json
Outdated
@@ -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#823cabfbb19d8b457730320010cb58df748ff9ee", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only the pick shaders here? Does triangle-fragment.glsl
need to same discard
statements?
package.json
Outdated
"gl-heatmap2d": "^1.0.4", | ||
"gl-line3d": "^1.1.2", | ||
"gl-line3d": "git://github.com/archmoj/gl-line3d.git#681398a5477f64cfd92ff7494215d5b6854e834b", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
@@ -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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
package.json
Outdated
"gl-contour2d": "^1.1.4", | ||
"gl-error3d": "^1.0.7", | ||
"gl-error3d": "git://github.com/archmoj/gl-error3d.git#eccf97514df079aea0eb30fca62dfc13379096b6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-heatmap2d": "^1.0.4", | ||
"gl-line3d": "^1.1.2", | ||
"gl-line3d": "git://github.com/archmoj/gl-line3d.git#7019b0c682ce39e1016f33813ac0a40a37bcc7a3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-mat4": "^1.2.0", | ||
"gl-mesh3d": "^2.0.0", | ||
"gl-mesh3d": "git://github.com/archmoj/gl-mesh3d.git#ec915f4996a606718a7c2a41f812363faa4db163", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-pointcloud2d": "^1.0.1", | ||
"gl-scatter3d": "^1.0.11", | ||
"gl-scatter3d": "git://github.com/archmoj/gl-scatter3d.git#6a4d678e128c3299df082073799387dec04ec8e5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
"gl-streamtube3d": "^1.0.0", | ||
"gl-surface3d": "^1.3.5", | ||
"gl-streamtube3d": "git://github.com/archmoj/gl-streamtube3d.git#5f2cf5e866865d32cc6b9058247c627af27549ac", | ||
"gl-surface3d": "git://github.com/archmoj/gl-surface3d.git#6d16d39cc858215a3df5a6c61dbcc19bd8a043b2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
} | ||
{"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}}}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
Having all those #pragma glslify: outOfRange = require(./reversed-scenes-out-of-range.glsl) isn't exactly what I meant in #3071 (comment). Would you be interested in publishing this helper to npm? Looks like you did address my
comment, but I'm curious, did swapping in the |
|
Closing in favour of #3141 |
This PR would allow users to display 3D data in plotly.js scenes that may have one or multiple reversed ranges.
The options such as autorange:'reversed' and/or range:[larger, smaller] could be applied in this regard.
Most of the fixes to expand this capability are performed at vertex and fragment shaders.
@etpinard @alexcjohnson