X3D Model Documentation: EventMonitorTest.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <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'>
  4       <head>
  5            <meta name='titlecontent='EventMonitorTest.x3d'/>
  6            <meta name='descriptioncontent='This scene demonstrates how to receive a simple event and report it graphically, repeating every few seconds. Scene conversion from the XML encoding (.x3d) is then used to demonstrate X3DOM event handling within a web page (.xhtml).'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='acknowledgementscontent='Chris Peri, Dave Arendash and Damon Hernandez'/>
  9            <meta name='createdcontent='15 March 2014'/>
 10            <meta name='modifiedcontent='31 October 2021'/>
 11            <meta name=' TODO content=' record log outputs, compare various X3D players '/>
 12            <meta name='referencecontent='AEC Hackathon v1.1, Facebook Menlo Park California'/>
 13            <meta name='referencecontent='http://www.aechackathon.org'/>
 14            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/UserExperienceUX/EventMonitorTest.x3d'/>
 15            <meta name='generatorcontent='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
 16            <meta name='generatorcontent='https://www.web3d.org/x3d/stylesheets/X3dToX3dom.xslt'/>
 17            <meta name='licensecontent='../license.html'/>
 18       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: BooleanSwitcher, DisplayDown, DisplayUp, DownColor, EventFalseTrigger, EventReceiverScript, EventSwitch, EventTrueTrigger, Font, SmallCone, SwitchTestClock, TextMaterial, UpColor

