<?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='DEF_USE_AnimationExample.x3d' name='title'/>
    <meta content='Illustrate how USE nodes implement copy by reference, resulting in immediate changes when original DEF node is modified. A single MasterMaterial node is animated, and changes in the parent MasterAppearance are reflected throughout the scene graph.' name='description'/>
    <meta content='Don Brutzman' name='creator'/>
    <meta content='1 September 2024' name='modified'/>
    <meta content='DEF_USE_AnimationExampleScreenshot.png' name='Image'/>
    <meta content='X3D Specification Mantis Issue https://www.web3d.org/member-only/mantis/view.php?id=690' name='TODO'/>
    <meta content='Wikipedia: Evaluation strategy, pass by sharing https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing' name='reference'/>
    <meta content='X3D 4.0 Architecture, ISO/IEC 19775-1:2023, clause 4 Concepts, 4.4.3 DEF/USE semantics' name='specificationSection'/>
    <meta content='https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-IS.proof/Part01/concepts.html#DEF_USE_Semantics' name='specificationUrl'/>
    <meta content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter02GeometryPrimitives/GeometryPrimitiveNodes.x3d' name='reference'/>
    <meta content='https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/Animation/DEF_USE_AnimationExample.x3d' name='identifier'/>
    <meta content='Altova XMLSpy https://www.altova.com/xmlspy-xml-editor' name='generator'/>
    <meta content='XMLSpyPrettyPrintSpacingTextViewSettings.png' name='reference'/>
    <meta content='X3D-Edit 4.0 https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='DEF_USE_AnimationExample.x3d'/>
    <Background skyColor='0.6 0.8 0.8'/>
    <Viewpoint DEF='EntryView' description='DEF - USE Animation Example' position='0 0 13'/>
    <!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip -->
    <TouchSensor DEF='TopLevelTouchSensor' description='select and hold to run animation'/>
    <Group>
      <Shape DEF='TransparentSelectableBox'>
        <Box size='16 8 .001'/>
        <Appearance>
          <Material transparency='1'/>
        </Appearance>
      </Shape>
      <Transform DEF='HighererRowTransform' translation='0 1.5 0'>
        <Transform translation='-5 0 0'>
          <Shape>
            <Box DEF='DefaultBox'/>
            <Appearance DEF='MasterAppearance'>
              <Material DEF='MasterMaterial' diffuseColor='0.4 0.4 0.4'/>
            </Appearance>
          </Shape>
          <Transform translation='0 1.6 0'>
            <Shape DEF='SmallDEFText'>
              <Text string='"DEF"'>
                <FontStyle DEF='SmallFontStyle' justify='"MIDDLE" "MIDDLE"' size='0.5'/>
              </Text>
              <Appearance DEF='TextAppearance'>
                <Material diffuseColor='1 1 1'/>
              </Appearance>
            </Shape>
          </Transform>
        </Transform>
        <Transform translation='-2.5 0 0'>
          <Shape>
            <Cone DEF='DefaultCone'/>
            <Appearance USE='MasterAppearance'/>
          </Shape>
          <Transform translation='0 1.6 0'>
            <Shape DEF='SmallUSEText'>
              <Text string='"USE"'>
                <FontStyle USE='SmallFontStyle'/>
              </Text>
              <Appearance USE='TextAppearance'/>
            </Shape>
          </Transform>
        </Transform>
        <Transform>
          <Shape>
            <Cylinder DEF='DefaultCylinder'/>
            <Appearance USE='MasterAppearance'/>
          </Shape>
          <Transform translation='0 1.6 0'>
            <Shape USE='SmallUSEText'/>
          </Transform>
        </Transform>
        <Transform translation='2.5 0 0'>
          <Shape>
            <Sphere DEF='DefaultSphere'/>
            <Appearance USE='MasterAppearance'/>
          </Shape>
          <Transform translation='0 1.6 0'>
            <Shape USE='SmallUSEText'/>
          </Transform>
        </Transform>
        <Transform translation='4 0 0'>
          <Shape>
            <Text DEF='DefaultText' string='"hello" "X3D!"'>
              <FontStyle DEF='DefaultFontStyle'/>
            </Text>
            <Appearance USE='MasterAppearance'/>
          </Shape>
          <Transform translation='1.2 1.6 0'>
            <Shape USE='SmallUSEText'/>
          </Transform>
        </Transform>
      </Transform>
      <TimeSensor DEF='Clock' cycleInterval='8' enabled='false' loop='true'/>
      <ColorInterpolator DEF='ColorChanger' key='0 0.5 0.5 0.75 1.0' keyValue='1 1 1 1 0 0 0 1 0 0 0 1 1 1 1'/>
      <ROUTE fromField='isActive' fromNode='TopLevelTouchSensor' toField='enabled' toNode='Clock'/>
      <ROUTE fromField='fraction_changed' fromNode='Clock' toField='set_fraction' toNode='ColorChanger'/>
      <ROUTE fromField='value_changed' fromNode='ColorChanger' toField='diffuseColor' toNode='MasterMaterial'/>
      <Transform DEF='LowerRowTransform' translation='0 -2 0'>
        <Shape>
          <Text DEF='UserMessage' string='"ColorInterpolator modifies one Material" "in a single DEF=MasterAppearance node," "other USE nodes apply those values." "" "To animate, select and hold" "using your pointing device."'>
            <FontStyle DEF='MessageFontStyle' justify='"MIDDLE" "MIDDLE"' size='0.6' style='BOLD'/>
          </Text>
          <Appearance>
            <Material diffuseColor='1 1 1'/>
          </Appearance>
        </Shape>
      </Transform>
    </Group>
  </Scene>
</X3D>