copyball_ring_0_00.x3d source
<?xml version="1.0" encoding="UTF-8"?>
<X3D>
<Scene>
<Viewpoint/>

<NavigationInfo
type='
"EXAMINE"'
/>

<Group DEF='Gp'>
</Group>

<Script DEF='Sc'>
<field accessType='outputOnly' type='MFNode' name='children'/>
<field accessType='initializeOnly' type='SFNode' name='Ball'>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Sphere radius='0.2'/>
</Shape>
</field>
<field accessType='initializeOnly' type='SFInt32' name='num' value='32'/>
<field accessType='initializeOnly' type='SFFloat' name='rad' value='3'/>
<![CDATA[ecmascript:

function initialize() {

var balls = new MFNode ();

for ( var i=0; i<num; i++ ) {

var angle = 2 * Math.PI * i / num;
var x = rad * Math.cos( angle );
var y = rad * Math.sin( angle );

var Tf = new SFNode ('Transform {}');
Tf.translation = new SFVec3f ( x, y, 0 );
Tf.children[0] = Ball;

balls[i] = Tf;

}

children = balls;

}
]]>
</Script>

<ROUTE fromNode='Sc' fromField='children' toNode='Gp' toField='children'/>
</Scene>
</X3D>