earthoutreach / earth-api-utility-library

Automatically exported from code.google.com/p/earth-api-utility-library
0 stars 0 forks source link

fx.TimedAnimation multiple completion function calls #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using a TimedAnimation to animate an object over a set of linestrings; 
here's the code I'm using:

var duration = 1000;
function animate_car (object, placemark) {
    var startlat = placemark.getGeometry ().getCoordinates ().get(0).getLatitude ();
    var startlon = placemark.getGeometry ().getCoordinates ().get(0).getLongitude ();
    var endlat = placemark.getGeometry ().getCoordinates ().get(1).getLatitude ();
    var endlon = placemark.getGeometry ().getCoordinates ().get(1).getLongitude ();

    var location = object.getGeometry().getLocation();

    var anim = new gex.fx.TimedAnimation (duration, function (t) {
        location.setLatitude (startlat + (endlat-startlat)*1.0*t/duration);
        location.setLongitude (startlon + (endlon-startlon)*1.0*t/duration);
    }, function () {
        var next_sibling = placemark.getNextSibling ();
        animate_car (object, next_sibling);
    });

So each second we should traverse one placemark, and then move onto the next.

The problem I'm having is that the "completionfunction" is called more than 
once occasionally. From inspecting the code for the TimedAnimation, it appears 
that the renderer functions are listening for _both_ the GE "frameend" and a 
tick of 100ms. If I comment either one of these out, everything works fine. 
What 
is the reason for the 100ms tick to be there, and can't we get by with only the 
GE frameend?

I'm assuming that multiple invocations of the completion function stem from 
both the frameend and 100ms tick timing out at the exact same time, causing a 
duplicate call...

kind regards,
Nik.

Original issue reported on code.google.com by nik.vand...@gmail.com on 12 Aug 2009 at 2:00

GoogleCodeExporter commented 8 years ago
The original reasoning was to handle the case where frameend wouldn't get 
called if
nothing changed in the 3D view. This may or may not still be possible. I'll 
investigate.

Thanks for filing the bug!

Original comment by api.roman.public@gmail.com on 12 Aug 2009 at 5:29

GoogleCodeExporter commented 8 years ago
Sorry for the delay, fixed in trunk as of Revision 52.

Original comment by api.roman.public@gmail.com on 3 Sep 2009 at 9:34