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

Add a rainfall example. #869

Merged
merged 2 commits into from
Jul 27, 2018
Merged

Add a rainfall example. #869

merged 2 commits into from
Jul 27, 2018

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Jul 13, 2018

This uses isolines and contours to animate annual rainfall in the United States based on NOAA data.

Fix a minor edge case in the contour feature where values near the top of the range could have a faint defect due to the way the sampler2d is used.

This uses isolines and contours to animate annual rainfall in the United
States based on noaa data.

Fix a minor edge case in the contour feature where values near the top
of the range could have a faint defect due to the way the sampler2d is
used.
* @returns {number|this} The current bin number or a reference to `this`.
*/
this.bin = function (val) {
if (val === undefined) {
if (m_bin === null) {
var parent = this.parent(),
idx = parent ? parent.children().indexOf(m_this) : -1;
Copy link
Member

Choose a reason for hiding this comment

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

why not just set it to 0 (instead of -1) here. Also, if we are returning a value even if m_bin is null, should we store this value in m_bin before returning it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indexOf returns -1 if the value isn't present, so return -1 here results in the same result if there is no parent or this is somehow not a child of its own parent. Although we then clamp it to zero, I felt handling the missing parent case identically to a missing entry case was clearer then doing otherwise.

No, we shouldn't store the value in m_bin. null is the special meaning of return the position based on where it is in the child list. If you had two children, A, B, both with null m_bin, they would have bin values of 0, 1. If you inserted a child, so you have A, C, B, they would then have bin values of 0, 1, 2 (so B would go from 1 to 2). This is desired, and overriding this would break that feature.

Copy link
Member

Choose a reason for hiding this comment

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

thanks makes sense to me, given this explanation.

' clr = texture2D(sampler2d, vec2(step / steps, 0.0));',
// our texture is padded on either end by a repeated value to ensure
// we interpolate smoothly at the ends.
' clr = texture2D(sampler2d, vec2((step + 1.0) / (steps + 2.0), 0.0));',
Copy link
Member

Choose a reason for hiding this comment

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

can we not use the GL texture GL_CLAMP_TO_EDGE which would probably give us the same behavior?

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 vgl.lookupTable texture is already using GL_CLAMP_TO_EDGE. I'm not sure why that was insufficient.

Copy link
Member

Choose a reason for hiding this comment

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

not sure, I will have a look but for now this is good.

@manthey manthey force-pushed the rainfall-example branch from d1d4037 to 152355f Compare July 27, 2018 14:40
@manthey manthey merged commit 74de72c into master Jul 27, 2018
@manthey manthey deleted the rainfall-example branch July 27, 2018 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants