<?xml version="1.0" encoding="UTF-8"?>
<X3D>
<Scene>
<Viewpoint/>
<NavigationInfo
type='
"EXAMINE"'
/>
<Background
skyColor='
1 1 1'
/>
<!-- Ball -->
<Transform translation='-2 0 0'>
<Shape>
<Appearance>
<Material DEF='Ball-Mt' diffuseColor='1 0 0'/>
</Appearance>
<Sphere/>
</Shape>
<TouchSensor DEF='Ball-ThS'/>
</Transform>
<!-- Box -->
<Transform translation='2 0 0'>
<Shape>
<Appearance>
<Material DEF='Box-Mt' diffuseColor='1 1 0'/>
</Appearance>
<Box/>
</Shape>
<TouchSensor DEF='Box-ThS'/>
</Transform>
<Script DEF='Sc'>
<field accessType='inputOnly' type='SFTime' name='touched_Ball'/>
<field accessType='inputOnly' type='SFTime' name='touched_Box'/>
<field accessType='outputOnly' type='SFColor' name='ballColor'/>
<field accessType='outputOnly' type='SFColor' name='boxColor'/>
<field accessType='initializeOnly' type='SFColor' name='black' value='0 0 0'/>
<field accessType='initializeOnly' type='SFColor' name='red' value='1 0 0'/>
<field accessType='initializeOnly' type='SFColor' name='col' value='0 1 1'/>
<![CDATA[ecmascript:
function initialize () {
ballColor = red;
}
function touched_Ball () {
// c0 is reference of ballColor.
var c0 = ballColor;
var b = c0.b;
c0.b = c0.g;
c0.g = c0.r;
c0.r = b;
// c0 is reference of black.
c0 = black;
}
function touched_Box () {
// c1 is reference of col.
var c1 = col;
// boxColor is copy of c1.
boxColor = c1;
var b = c1.b;
c1.b = c1.g;
c1.g = c1.r;
c1.r = b;
print( 'boxColor = ' + boxColor );
print( 'col = ' + col );
}
]]>
</Script>
<ROUTE fromNode='Ball-ThS' fromField='touchTime' toNode='Sc' toField='touched_Ball'/>
<ROUTE fromNode='Box-ThS' fromField='touchTime' toNode='Sc' toField='touched_Box'/>
<ROUTE fromNode='Sc' fromField='ballColor' toNode='Ball-Mt' toField='diffuseColor'/>
<ROUTE fromNode='Sc' fromField='boxColor' toNode='Box-Mt' toField='diffuseColor'/>
</Scene>
</X3D>