<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' https://www.web3d.org/specifications/x3d-3.3.xsd '>
<head>
<meta name='titlecontent='BackgroundSequencer.x3d'/>
<meta name='descriptioncontent='Cycle through four Background nodes to show a time-of-day effect.'/>
<meta name='creatorcontent='Dale Tourtelotte, Don Brutzman and MV4205 class'/>
<meta name='createdcontent='20 April 2009'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='referencecontent=' https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter11LightingEnvironmentalEffects/BackgroundColorsOnly.x3d '/>
<meta name='subjectcontent='X3D Background example'/>
<meta name='identifiercontent=' https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter11LightingEnvironmentalEffects/BackgroundSequencer.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<WorldInfo title='BackgroundSequencer.x3d'/>
<Transform translation='0 3 0'>
<Shape>
<Text string='"Background Sequencer"'>
<FontStyle justify='"MIDDLE" "MIDDLE"'/>
</Text>
<Appearance>
<Material/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for TimeOfDayClock node:  [from fraction_changed to BackgroundSequencer.set_fraction ] -->
<TimeSensor DEF='TimeOfDayClockcycleInterval='12loop='true'/>
<!-- ROUTE information for BackgroundSequencer node:  [from TimeOfDayClock.fraction_changed to set_fraction ] [from value_changed to SelectorScript.whichBackground ] -->
<IntegerSequencer DEF='BackgroundSequencerkey='0 0.25 0.5 0.75 1keyValue='0 1 2 3 0containerField='children'/>
<ROUTE fromNode='TimeOfDayClockfromField='fraction_changedtoNode='BackgroundSequencertoField='set_fraction'/>
<!-- ROUTE information for SelectorScript node:  [from BackgroundSequencer.value_changed to whichBackground ] [from bind0 to SunRiseSky.set_bind ] [from bind1 to HighNoonSky.set_bind ] [from bind2 to SunsetSky.set_bind ] [from bind3 to NightSky.set_bind ] -->
<Script DEF='SelectorScript'>
<field name='whichBackgroundtype='SFInt32accessType='inputOnly'/>
<field name='currentBackgroundtype='SFInt32value='-1accessType='inputOutput'/>
<field name='bind0type='SFBoolaccessType='outputOnly'/>
<field name='bind1type='SFBoolaccessType='outputOnly'/>
<field name='bind2type='SFBoolaccessType='outputOnly'/>
<field name='bind3type='SFBoolaccessType='outputOnly'/>
<![CDATA[
      
ecmascript:
function whichBackground (inputValue)
{
    if (currentBackground == inputValue)
        return; // avoid rapid Background binding (probably overcautious)
    currentBackground = inputValue; // remember state
    Browser.println ("currentBackground=" + currentBackground);
    if      (inputValue == 0) bind0 = true; // send event
    else if (inputValue == 1) bind1 = true; // send event
    else if (inputValue == 2) bind2 = true; // send event
    else if (inputValue == 3) bind3 = true; // send event
}

    
]]>
</Script>
<ROUTE fromNode='BackgroundSequencerfromField='value_changedtoNode='SelectorScripttoField='whichBackground'/>
<!-- ROUTE information for SunRiseSky node:  [from SelectorScript.bind0 to set_bind ] -->
<Background DEF='SunRiseSkygroundAngle='0.75 1.2 1.25 1.26 1.5 1.57groundColor='0.133333 0.419608 0 0.36 0.1 0 1 0.74 0.4 1 0.74 0.4 0 0 0.5 0 0 0.2 0 0.231373 0.380392skyAngle='0.5 0.7 1.35 1.45 1.57skyColor='0 0.035 0.34 0 0.015 0.44 0 0.05 0.5 0 0.1 0.6 0.44 0.8 1 1 1 0.7'/>
<!-- ROUTE information for HighNoonSky node:  [from SelectorScript.bind1 to set_bind ] -->
<Background DEF='HighNoonSkygroundAngle='0.75 1.2 1.25 1.26 1.57groundColor='0.133333 0.419608 0 0.36 0.1 0 1 0.74 0.4 1 0.74 0.4 0 0.2 0.75 0 0.1 0.5skyAngle='0.05 0.07 1.57skyColor='1 1 0.2 1 1 0 0.36 0.63 1 0 0.4 1'/>
<!-- ROUTE information for SunsetSky node:  [from SelectorScript.bind2 to set_bind ] -->
<Background DEF='SunsetSkygroundAngle='0.75 1.2 1.25 1.26 1.57groundColor='0.133333 0.419608 0 0.36 0.1 0 1 0.74 0.4 1 0.74 0.4 0 0 0.5 0 0 0.2skyAngle='0.5 0.7 1.2 1.4 1.57skyColor='0 0 0.38 0 0 0.68 0.5 0.2 1 0.5 0.2 1 1 0.3 0 1 0.2 0.8'/>
<!-- ROUTE information for NightSky node:  [from SelectorScript.bind3 to set_bind ] -->
<Background DEF='NightSkygroundAngle='0.75 1.2 1.25 1.26 1.57groundColor='0.133333 0.419608 0 0.36 0.1 0 1 0.74 0.4 1 0.74 0.4 0 0 0.5 0 0 0.2skyAngle='0.03 0.05 1.57skyColor='1 1 1 0.8 0.8 0.8 0.1 0.1 0.1 0 0 0'/>
<ROUTE fromNode='SelectorScriptfromField='bind0toNode='SunRiseSkytoField='set_bind'/>
<ROUTE fromNode='SelectorScriptfromField='bind1toNode='HighNoonSkytoField='set_bind'/>
<ROUTE fromNode='SelectorScriptfromField='bind2toNode='SunsetSkytoField='set_bind'/>
<ROUTE fromNode='SelectorScriptfromField='bind3toNode='NightSkytoField='set_bind'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : BackgroundSequencer, HighNoonSky, NightSky, SelectorScript, SunRiseSky, SunsetSky, TimeOfDayClock
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->

<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources and X3D Scene Authoring Hints. -->