<head>
</head>
<!--
-->
<Scene>
<Viewpoint description='Background select' orientation='1 0 0 -0.2' position='0 2 10'/>
<!-- Background nodes are usually best placed at the top of the scene since they have global effect and are bindable nodes. -->
<!-- Bindable Backgrounds (cyan, red, blue) -->
<Background DEF='Default'/>
<!--
BackgroundCyan-ish ROUTE:
[
from Filter1.activated to set_bind
]
-->
<Background DEF='BackgroundCyan-ish' groundAngle='1.309 1.570796' groundColor='0.1 0.1 0 0.4 0.25 0.2 0.6 0.6 0.6' skyAngle='1.309 1.571' skyColor='0 0.2 0.7 0.0 0.5 1 1 1 1'/>
<!--
BackgroundReddish ROUTE:
[
from Filter2.activated to set_bind
]
-->
<Background DEF='BackgroundReddish' groundAngle='1.309 1.570796' groundColor='0.1 0.1 0 0.5 0.25 0.2 0.6 0.6 0.2' skyAngle='1.309 1.571' skyColor='1 0 0 1 0.4 0 1 1 0'/>
<!--
BackgroundBluish ROUTE:
[
from Filter3.activated to set_bind
]
-->
<Background DEF='BackgroundBluish' groundAngle='1.309 1.570796' groundColor='0 0 0.1 0 0.1 0.3 0.3 0.3 0.6' skyAngle='1.309 1.571' skyColor='1 0 0.8 0.5 0 0.8 0 0 0.8'/>
<Group>
<Transform translation='-3 0 0'>
<Shape>
<Box/>
<Appearance>
<Material diffuseColor='0 0.5 0.8'/>
</Appearance>
</Shape>
<!--
SensorButton1 ROUTE:
[
from isActive to Filter1.set_boolean
]
-->
<TouchSensor DEF='SensorButton1' description='Cyan background'/>
</Transform>
<!--
Filter1 ROUTEs:
[
from SensorButton1.isActive to set_boolean
]
[
from activated to BackgroundCyan-ish.set_bind
]
-->
<
Script DEF='
Filter1'>
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='filter input value'/>
<field name='activated' type='SFBool' accessType='outputOnly'
appinfo='activated provides a persistent binding value otherwise isActive events will toggle Background binding on/off.'/>
<field name='count' type='SFInt32' value='1' accessType='initializeOnly'
appinfo='count is only used locally so it is declared as an interface for persistence'/>
<![CDATA[
ecmascript:
function initialize () {
Browser.print (' '); // skip line
Browser.print ('Click shapes to select a background...');
Browser.print (' '); // skip line
}
// setting the value of an eventOut variable also sends it as an event
function set_boolean ( value, eventTime ) {
// only trigger on true values so that Background stays bound
if ( value == true ) {
activated = value;
Browser.print ('Cyan background ' + count);
}
else count++; // received isActive value = false
}
]]>
</
Script>
<ROUTE fromNode='SensorButton1' fromField='isActive' toNode='Filter1' toField='set_boolean'/>
<ROUTE fromNode='Filter1' fromField='activated' toNode='BackgroundCyan-ish' toField='set_bind'/>
<Group>
<Shape>
<Sphere/>
<Appearance>
<Material diffuseColor='1 0.3 0.3'/>
</Appearance>
</Shape>
<!--
SensorButton2 ROUTE:
[
from isActive to Filter2.set_boolean
]
-->
<TouchSensor DEF='SensorButton2' description='Red background'/>
</Group>
<!--
Filter2 ROUTEs:
[
from SensorButton2.isActive to set_boolean
]
[
from activated to BackgroundReddish.set_bind
]
-->
<
Script DEF='
Filter2'>
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='filter input value'/>
<field name='activated' type='SFBool' accessType='outputOnly'
appinfo='activated provides a persistent binding value otherwise isActive events will toggle Background binding on/off.'/>
<field name='count' type='SFInt32' value='1' accessType='initializeOnly'
appinfo='count is only used locally so it is declared as an interface for persistence'/>
<![CDATA[
ecmascript:
// setting the value of an eventOut variable also sends it as an event
function set_boolean ( value, eventTime ) {
// only trigger on true values so that Background stays bound
if ( value == true ) {
activated = value;
Browser.print ('Red background ' + count);
}
else count++; // received isActive value = false
}
]]>
</
Script>
<ROUTE fromNode='SensorButton2' fromField='isActive' toNode='Filter2' toField='set_boolean'/>
<ROUTE fromNode='Filter2' fromField='activated' toNode='BackgroundReddish' toField='set_bind'/>
<Transform translation='3 0 0'>
<Shape>
<Cone/>
<Appearance>
<Material diffuseColor='0.2 0.2 0.8'/>
</Appearance>
</Shape>
<!--
SensorButton3 ROUTE:
[
from isActive to Filter3.set_boolean
]
-->
<TouchSensor DEF='SensorButton3' description='Blue background'/>
</Transform>
<!--
Filter3 ROUTEs:
[
from SensorButton3.isActive to set_boolean
]
[
from activated to BackgroundBluish.set_bind
]
-->
<
Script DEF='
Filter3'>
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='filter input value'/>
<field name='activated' type='SFBool' accessType='outputOnly'
appinfo='activated provides a persistent binding value otherwise isActive events will toggle Background binding on/off.'/>
<field name='count' type='SFInt32' value='1' accessType='initializeOnly'
appinfo='count is only used locally so it is declared as an interface for persistence'/>
<![CDATA[
ecmascript:
// setting the value of an eventOut variable also sends it as an event
function set_boolean ( value, eventTime ) {
// only trigger on true values so that Background stays bound
if ( value == true ) {
activated = value;
Browser.print ('Blue background ' + count);
}
else count++; // received isActive value = false
}
]]>
</
Script>
<ROUTE fromNode='SensorButton3' fromField='isActive' toNode='Filter3' toField='set_boolean'/>
<ROUTE fromNode='Filter3' fromField='activated' toNode='BackgroundBluish' toField='set_bind'/>
<Transform translation='0 -3 0'>
<Shape>
<Text string='"Click on a Shape to change a Background," "Open player console to see trace statements."'>
<FontStyle justify='"MIDDLE" "MIDDLE"' size='0.6'/>
</Text>
<Appearance>
<Material diffuseColor='0.7 0.7 0.7'/>
</Appearance>
</Shape>
</Transform>
</Group>
</Scene>