Index for Viewpoint node: Viewpoint_1
-->
 19       <Scene>
 20            <!-- ================================================== -->
 21            <!-- Reusable code block for X3DOM: indicate event status -->
 22            <WorldInfo title='EventMonitorTest.x3d'/>
 23            <Background skyColor='0.4 0.6 1'/>
 24            <Viewpoint description='Event Monitor Textposition='0 0 6'/>
 25            <Transform translation='-0.6 1.2 0'>
 26                 <Shape>
 27                      <Text string='"Event Status"'>
 28 
                         <!-- FontStyle Font is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
                         <FontStyle DEF='Fontjustify='"MIDDLE" "MIDDLE"style='BOLD'/>
 29                      </Text>
 30                      <Appearance>
 31                           <Material DEF='TextMaterialdiffuseColor='0.7 0.7 0.1'/>
 32                      </Appearance>
 33                 </Shape>
 34            </Transform>
 35 
          <!-- ROUTE information for EventSwitch node:  [from EventTrueTrigger.triggerValue to whichChoice ] [from EventFalseTrigger.triggerValue to whichChoice ] -->
          <Switch DEF='EventSwitchwhichChoice='0'>
 36                 <Group DEF='DisplayUp'>
 37                      <Shape>
 38                           <Text string='"UP"'>
 39                                <FontStyle USE='Font'/>
 40                           </Text>
 41                           <Appearance>
 42 
                              <!-- Material UpColor is a DEF node that has 1 USE node: USE_1 -->
                              <Material DEF='UpColordiffuseColor='0.2 0.7 0.3'/>
 43                           </Appearance>
 44                      </Shape>
 45                      <Transform translation='-2.5 0 0'>
 46                           <Shape>
 47 
                              <!-- Cone SmallCone is a DEF node that has 1 USE node: USE_1 -->
                              <Cone DEF='SmallConebottomRadius='0.4height='0.6'/>
 48                                <Appearance>
 49                                     <Material USE='UpColor'/>
 50                                </Appearance>
 51                           </Shape>
 52                      </Transform>
 53                 </Group>
 54                 <Group DEF='DisplayDown'>
 55                      <Shape>
 56                           <Text string='"DOWN"'>
 57                                <FontStyle USE='Font'/>
 58                           </Text>
 59                           <Appearance>
 60 
                              <!-- Material DownColor is a DEF node that has 1 USE node: USE_1 -->
                              <Material DEF='DownColordiffuseColor='1 0.2 0.2'/>
 61                           </Appearance>
 62                      </Shape>
 63                      <Transform rotation='1 0 0 3.14159translation='-2.5 0 0'>
 64                           <Shape>
 65                                <Cone USE='SmallCone'/>
 66                                <Appearance>
 67                                     <Material USE='DownColor'/>
 68                                </Appearance>
 69                           </Shape>
 70                      </Transform>
 71                 </Group>
 72            </Switch>
 73            <!-- ================================================== -->
 74            <!-- Test harness: produce true/false events, flip the Switch -->
 75 
          <!-- ROUTE information for EventTrueTrigger node:  [from EventReceiverScript.eventIsTrue to set_boolean ] [from triggerValue to EventSwitch.whichChoice ] -->
          <IntegerTrigger DEF='EventTrueTriggerintegerKey='0'/>
 76            < ROUTE  fromNode='EventTrueTrigger' fromField='triggerValue' toNode='EventSwitch' toField='whichChoice'/>
 77 
          <!-- ROUTE information for EventFalseTrigger node:  [from EventReceiverScript.eventIsFalse to set_boolean ] [from triggerValue to EventSwitch.whichChoice ] -->
          <IntegerTrigger DEF='EventFalseTriggerintegerKey='1'/>
 78            < ROUTE  fromNode='EventFalseTrigger' fromField='triggerValue' toNode='EventSwitch' toField='whichChoice'/>
 79 
          <!-- ROUTE information for EventReceiverScript node:  [from BooleanSwitcher.value_changed to input ] [from eventIsTrue to EventTrueTrigger.set_boolean ] [from eventIsFalse to EventFalseTrigger.set_boolean ] -->
          <Script DEF='EventReceiverScript'>
 80                 <field name='inputtype='SFBoolaccessType='inputOnly'/>
 81                 <field name='eventIsTruetype='SFBoolaccessType='outputOnly'/>
 82                 <field name='eventIsFalsetype='SFBoolaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function input (eventValue) // input eventValue received for inputOnly field
{
   if (eventValue) eventIsTrue  = true;
   else            eventIsFalse = true;
}

    
]]>
 84            </Script>
 85            < ROUTE  fromNode='EventReceiverScript' fromField='eventIsTrue' toNode='EventTrueTrigger' toField='set_boolean'/>
 86            < ROUTE  fromNode='EventReceiverScript' fromField='eventIsFalse' toNode='EventFalseTrigger' toField='set_boolean'/>
 87            <!-- Testing block: alternate true/false -->
 88 
          <!-- ROUTE information for BooleanSwitcher node:  [from SwitchTestClock.fraction_changed to set_fraction ] [from value_changed to EventReceiverScript.input ] -->
          <BooleanSequencer DEF='BooleanSwitcherkey='0 0.5 1keyValue='true false false'/>
 89            < ROUTE  fromNode='BooleanSwitcher' fromField='value_changed' toNode='EventReceiverScript' toField='input'/>
 90 
          <!-- ROUTE information for SwitchTestClock node:  [from fraction_changed to BooleanSwitcher.set_fraction ] -->
          <TimeSensor DEF='SwitchTestClockcycleInterval='6loop='true'/>
 91            < ROUTE  fromNode='SwitchTestClock' fromField='fraction_changed' toNode='BooleanSwitcher' toField='set_fraction'/>
 92       </Scene>
 93  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: BooleanSwitcher, DisplayDown, DisplayUp, DownColor, EventFalseTrigger, EventReceiverScript, EventSwitch, EventTrueTrigger, Font, SmallCone, SwitchTestClock, TextMaterial, UpColor

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Appearance, Background, BooleanSequencer, Cone, field, FontStyle, Group, head, IntegerTrigger, Material, meta, ROUTE, Scene, Script, Shape, Switch, Text, TimeSensor, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table entries with 6 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

SwitchTestClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
BooleanSwitcher
BooleanSequencer
set_fraction
SFFloat
then
 
 
 
BooleanSwitcher
BooleanSequencer
value_changed
SFBool

ROUTE
event to
(2)
EventReceiverScript
Script
input
SFBool
then
 
 
 
EventReceiverScript
Script
eventIsFalse
SFBool

ROUTE
event to
(3)
EventFalseTrigger
IntegerTrigger
set_boolean
SFBool
then
 
 
 
EventFalseTrigger
IntegerTrigger
triggerValue
SFInt32

ROUTE
event to
(4)
EventSwitch
Switch
whichChoice
SFInt32
  then
 
 
 
EventReceiverScript
Script
eventIsTrue
SFBool

ROUTE
event to
(3)
EventTrueTrigger
IntegerTrigger
set_boolean
SFBool
then
 
 
 
EventTrueTrigger
IntegerTrigger
triggerValue
SFInt32

ROUTE
event to
(4)
EventSwitch
Switch
whichChoice
SFInt32

Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/UserExperienceUX/EventMonitorTestIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/UserExperienceUX/EventMonitorTest.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
-->

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