<?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 content='TimeOfDay.x3d' name='title'/>
    <meta content='Joe Roth' name='creator'/>
    <meta content='29 December 2000' name='created'/>
    <meta content='20 October 2019' name='modified'/>
    <meta content='Control scene lighting to simulate time of day, and also modify Fog for visibility.' name='description'/>
    <meta content='Fog affects 3D objects but not background in scene.' name='warning'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/TimeOfDay.x3d' name='identifier'/>
    <meta content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='../../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='TimeOfDay.x3d'/>
    <ExternProtoDeclare name='ClockMechanism' url='"ClockMechanismPROTO.x3d#ClockMechanism" "https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/ClockMechanismPROTO.x3d#ClockMechanism" "ClockMechanismPROTO.wrl#ClockMechanism" "https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/ClockMechanismPROTO.wrl#ClockMechanism" "http://www.cgrg.ohio-state.edu/%257Epgerstma/protolib/protolib/ClockMechanism/ClockMechanismPROTO.wrl#ClockMechanism"'>
      <field accessType='inputOnly' name='set_hour' type='SFInt32'/>
      <field accessType='inputOnly' name='set_minute' type='SFInt32'/>
      <field accessType='inputOnly' name='set_second' type='SFInt32'/>
      <field accessType='initializeOnly' name='autoClock' type='SFBool'/>
      <field accessType='initializeOnly' name='hour' type='SFInt32'/>
      <field accessType='initializeOnly' name='minute' type='SFInt32'/>
      <field accessType='initializeOnly' name='second' type='SFInt32'/>
      <field accessType='initializeOnly' name='hourHandAxis' type='SFVec3f'/>
      <field accessType='initializeOnly' name='minuteHandAxis' type='SFVec3f'/>
      <field accessType='initializeOnly' name='secondHandAxis' type='SFVec3f'/>
      <field accessType='initializeOnly' name='twentyFourHours' type='SFBool'/>
      <field accessType='outputOnly' name='hour_changed' type='SFInt32'/>
      <field accessType='outputOnly' name='minute_changed' type='SFInt32'/>
      <field accessType='outputOnly' name='second_changed' type='SFInt32'/>
      <field accessType='outputOnly' name='hourHand_changed' type='SFRotation'/>
      <field accessType='outputOnly' name='minuteHand_changed' type='SFRotation'/>
      <field accessType='outputOnly' name='secondHand_changed' type='SFRotation'/>
      <field accessType='outputOnly' name='hourpercent_changed' type='SFFloat'/>
    </ExternProtoDeclare>
    <ProtoInstance DEF='ClockMechanism' name='ClockMechanism'/>
    <!-- Note headlight turned off in NavigationInfo. Most browsers allow user toggling headlight also. -->
    <!-- This NavigationInfo node is bound at runtime and overrides the NavigationInfo headlight setting within the Inlined scene. -->
    <Background groundColor='0 0 0'/>
    <Background backUrl='"urn:web3d:media:textures/panoramas/ocean_3_back.jpg" "../../../Basic/UniversalMediaPanoramas/ocean_3_back.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_3_back.jpg" "https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_3_back.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_3_back.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_3_back.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/ocean_3_back.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_3_back.jpg"' bottomUrl='"urn:web3d:media:textures/panoramas/ocean_3_bottom.jpg" "../../../Basic/UniversalMediaPanoramas/ocean_3_bottom.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_3_bottom.jpg" "https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_3_bottom.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_3_bottom.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_3_bottom.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/ocean_3_bottom.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_3_bottom.jpg"' frontUrl='"urn:web3d:media:textures/panoramas/ocean_3_front.jpg" "../../../Basic/UniversalMediaPanoramas/ocean_3_front.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_3_front.jpg" "https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_3_front.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_3_front.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_3_front.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/ocean_3_front.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_3_front.jpg"' groundAngle='0.1 1.309 1.570796' groundColor='0 0 0 0 0.1 0.3 0 0.2 0.5 0 0.3 0.8' leftUrl='"urn:web3d:media:textures/panoramas/ocean_3_left.jpg" "../../../Basic/UniversalMediaPanoramas/ocean_3_left.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_3_left.jpg" "https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_3_left.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_3_left.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_3_left.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/ocean_3_left.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_3_left.jpg"' rightUrl='"urn:web3d:media:textures/panoramas/ocean_3_right.jpg" "../../../Basic/UniversalMediaPanoramas/ocean_3_right.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_3_right.jpg" "https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_3_right.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_3_right.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_3_right.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/ocean_3_right.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_3_right.jpg"' skyAngle='0.1 0.15 1.309 1.57079' skyColor='0.4 0.4 0.1 0.4 0.4 0.1 0 0.1 0.3 0 0.2 0.6 0.8 0.8 0.8' topUrl='"urn:web3d:media:textures/panoramas/ocean_3_top.jpg" "../../../Basic/UniversalMediaPanoramas/ocean_3_top.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_3_top.jpg" "https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_3_top.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_3_top.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_3_top.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/ocean_3_top.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_3_top.jpg"'/>
    <NavigationInfo headlight='false'/>
    <Group>
      <DirectionalLight DEF='SunLight' ambientIntensity='0.5' color='.25 .25 .25' direction='-0.8 -0.2 -0.2'/>
      <ScalarInterpolator DEF='LightAmbient' key='0 0.1 0.5 0.9 1' keyValue='0.3 0.3 0.7 0.2 0.2'/>
      <PositionInterpolator DEF='LightDirection' key='0 0.1 0.5 0.9 1' keyValue='0.8 -0.2 -0.2 0.8 -0.2 -0.2 0 -1 -0.2 -0.8 -0.2 -0.2 -0.8 -0.2 -0.2'/>
      <Transform translation='0 5 135'>
        <Viewpoint description='Control Panel'/>
      </Transform>
      <Transform translation='0 0 100'>
        <Transform rotation='-1 0 0 1.57' translation='0 -10 0'>
          <Inline DEF='Indy' bboxCenter='0 1 0' bboxSize='6 2 6' url='"indy.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/indy.x3d" "indy.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/indy.wrl"'/>
        </Transform>
        <Transform scale='5 5 5' translation='-3 10 0'>
          <Inline DEF='clock' url='"ClockMechanismExample2.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/ClockMechanismExample2.x3d" "ClockMechanismExample2.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/ClockMechanismExample2.wrl"'/>
          <TouchSensor DEF='button' description='click to increment'/>
          <Transform DEF='M'>
            <Shape>
              <Appearance DEF='green'>
                <Material emissiveColor='0 1 0'/>
              </Appearance>
              <IndexedLineSet coordIndex='0 1 2 3 4 5 6 7 -1 7 8 9 10 11 12 13 14 -1 14 15 16 17 18 19 20 21 0 -1'>
                <Coordinate point='-.02 .705 .04 -.019 .711 .04 -.016 .716 .04 -.012 .721 .04 -.006 .723 .04 0 .724 .04 .006 .723 .04 .012 .721 .04 .016 .716 .04 .019 .711 .04 .02 .705 .04 .02 -.005 .04 .019 -.011 .04 .016 -.016 .04 .012 -.021 .04 .006 -.023 .04 0 -.024 .04 -.003 -.023 .04 -.012 -.021 .04 -.016 -.016 .04 -.019 -.011 .04 -.02 -.005 .04'/>
              </IndexedLineSet>
            </Shape>
          </Transform>
          <Transform DEF='H'>
            <Shape>
              <Appearance>
                <Material emissiveColor='0 1 0'/>
              </Appearance>
              <IndexedLineSet coordIndex='0 1 2 3 4 5 6 7 -1 7 8 9 10 11 12 13 14 -1 14 15 16 17 18 19 20 21 0 -1'>
                <Coordinate point='-.056 .62 .02 -.053 .637 .02 -.045 .653 .02 -.033 .665 .02 -.017 .673 .02 0 .676 .02 .017 .673 .02 .033 .665 .02 .045 .653 .02 .053 .637 .02 .056 .62 .02 .056 0 .02 .053 -.017 .02 .045 -.033 .02 .033 -.045 .02 .017 -.053 .02 0 -.056 .02 -.017 -.053 .02 -.033 -.045 .02 -.045 -.033 .02 -.053 -.017 .02 -.056 0 .02'/>
              </IndexedLineSet>
            </Shape>
          </Transform>
          <Transform DEF='S'>
            <Shape>
              <Appearance>
                <Material emissiveColor='0 1 0'/>
              </Appearance>
              <IndexedLineSet coordIndex='0 1 2 3 4 5 6 7 -1 7 8 9 10 11 12 13 14 -1 14 15 16 17 18 19 20 21 0 -1'>
                <Coordinate point='-.02 .705 .04 -.019 .711 .04 -.016 .716 .04 -.012 .721 .04 -.006 .723 .04 0 .724 .04 .006 .723 .04 .012 .721 .04 .016 .716 .04 .019 .711 .04 .02 .705 .04 .02 -.005 .04 .019 -.011 .04 .016 -.016 .04 .012 -.021 .04 .006 -.023 .04 0 -.024 .04 -.003 -.023 .04 -.012 -.021 .04 -.016 -.016 .04 -.019 -.011 .04 -.02 -.005 .04'/>
              </IndexedLineSet>
            </Shape>
          </Transform>
          <Shape>
            <Appearance>
              <Material transparency='1'/>
            </Appearance>
            <Box/>
          </Shape>
        </Transform>
        <Transform scale='5 5 5' translation='5 10 0'>
          <Switch DEF='ampmswitch' whichChoice='0'>
            <Group>
              <Shape>
                <Appearance USE='green'/>
                <Text string='"AM"'>
                  <FontStyle/>
                </Text>
              </Shape>
            </Group>
            <Group>
              <Shape>
                <Appearance USE='green'/>
                <Text string='"PM"'>
                  <FontStyle/>
                </Text>
              </Shape>
            </Group>
          </Switch>
          <Script DEF='ampm'>
            <field accessType='inputOnly' name='set_boolean' type='SFBool'/>
            <field accessType='outputOnly' name='whichchoice' type='SFInt32'/>
            <![CDATA[
ecmascript:

function set_boolean ( boolean_input, eventTime)
{

        if ( boolean_input== false ) { whichchoice = 0;}

	if ( boolean_input== true ) { whichchoice = 1; }

}
]]>
          </Script>
          <Transform scale='4 1 1' translation='-1 2.5 0'>
            <Shape>
              <Appearance>
                <Material transparency='1'/>
              </Appearance>
              <Box/>
            </Shape>
            <TouchSensor DEF='VisibilityButton' description='click to change'/>
          </Transform>
        </Transform>
        <Transform scale='5 5 5' translation='-37 2 0'>
          <Shape>
            <Appearance USE='green'/>
            <Text string='"Click on the clock to increment time by one hour."'>
              <FontStyle size='.7'/>
            </Text>
          </Shape>
          <Transform translation='0 -1 0'>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Select the word Visibility to change  visibility range"'>
                <FontStyle size='.7'/>
              </Text>
            </Shape>
          </Transform>
        </Transform>
      </Transform>
      <Transform>
        <Shape>
          <Extrusion crossSection='0 0 0 100 100 100 100 0 0 0' solid='false' spine='-50 -50 50 -50 50 50'/>
          <Appearance>
            <Material DEF='transparent' diffuseColor='0 0 0'/>
          </Appearance>
        </Shape>
      </Transform>
      <Transform rotation='0 1 0 3.14' translation='0 0 -60'>
        <Viewpoint description='outside'/>
      </Transform>
      <Script DEF='Incrementor'>
        <field accessType='inputOnly' name='set_boolean' type='SFBool'/>
        <field accessType='outputOnly' name='hour_changed' type='SFInt32'/>
        <field accessType='outputOnly' name='twelvebool' type='SFBool'/>
        <![CDATA[
ecmascript:

function set_boolean ( boolean_input, eventTime)
{
	Browser.println ('boolean_input=' + boolean_input);
	if ( boolean_input == true )
		{ hour_changed = hour_changed + 1;}

        if (hour_changed <= 11){twelvebool = false; }

	if (hour_changed > 11){twelvebool = true; }
	if (hour_changed ==24) {hour_changed = 0;}
}

// separage function needed for set_hour
// hour_changed is an output, it gets set in the function
]]>
      </Script>
      <Transform scale='5 5 5' translation='-18 18 100'>
        <Switch DEF='FogSwitch' whichChoice='0'>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility Unlimited"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 5000 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 2500 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 1000 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 500 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 250 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 100 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 50 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 25 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 10 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 5 Meters"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
          <Group>
            <Shape>
              <Appearance USE='green'/>
              <Text string='"Visibility 1 Meter"'>
                <FontStyle/>
              </Text>
            </Shape>
          </Group>
        </Switch>
        <Script DEF='VisibilityScript'>
          <field accessType='inputOnly' name='set_boolean' type='SFBool'/>
          <field accessType='outputOnly' name='whichchoice' type='SFInt32'/>
          <field accessType='outputOnly' name='range' type='SFFloat'/>
          <field accessType='outputOnly' name='binder' type='SFBool'/>
          <![CDATA[
ecmascript:

function set_boolean ( boolean_input, eventTime)
{
binder =true;
if ( boolean_input== false ) { return; }
whichchoice = whichchoice +1;
if ( whichchoice ==12 ) { whichchoice = 0; }
if (whichchoice ==0) {range = 0;}
if (whichchoice ==1) {range = 5000;}
if (whichchoice ==2) {range = 2500;}
if (whichchoice ==3) {range = 1000;}
if (whichchoice ==4) {range = 500;}
if (whichchoice ==5) {range = 250;}
if (whichchoice ==6) {range = 100;}
if (whichchoice ==7) {range = 50;}
if (whichchoice ==8) {range = 25;}
if (whichchoice ==9) {range = 10;}
if (whichchoice ==10) {range = 5;}
if (whichchoice ==11) {range = 1;}
}
]]>
        </Script>
      </Transform>
    </Group>
    <Fog DEF='Foggy' color='0 0 0' fogType='EXPONENTIAL'/>
    <!-- The following two routes toggle the twelve Visibility Text Range labels driven by a touch sensor. -->
    <ROUTE fromField='isActive' fromNode='VisibilityButton' toField='set_boolean' toNode='VisibilityScript'/>
    <ROUTE fromField='whichchoice' fromNode='VisibilityScript' toField='whichChoice' toNode='FogSwitch'/>
    <!-- The following two routes change the visibility range on the Fog node through twelve settings. -->
    <ROUTE fromField='range' fromNode='VisibilityScript' toField='visibilityRange' toNode='Foggy'/>
    <ROUTE fromField='binder' fromNode='VisibilityScript' toField='set_bind' toNode='Foggy'/>
    <!-- The following two routes changes the am to pm text and vice-versa when the clock strikes twelve. -->
    <ROUTE fromField='twelvebool' fromNode='Incrementor' toField='set_boolean' toNode='ampm'/>
    <ROUTE fromField='whichchoice' fromNode='ampm' toField='whichChoice' toNode='ampmswitch'/>
    <!-- The following three routes rotate the hour, minute, and second hands. -->
    <ROUTE fromField='hourHand_changed' fromNode='ClockMechanism' toField='set_rotation' toNode='H'/>
    <ROUTE fromField='minuteHand_changed' fromNode='ClockMechanism' toField='set_rotation' toNode='M'/>
    <ROUTE fromField='secondHand_changed' fromNode='ClockMechanism' toField='set_rotation' toNode='S'/>
    <!-- The following two routes incremnet the clock one hour when the button is pushed. -->
    <ROUTE fromField='isActive' fromNode='button' toField='set_boolean' toNode='Incrementor'/>
    <ROUTE fromField='hour_changed' fromNode='Incrementor' toField='set_hour' toNode='ClockMechanism'/>
    <!-- The following five routes have the clock mechanism drive the light direction, light ambient intensity, as well as the transparency of a box around the world which has the effect darkening the background nodes. -->
    <ROUTE fromField='hourpercent_changed' fromNode='ClockMechanism' toField='set_fraction' toNode='LightAmbient'/>
    <ROUTE fromField='hourpercent_changed' fromNode='ClockMechanism' toField='set_fraction' toNode='LightDirection'/>
    <ROUTE fromField='value_changed' fromNode='LightDirection' toField='set_direction' toNode='SunLight'/>
    <ROUTE fromField='value_changed' fromNode='LightAmbient' toField='set_ambientIntensity' toNode='SunLight'/>
    <ROUTE fromField='value_changed' fromNode='LightAmbient' toField='set_transparency' toNode='transparent'/>
  </Scene>
</X3D>