-
-
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
Changes from 5 commits
875067b
5e4b75b
d338aa3
e65f346
ab18276
95aa008
60ee80d
7fa34f6
0414976
f65b388
2a72dac
a8d0dab
1b1a827
292d34b
7fc8f23
a77b9fd
8eb570a
b0c1cba
f646d3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Now the checks are performed with 2 OR operator ||. |
||
"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 commentThe 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 commentThe 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 commentThe 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 : ) |
||
"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 commentThe 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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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#b649f8fb619242525b64ccf1def62cb2ed3f224f", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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#f4f5a63ffb19704a1ab1cadcc7aa848d7b68f7bf", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"gl-surface3d": "git://github.com/archmoj/gl-surface3d.git#2455aad56d3727b940fad8d02727806abca0fdf4", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I suppose that's a looser condition than 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 commentThe reason will be displayed to describe this comment to others. Learn more. @archmoj did adding this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your detailed review and great input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Great thinking. Thanks! |
||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
proto.plot = function(sceneData, fullLayout, layout) { | ||
|
||
// Save parameters | ||
|
@@ -435,17 +442,8 @@ proto.plot = function(sceneData, fullLayout, layout) { | |
} | ||
var dataScale = [1, 1, 1]; | ||
for(j = 0; j < 3; ++j) { | ||
if(dataBounds[0][j] > dataBounds[1][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]); | ||
} | ||
} | ||
var diff = dataBounds[1][j] - dataBounds[0][j]; | ||
if(!isCloseToZero(diff)) dataScale[j] = 1.0 / diff; | ||
} | ||
|
||
// Save scale | ||
|
@@ -560,6 +558,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]); | ||
|
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.
gl-vis/gl-cone3d@master...archmoj:rev-bounds
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 samediscard
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.