<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "https://www.web3d.org/specifications/x3d-4.0.dtd">
<X3D profile='Immersive' version='4.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.0.xsd'>
  <head>
    <meta content='TwoLeggedTablePrototype.x3d' name='title'/>
    <meta content='X3D encodings example: defining a Prototype, demonstration of IS/connect definitions.' name='description'/>
    <meta content='Don Brutzman and Joe Williams' name='creator'/>
    <meta content='1 June 2002' name='created'/>
    <meta content='28 September 2025' name='modified'/>
    <meta content='X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, Annex C.4 Prototype example' name='specificationSection'/>
    <meta content='https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19776-1v4.0-CD/Part01/examples.html#PrototypeExample' name='specificationUrl'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/TwoLeggedTablePrototype.x3d' name='identifier'/>
    <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='TwoLeggedTablePrototype.x3d'/>
    <NavigationInfo type='"EXAMINE" "ANY"'/>
    <!-- Use the Examine viewer -->
    <ProtoDeclare name='TwoColorTable'>
      <ProtoInterface>
        <field accessType='initializeOnly' name='legColor' type='SFColor' value='.8 .4 .7'/>
        <field accessType='initializeOnly' name='topColor' type='SFColor' value='.6 .6 .1'/>
      </ProtoInterface>
      <ProtoBody>
        <Transform>
          <Transform translation='0.0 0.6 0.0'>
            <!-- table top -->
            <Shape>
              <Appearance>
                <Material DEF='TableTopMaterial'>
                  <IS>
                    <connect nodeField='diffuseColor' protoField='topColor'/>
                  </IS>
                </Material>
              </Appearance>
              <Box size='1.2 0.2 1.2'/>
            </Shape>
          </Transform>
          <Transform translation='-0.5 0.0 -0.5'>
            <!-- first table leg -->
            <Shape DEF='Leg'>
              <Appearance>
                <Material DEF='LegMaterial' diffuseColor='1.0 0.0 0.0'>
                  <IS>
                    <connect nodeField='diffuseColor' protoField='legColor'/>
                  </IS>
                </Material>
              </Appearance>
              <Cylinder height='1.0' radius='0.1'/>
            </Shape>
          </Transform>
          <Transform translation='0.5 0.0 -0.5'>
            <!-- another table leg -->
            <Shape USE='Leg'/>
          </Transform>
          <Transform translation='-0.5 0.0 0.5'>
            <Shape USE='Leg'/>
            <!-- another table leg -->
          </Transform>
          <Transform translation='0.5 0.0 0.5'>
            <Shape USE='Leg'/>
            <!-- another table leg -->
          </Transform>
          <!-- End of root Transform's children -->
        </Transform>
        <!-- End of root Transform -->
      </ProtoBody>
    </ProtoDeclare>
    <!-- End of prototype -->
    <!-- The prototype is now defined. Although it contains a number of nodes, only the legColor and topColor fields are public. Instead of using the default legColor and topColor, this instance of the table has red legs and a green top: -->
    <!-- show both DEF ProtoInstance and USE ProtoInstance -->
    <Group DEF='TwoTables'>
      <Transform translation='-1 0 0'>
        <ProtoInstance DEF='TCT' name='TwoColorTable'>
          <fieldValue name='legColor' value='1 0 0'/>
          <fieldValue name='topColor' value='0 1 0'/>
        </ProtoInstance>
      </Transform>
      <Transform translation='1 0 0'>
        <ProtoInstance USE='TCT' name='NewProtoInstance'/>
      </Transform>
    </Group>
  </Scene>
</X3D>