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

Update vtk.js pointFeature #953

Merged
merged 7 commits into from
Nov 26, 2018
Merged

Update vtk.js pointFeature #953

merged 7 commits into from
Nov 26, 2018

Conversation

jourdain
Copy link
Contributor

@jourdain jourdain commented Nov 2, 2018

No description provided.

@jourdain jourdain requested a review from manthey November 2, 2018 18:51
@aashish24
Copy link
Member

@manthey could you review this branch?

@manthey
Copy link
Contributor

manthey commented Nov 13, 2018

@jourdain This doesn't work as written, and I suspect that we are doing things in a more obtuse way than we should. For ease of trying this out, I've made two interactive tutorial links to allow adjusting the code. This link is the existing vtk.js pointFeature. This link is this branch (adjusted to work in the tutorial context).

@jourdain
Copy link
Contributor Author

I noticed some issue here:

    var mapper = vtkMapper.newInstance({
      // Orientation
      // orient: false,

      // Color
      // useLookupTableScalarRange: true,  // FIXME <----
      // lookupTable,                      // FIXME <----
      colorByArrayName: 'color',
      colorMode: vtk.Rendering.Core.vtkMapper.ColorMode.MAP_SCALARS,
      scalarMode: vtk.Rendering.Core.vtkMapper.ScalarMode.USE_POINT_FIELD_DATA,
      scalarVisibility: true,

      // Opactity
      // => not available yet

      // Scaling
      scaling: true,
      scaleArray: 'radius',
      scaleMode: vtk.Rendering.Core.vtkGlyph3DMapper.ScaleModes.SCALE_BY_MAGNITUDE,
    });

But by fixing that, I get the following error:

map.js:1819 Error: Coordinates are not valid
    at Function.s.transformCoordinatesArray (VM64 geo.min.js:39)
    at Function.s.transformCoordinates (VM64 geo.min.js:39)
    at vtkjs_pointFeature._build (about:blank:156)
    at vtkjs_pointFeature._update (about:blank:192)
    at _renderFrame (VM64 geo.min.js:39)
    at V (VM64 geo.min.js:83)

This still needs to adjust opacity and color by point.
@manthey
Copy link
Contributor

manthey commented Nov 14, 2018

I've pushed a change that fixes setting the radius. It still doesn't alter the color or opacity by point. I've marked some TODO spots.

Here is a tutorial editor link to this code, in case it is useful.

Note that this is done via hacking the mapper's lookup table, so there
is probably a better way to do it.
@jourdain
Copy link
Contributor Author

Is there still something for me to look at?

@manthey
Copy link
Contributor

manthey commented Nov 16, 2018

@aashish24 This works. It has some mild eccentricities which I should document. For instance, when zoomed out, points become annular:
image
versus zoomed in:
image
Also, since in other renderers, points have strokes and/or fills, and here we only have fill values, I need to document that. I should also add one more test.

@manthey
Copy link
Contributor

manthey commented Nov 16, 2018

@jourdain I hacked around how the lookup table returns color information. I still have a color array, but the values of it don't seem to be used, and then I return a lookup table data array which has the packed rgba color values (which is where I end up supporting opacity).

I have two questions:

Is there a simple way to not need the extra color array?

Is there an example showing how to subclass something in vtkjs? It seems like it would be better for me to subclass LookupTable instead of abusing it the way I did.

@jourdain
Copy link
Contributor Author

For class extension: https://kitware.github.io/vtk-js/docs/develop_class.html

What do you colorBy if you don't have the color array? The LookupTable is meant to convert a field into an actual color.

Since you seems to build the full RGBA for the full set of points, you should probably not use a lookup table and just use the raw data as an array in your pointset by setting "mapScalars=false".

Make sure vtkjs features can be rerendered with a draw call.

Mark the vtkjs point feature as not supporting stroke.
@manthey
Copy link
Contributor

manthey commented Nov 19, 2018

@jourdain Thanks -- I've refactored this to be simpler. I was misunderstanding the vtk.js documentation.

Modify test to ensure the vtkjs point feature is updated at least once
on an initial draw call.
@manthey
Copy link
Contributor

manthey commented Nov 19, 2018

@aashish24 This is ready for review.

@aashish24
Copy link
Member

@aashish24 This is ready for review.

thanks. Do we still have the issue with "annular"? I believe that may be caused by clipping of spheres that are drawn by vtk.js.

@manthey
Copy link
Contributor

manthey commented Nov 20, 2018

thanks. Do we still have the issue with "annular"? I believe that may be caused by clipping of spheres that are drawn by vtk.js.

Yes. And, you are correct, it is the clipping. We can set the clip bounds to a larger range -- but I think that we should defer that to a future PR where we add a more general method to get the extents needed and set the bounds based on the actual extents (so we don't degrade z-buffer precision needlessly).

@aashish24
Copy link
Member

Yes. And, you are correct, it is the clipping. We can set the clip bounds to a larger range -- but I think that we should defer that to a future PR where we add a more general method to get the extents needed and set the bounds based on the actual extents (so we don't degrade z-buffer precision needlessly).

sure sounds good. I guess this branch needs to be updated? Once that happens, I can approve it.

@manthey
Copy link
Contributor

manthey commented Nov 26, 2018

You can approve it while it updates -- the checks ensure that the merge to master will be valid.

@manthey manthey merged commit b6b798b into master Nov 26, 2018
@manthey manthey deleted the vtkjs-point-features branch November 26, 2018 20:56
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.

3 participants