| 1 | 
            <?xml version="1.0" encoding="UTF-8"?>
          | 
      
| 2 | 
            <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
          | 
      
| 3 | <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'> | 
| 4 | <head> | 
| 5 | <meta name='title' content=' ParallelepipedPrototype.x3d '/> | 
| 6 | <meta name='description' content='Reusable prototype for creating a Parallelepiped, which is a 3D figure formed by six parallelograms; also sometimes referred to as a rhomboid.'/> | 
| 7 | <meta name='creator' content='Don Brutzman'/> | 
| 8 | <meta name='created' content='25 November 2011'/> | 
| 9 | <meta name='modified' content='7 December 2024'/> | 
| 10 | <meta name='reference' content=' ParallelepipedExamples.x3d '/> | 
| 11 | 
                         
                                  <meta name='Image' content='ParallelepipedVertexIndices.png' />
 | 
                  
| 12 | <meta name='drawing' content='GeometricShapes.vsdx'/> | 
| 13 | <meta name='reference' content='https://en.wikipedia.org/wiki/Parallelepiped'/> | 
| 14 | 
                         
                                  <meta name='reference' content='
                           http://upload.wikimedia.org/wikipedia/commons/f/f6/Parallelepiped.svg
                        ' | 
                  
| 15 | 
                         
                                  <meta name='reference' content='http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Parallelepiped.svg/500px-Parallelepiped.svg.png' | 
                  
| 16 | <meta name='subject' content='parallelepiped rhomboid geometry polyhedron'/> | 
| 17 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedPrototype.x3d '/> | 
| 18 | <meta name='reference' content=' https://www.web3d.org/x3d/content/examples/X3dResources.html '/> | 
| 19 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> | 
| 20 | <meta name='license' content='../license.html'/> | 
| 21 | </head> | 
| 22 | <Scene> | 
| 23 | <WorldInfo title='ParallelepipedPrototype.x3d'/> | 
| 24 | <ProtoDeclare name='Parallelepiped' appinfo='Parallelepiped is a 3D figure formed by six parallelograms; also sometimes referred to as a rhomboid'> | 
| 25 | <ProtoInterface> | 
| 26 | <field name='point' type='MFVec3f' value='0 1 0 1 1 0 1 1 1 0 1 1 0 0 0 1 0 0 1 0 1 0 0 1' accessType='inputOutput'/> | 
| 27 | <field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/> | 
| 28 | <field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/> | 
| 29 | <field name='colorIndex' type='MFInt32' accessType='initializeOnly'/> | 
| 30 | <field name='normalIndex' type='MFInt32' accessType='initializeOnly'/> | 
| 31 | <field name='texCoordIndex' type='MFInt32' accessType='initializeOnly'/> | 
| 32 | <field name='colorNode' type='SFNode' accessType='inputOutput'> | 
| 33 | <Color DEF='DefaultColor'/> | 
| 34 | </field> | 
| 35 | <field name='normalNode' type='SFNode' accessType='inputOutput'> | 
| 36 | <Normal DEF='DefaultNormal'/> | 
| 37 | </field> | 
| 38 | <field name='texCoordNode' type='SFNode' accessType='inputOutput'> | 
| 39 | <TextureCoordinate DEF='DefaultTextureCoordinate'/> | 
| 40 | </field> | 
| 41 | </ProtoInterface> | 
| 42 | <ProtoBody> | 
| 43 | <!-- First node determines node type of this prototype --> | 
| 44 | <IndexedFaceSet DEF='IFS' convex='false' solid='false' coordIndex='0 3 2 1 -1 4 5 6 7 -1 0 1 5 4 -1 1 2 6 5 -1 2 3 7 6 -1 3 0 4 7 -1'> | 
| 45 | <IS> | 
| 46 | <connect nodeField='colorPerVertex' protoField='colorPerVertex'/> | 
| 47 | <connect nodeField='normalPerVertex' protoField='normalPerVertex'/> | 
| 48 | <connect nodeField='colorIndex' protoField='colorIndex'/> | 
| 49 | <connect nodeField='normalIndex' protoField='normalIndex'/> | 
| 50 | <connect nodeField='texCoordIndex' protoField='texCoordIndex'/> | 
| 51 | <connect nodeField='colorNode' protoField='colorNode'/> | 
| 52 | <connect nodeField='normalNode' protoField='normalNode'/> | 
| 53 | <connect nodeField='texCoordNode' protoField='texCoordNode'/> | 
| 54 | </IS> | 
| 55 | <Coordinate> | 
| 56 | <IS> | 
| 57 | <connect nodeField='point' protoField='point'/> | 
| 58 | </IS> | 
| 59 | </Coordinate> | 
| 60 | </IndexedFaceSet> | 
| 61 | <!-- This embedded Script provides the X3D author with additional visibility and control over prototype inputs and outputs --> | 
| 62 | <Script DEF='ParallelepipedScript'> | 
| 63 | <field name='point' type='MFVec3f' accessType='inputOutput'/> | 
| 64 | <IS> | 
| 65 | <connect nodeField='point' protoField='point'/> | 
| 66 | </IS> | 
                                          
                                             <![CDATA[
                                          
                                          
          
ecmascript:
function initialize ()
{
    checkCoordinatePoints ();
}
function checkCoordinatePoints ()
{
    // A parallelepiped has three sets of four parallel edges; the edges within each set are of equal length.
    // Quality assurance: check that lengths of corresponding sides match.
    
    edge01 = length2(point[0], point[1]); // top
    edge12 = length2(point[1], point[2]);
    edge23 = length2(point[2], point[3]);
    edge30 = length2(point[3], point[0]);
    edge45 = length2(point[4], point[5]); // bottom
    edge56 = length2(point[5], point[6]);
    edge67 = length2(point[6], point[7]);
    edge74 = length2(point[7], point[4]);
    edge04 = length2(point[0], point[4]); // sides
    edge15 = length2(point[1], point[5]);
    edge26 = length2(point[2], point[6]);
    edge37 = length2(point[3], point[7]);
    
    epsilon = edge01 * 0.001;
    
    if      ((Math.abs(edge01 - edge23) > epsilon) ||
             (Math.abs(edge23 - edge67) > epsilon) ||
             (Math.abs(edge67 - edge45) > epsilon) ||
             (Math.abs(edge45 - edge01) > epsilon))
         Browser.println ('Warning, mismatched parallelepiped sides 02/33/45/67');
    else if ((Math.abs(edge30 - edge12) > epsilon) ||
             (Math.abs(edge12 - edge56) > epsilon) ||
             (Math.abs(edge56 - edge74) > epsilon) ||
             (Math.abs(edge74 - edge30) > epsilon))
         Browser.println ('Warning, mismatched parallelepiped sides 30/12/56/74');
    else if ((Math.abs(edge04 - edge15) > epsilon) ||
             (Math.abs(edge15 - edge26) > epsilon) ||
             (Math.abs(edge26 - edge37) > epsilon) ||
             (Math.abs(edge37 - edge04) > epsilon))
         Browser.println ('Warning, mismatched parallelepiped sides 04/15/26/37');
}
function length2 (pointA, pointB)
{    
    return Math.sqrt((pointA.x - pointB.x)*(pointA.x - pointB.x) +
                     (pointA.y - pointB.y)*(pointA.y - pointB.y) +
                     (pointA.z - pointB.z)*(pointA.z - pointB.z));
}
function set_point (eventValue)
{
   // input eventValue received for inputOutput field
    point = eventValue;
    checkCoordinatePoints ();
}
        
                                          
                                             ]]>
                                          
                                        | 
                                    |
