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

Scale vertexIntensity values by max value encountered #5

Merged
merged 3 commits into from
Jun 1, 2018

Conversation

etpinard
Copy link
Member

to bring gl-streamtube3d to par with gl-cone3d and make the plotly.js wrapper a lot less painful to write.

I hope @kig won't mind.

@@ -34,7 +39,7 @@ var streamToTube = function(stream, maxDivergence, minDistance) {
if (maxDivergence === 0) {
r = minDistance * 0.05;
}
currentIntensity = vec3.length(fwd);
currentIntensity = vec3.length(fwd) / maxNorm;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was going to suggest dealing with division by zero here, but on second thought, it's not necessary. With zero field, you'd end up with a division by zero. But with a zero field you wouldn't have a stream anyway, so you shouldn't encounter this line with zero maxNorm.

streamtube.js Outdated
var maxNorm = 0;

for (var i = 0; i < points.length; i++) {
maxNorm = Math.max(vec3.length(velocities[i]), maxNorm);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a per-stream maxNorm. You probably want to compute a maxNorm of all the streams instead and pass it to streamToTube.

@kig
Copy link
Collaborator

kig commented Jun 1, 2018

Thanks, this is good to have.

If need be, we could also add something like an intensityRange: [min, max] config parameter that would be used to map velocity values to 0..1 range.

@kig kig merged commit d004f17 into master Jun 1, 2018
@etpinard
Copy link
Member Author

etpinard commented Jun 1, 2018

Thanks for fixing this up @kig 🎉

If need be, we could also add something like an intensityRange: [min, max] config parameter that would be used to map velocity values to 0..1 range.

We could, but we don't need to add this to ./streamtube.js. Setting vertexIntensityBounds on the meshData work fine too e.g:

var meshData = tube2mesh({/* */})
meshData.vertexIntensityBounds = [/**/, /**/]
createTubeMesh(meshData)

@etpinard etpinard deleted the scale-vertex-intenstity branch June 1, 2018 14:35
etpinard added a commit to plotly/plotly.js that referenced this pull request Jun 1, 2018
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