X3D Model Documentation: Example19.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2 
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
  3  <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'>
  4       <head>
  5            <meta name='titlecontent='Example19.x3d'/>
  6            <meta name='creatorcontent='Don Brutzman'/>
  7            <meta name='createdcontent='24 May 2000'/>
  8            <meta name='modifiedcontent='28 October 2019'/>
  9            <meta name='creatorcontent='X3D working group'/>
 10            <meta name='descriptioncontent='VRML 97 specification example: Execution model demonstrated. Click ball to see script-generated text appear.'/>
 11            <meta name='referencecontent='originals/exampleD_19.wrl'/>
 12            <meta name='specificationSectioncontent='VRML 97, ISO/IEC 14772-1, Part 1: Functional specification and UTF-8 encoding, D.19 Execution model'/>
 13            <meta name='specificationUrlcontent='https://www.web3d.org/documents/specifications/14772/V2.0/part1/examples.html#D.19'/>
 14            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Example19.x3d'/>
 15            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 16            <meta name='licensecontent='../license.html'/>
 17       </head>
<!--

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

<!-- to top Index for DEF nodes: Collector, DefaultAppearance, Result, Script1, Script2, Script3, Script4, Script5, Script6, Script7, TS

Index for Viewpoint node: Viewpoint_1
-->
 18       <Scene>
 19            <WorldInfo title='Example19.x3d'/>
 20 
          <!-- ROUTE information for TS node:  [from touchTime to Script1.touchTime ] -->
          <TouchSensor DEF='TSdescription='touch to trigger more events'/>
 21            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 22 
          <!-- ROUTE information for Script1 node:  [from TS.touchTime to touchTime ] [from toScript2 to Script2.fromScript1 ] [from toScript3 to Script3.fromScript1 ] [from string to Collector.fromString ] -->
          <Script DEF='Script1'>
 23                 <field name='touchTimetype='SFTimeaccessType='inputOnly'/>
 24                 <field name='toScript2type='SFBoolaccessType='outputOnly'/>
 25                 <field name='toScript3type='SFBoolaccessType='outputOnly'/>
 26                 <field name='stringtype='SFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function touchTime()
{
	toScript2 = true;
}
function eventsProcessed()
{
	string = 'Script1.eventsProcessed';
	toScript3 = true;
}

    
]]>
 28            </Script>
 29            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 30 
          <!-- ROUTE information for Script2 node:  [from Script1.toScript2 to fromScript1 ] [from toScript4 to Script4.fromScript2 ] [from string to Collector.fromString ] -->
          <Script DEF='Script2'>
 31                 <field name='fromScript1type='SFBoolaccessType='inputOnly'/>
 32                 <field name='toScript4type='SFBoolaccessType='outputOnly'/>
 33                 <field name='stringtype='SFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function fromScript1() { }

