| 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='title' content=' Example16.x3d '/> |
| 6 | <meta name='creator' content='X3D working group'/> |
| 7 | <meta name='creator' content='Don Brutzman'/> |
| 8 | <meta name='created' content='26 June 2000'/> |
| 9 | <meta name='modified' content='28 October 2019'/> |
| 10 | <meta name='description' content='VRML 97 specification example: Chopper. Click chopper to toggle rotor spinning.'/> |
| 11 | <meta name='reference' content='originals/exampleD_16.wrl'/> |
| 12 | <meta name='specificationSection' content='VRML 97, ISO/IEC 14772-1, Part 1: Functional specification and UTF-8 encoding, D.16 Chopper'/> |
| 13 | <meta name='specificationUrl' content='https://www.web3d.org/documents/specifications/14772/V2.0/part1/examples.html#D.16'/> |
| 14 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Example16.x3d '/> |
| 15 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 16 | <meta name='license' content='../license.html'/> |
| 17 | </head> |
| 18 | <Scene> |
| 19 | <WorldInfo title='Example16.x3d'/> |
| 20 | <ExternProtoDeclare name='Rotor' appinfo='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='rate' type='SFTime' accessType='initializeOnly'
appinfo='rotation rate'/> |
| 22 |
<field name='children' type='MFNode' accessType='initializeOnly'
appinfo='children geometry to spin'/> |
| 23 |
<field name='startTime' type='SFTime' accessType='inputOutput'
appinfo='exposed TimeSensor field for animation'/> |
| 24 |
<field name='stopTime' type='SFTime' accessType='inputOutput'
appinfo='exposed TimeSensor field for animation'/> |
| 25 | </ExternProtoDeclare> |
| 26 | <ProtoDeclare name='Chopper'> |
| 27 | <ProtoInterface> |
| 28 | <field name='rotorSpeed' type='SFTime' value='1' accessType='initializeOnly'/> |
| 29 | </ProtoInterface> |
| 30 | <ProtoBody> |
| 31 | <Group> |
| 32 |
<!-- ROUTE information for Touch node:
[from touchTime to RotorScript.startOrStopEngine
]
-->
<TouchSensor DEF='Touch' description='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='Rotor' DEF='Top'> |
| 35 | <fieldValue name='stopTime' value='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='rate' protoField='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='startOrStopEngine' type='SFTime' accessType='inputOnly'/> |
| 47 | <field name='startEngine' type='SFTime' accessType='outputOnly'/> |
| 48 | <field name='stopEngine' type='SFTime' accessType='outputOnly'/> |
| 49 | <field name='engineStarted' type='SFBool' value='false' accessType='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 16' position='0 0 5'/> |
| 59 | <Group> |
| 60 | <ProtoInstance name='Chopper' DEF='MikesChopper'/> |
| 61 | </Group> |
| 62 | </Scene> |
| 63 | </X3D> |
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 |
RotorScript
Script startOrStopEngine SFTime |
then
|
RotorScript
Script startEngine SFTime |
Top
ProtoInstance startTime SFTime |
||
|
then
|
RotorScript
Script stopEngine SFTime |
Top
ProtoInstance stopTime SFTime |
||||
|
MikesChopper
ProtoInstance Chopper |
No direct ROUTE connection found for events to/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. |
|
Top
ProtoInstance Rotor |
No direct ROUTE connection found for events to/from this node. This ProtoInstance contains SFNode/MFNode fieldValue declaration with direct access to other nodes, and thus has potential to produce run-time animation. |
<!--
Color-coding 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>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->