<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://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='https://www.web3d.org/specifications/x3d-3.3.xsd'>
  <head>
    <meta content='ScalarInterpolatorExample.x3d' name='title'/>
    <meta content='Demonstrate use of ScalarInterpolator to animate transparency.' name='description'/>
    <meta content='Don Brutzman' name='creator'/>
    <meta content='28 January 2008' name='created'/>
    <meta content='25 August 2023' name='modified'/>
    <meta content='https://X3dGraphics.com' name='reference'/>
    <meta content='https://www.web3d.org/x3d/content/examples/X3dResources.html' name='reference'/>
    <meta content='Copyright Don Brutzman and Leonard Daly 2007' name='rights'/>
    <meta content='X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com' name='subject'/>
    <meta content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/ScalarInterpolatorExample.x3d' name='identifier'/>
    <meta content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='ScalarInterpolatorExample.x3d'/>
    <Transform translation='0 -1 0'>
      <Shape>
        <Sphere radius='2'/>
        <Appearance>
          <Material DEF='SphereMaterial' diffuseColor='0.941176 0.027451 0'/>
        </Appearance>
      </Shape>
    </Transform>
    <!-- note that final value equals first value in keyValue array in order to support smooth looping -->
    <ScalarInterpolator DEF='TransparencyAnimator' key='0 0.5 1' keyValue='0 1 0'/>
    <TimeSensor DEF='AnimationClock' cycleInterval='8' loop='true'/>
    <ROUTE fromField='fraction_changed' fromNode='AnimationClock' toField='set_fraction' toNode='TransparencyAnimator'/>
    <ROUTE fromField='value_changed' fromNode='TransparencyAnimator' toField='transparency' toNode='SphereMaterial'/>
    <!-- notice that Text appears later in scene although it is located above Sphere -->
    <Transform translation='0 1.5 0'>
      <Shape>
        <Text string='"Animating transparency" "using ScalarInterpolator"'>
          <FontStyle justify='"MIDDLE" "MIDDLE"'/>
        </Text>
        <Appearance DEF='TextAppearance'>
          <Material diffuseColor='0 0.7 0.7'/>
        </Appearance>
      </Shape>
    </Transform>
  </Scene>
</X3D>