| 68 | </Script> | 
| 69 | </ProtoBody> | 
| 70 | </ProtoDeclare> | 
| 71 | <!-- ================================================================================ --> | 
| 72 | <Background skyColor='0.905882 1 0.858824'/> | 
| 73 | <Anchor description='Open ParallelepipedExamples scene' url=' "ParallelepipedExamples.x3d" "https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedExamples.x3d" "ParallelepipedExamples.wrl" "https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedExamples.wrl" '> | 
| 74 | <Shape> | 
| 75 | <Text string='"This scene defines a" "Parallelepiped prototype" "" "Select this text to open" "ParallelepipedExamples scene"'> | 
| 76 | <FontStyle justify='"MIDDLE" "MIDDLE"'/> | 
| 77 | </Text> | 
| 78 | <Appearance DEF='BlueAppearance'> | 
| 79 | <Material diffuseColor='0 0.698039 1'/> | 
| 80 | </Appearance> | 
| 81 | </Shape> | 
| 82 | <Shape DEF='TransparentBox'> | 
| 83 | <Box size='11 5 0.1'/> | 
| 84 | <Appearance> | 
| 85 | <Material transparency='1'/> | 
| 86 | </Appearance> | 
| 87 | </Shape> | 
| 88 | </Anchor> | 
| 89 | </Scene> | 
| 90 | </X3D> | 
Event Graph ROUTE Table with 0 ROUTE connections total, showing X3D event-model relationships for this scene.
Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.
| 
               ParallelepipedScript
                Script  | 
            No direct ROUTE connection found for events to/from this node. This Script has no direct access to other nodes.  | 
         
| line 73
                Anchor  | 
            
               description='Open ParallelepipedExamples scene'  User-interaction hint for this node.  | 
         
         <!--
Color-coding legend: X3D terminology 
<X3dNode
          DEF='idName' field='value'/> 
 matches XML terminology 
<XmlElement
          DEF='idName' attribute='value'/> 
(Light-blue background: event-based behavior node or statement)
(Grey background inside box: inserted documentation)
(Magenta background: X3D Extensibility)
   
<ProtoDeclare name='ProtoName'>
	<field
         name='fieldName'/> </ProtoDeclare>
 -->
      
         
            
         
         <!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->