proto_colorball_0_00.x3d source
<?xml version="1.0" encoding="UTF-8"?>
<X3D>
<Scene>
<ProtoDeclare name='ColorBall'>
<ProtoInterface>
<field accessType='inputOutput' type='SFVec3f' name='ballPosition' value='0 0 0'/>
<field accessType='inputOnly' type='SFTime' name='startFloat'/>
</ProtoInterface>
<ProtoBody>
<Transform DEF='Tf'>
<Transform DEF='Float-Tf'>
<Shape>
<Appearance>
<Material DEF='Mt' diffuseColor='1 0 0'/>
</Appearance>
<Sphere radius='0.1'/>
</Shape>
</Transform>
<IS>
<connect nodeField='translation' protoField='ballPosition'/>
</IS>
</Transform>

<Script DEF='Sc'>
<field accessType='inputOnly' type='SFVec3f' name='set_translation'/>
<field accessType='outputOnly' type='SFColor' name='diffuseColor'/>
<![CDATA[ecmascript:

function set_translation (vec) {

var h = Math.cos ( vec.x ) * 0.5 + 0.5;
var s = Math.cos ( vec.z ) * 0.4 + 0.6;

diffuseColor = new SFColor ();
diffuseColor.setHSV( h, s, 1 );

}
]]>
</Script>
<ROUTE fromNode='Tf' fromField='translation' toNode='Sc' toField='set_translation'/>
<ROUTE fromNode='Sc' fromField='diffuseColor' toNode='Mt' toField='diffuseColor'/>

<TimeSensor DEF='TiS' cycleInterval='20'>
<IS>
<connect nodeField='startTime' protoField='startFloat'/>
</IS>
</TimeSensor>

<PositionInterpolator DEF='PI'
key='0 0.25 0.5 0.75 1'
keyValue='
0 0 0
0 1 0
0 4 0
0 9 0
0 16 0'
/>
<ROUTE fromNode='TiS' fromField='fraction_changed' toNode='PI' toField='set_fraction'/>
<ROUTE fromNode='PI' fromField='value_changed' toNode='Float-Tf' toField='translation'/>
</ProtoBody>
</ProtoDeclare>
</Scene>
</X3D>