<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<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 ' >
<head>
<meta name='titlecontent='Figure30_4ScriptSpiralingBallTrace.x3d'/>
<meta name='creatorcontent='Figure 30.4, The VRML 2.0 Sourcebook, Copyright [1997] By Andrea L. Ames, David R. Nadeau, and John L. Moreland'/>
<meta name='referencecontent=' http://www.wiley.com/legacy/compbooks/vrml2sbk/ch30/30fig04.htm '/>
<meta name='translatorcontent='Don Brutzman'/>
<meta name='createdcontent='2 September 2000'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='descriptioncontent='A spiraling red sphere and a custom interpolation script.'/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter30Scripts/Figure30_4ScriptSpiralingBallTrace.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BallTransform, Clock, Debug, Message, Mover

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2, Viewpoint_3
-->
<Scene>
<WorldInfo title='Figure30_4ScriptSpiralingBallTrace.x3d'/>
<Viewpoint description='spiraling ballorientation='1 0 0 -0.3position='0 3 8'/>
<Viewpoint description='view from aboveorientation='1 0 0 -1.57position='0 6 0'/>
<Viewpoint description='side vieworientation='0 1 0 1.57position='6 1 0'/>
<!-- Background nodes are usually best placed at the top of the scene since they have global effect and are bindable nodes. -->
<Background groundAngle='1.309 1.570796groundColor='0 0.1 0.3 0.3 0.3 0.6 0.4 0.4 0.6skyAngle='1.309 1.571skyColor='1 0 0.8 0.5 0 0.8 0 0 0.8'/>
<Group>
<Transform translation='0 -0.005 0'>
<Shape>
<Box size='2 0.01 4'/>
<Appearance>
<Material diffuseColor='0.7 0.7 0.7'/>
</Appearance>
</Shape>
</Transform>
<Transform translation='0 1.1 0'>
<!-- ROUTE information for BallTransform node:  [from Mover.value_changed to set_translation ] -->
<Transform DEF='BallTransform'>
<Shape>
<Appearance>
<Material diffuseColor='1 0.3 0.3'/>
</Appearance>
<Sphere radius='0.1'/>
</Shape>
</Transform>
</Transform>
<!-- ROUTE information for Clock node:  [from fraction_changed to Mover.set_fraction ] [from fraction_changed to Debug.set_float ] -->
<TimeSensor DEF='ClockcycleInterval='10loop='true'/>

<field name='set_fractiontype='SFFloataccessType='inputOnly'/>
<field name='value_changedtype='SFVec3faccessType='outputOnly'/>
<field name='radiustype='SFFloatvalue='1accessType='initializeOnly'/>
<field name='turnstype='SFFloatvalue='4accessType='initializeOnly'/>
<![CDATA[
        
ecmascript:

function set_fraction ( fraction, eventTime ) {
	value_changed[0] = radius * Math.sin( turns * fraction * 6.28 ); // x
	value_changed[1] = radius * Math.cos( turns * fraction * 6.28 ); // y
	value_changed[2] = turns * (fraction - 0.5);                     // z
}

      
]]>
</Script>
<!-- ROUTE information for Debug node:  [from Clock.fraction_changed to set_float ] [from string_changed to Message.set_string ] -->
<Script DEF='Debug'>
<field name='labeltype='SFStringvalue='fractionaccessType='initializeOnly'/>
<field name='set_floattype='SFFloataccessType='inputOnly'/>
<field name='string_changedtype='MFStringaccessType='outputOnly'/>
<![CDATA[
        
ecmascript:

function initalize( )
{
	string_changed[0] = label + ':';
}
function set_float( value, timestamp )
{
	string_changed[0] = label + ': ' + Math.round (value * 100) / 100;
}

      
]]>
</Script>
<Transform translation='0 0.5 0'>
<Billboard axisOfRotation='0 0 0'>
<Shape>
<!-- ROUTE information for Message node:  [from Debug.string_changed to set_string ] -->
<Text DEF='Message'>
<FontStyle justify='"MIDDLE" "MIDDLE"size='0.3'/>
</Text>
<Appearance>
<Material diffuseColor='0 0 0emissiveColor='0 1 1'/>
</Appearance>
</Shape>
</Billboard>
</Transform>
<Transform rotation='1 0 0 1.57079translation='0 1.1 0'>
<Shape>
<Appearance>
<Material diffuseColor='0.5 0 0transparency='0.7'/>
</Appearance>
<Cylinder height='4'/>
</Shape>
</Transform>
</Group>
< ROUTE  fromNode=' Clock' fromField='fraction_changed' toNode=' Mover' toField='set_fraction'/>
< ROUTE  fromNode=' Mover' fromField='value_changed' toNode=' BallTransform' toField='set_translation'/>
< ROUTE  fromNode=' Clock' fromField='fraction_changed' toNode=' Debug' toField='set_float'/>
< ROUTE  fromNode=' Debug' fromField='string_changed' toNode=' Message' toField='set_string'/>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BallTransform, Clock, Debug, Message, Mover

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2, Viewpoint_3
-->

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

ROUTE
event to
(1)
Mover
Script
set_fraction
SFFloat

 
 
then
Mover
Script
value_changed
SFVec3f

ROUTE
event to
(2)
BallTransform
Transform
set_translation
SFVec3f
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
Debug
Script
set_float
SFFloat

 
 
then
Debug
Script
string_changed
MFString

ROUTE
event to
(2)
Message
Text
set_string
MFString



-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter30Scripts/Figure30_4ScriptSpiralingBallTraceIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter30Scripts/Figure30_4ScriptSpiralingBallTrace.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. -->