I found a great little VRML example that uses PROTO's and javascript and
almost loads into DIY browser.
There is a array out of bounds exception that causes the problem, any ideas?

#VRML V2.0 utf8 CosmoWorlds V1.0

PROTO random_mover [
        field SFVec3f start_location 0 0 0
        field SFFloat alteration 1
        field SFFloat spread 1
]

{
        Group {
                children      [
                        DEF Ball Transform {
                                children  Shape {
                                        appearance      Appearance {
                                                material      DEF _1 Material {
                                                        diffuseColor        0.8 0.8 0.8
                                                        specularColor .8 .5 .5
                                                }
                                        }
                                        geometry        Sphere {}
                                }
                                translation       IS start_location
                                scale     0.33258 0.33258 0.33258
                        }

                        DEF mover Script {
                                eventOut      SFVec3f      move_to
                                eventOut      SFColor      color_change
                                eventOut      SFVec3f      scaler
                                eventIn       SFFloat      time_changed
                                eventIn       SFFloat      loop_time
                                field         SFVec3f      location IS start_location
                                field         SFFloat      alteration IS alteration
                                field         SFFloat      spread IS spread
                                field         SFVec3f      delta 0 0 0
                                field         SFBool       first_time TRUE

                                url       "javascript:

                                function time_changed(value, time)
                                {

                                if(first_time == TRUE){
                                move_to[0]=location[0];
                                move_to[1]=location[1];
                                move_to[2]=location[2];


                                first_time=FALSE;
                                }

                                //alteration+=Math.random()*.05;

                                mu=value*Math.PI*2+alteration;

                                radius  =       2*Math.sin(mu/2);
                                theta   =       10*Math.cos(mu)*Math.sin(mu);
                                phi     =       10*Math.sin(mu*2)*Math.cos(mu);


                                scaler[0]=.5 + Math.abs(Math.sin(mu*3))*.5;
                                scaler[1]=.5 + Math.abs(Math.cos(mu*2))*.5;
                                scaler[2]=.5 + Math.abs(Math.sin(mu*4))*.5;

                                scaler[0]=scaler[0]*1;
                                scaler[1]=scaler[1]*1;
                                scaler[2]=scaler[2]*1;

                                move_to[0]=1 *radius * spread * 
Math.cos(phi)*Math.cos(theta);
                                move_to[1]=1 *radius * spread * 
Math.cos(phi)*Math.sin(theta);
                                move_to[2]=1 *radius * spread * Math.sin(phi);

                                
color_change[0]=Math.abs(Math.sin(mu*1.47967529296875));
                                
color_change[1]=Math.abs(Math.cos(mu*0.377838134765625));
                                
color_change[2]=Math.abs(Math.sin(mu*1.07968139648438));

                                }


                                "
                        }
                        DEF Clock TimeSensor {
                                cycleInterval     120
                                loop      TRUE
                                #startTime 1
                        }

                ]
        }
        ROUTE Clock.fraction_changed TO mover.time_changed
        ROUTE mover.color_change TO _1.set_diffuseColor
        ROUTE mover.move_to TO Ball.set_translation
        ROUTE mover.scaler TO Ball.set_scale

}



random_mover{start_location 0 0 0
alteration 0}
random_mover{start_location 0 0 0
alteration 0.0666666666666667}
random_mover{start_location 0 0 0
alteration 0.133333333333333}
random_mover{start_location 0 0 0
alteration 0.2}
random_mover{start_location 0 0 0
alteration 0.266666666666667}
random_mover{start_location 0 0 0
alteration 0.333333333333333}
random_mover{start_location 0 0 0
alteration 0.4}
random_mover{start_location 0 0 0
alteration 0.466666666666667}
random_mover{start_location 0 0 0
alteration 0.533333333333333}
random_mover{start_location 0 0 0
alteration 0.6}

DEF Background Transform {
        children  Background {
                skyColor        .5 .5 1
        }
}


********************
Jack S. Gundrum
Visualization Group
Research Support
Academic Services and Emerging Technology Systems
Information Technology Services
Penn State University

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to