X3D Model Documentation: Example16.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='Example16.x3d'/>
  6            <meta name='creatorcontent='X3D working group'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='26 June 2000'/>
  9            <meta name='modifiedcontent='28 October 2019'/>
 10            <meta name='descriptioncontent='VRML 97 specification example: Chopper. Click chopper to toggle rotor spinning.'/>
 11            <meta name='referencecontent='originals/exampleD_16.wrl'/>
 12            <meta name='specificationSectioncontent='VRML 97, ISO/IEC 14772-1, Part 1: Functional specification and UTF-8 encoding, D.16 Chopper'/>
 13            <meta name='specificationUrlcontent='https://www.web3d.org/documents/specifications/14772/V2.0/part1/examples.html#D.16'/>
 14            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Example16.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: MikesChopper, RotorScript, Top, Touch

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definition: Rotor

Index for ProtoDeclare definition: Chopper
-->
 18       <Scene>
 19            <WorldInfo title='Example16.x3d'/>
 20            <ExternProtoDeclare name='Rotorappinfo='Rotor prototype to spin children geometry'   url=' "Rotor.x3d#Rotor" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Rotor.x3d#Rotor" "Rotor.wrl#Rotor" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Rotor.wrl#Rotor" '>
 21                 <field name='ratetype='SFTimeaccessType='initializeOnly'
                appinfo='rotation rate'/>
 22                 <field name='childrentype='MFNodeaccessType='initializeOnly'
                appinfo='children geometry to spin'/>
 23                 <field name='startTimetype='SFTimeaccessType='inputOutput'
                appinfo='exposed TimeSensor field for animation'/>
 24                 <field name='stopTimetype='SFTimeaccessType='inputOutput'
                appinfo='exposed TimeSensor field for animation'/>
 25            </ExternProtoDeclare>
 26            <ProtoDeclare name='Chopper'>
 27                 <ProtoInterface>
 28                      <field name='rotorSpeedtype='SFTimevalue='1accessType='initializeOnly'/>
 29                 </ProtoInterface>
 30                 <ProtoBody>
 31                      <Group>
 32 
                         <!-- ROUTE information for Touch node:  [from touchTime to RotorScript.startOrStopEngine ] -->
                         <TouchSensor DEF='Touchdescription='touch to start/stop spinning rotor'/>
 33                           <Inline   url=' "ChopperBody.x3d" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/ChopperBody.x3d" "ChopperBody.wrl" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/ChopperBody.wrl" '/>
 34 
                         <!-- ROUTE information for Top node:  [from RotorScript.startEngine to startTime ] [from RotorScript.stopEngine to stopTime ] -->
                         <ProtoInstance name='RotorDEF='Top'>
 35                                <fieldValue name='stopTimevalue='1'/>
 36                                <fieldValue name='children'>
 37                                     <Inline   url=' "ChopperRotor.x3d" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/ChopperRotor.x3d" "ChopperRotor.wrl" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/ChopperRotor.wrl" '/>
 38                                </fieldValue>
 39                                <IS>
 40                                     <connect nodeField='rateprotoField='rotorSpeed'/>
 41                                </IS>
 42                           </ProtoInstance>
 43                      </Group>
 44                      <!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
 45 
                    <!-- ROUTE information for RotorScript node:  [from Touch.touchTime to startOrStopEngine ] [from startEngine to Top.startTime ] [from stopEngine to Top.stopTime ] -->
                    <Script DEF='RotorScript'>
 46                           <field name='startOrStopEnginetype='SFTimeaccessType='inputOnly'/>
 47                           <field name='startEnginetype='SFTimeaccessType='outputOnly'/>
 48                           <field name='stopEnginetype='SFTimeaccessType='outputOnly'/>
 49                           <field name='engineStartedtype='SFBoolvalue='falseaccessType='initializeOnly'/>
  <![CDATA[
          
ecmascript:

function startOrStopEngine(value) {
	// start or stop engine:
	if (!engineStarted) {
		startEngine = value;
		engineStarted = true;
	}
	else
	{
		stopEngine = value;
		engineStarted = false;
	}
}

        
]]>
 51                      </Script>
 52                      < ROUTE  fromNode='Touch' fromField='touchTime' toNode='RotorScript' toField='startOrStopEngine'/>
 53                      < ROUTE  fromNode='RotorScript' fromField='startEngine' toNode='Top' toField='startTime'/>
 54                      < ROUTE  fromNode='RotorScript' fromField='stopEngine' toNode='Top' toField='stopTime'/>
 55                 </ProtoBody>
 56            </ProtoDeclare>
 57            <!-- ==================== -->
 58            <Viewpoint description='Example 16position='0 0 5'/>
 59            <Group>
 60                 <ProtoInstance name='ChopperDEF='MikesChopper'/>
 61            </Group>
 62       </Scene>
 63  </X3D>
<!--

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

<!-- to top Index for DEF nodes: MikesChopper, RotorScript, Top, Touch

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definition: Rotor

Index for ProtoDeclare definition: Chopper
-->
X3D Tooltips element index: connect, ExternProtoDeclare, field, fieldValue, Group, head, Inline, IS, meta, ProtoBody, ProtoDeclare, ProtoInstance, ProtoInterface, ROUTE, Scene, Script, TouchSensor, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

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

Touch
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
RotorScript
Script
startOrStopEngine
SFTime
then
 
 
 
RotorScript
Script
startEngine
SFTime

ROUTE
event to
(2)
Top
ProtoInstance
startTime
SFTime
  then
 
 
 
RotorScript
Script
stopEngine
SFTime

ROUTE
event to
(2)
Top
ProtoInstance
stopTime
SFTime

MikesChopper
ProtoInstance
Chopper
No ROUTE connection found for output events from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declarations with
direct access to other nodes, and thus has potential to produce run-time animation. 

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/Example16Index.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Example16.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)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

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