{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"4.0",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-4.0.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"ShuttlesAndPendulums.x3d"
          },
          {
            "@name":"description",
            "@content":"X3D encodings example: animation of shuttle and pendulum prototype nodes."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman and Joe Williams"
          },
          {
            "@name":"created",
            "@content":"1 June 2002"
          },
          {
            "@name":"modified",
            "@content":"28 September 2025"
          },
          {
            "@name":"specificationSection",
            "@content":"X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, Annex C.14 Shuttles and pendulums"
          },
          {
            "@name":"specificationUrl",
            "@content":"https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19776-1v4.0-CD/Part01/examples.html#ShuttlesAndPendulums"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ShuttlesAndPendulums.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"28 September 2025"
          },
          {
            "@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":"ShuttlesAndPendulums.x3d"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"Shuttle",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"rate",
                      "@accessType":"initializeOnly",
                      "@type":"SFTime",
                      "@value":1
                    },
                    {
                      "@name":"distance",
                      "@accessType":"initializeOnly",
                      "@type":"SFFloat",
                      "@value":1
                    },
                    {
                      "@name":"children",
                      "@accessType":"initializeOnly",
                      "@type":"MFNode",
                      "-children":[
                        {
                          "#comment":"initial value is empty node array"
                        }
                      ]
                    },
                    {
                      "@name":"startTime",
                      "@accessType":"inputOutput",
                      "@type":"SFTime",
                      "@value":0
                    },
                    {
                      "@name":"stopTime",
                      "@accessType":"inputOutput",
                      "@type":"SFTime",
                      "@value":0
                    },
                    {
                      "@name":"loop",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":true
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Transform":
                      {
                        "@DEF":"F",
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"children",
                                "@protoField":"children"
                              }
                            ]
                        }
                      }
                    },
                    {
                      "#comment":"after first node in ProtoDeclare, remainder of nodes do not render"
                    },
                    { "TimeSensor":
                      {
                        "@DEF":"T",
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"cycleInterval",
                                "@protoField":"rate"
                              },
                              {
                                "@nodeField":"startTime",
                                "@protoField":"startTime"
                              },
                              {
                                "@nodeField":"stopTime",
                                "@protoField":"stopTime"
                              },
                              {
                                "@nodeField":"loop",
                                "@protoField":"loop"
                              }
                            ]
                        }
                      }
                    },
                    { "Script":
                      {
                        "@DEF":"S",
                        "field": [
                          {
                            "@name":"distance",
                            "@accessType":"initializeOnly",
                            "@type":"SFFloat"
                          },
                          {
                            "@name":"position",
                            "@accessType":"outputOnly",
                            "@type":"MFVec3f"
                          }
                        ],
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"distance",
                                "@protoField":"distance"
                              }
                            ]
                        },
                        "#sourceCode":[
"",
"",
"ecmascript:",
"            function initialize () {     // constructor:setup interpolator",
"              pos1 = new SFVec3f(-distance, 0, 0);",
"              pos2 = new SFVec3f(distance, 0, 0);",
"              position = new MFVec3f(pos1, pos2, pos1);",
"            }",
"",
""
]
                      }
                    },
                    { "PositionInterpolator":
                      {
                        "@DEF":"I",
                        "@key":[0,0.5,1],
                        "@keyValue":[-1,0,0,1,0,0,-1,0,0]
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"fraction_changed",
                        "@fromNode":"T",
                        "@toField":"set_fraction",
                        "@toNode":"I"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"value_changed",
                        "@fromNode":"I",
                        "@toField":"translation",
                        "@toNode":"F"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"position",
                        "@fromNode":"S",
                        "@toField":"keyValue",
                        "@toNode":"I"
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoDeclare":
            {
              "@name":"Pendulum",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"rate",
                      "@accessType":"initializeOnly",
                      "@type":"SFTime",
                      "@value":1
                    },
                    {
                      "@name":"maxAngle",
                      "@accessType":"initializeOnly",
                      "@type":"SFFloat",
                      "@value":3.14159
                    },
                    {
                      "@name":"children",
                      "@accessType":"initializeOnly",
                      "@type":"MFNode",
                      "-children":[
                        {
                          "#comment":"initial value is empty node array"
                        }
                      ]
                    },
                    {
                      "@name":"startTime",
                      "@accessType":"inputOutput",
                      "@type":"SFTime",
                      "@value":0
                    },
                    {
                      "@name":"stopTime",
                      "@accessType":"inputOutput",
                      "@type":"SFTime",
                      "@value":0
                    },
                    {
                      "@name":"loop",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":true
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Transform":
                      {
                        "@DEF":"FF",
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"children",
                                "@protoField":"children"
                              }
                            ]
                        }
                      }
                    },
                    {
                      "#comment":"after first node in ProtoDeclare, remainder of nodes do not render"
                    },
                    { "TimeSensor":
                      {
                        "@DEF":"TT",
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"cycleInterval",
                                "@protoField":"rate"
                              },
                              {
                                "@nodeField":"startTime",
                                "@protoField":"startTime"
                              },
                              {
                                "@nodeField":"stopTime",
                                "@protoField":"stopTime"
                              },
                              {
                                "@nodeField":"loop",
                                "@protoField":"loop"
                              }
                            ]
                        }
                      }
                    },
                    { "Script":
                      {
                        "@DEF":"SS",
                        "field": [
                          {
                            "@name":"maxAngle",
                            "@accessType":"initializeOnly",
                            "@type":"SFFloat"
                          },
                          {
                            "@name":"rotation",
                            "@accessType":"outputOnly",
                            "@type":"MFRotation"
                          }
                        ],
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"maxAngle",
                                "@protoField":"maxAngle"
                              }
                            ]
                        },
                        "#sourceCode":[
"",
"",
"ecmascript:",
"            function initialize() {     // constructor: setup interpolator",
"              rot1 = new SFRotation(0, 0, 1, 0);",
"              rot2 = new SFRotation(0, 0, 1, maxAngle/2);",
"              rot3 = new SFRotation(0, 0, 1, maxAngle);",
"              rotation = new MFRotation(rot1, rot2, rot3, rot2, rot1);",
"            }",
"",
""
]
                      }
                    },
                    { "OrientationInterpolator":
                      {
                        "@DEF":"II",
                        "@key":[0,0.25,0.5,0.75,1],
                        "@keyValue":[0,0,1,0,0,0,1,1.57,0,0,1,3.14,0,0,1,1.57,0,0,1,0]
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"fraction_changed",
                        "@fromNode":"TT",
                        "@toField":"set_fraction",
                        "@toNode":"II"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"value_changed",
                        "@fromNode":"II",
                        "@toField":"rotation",
                        "@toNode":"FF"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"rotation",
                        "@fromNode":"SS",
                        "@toField":"keyValue",
                        "@toNode":"II"
                      }
                    }
                  ]
              }
            }
          },
          { "Transform":
            {
              "@translation":[-3,0,0],
              "-children":[
                { "ProtoInstance":
                  {
                    "@name":"Pendulum",
                    "fieldValue": [
                      {
                        "@name":"rate",
                        "@value":3
                      },
                      {
                        "@name":"maxAngle",
                        "@value":6.28
                      },
                      {
                        "@name":"children",
                        "-children":[
                          { "Shape":
                            {
                              "-geometry":
                                { "Cylinder":
                                  {
                                    "@height":5
                                  }
                                },
                              "-appearance":
                                { "Appearance":
                                  {
                                    "-material":
                                      { "Material":
                                        {
                                          "@diffuseColor":[0.8,0.1,0]
                                        }
                                      }
                                  }
                                }
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "-children":[
                { "ProtoInstance":
                  {
                    "@name":"Shuttle",
                    "fieldValue": [
                      {
                        "@name":"rate",
                        "@value":2
                      },
                      {
                        "@name":"children",
                        "-children":[
                          { "Shape":
                            {
                              "-geometry":
                                { "Sphere":
                                  {
                                  }
                                },
                              "-appearance":
                                { "Appearance":
                                  {
                                    "-material":
                                      { "Material":
                                        {
                                          "@diffuseColor":[0.1,0.8,0]
                                        }
                                      }
                                  }
                                }
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
    }
  }
}