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='title' content='ElevationGridSimpleWaveAnimation.x3d'/> |
6 | <meta name='description' content='Simple Javascript animation of ElevationGrid'/> |
7 | <meta name='creator' content='Don Brutzman'/> |
8 | <meta name='created' content='2 December 2012'/> |
9 | <meta name='modified' content='20 October 2019'/> |
10 | <meta name='Image' content='ElevationGridSimpleWaveAnimation.png'/> |
11 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ElevationGridSimpleWaveAnimation.x3d'/> |
12 | <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/> |
13 | <meta name='license' content='../license.html'/> |
14 | </head> |
15 | <Scene> |
16 | <WorldInfo title='ElevationGridSimpleWaveAnimation.x3d'/> |
17 | <Viewpoint description='Wave view' orientation='1 0 0 -0.358771' position='0 3 8'/> |
18 | <Background groundColor='1 1 1' skyColor='1 1 1'/> |
19 | <!-- Shift zero-based ElevationGrid to left, centering it --> |
20 | <Transform translation='-4 0 0'> |
21 | <Shape> |
22 |
<!-- ROUTE information for GridSurface node:
[from WaveGenerationScript.gridOutput to set_height
]
-->
<ElevationGrid DEF='GridSurface' solid='false' xDimension='9' zDimension='3' height='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'/> |
23 | <Appearance> |
24 | <Material diffuseColor='0 0.5 1'/> |
25 | </Appearance> |
26 | </Shape> |
27 | </Transform> |
28 |
<!-- ROUTE information for Clock node:
[from fraction_changed to WaveGenerationScript.newInputValue
]
-->
<TimeSensor DEF='Clock' cycleInterval='5' loop='true'/> |
29 |
<!-- ROUTE information for WaveGenerationScript node:
[from Clock.fraction_changed to newInputValue
]
[from gridOutput to GridSurface.set_height
]
-->
<Script DEF='WaveGenerationScript'> |
30 |
<field name='newInputValue' type='SFFloat' accessType='inputOnly'
appinfo='provide value and trigger new computation'/> |
31 |
<field name='gridOutput' type='MFFloat' accessType='outputOnly'
appinfo='provide values to ElevationGrid'/> |
32 |
<field name='waveStep' type='SFTime' value='0.1' accessType='initializeOnly'
appinfo='wave variation'/> |
<![CDATA[
ecmascript: function newInputValue (eventValue) { fraction = eventValue; // connected by ROUTE, receives values from TimeSensor Clock fraction_changed value0 = 0.2 * Math.sin (2 * Math.PI * (fraction - 4*waveStep)); value1 = 0.2 * Math.sin (2 * Math.PI * (fraction - 3*waveStep)); value2 = 0.2 * Math.sin (2 * Math.PI * (fraction - 2*waveStep)); value3 = 0.2 * Math.sin (2 * Math.PI * (fraction - waveStep)); value4 = 0.2 * Math.sin (2 * Math.PI * (fraction )); value5 = 0.2 * Math.sin (2 * Math.PI * (fraction + waveStep)); value6 = 0.2 * Math.sin (2 * Math.PI * (fraction + 2*waveStep)); value7 = 0.2 * Math.sin (2 * Math.PI * (fraction + 3*waveStep)); value8 = 0.2 * Math.sin (2 * Math.PI * (fraction + 4*waveStep)); // setting the gridOutput value creates an output event that is connected via ROUTE to the ElevationGrid set_height field. // note that types match (MFFloat) and accessTypes also match (output_only connects to inputOnly). gridOutput = new MFFloat ( value0, value1, value2, value3, value4, value5, value6, value7, value8, value0, value1, value2, value3, value4, value5, value6, value7, value8, value0, value1, value2, value3, value4, value5, value6, value7, value8 ); }
]]>
|
|
34 | </Script> |
35 | < ROUTE fromNode='Clock' fromField='fraction_changed' toNode='WaveGenerationScript' toField='newInputValue'/> |
36 | < ROUTE fromNode='WaveGenerationScript' fromField='gridOutput' toNode='GridSurface' toField='set_height'/> |
37 | </Scene> |
38 | </X3D> |
Event Graph ROUTE Table entries with 2 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.
Clock
TimeSensor fraction_changed SFFloat |
WaveGenerationScript
Script newInputValue SFFloat |
then
|
WaveGenerationScript
Script gridOutput MFFloat |
GridSurface
ElevationGrid set_height MFFloat |
<!--
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)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->