{ "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":"ElevationGridSimpleWaveAnimation.x3d"
          },
          {
            "@name":"description",
            "@content":"Simple Javascript animation of ElevationGrid"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"2 December 2012"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"Image",
            "@content":"ElevationGridSimpleWaveAnimation.png"
          },
          {
            "@name":"identifier",
            "@content":"https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ElevationGridSimpleWaveAnimation.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"25 April 2023"
          },
          {
            "@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":"ElevationGridSimpleWaveAnimation.x3d"
            }
          },
          { "Viewpoint":
            {
              "@description":"Wave view",
              "@orientation":[1,0,0,-0.358771],
              "@position":[0,3,8]
            }
          },
          { "Background":
            {
              "@groundColor":[1,1,1],
              "@skyColor":[1,1,1]
            }
          },
          {
            "#comment":"Shift zero-based ElevationGrid to left, centering it"
          },
          { "Transform":
            {
              "@translation":[-4,0,0],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "ElevationGrid":
                        {
                          "@DEF":"GridSurface",
                          "@height":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                          "@solid":false,
                          "@xDimension":9,
                          "@zDimension":3
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0,0.5,1]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "TimeSensor":
            {
              "@DEF":"Clock",
              "@cycleInterval":5,
              "@loop":true
            }
          },
          { "Script":
            {
              "@DEF":"WaveGenerationScript",
              "field": [
                {
                  "@name":"newInputValue",
                  "@accessType":"inputOnly",
                  "@appinfo":"provide value and trigger new computation",
                  "@type":"SFFloat"
                },
                {
                  "@name":"gridOutput",
                  "@accessType":"outputOnly",
                  "@appinfo":"provide values to ElevationGrid",
                  "@type":"MFFloat"
                },
                {
                  "@name":"waveStep",
                  "@accessType":"initializeOnly",
                  "@appinfo":"wave variation",
                  "@type":"SFTime",
                  "@value":0.1
                }
              ],
              "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function newInputValue (eventValue)",
"{",
"   fraction = eventValue; // connected by ROUTE, receives values from TimeSensor Clock fraction_changed",
"",
"   value0 = 0.2 * Math.sin (2 * Math.PI * (fraction - 4*waveStep));",
"   value1 = 0.2 * Math.sin (2 * Math.PI * (fraction - 3*waveStep));",
"   value2 = 0.2 * Math.sin (2 * Math.PI * (fraction - 2*waveStep));",
"   value3 = 0.2 * Math.sin (2 * Math.PI * (fraction -   waveStep));",
"   value4 = 0.2 * Math.sin (2 * Math.PI * (fraction             ));",
"   value5 = 0.2 * Math.sin (2 * Math.PI * (fraction +   waveStep));",
"   value6 = 0.2 * Math.sin (2 * Math.PI * (fraction + 2*waveStep));",
"   value7 = 0.2 * Math.sin (2 * Math.PI * (fraction + 3*waveStep));",
"   value8 = 0.2 * Math.sin (2 * Math.PI * (fraction + 4*waveStep));",
"",
"   // setting the gridOutput value creates an output event that is connected via ROUTE to the ElevationGrid set_height field.",
"   // note that types match (MFFloat) and accessTypes also match (output_only connects to inputOnly).",
"   gridOutput = new MFFloat (",
"\t\tvalue0, value1, value2, value3, value4, value5, value6, value7, value8,",
"\t\tvalue0, value1, value2, value3, value4, value5, value6, value7, value8,",
"\t\tvalue0, value1, value2, value3, value4, value5, value6, value7, value8 );",
"}",
"",
""
]
            }
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"newInputValue",
              "@toNode":"WaveGenerationScript"
            }
          },
          { "ROUTE":
            {
              "@fromField":"gridOutput",
              "@fromNode":"WaveGenerationScript",
              "@toField":"set_height",
              "@toNode":"GridSurface"
            }
          }
        ]
    }
  }
}