{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"ParallelepipedPrototype.x3d"
          },
          {
            "@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."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"25 November 2011"
          },
          {
            "@name":"modified",
            "@content":"7 December 2024"
          },
          {
            "@name":"reference",
            "@content":"ParallelepipedExamples.x3d"
          },
          {
            "@name":"Image",
            "@content":"ParallelepipedVertexIndices.png"
          },
          {
            "@name":"drawing",
            "@content":"GeometricShapes.vsdx"
          },
          {
            "@name":"reference",
            "@content":"https://en.wikipedia.org/wiki/Parallelepiped"
          },
          {
            "@name":"reference",
            "@content":"http://upload.wikimedia.org/wikipedia/commons/f/f6/Parallelepiped.svg"
          },
          {
            "@name":"reference",
            "@content":"http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Parallelepiped.svg/500px-Parallelepiped.svg.png"
          },
          {
            "@name":"subject",
            "@content":"parallelepiped rhomboid geometry polyhedron"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedPrototype.x3d"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/content/examples/X3dResources.html"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"16 April 2026"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "WorldInfo":
            {
              "@title":"ParallelepipedPrototype.x3d"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"Parallelepiped",
              "@appinfo":"Parallelepiped is a 3D figure formed by six parallelograms; also sometimes referred to as a rhomboid",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"point",
                      "@accessType":"inputOutput",
                      "@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]
                    },
                    {
                      "@name":"colorPerVertex",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"normalPerVertex",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"colorIndex",
                      "@accessType":"initializeOnly",
                      "@type":"MFInt32"
                    },
                    {
                      "@name":"normalIndex",
                      "@accessType":"initializeOnly",
                      "@type":"MFInt32"
                    },
                    {
                      "@name":"texCoordIndex",
                      "@accessType":"initializeOnly",
                      "@type":"MFInt32"
                    },
                    {
                      "@name":"colorNode",
                      "@accessType":"inputOutput",
                      "@type":"SFNode",
                      "-children":[
                        { "Color":
                          {
                            "@DEF":"DefaultColor"
                          }
                        }
                      ]
                    },
                    {
                      "@name":"normalNode",
                      "@accessType":"inputOutput",
                      "@type":"SFNode",
                      "-children":[
                        { "Normal":
                          {
                            "@DEF":"DefaultNormal"
                          }
                        }
                      ]
                    },
                    {
                      "@name":"texCoordNode",
                      "@accessType":"inputOutput",
                      "@type":"SFNode",
                      "-children":[
                        { "TextureCoordinate":
                          {
                            "@DEF":"DefaultTextureCoordinate"
                          }
                        }
                      ]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    {
                      "#comment":"First node determines node type of this prototype"
                    },
                    { "IndexedFaceSet":
                      {
                        "@DEF":"IFS",
                        "@convex":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],
                        "@solid":false,
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"colorPerVertex",
                                "@protoField":"colorPerVertex"
                              },
                              {
                                "@nodeField":"normalPerVertex",
                                "@protoField":"normalPerVertex"
                              },
                              {
                                "@nodeField":"colorIndex",
                                "@protoField":"colorIndex"
                              },
                              {
                                "@nodeField":"normalIndex",
                                "@protoField":"normalIndex"
                              },
                              {
                                "@nodeField":"texCoordIndex",
                                "@protoField":"texCoordIndex"
                              },
                              {
                                "@nodeField":"colorNode",
                                "@protoField":"colorNode"
                              },
                              {
                                "@nodeField":"normalNode",
                                "@protoField":"normalNode"
                              },
                              {
                                "@nodeField":"texCoordNode",
                                "@protoField":"texCoordNode"
                              }
                            ]
                        },
                        "-coord":
                          { "Coordinate":
                            {
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"point",
                                      "@protoField":"point"
                                    }
                                  ]
                              }
                            }
                          }
                      }
                    },
                    {
                      "#comment":"This embedded Script provides the X3D author with additional visibility and control over prototype inputs and outputs"
                    },
                    { "Script":
                      {
                        "@DEF":"ParallelepipedScript",
                        "field": [
                          {
                            "@name":"point",
                            "@accessType":"inputOutput",
                            "@type":"MFVec3f"
                          }
                        ],
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"point",
                                "@protoField":"point"
                              }
                            ]
                        },
                        "#sourceCode":[
"",
"",
"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 ();",
"}",
"",
""
]
                      }
                    }
                  ]
              }
            }
          },
          {
            "#comment":"================================================================================"
          },
          { "Background":
            {
              "@skyColor":[0.905882,1,0.858824]
            }
          },
          { "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"],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["This scene defines a","Parallelepiped prototype","Select this text to open","ParallelepipedExamples scene"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"]
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "@DEF":"BlueAppearance",
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0,0.698039,1]
                              }
                            }
                        }
                      }
                  }
                },
                { "Shape":
                  {
                    "@DEF":"TransparentBox",
                    "-geometry":
                      { "Box":
                        {
                          "@size":[11,5,0.1]
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@transparency":1
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          }
        ]
    }
  }
}