<?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 content='ShapeChildRoutingExample.x3d' name='title'/>
    <meta content='Don Brutzman' name='creator'/>
    <meta content='7 November 2000' name='created'/>
    <meta content='20 October 2019' name='modified'/>
    <meta content='Show routing of a node as an input to a Script - success shows a Sphere, failure shows a Box.' name='description'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Basic/development/ShapeChildRoutingExample.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='ShapeChildRoutingExample.x3d'/>
    <Transform>
      <Shape DEF='A_SHAPE'>
        <Box/>
        <Appearance>
          <Material diffuseColor='0.8 0.4 0'/>
        </Appearance>
      </Shape>
      <Script DEF='A_SCRIPT' directOutput='true'>
        <field accessType='outputOnly' name='geometryResult' type='SFNode'/>
        <!-- Scripting code is wrapped in a CDATA section to preserve all characters without normalization -->
        <![CDATA[
ecmascript:

function initialize ()
{
    sphereResult   = Browser.createVrmlFromString ('Sphere { }');
    geometryResult = sphereResult [0]; // type casting MF -> SFNode
}
]]>
      </Script>
    </Transform>
    <ROUTE fromField='geometryResult' fromNode='A_SCRIPT' toField='geometry' toNode='A_SHAPE'/>
  </Scene>
</X3D>