GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add support for mesh and surface by almarklein · Pull Request #953 · fastplotlib/fastplotlib

Conversation

@almarklein

@almarklein almarklein commented Nov 28, 2025 •
edited by kushalkolar
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Closes #487, closes #917, ref #959

  • Add MeshGraphgic
  • Add plot.add_mesh() and plot.add_surface().
  • Add light to a scene by default.
  • Add examples.
  • Support for 2D colormaps.
  • This relies more on PyGfx colormap mechanics. I am not sure why fastplotlib 'renders' its own colormap into vertex colors for lines and scatter.

Possible upstream (pygfx) improvements:

  • Support for clim everywhere where a map is supported.
  • Possibility to set map as a numpy array?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar reacted with rocket emoji
All reactions
  • 🚀 1 reaction
almarklein added 5 commits November 28, 2025 10:28
@almarklein
Add support for mesh and surface
00b7ccf
@almarklein
restore line example
d944f55
@almarklein
Implement image-surface example
d4897b4
@almarklein
Fix 3D camera for mesh examples
99d00aa
@almarklein
Just remove selector logic for now
3505005
@almarklein
almarklein marked this pull request as ready for review November 28, 2025 11:00
@almarklein
almarklein requested review from clewis7 and kushalkolar as code owners November 28, 2025 11:00
@almarklein

almarklein commented Nov 28, 2025

Copy link
Copy Markdown
Collaborator Author

I cannot find the new screenshots. Do I need to whitelist the new examples/mesh dir somewhere?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@almarklein
new examples in gallery
c93b13f
@github-actions

github-actions Bot commented Nov 28, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/mesh

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Nov 28, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Good start!

_graphic_methods_mixin.py is meant to be auto-generated, so we should make a SurfaceGraphic that probably just subclasses MeshGraphic.

Working on figuring out how to make the surface data dynamically settable so we can have a data @property. I think all the properties should be mutable like the other graphics where it make sense.

For general mesh:

  • positions
  • indices
  • mapcoords
  • cmap
  • colors

For surface:

  • data (which under the hood computes positions, indices, mapcoords)
  • cmap
  • colors

Seems like the normals have to be re-computed if using phong material when positions change. No difference with basic. Edit: Can just set the material.map again. Is there a flag for this we can set?

Anyways, I think we can make the basic material mode as the default and also allow phong and slice. Nah phong default seems best for most functions.

Are morph targets useful for this? Or just setting the position directly is the way to go?

I'm not sure if any of the existing "2D" selectors are useful here, in the future we could make a "cube selector", maybe based on the pygfx gizmo example using an expandable cube that can be used to select the triangles inside the cube?

Other than that that #545 might be useful here when it's available, and we could also make a selector that just allows selecting faces on a mesh (I think pygfx has an example for this, but we could maybe make a easy way to Cntrl + Click to build a selection?). Anyways not a priority for now, just thoughts.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Nov 28, 2025

Copy link
Copy Markdown
Member

I'm going to add a few commits to this branch based on #953 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Nov 29, 2025
View reviewed changes
Comment thread fastplotlib/graphics/mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_graphic_methods_mixin.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_plot_area.py Outdated
Comment on lines +120 to +121
self.scene.add(pygfx.AmbientLight())
self.scene.add(self._camera.add(pygfx.DirectionalLight()))

@kushalkolar kushalkolar Nov 29, 2025

Copy link
Copy Markdown
Member

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 these can be settable properties of the PlotArea

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@almarklein almarklein Dec 3, 2025

Copy link
Copy Markdown
Collaborator Author

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.

mmm ... Having an ambient light and one directional light on the camera is a sweet default that makes sure phong-shaded meshes look good. A user that wants custom lights will probably want to add more lights to the scene, and control on which objects they are attached. That would be tricky to expose as a prop, I think?

FWIW these lights add negligible overhead for objects that don't use lights.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Dec 4, 2025

Copy link
Copy Markdown
Member

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 it's useful to have easy access to them though, and if a new camera is set on the PlotArea it needs to get the directional light. This is what I mean:

https://github.com/fastplotlib/fastplotlib/pull/953/files#diff-2a0f782c81512ab17081f35fd6cac201fafd429eded696cb76981946bc6baaecR120-R294

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@almarklein almarklein Dec 4, 2025

Copy link
Copy Markdown
Collaborator Author

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.

Ah I see. Nice fix!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kushalkolar kushalkolar mentioned this pull request Nov 29, 2025
mesh with graphic features #954
Merged
kushalkolar
kushalkolar reviewed Nov 30, 2025
View reviewed changes
Comment thread fastplotlib/layouts/_graphic_methods_mixin.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Dec 1, 2025

Copy link
Copy Markdown
Member

I cannot find the new screenshots. Do I need to whitelist the new examples/mesh dir somewhere?

example dirs for tests are listed here:

fastplotlib/examples/tests/testutils.py

Lines 18 to 34 in 7b4c687

# examples live in themed sub-folders
example_globs = [
"image/*.py",
"image_volume/*.py",
"image_widget/*.py",
"heatmap/*.py",
"scatter/*.py",
"line/*.py",
"line_collection/*.py",
"vectors/*.py"
"gridplot/*.py",
"window_layouts/*.py",
"events/*.py",
"selection_tools/*.py",
"misc/*.py",
"guis/*.py",
]

Did you automate finding them in pygfx?

Similarly for docs that dir needs a readme, making these changes in #954

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Dec 1, 2025
PolygonGraphic improvements #957
Open
@kushalkolar

kushalkolar commented Dec 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This relies more on PyGfx colormap mechanics. I am not sure why fastplotlib 'renders' its own colormap into vertex colors for lines and scatter.

pygfx.cm.create_colormap() didn't exist when we implemented lines and scatter, is this what you mean?

Edit: I see LineMaterial.map which can be a TextureMap. Is it possible to apply what we call a "cmap transform" as well, for instance in this example it samples from the colormap using the y-values of a sine function: https://www.fastplotlib.org/ver/dev/_gallery/line/line_cmap.html#sphx-glr-gallery-line-line-cmap-py

But this can be arbitrary, we often use it to indicate things like velocity along a 2d trajectory.

I cannot find the new screenshots. Do I need to whitelist the new examples/mesh dir somewhere?

a comma was also missing, added it , slipped by in the vectors PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 9 commits December 1, 2025 21:52
@kushalkolar
mesh with graphic features (#954)
a5c7285
* mesh with gfeatures

* surface graphic works

* update, add PolygonGraphic, works

* black

* for docs and test screenshots

* black

* polygon data updating works

* update

* black

* more examples

* update add_graphic mixin

* code review changes

* fix

* better polygon example
@kushalkolar
remove unused import
8bac8b9
@kushalkolar
update graphics mixin
83ac73d
@kushalkolar
docs
fbecf03
@kushalkolar
black
2ccd785
@kushalkolar
don't need to set limit for docs gen
5dfdb08
@kushalkolar
add missing comma
2ddb97f
@kushalkolar
dont run terrain example
a4eecea
@kushalkolar
new screenshots
c3c528e
kushalkolar
kushalkolar reviewed Dec 2, 2025
View reviewed changes
Comment thread fastplotlib/graphics/mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/features/_mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Dec 3, 2025
Improvements to mesh graphics #959
Open
4 tasks
@almarklein

almarklein commented Dec 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

pygfx.cm.create_colormap() didn't exist when we implemented lines and scatter, is this what you mean?

Edit: I see LineMaterial.map which can be a TextureMap. Is it possible to apply what we call a "cmap transform" as well, for instance in this example it samples from the colormap using the y-values of a sine function: https://www.fastplotlib.org/ver/dev/_gallery/line/line_cmap.html#sphx-glr-gallery-line-line-cmap-py

Ah, create_colormap() not existing at the time explains it. Though it would be nice if fpl could simply leverage Pygfx's colormap support, by setting geometry.texcoords and material.map.

If I understand correctly, the current line's geometrytexcoords are simply the vertex indices, and map_transform is used to map that to real values. So in fact, the current map_transform is the mapcoords. Which is good news, I guess, because it means moving to pygfx doing the colormapping should be relatively easy (in a different pr).

edit: easy as in not that complex. Still quite a bit of work, I imagine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@almarklein
remove (i expect) unnecessary check
8344216
almarklein
almarklein commented Dec 3, 2025
View reviewed changes
Comment thread fastplotlib/graphics/features/_mesh.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
lights as properties
1c6dbde
@kushalkolar

kushalkolar commented Dec 4, 2025

Copy link
Copy Markdown
Member

If I understand correctly, the current line's geometrytexcoords are simply the vertex indices, and map_transform is used to map that to real values. So in fact, the current map_transform is the mapcoords. Which is good news, I guess, because it means moving to pygfx doing the colormapping should be relatively easy (in a different pr).

Yes! Thanks I understand it better now :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Dec 4, 2025
Use pygfx material.map directly for cmap and cmap_transform #960
Closed
kushalkolar added 6 commits December 3, 2025 23:04
@kushalkolar
just use VertexPositions
14159ef
@kushalkolar
Merge branch 'mesh' of https://github.com/fastplotlib/fastplotlib int…
bf29ba2
…o mesh
@kushalkolar
Merge branch 'main' into mesh
26533b9
@kushalkolar
update PolyData
c60fe31
@kushalkolar
I need to use precommit
9d3a007
@kushalkolar
update api docs
868ee95
@kushalkolar

kushalkolar commented Dec 4, 2025

Copy link
Copy Markdown
Member

@almarklein I think this is done 🥳 . Let me know what you think

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@almarklein

almarklein commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator Author

I was getting ready to update the buffer resizing logic for the poly data, but saw you already fixed that too. Awesome! Ready from my end then! 👍

kushalkolar reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@almarklein almarklein mentioned this pull request Dec 4, 2025
Add uniform.maprange to (almost) all objects that have .map pygfx/pygfx#1246
Merged
kushalkolar
kushalkolar approved these changes Dec 4, 2025
View reviewed changes
@kushalkolar
kushalkolar merged commit db49c62 into main Dec 4, 2025
36 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Feb 26, 2026
Simplify colormap handling #1004
Closed
@kushalkolar
kushalkolar deleted the mesh branch April 14, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kushalkolar kushalkolar kushalkolar approved these changes
@clewis7 clewis7 Awaiting requested review from clewis7 clewis7 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Mesh based graphics 2D polygon graphics

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@almarklein @kushalkolar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.