Skip to content
Snippets Groups Projects
TimeDelaySensorExample.x3d 3.56 KiB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'>
  <head>
    <meta content='TimeDelaySensorExample.x3d' name='title'/>
    <meta content='Time delay sensor design pattern: example use.' name='description'/>
    <meta content='Don Brutzman and MV4204 class' name='creator'/>
    <meta content='18 August 2003' name='created'/>
    <meta content='28 November 2019' name='modified'/>
    <meta content='TimeDelaySensorPrototype.x3d' name='reference'/>
    <meta content='https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/time.html' name='reference'/>
    <meta content='https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/utils.html' name='reference'/>
    <meta content='TimeDelaySensor' name='subject'/>
    <meta content='https://savage.nps.edu/Savage/Tools/Animation/TimeDelaySensorExample.x3d' name='identifier'/>
    <meta content='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit' name='generator'/>
    <meta content='../../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='TimeDelaySensorExample.x3d'/>
    <ExternProtoDeclare appinfo='TimeSensor functionality commences after delayInterval pause' name='TimeDelaySensor' url='"TimeDelaySensorPrototype.x3d#TimeDelaySensor" "https://savage.nps.edu/Savage/Tools/Animation/TimeDelaySensorPrototype.x3d#TimeDelaySensor" "TimeDelaySensorPrototype.wrl#TimeDelaySensor" "https://savage.nps.edu/Savage/Tools/Animation/TimeDelaySensorPrototype.wrl#TimeDelaySensor"'>
      <field accessType='inputOutput' appinfo='describe the purpose of this sensor' name='description' type='SFString'/>
      <field accessType='inputOutput' name='startTime' type='SFTime'/>
      <field accessType='inputOutput' name='enabled' type='SFBool'/>
      <field accessType='inputOutput' appinfo='seconds' name='delayInterval' type='SFTime'/>
      <field accessType='outputOnly' name='delayCompleteTime' type='SFTime'/>
      <field accessType='initializeOnly' name='traceEnabled' type='SFBool'/>
    </ExternProtoDeclare>
    <!-- ==================== -->
    <Group DEF='TextTouchGroup'>
      <Shape>
        <Text string='"click text then wait for" "3 second time delay" "before color changes"'>
          <FontStyle justify='"MIDDLE" "MIDDLE"'/>
        </Text>
        <Appearance>
          <Material DEF='TextColor'/>
        </Appearance>
      </Shape>
      <TouchSensor DEF='TouchSensorActive' description='click to initiate time delay and color change'/>
    </Group>
    <!-- ==================== -->
    <Group DEF='TextAnimationGroup'>
      <ProtoInstance DEF='DelayTimer' name='TimeDelaySensor'>
        <fieldValue name='delayInterval' value='3'/>
        <fieldValue name='traceEnabled' value='true'/>
      </ProtoInstance>
      <TimeSensor DEF='AnimationClock' cycleInterval='2'/>
      <ROUTE fromField='touchTime' fromNode='TouchSensorActive' toField='set_startTime' toNode='DelayTimer'/>
      <ROUTE fromField='delayCompleteTime' fromNode='DelayTimer' toField='set_startTime' toNode='AnimationClock'/>
      <ColorInterpolator DEF='ColorChangerRGB' key='0 0.5 1' keyValue='1 0 0 0 1 0 0 0 1'/>
      <ROUTE fromField='fraction_changed' fromNode='AnimationClock' toField='set_fraction' toNode='ColorChangerRGB'/>
      <ROUTE fromField='value_changed' fromNode='ColorChangerRGB' toField='diffuseColor' toNode='TextColor'/>
    </Group>
  </Scene>
</X3D>