function eventsProcessed()
{
	string = 'Script2.eventsProcessed';
	toScript4 = true;
}

    
]]>
 35            </Script>
 36            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 37 
 38                 <field name='fromScript1type='SFBoolaccessType='inputOnly'/>
 39                 <field name='toScript5type='SFBoolaccessType='outputOnly'/>
 40                 <field name='toScript6type='SFBoolaccessType='outputOnly'/>
 41                 <field name='stringtype='SFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function fromScript1()
{
	toScript5 = true;
}
function eventsProcessed()
{
	string = 'Script3.eventsProcessed';
	toScript6 = true;
}

    
]]>
 43            </Script>
 44            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 45 
          <!-- ROUTE information for Script4 node:  [from Script2.toScript4 to fromScript2 ] -->
          <Script DEF='Script4'>
 46                 <field name='fromScript2type='SFBoolaccessType='inputOnly'/>
  <![CDATA[
      
ecmascript:

function fromScript2() { }

    
]]>
 48            </Script>
 49            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 50 
          <!-- ROUTE information for Script5 node:  [from Script3.toScript5 to fromScript3 ] -->
          <Script DEF='Script5'>
 51                 <field name='fromScript3type='SFBoolaccessType='inputOnly'/>
  <![CDATA[
      
ecmascript:

function fromScript3() { }

    
]]>
 53            </Script>
 54            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 55 
          <!-- ROUTE information for Script6 node:  [from Script3.toScript6 to fromScript3 ] [from toScript7 to Script7.fromScript6 ] [from string to Collector.fromString ] -->
          <Script DEF='Script6'>
 56                 <field name='fromScript3type='SFBoolaccessType='inputOnly'/>
 57                 <field name='toScript7type='SFBoolaccessType='outputOnly'/>
 58                 <field name='stringtype='SFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function fromScript3()
{
	toScript7 = true;
}
function eventsProcessed()
{
	string = 'Script6.eventsProcessed';
}

    
]]>
 60            </Script>
 61            <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 62 
          <!-- ROUTE information for Script7 node:  [from Script6.toScript7 to fromScript6 ] -->
          <Script DEF='Script7'>
 63                 <field name='fromScript6type='SFBoolaccessType='inputOnly'/>
  <![CDATA[
      
ecmascript:

function fromScript6 () { }

    
]]>
 65            </Script>
 66            <!-- Display the results -->
 67 
 68                 <field name='stringtype='MFStringaccessType='outputOnly'/>
 69                 <field name='fromStringtype='SFStringaccessType='inputOnly'/>
  <![CDATA[
      
ecmascript:

function initialize()
{
	string[0] = 'Event Sequence:';
}
function fromString(s)
{
	i = string.length;
	string[i] = '('+i+') '+s+' occurred';
}

    
]]>
 71            </Script>
 72            <Transform translation='0 -6 0'>
 73                 <Transform translation='-2 2 0'>
 74                      <Shape>
 75                           <Appearance>
 76                                <Material diffuseColor='0 0.6 0'/>
 77                           </Appearance>
 78                           <Sphere/>
 79                      </Shape>
 80                 </Transform>
 81                 <Shape>
 82 
                    <!-- ROUTE information for Result node:  [from Collector.string to string ] -->
                    <Text DEF='Result'>
 83                           <FontStyle justify='"BEGIN" "END"'/>
 84                      </Text>
 85                      <Appearance DEF='DefaultAppearance'>
 86                           <Material/>
 87                      </Appearance>
 88                 </Shape>
 89            </Transform>
 90            <Viewpoint description='Touch ball to trigger eventsposition='7 -1 18'/>
 91            < ROUTE  fromNode='TS' fromField='touchTime' toNode='Script1' toField='touchTime'/>
 92            < ROUTE  fromNode='Script1' fromField='toScript2' toNode='Script2' toField='fromScript1'/>
 93            < ROUTE  fromNode='Script1' fromField='toScript3' toNode='Script3' toField='fromScript1'/>
 94            < ROUTE  fromNode='Script2' fromField='toScript4' toNode='Script4' toField='fromScript2'/>
 95            < ROUTE  fromNode='Script3' fromField='toScript5' toNode='Script5' toField='fromScript3'/>
 96            < ROUTE  fromNode='Script3' fromField='toScript6' toNode='Script6' toField='fromScript3'/>
 97            < ROUTE  fromNode='Script6' fromField='toScript7' toNode='Script7' toField='fromScript6'/>
 98            < ROUTE  fromNode='Script1' fromField='string' toNode='Collector' toField='fromString'/>
 99            < ROUTE  fromNode='Script2' fromField='string' toNode='Collector' toField='fromString'/>
100            < ROUTE  fromNode='Script3' fromField='string' toNode='Collector' toField='fromString'/>
101            < ROUTE  fromNode='Script6' fromField='string' toNode='Collector' toField='fromString'/>
102            < ROUTE  fromNode='Collector' fromField='string' toNode='Result' toField='string'/>
103       </Scene>
104  </X3D>
<!--

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

<!-- to top Index for DEF nodes: Collector, DefaultAppearance, Result, Script1, Script2, Script3, Script4, Script5, Script6, Script7, TS

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Appearance, field, FontStyle, head, Material, meta, ROUTE, Scene, Script, Shape, Sphere, Text, TouchSensor, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table entries with 12 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.

TS
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
Script1
Script
touchTime
SFTime
then
 
 
 
Script1
Script
string
SFString

ROUTE
event to
(2)
Collector
Script
fromString
SFString
then
 
 
 
Collector
Script
string
MFString

ROUTE
event to
(3)
Result
Text
string
MFString
  then
 
 
 
Script1
Script
toScript2
SFBool

ROUTE
event to
(2)
Script2
Script
fromScript1
SFBool
then
 
 
 
Script2
Script
string
SFString

ROUTE
event to
(3)
Collector
Script
fromString
SFString
then
 
 
 
Collector
Script
string
MFString

ROUTE
event to
(4)
Result
Text
string
MFString
  then
 
 
 
Script2
Script
toScript4
SFBool

ROUTE
event to
(3)
Script4
Script
fromScript2
SFBool
  then
 
 
 
Script1
Script
toScript3
SFBool

ROUTE
event to
(2)
Script3
Script
fromScript1
SFBool
then
 
 
 
Script3
Script
string
SFString

ROUTE
event to
(3)
Collector
Script
fromString
SFString
then
 
 
 
Collector
Script
string
MFString

ROUTE
event to
(4)
Result
Text
string
MFString
  then
 
 
 
Script3
Script
toScript5
SFBool

ROUTE
event to
(3)
Script5
Script
fromScript3
SFBool
  then
 
 
 
Script3
Script
toScript6
SFBool

ROUTE
event to
(3)
Script6
Script
fromScript3
SFBool
then
 
 
 
Script6
Script
string
SFString

ROUTE
event to
(4)
Collector
Script
fromString
SFString
then
 
 
 
Collector
Script
string
MFString

ROUTE
event to
(5)
Result
Text
string
MFString
  then
 
 
 
Script6
Script
toScript7
SFBool

ROUTE
event to
(4)
Script7
Script
fromScript6
SFBool

      Collector
Script
string
MFString

ROUTE
event to
(1)
Result
Text
string
MFString

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/Basic/Vrml97Specification/Example19Index.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Example19.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. -->