ArcLayer point-to-point animation #2531
Replies: 14 comments 1 reply
-
backgroundThanks for Yaryna Serkez's work on animating arcs:
Though I need more time to understand the ideas of drawing animating arcs with help of colors and opactiy, I think the framework of this kind of AnimationArclayer is clear. For normal ArcLayer, we can enhance it's interaction by providing a point-to-point (from source point to target point) animation. Approaches
And for deck.gl developers, we can provide the same API as Arclayer, except one more property called The usage can be formatted like this:
The idea is pretty similar to the first approach, except we let Layer handle the drawing process by itself. We should add a setInterval to the constructor, and provide a
Last, we get |
Beta Was this translation helpful? Give feedback.
-
Hi @hijiangtao, first of all thank you for providing your code! I tried to use the second way - seems to me way more beautiful - but I ran into a problem. Calling
My AnimatedArcLayer looks like the following:
I also tried to bind
Have you any idea on how to implement an AnimatedArcLayer in deck.gl@6.4.10? Any is help appreciated :D |
Beta Was this translation helpful? Give feedback.
-
Hi, @stoney95 The base layer of deck.gl is not extensible so the second way is still a propose to be discussed here. And for the first question, I couldn't see the calling of As the issue hasn't been accepted by deck.gl, I implemented it in this way, you may find some useful code here https://github.com/hijiangtao/glmaps/blob/master/src/layers/ArcLayer/animate.js#L31-L88 and here https://github.com/hijiangtao/glmaps/blob/master/src/layers/ArcLayer/index.js#L13-L22 (which is put the timer out of drawing layer itself) |
Beta Was this translation helpful? Give feedback.
-
While I appreciate the detail, the text here got a bit long so I am trying to understand what effect you want to achieve. Is it mainly a question of wanting the arc endpoints to gradually move to the new positions, rather than "jump"? In that case you should just use the
You can use the |
Beta Was this translation helpful? Give feedback.
-
@hijiangtao Thank you for your fast reply and also for providing your code!! I will submit an issue to your repo as i had to make two small fixes to get it running. @ibgreen I'd like to achieve something similar to this: https://www.youtube.com/watch?v=6P4XQcnNTAo
Don't quite get how to add methods using the layer-state. But I'm also pretty new to deck.gl and didn't get to extending layers so far. |
Beta Was this translation helpful? Give feedback.
-
@stoney95 That's really great, hope to see your practice with deck.gl and learn from you. And for @ibgreen 's mentioning - If you want to write your own layer in the future, I think this document may help you more or less https://deck.gl/#/documentation/developer-guide/writing-custom-layers/writing-your-own-layer?section=preparations |
Beta Was this translation helpful? Give feedback.
-
Updated to deck.gl 7.3.4, and Yaryna Serkez's solution no longer works (no arcs rendering for me). Seems like breaking changes in luma.gl? |
Beta Was this translation helpful? Give feedback.
-
@DarryQueen Hi, I mainly used |
Beta Was this translation helpful? Give feedback.
-
I am wondering if anyone has solved the animation arc layer issue with v8.1 @hijiangtao |
Beta Was this translation helpful? Give feedback.
-
I have solved after pulling quite a bit of hair. Not sure if it's the right solution since I have no clue about shader code but it seems to be working. Maybe it will help someone. Deckgl version 8.2.5.
|
Beta Was this translation helpful? Give feedback.
-
@Fl0rianFischer thank you for your code,this can work on deckgl 8.X version; |
Beta Was this translation helpful? Give feedback.
-
@Diazhao @Fl0rianFischer I think we can always customize shaders via these APIs (as I mentioned above, in a very long time ago), what I supposed is to expose one explicit API to developers, which can let them draw animations easily, did you mean we can use such things already? :-) |
Beta Was this translation helpful? Give feedback.
-
@hijiangtao my comment was more about improving on Yaryna Serkez's blog post on arc animation, since it doesn't work with recent versions of deck.gl. Most people trying to do this will stumble on this thread so I thought it might be a good idea to post it here. I'd be very interested none the less to see a unified API in deck.gl for animating arcs and routes. |
Beta Was this translation helpful? Give feedback.
-
Hey guys! First of all I wanna thank @hijiangtao and @Fl0rianFischer for publishing awesome stuff. At least I had something to start off from when I thought about animating arcs. I'd like to leave my small contribution here - an example of a typed layer for animation, extending Typescript for the win! I guess the solution is quite minimal, injections boil down to this: shaders.inject = {
"vs:#decl": `
uniform float coef;
`,
"fs:#decl": `
uniform float coef;
`,
"vs:#main-end": `
if (coef == 0.0 || geometry.uv.x > coef) {
isValid = 0.0;
}
`,
"fs:DECKGL_FILTER_COLOR": `
float lowerBound = 0.0;
if (coef > 0.05) {
lowerBound = coef - 0.05;
}
if (coef != 1.0 ) {
color.a = 1.0 - smoothstep(lowerBound, coef, geometry.uv.x);
}
`,
}; Checked that works with deck.gl Some notes regarding the solution:Initially I thought the version proposed at the beginning of this thread was enough for me but then I went on a journey with GPT-4 and by feeding it docs / shaders code / anything (Cursor editor is awesome btw) I was able to arrive at what I have now. My computer graphics skills are not great, but I think after 6+ hours of debugging I finally get almost all important details about how shaders work.
|
Beta Was this translation helpful? Give feedback.
-
Update: Enhancement about ArcLayer animation, see #2531 (comment)
Original Post (problem deprecated):
As mentioned in the title, I want to draw an animation with ArcLayer. As iuntroduced by deck.gl website, the Arc Layer renders raised arcs joining pairs of source and target points, specified as latitude/longitude coordinates, all arcs will be rendered at the same time, so can I animate it from source to target with some time latency?
By looking through the docs, I couldn't find a way to do that, however I found some documents may be useful for me, such as Animation and attribute-manager ,but I couldn't find concrete example of these usage.
However, I found some similar issues, like "How to animate ArcLayer arcs individually?" #633 It seems the developer want to draw different arcs at different time, and your team gave him an approach to do it with
updateTriggers
. I also need to animation the arc, but not different arcs. I want to draw arc with animation from source to target with some time, as I mentioned above.I did some trying with his method. I look through the usage of
updateTriggers
and change the ArcLayer Demo codes with this property (updateTriggers
method andgetTargetPosition
method):However, I found it can only change arcs suddenly like this, not the animation I want.
Any ideas on it? Thanks very much.
Beta Was this translation helpful? Give feedback.
All reactions