-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
"canvas" source type #3580
Comments
I have some time to play with this today |
Quick note: performance ought to be good when using this with a 2D canvas context but not with a 3D (WebGL canvas context) |
In progress in https://github.com/mapbox/mapbox-gl-js/tree/canvas_type (using 2D canvas context). |
@lbud wow, that looks great! |
BTW, I just realized that while |
This would be the performant way to do it. We'd have to expose our gl context and make sure we unset and reset all state before and after they render. |
I'm not sure it's worth going down this road, at least at this point. I think the intent of the canvas source type proposal was to quickly enable users familiar with common HTML drawing techniques like HTML canvas to attach their graphics to the map, and IMO it may make most sense here to at least start with a 2D canvas context iteration. If people are really dying to attach their own WebGL framebuffers to the map, we can consider going down that road as well (and I'm certainly open to being convinced by some tangible use cases), but particularly at a time when we've also been talking more and more about how much we'd like to revisit custom shaders #281 — AND before we nail down more robust maintenance of our GL state #145 — it seems to me we should leave the 3D webgl framebuffer transference on the shelf. |
Great work! This feature could definitely open up a lot of possibilities for us. We've been playing around with trying to get live weather overlay which seems to work nicely. Although we're struggling with performance a little, the canvas animation seems to be running at a lot less fps than it should do. Would the correct approach for something like this be splitting up the animation into multiple canvas sources, rather than a single overlay? |
@core44 slightly unrelated to the issue (canvas source type), but I've been recently working on a purely WebGL implementation of the wind animation. My goal is to design the custom layers API #281 so that it can accommodate such animations directly (drawing with the same GL context), without loss of performance, although it may take a while to get there. |
@mourner Incredible... cant stop staring at it! Certainly fits the 'Design and Publish Beautiful Maps' message. Repository watched. Thanks. |
Attached screenshot is the sort of performance loss we're seeing in comparison to the external canvas animation. It seems to be heavily downsampled. The animation should also be running at 20fps but it looks like we're getting more like 2 or 3fps. Is there any particular reason for this... and is there anything we might be able to do to squeeze out a few more frames per second? |
A thought after trying out @lbud's implementation: I want to do custom rendering of data in my Can we add something like a
Instead of my workaround right now which has me adding an invisible layer like so:
|
@kronick that goes beyond the scope/intention of a canvas source type (but will be possible with the later-down-the-road custom layer type). The canvas source type should and will be pretty naïve, just copying pixels like the |
@lucaswoj Continuing discussion from #3745 which was closed and redirected here. This post is mainly to restart our engagement.
The second option is actually quite attractive - and on the surface looks like the simplest to implement.
Thus providing basic interleaving of layers and styles. This simple addition of a 'screen coordinate' option for the canvas style could be a big enabler for us, until we can get WebGL context access. |
Creating a custom layer API that allows developers to draw directly into the map's canvas is a huge project.
A simpler solution (and perhaps a solution more in line with our users' needs) is to create a
canvas
source type which copies the contents of an external<canvas>
element onto the map.The implementation of this source type would be almost identical to the implementation of the
video
source type, which copies the contents of a<video>
element onto the map.We'll need to include an example of using this source type along with the implementation.
The text was updated successfully, but these errors were encountered: