<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.3.xsd '>
<head>
<meta name='titlecontent='BackgroundColorArrayAnimation.x3d'/>
<meta name='descriptioncontent='Design pattern demonstrating type conversion from single SFColor value (sent from a ColorInterpolator node) to an MFColor array (in a Background node).'/>
<meta name='creatorcontent='Don Brutzman and MV3204 class'/>
<meta name='createdcontent='8 September 2009'/>
<meta name='modifiedcontent='8 September 2009'/>
<meta name='TODOcontent='also create a new prototype ColorArrayInterpolator in Chapter 14'/>
<meta name='referencecontent=' http://openclipart.org/media/tags/smiley '/>
<meta name='identifiercontent=' http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/BackgroundColorArrayAnimation.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<!-- ROUTE information for Clock node:  [from fraction_changed to ColorChanger.set_fraction ] -->
<TimeSensor DEF='ClockcycleInterval='10loop='true'/>
<!-- ROUTE information for ColorChanger node:  [from Clock.fraction_changed to set_fraction ] [from value_changed to ColorTypeConversionScript.colorValueInput ] -->
<ColorInterpolator DEF='ColorChangerkey='0 0.333333 0.666667 1keyValue='1 0 0 0 1 0 0 0 1 1 0 0'/>
<ROUTE fromNode='ClockfromField='fraction_changedtoNode='ColorChangertoField='set_fraction'/>
<!-- ROUTE information for ColorTypeConversionScript node:  [from ColorChanger.value_changed to colorValueInput ] [from colorArrayOutput to SingleColorBackground.skyColor ] -->
<Script DEF='ColorTypeConversionScript'>
<field name='colorValueInputtype='SFColoraccessType='inputOnly'/>
<field name='colorArrayOutputtype='MFColoraccessType='outputOnly'/>
<![CDATA[
      
ecmascript:

function colorValueInput (inputValue) // input event received for inputOnly field
{
   colorArrayOutput[0] =  inputValue; // perform type conversion, result is sent as output event
}

    
]]>
</Script>
<ROUTE fromNode='ColorChangerfromField='value_changedtoNode='ColorTypeConversionScripttoField='colorValueInput'/>
<!-- ROUTE information for SingleColorBackground node:  [from ColorTypeConversionScript.colorArrayOutput to skyColor ] -->
<Background DEF='SingleColorBackground'/>
<ROUTE fromNode='ColorTypeConversionScriptfromField='colorArrayOutputtoNode='SingleColorBackgroundtoField='skyColor'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : Clock, ColorChanger, ColorTypeConversionScript, SingleColorBackground
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->