Microsoft Research Community

wwtArrived() question

rated by 0 users
This post has 4 Replies | 2 Followers

Top 75 Contributor
Posts 9
ecofriend Posted: 06-29-2009 3:47 PM

Since the web client and documentation came out, I have been able to put together the following webpage: http://glast.sonoma.edu:81/wwt/index.php

 

It is pretty complete as far as content goes but I was hoping to make it a little flashy by making the making the red circle blink while changing in size. For that I implemented the following code.

 

function wwtArrived() {

// Show that we have arrived by drawing a red circle at the new ra, dec

                                               

var ii = 0;

for(jj = 0; jj < 10; jj++) // repeat the blinking effect 10 times.

{

while(ii <= 15.0)  // increase radius of circle while radius is less than or equal to 15

{

                                wwtView.ClearAnnotations();   // clear previous circle

var circle1 = createWWTCircle(false, 0xFFFF0033, 0xFFFF0033, 3, 0.5, ii, false, wwtView.GetRA(), wwtView.GetDec());      // create new circle

                                wwtView.AddAnnotation(circle1); // draw new circle

                                ii = ii + 0.5;           // increase radius

}

ii = 0;      // reset radius to zero

}

}

 

 

As you can see, the effect does not work. I have used the script debugger in IE8 to step through script and it is as if the circles are not drawn until after wwtArrived() has finished executing. I am not sure if this is intentional or if it is a bug.

Any insight on this matter will be much appreciated.

Sincerely,

Kamal

Top 75 Contributor
Posts 9

FYI, we are currently (Jul 6) having database issues so you may encounter errors when visiting http://glast.sonoma.edu:81/wwt/index.php but the WWT Web Client is functioning properly, including the drawing the red circle (minus the blinking effect).

Not Ranked
Posts 1


This is an interesting discussion.. thank you for sharing.

 


pret auto

Top 50 Contributor
Posts 17

Try code similar to the following. Use the setInterval function to set up a timer, ticking at the rate you wish the circle to blink. Create the circle once only - perhaps in the wwtReady function. The following code blinks a circle 5 times, at 750 millisecond intervals.

    var onOff;
    var circle1;
    var intervalID;
    var count;

    function intervalCode() {
        ++count;
        if (count < 10) {

            onOff = 1 - onOff;
            if (onOff == 1) {
                wwtView.AddAnnotation(circle1);
            } else {
                wwtView.RemoveAnnotation(circle1);
            }
        } else {
            wwtView.RemoveAnnotation(circle1);
            clearInterval(intervalID);
        }
    }

    function wwtArrived() {
        circle1.SetCenter(wwtView.GetRA(), wwtView.GetDec());
        wwtView.AddAnnotation(circle1);
        onOff = 1;
        count = 0;
        intervalID = setInterval("intervalCode()", 750);
    }

 

 

Top 75 Contributor
Posts 9

Hi Peter, thanks for your reply. Your code works as advertised.

After testing it with some co-workers it appears that the consensus is that the blinking effect is distracting.

I did learn a little more about WWT coding and javascript though.

Thanks again, Kamal

Page 1 of 1 (5 items) | RSS
©2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Feedback