{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.0",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.0.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"ProjectileInterpolatorArena.x3d"
          },
          {
            "@name":"description",
            "@content":"A projectile motion application which displays range and max height values accoding to Vi and theta inputs. Calculations for drag force with air density are also taken into account."
          },
          {
            "@name":"creator",
            "@content":"Ozan APAYDIN"
          },
          {
            "@name":"created",
            "@content":"10 December 2001"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorArena.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"02 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":"ProjectileInterpolatorArena.x3d"
            }
          },
          { "ExternProtoDeclare":
            {
              "@name":"ProjectileSliderBar",
              "@url":["ProjectileSliderBarPrototype.wrl#ProjectileSliderBar","https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileSliderBarPrototype.wrl#ProjectileSliderBar","ProjectileSliderBarPrototype.x3d#ProjectileSliderBar","https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileSliderBarPrototype.x3d#ProjectileSliderBar"],
              "field": [
                {
                  "@name":"name",
                  "@accessType":"initializeOnly",
                  "@type":"MFString"
                },
                {
                  "@name":"length",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"width",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"maxValue",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"minValue",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"barColor",
                  "@accessType":"initializeOnly",
                  "@type":"SFColor"
                },
                {
                  "@name":"pointerColor",
                  "@accessType":"initializeOnly",
                  "@type":"SFColor"
                },
                {
                  "@name":"nameColor",
                  "@accessType":"initializeOnly",
                  "@type":"SFColor"
                },
                {
                  "@name":"currentValueColor",
                  "@accessType":"initializeOnly",
                  "@type":"SFColor"
                },
                {
                  "@name":"currentValueInt",
                  "@accessType":"outputOnly",
                  "@type":"SFInt32"
                },
                {
                  "@name":"currentValueFloat",
                  "@accessType":"outputOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"precision",
                  "@accessType":"initializeOnly",
                  "@type":"SFInt32"
                },
                {
                  "@name":"translation",
                  "@accessType":"initializeOnly",
                  "@type":"SFVec3f"
                }
              ]
            }
          },
          { "ExternProtoDeclare":
            {
              "@name":"ProjectileInterpolator",
              "@url":["ProjectileInterpolatorPrototype.wrl#ProjectileInterpolator","https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorPrototype.wrl#ProjectileInterpolator","ProjectileInterpolatorPrototype.x3d#ProjectileInterpolator","https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorPrototype.x3d#ProjectileInterpolator"],
              "field": [
                {
                  "@name":"Vi",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"theta",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"B_m",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"dt",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"fraction",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"set_fraction",
                  "@accessType":"inputOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"set_theta",
                  "@accessType":"inputOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"set_Vi",
                  "@accessType":"inputOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"value_changed",
                  "@accessType":"outputOnly",
                  "@type":"SFVec3f"
                }
              ]
            }
          },
          { "Viewpoint":
            {
              "@DEF":"FirstView",
              "@description":"First view",
              "@position":[60,15,150]
            }
          },
          { "Background":
            {
              "@backUrl":["urn:web3d:media:textures/panoramas/space_1_back.jpg","space_1_back.jpg","https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_back.jpg","https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_back.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_back.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_back.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/space_1_back.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_back.jpg"],
              "@bottomUrl":["urn:web3d:media:textures/panoramas/space_1_bottom.jpg","space_1_bottom.jpg","https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_bottom.jpg","https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_bottom.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_bottom.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_bottom.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/space_1_bottom.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_bottom.jpg"],
              "@frontUrl":["urn:web3d:media:textures/panoramas/space_1_front.jpg","space_1_front.jpg","https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_front.jpg","https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_front.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_front.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_front.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/space_1_front.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_front.jpg"],
              "@groundAngle":[1.309,1.570796],
              "@groundColor":[0,0,0],
              "@leftUrl":["urn:web3d:media:textures/panoramas/space_1_left.jpg","space_1_left.jpg","https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_left.jpg","https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_left.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_left.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_left.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/space_1_left.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_left.jpg"],
              "@rightUrl":["urn:web3d:media:textures/panoramas/space_1_right.jpg","space_1_right.jpg","https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_right.jpg","https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_right.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_right.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_right.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/space_1_right.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_right.jpg"],
              "@skyAngle":[1.309,1.571],
              "@topUrl":["urn:web3d:media:textures/panoramas/space_1_top.jpg","space_1_top.jpg","https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_top.jpg","https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_top.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_top.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_top.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/space_1_top.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_top.jpg"]
            }
          },
          { "DirectionalLight":
            {
              "@direction":[0,-1,0],
              "@intensity":0.5
            }
          },
          { "ProtoInstance":
            {
              "@name":"ProjectileSliderBar",
              "@DEF":"SliderVelocity",
              "fieldValue": [
                {
                  "@name":"name",
                  "@value":["Vi"]
                },
                {
                  "@name":"length",
                  "@value":1.5
                },
                {
                  "@name":"width",
                  "@value":1
                },
                {
                  "@name":"maxValue",
                  "@value":30
                },
                {
                  "@name":"minValue",
                  "@value":0
                },
                {
                  "@name":"barColor",
                  "@value":[0,0,1]
                },
                {
                  "@name":"pointerColor",
                  "@value":[1,1,0]
                },
                {
                  "@name":"nameColor",
                  "@value":[1,0,1]
                },
                {
                  "@name":"precision",
                  "@value":1
                },
                {
                  "@name":"translation",
                  "@value":[-0.04,0.06,0.0]
                }
              ]
            }
          },
          { "ProtoInstance":
            {
              "@name":"ProjectileSliderBar",
              "@DEF":"SliderAngle",
              "fieldValue": [
                {
                  "@name":"name",
                  "@value":["Theta"]
                },
                {
                  "@name":"length",
                  "@value":1.5
                },
                {
                  "@name":"width",
                  "@value":1
                },
                {
                  "@name":"maxValue",
                  "@value":90
                },
                {
                  "@name":"minValue",
                  "@value":0
                },
                {
                  "@name":"barColor",
                  "@value":[1,0,0]
                },
                {
                  "@name":"pointerColor",
                  "@value":[1,1,0]
                },
                {
                  "@name":"nameColor",
                  "@value":[0,1,1]
                },
                {
                  "@name":"precision",
                  "@value":1
                },
                {
                  "@name":"translation",
                  "@value":[-0.04,0.05,0.0]
                }
              ]
            }
          },
          { "ProtoInstance":
            {
              "@name":"ProjectileSliderBar",
              "@DEF":"TimeCycle",
              "fieldValue": [
                {
                  "@name":"name",
                  "@value":["CycleInterval"]
                },
                {
                  "@name":"length",
                  "@value":1.5
                },
                {
                  "@name":"width",
                  "@value":1
                },
                {
                  "@name":"maxValue",
                  "@value":5
                },
                {
                  "@name":"minValue",
                  "@value":1
                },
                {
                  "@name":"barColor",
                  "@value":[0,1,0]
                },
                {
                  "@name":"pointerColor",
                  "@value":[1,1,0]
                },
                {
                  "@name":"nameColor",
                  "@value":[0,0.3,1]
                },
                {
                  "@name":"precision",
                  "@value":1
                },
                {
                  "@name":"translation",
                  "@value":[-0.04,0.04,0.0]
                }
              ]
            }
          },
          { "ProtoInstance":
            {
              "@name":"ProjectileInterpolator",
              "@DEF":"ProjectileInterpolator"
            }
          },
          { "ROUTE":
            {
              "@fromField":"currentValueFloat",
              "@fromNode":"SliderVelocity",
              "@toField":"set_Vi",
              "@toNode":"ProjectileInterpolator"
            }
          },
          { "ROUTE":
            {
              "@fromField":"currentValueFloat",
              "@fromNode":"SliderAngle",
              "@toField":"set_theta",
              "@toNode":"ProjectileInterpolator"
            }
          },
          { "Transform":
            {
              "-children":[
                { "Group":
                  {
                    "@DEF":"HUDGroup",
                    "-children":[
                      { "Collision":
                        {
                          "@enabled":false,
                          "-children":[
                            { "ProximitySensor":
                              {
                                "@DEF":"HudProx",
                                "@size":[1000000,1000000,1000000]
                              }
                            },
                            { "Transform":
                              {
                                "@DEF":"HudTransform",
                                "-children":[
                                  { "Transform":
                                    {
                                      "@translation":[0.05,0.06,-0.2],
                                      "-children":[
                                        { "Transform":
                                          {
                                            "@DEF":"TrajectoryTextTransform",
                                            "-children":[
                                              { "Shape":
                                                {
                                                  "-geometry":
                                                    { "Text":
                                                      {
                                                        "@DEF":"RangeText",
                                                        "@string":["Range 0.0"],
                                                        "-fontStyle":
                                                          { "FontStyle":
                                                            {
                                                              "@size":0.01,
                                                              "@style":"BOLD"
                                                            }
                                                          }
                                                      }
                                                    },
                                                  "-appearance":
                                                    { "Appearance":
                                                      {
                                                        "-material":
                                                          { "Material":
                                                            {
                                                              "@diffuseColor":[0.9,0.7,0.0]
                                                            }
                                                          }
                                                      }
                                                    }
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        { "Transform":
                                          {
                                            "@translation":[0.0,-0.015,0.0],
                                            "-children":[
                                              { "Shape":
                                                {
                                                  "-geometry":
                                                    { "Text":
                                                      {
                                                        "@DEF":"HeightText",
                                                        "@string":["Max Height 0.0"],
                                                        "-fontStyle":
                                                          { "FontStyle":
                                                            {
                                                              "@size":0.01,
                                                              "@style":"BOLD"
                                                            }
                                                          }
                                                      }
                                                    },
                                                  "-appearance":
                                                    { "Appearance":
                                                      {
                                                        "-material":
                                                          { "Material":
                                                            {
                                                              "@diffuseColor":[0,1,0]
                                                            }
                                                          }
                                                      }
                                                    }
                                                }
                                              }
                                            ]
                                          }
                                        }
                                      ]
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          { "ROUTE":
            {
              "@fromField":"position_changed",
              "@fromNode":"HudProx",
              "@toField":"set_translation",
              "@toNode":"HudTransform"
            }
          },
          { "ROUTE":
            {
              "@fromField":"position_changed",
              "@fromNode":"HudProx",
              "@toField":"center",
              "@toNode":"HudProx"
            }
          },
          { "ROUTE":
            {
              "@fromField":"orientation_changed",
              "@fromNode":"HudProx",
              "@toField":"set_rotation",
              "@toNode":"HudTransform"
            }
          },
          { "Script":
            {
              "@DEF":"ValueDisplayer",
              "@directOutput":true,
              "field": [
                {
                  "@name":"setTextValues",
                  "@accessType":"inputOnly",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"reset",
                  "@accessType":"inputOnly",
                  "@type":"SFBool"
                },
                {
                  "@name":"RangeText",
                  "@accessType":"initializeOnly",
                  "@type":"SFNode",
                  "-children":[
                    { "Text":
                      {
                        "@USE":"RangeText"
                      }
                    }
                  ]
                },
                {
                  "@name":"HeightText",
                  "@accessType":"initializeOnly",
                  "@type":"SFNode",
                  "-children":[
                    { "Text":
                      {
                        "@USE":"HeightText"
                      }
                    }
                  ]
                }
              ],
              "#sourceCode":[
"",
"",
"ecmascript:",
"var maxValue;",
"",
"function initialize() {",
"   maxValue = 0;",
"}",
"",
"function setTextValues(values, timeEvent) {",
"   var precision = 2;",
"   RangeText.string[0] ='Range            ' + roundOff(values[0], precision);",
"   if(values[1] > maxValue) {",
"      maxValue = roundOff(values[1], precision);",
"      Browser.println ('maximum' + maxValue);",
"   }",
"",
"   Browser.println ('values' + values[1]);",
"   HeightText.string[0] ='Max Height   ' + maxValue;",
"}",
"",
"function reset(bool, eventTime) {",
"   maxValue = 0;",
"}",
"",
"//A function to round the values regarding to given precision.",
"function roundOff(value, precision) {",
"",
"   var result;",
"   var isNegative = false;",
"   var wholeInt = Math.round(value * Math.pow(10, precision));",
"",
"   //Negative numbers creates exceptional condition, therefor they are converted",
"   //to positive values.",
"   if(wholeInt < 0) {",
"      wholeInt = -wholeInt;",
"      isNegative = true;",
"   }",
"",
"   var whole = wholeInt.toString();",
"",
"   var decPoint = whole.length - precision;",
"",
"   //Exception when precision is bigger than the string length   ",
"   if(decPoint < 0) {",
"      i = -decPoint;",
"      for(i; i > 0; i--) {  ",
"         whole ='0' + whole;",
"      }",
"",
"      //Calculate decPoint according to new string expanded with 0s      ",
"      decPoint = whole.length - precision;",
"   }",
"",
"   if(whole !='0') {",
"      //Put the decimal point on the appropriate place",
"      result = whole.substring(0, decPoint);",
"      result +='.';",
"      result += whole.substring(decPoint, whole.length);",
"   }",
"   else { //If the string is'0', then result is'0'",
"      result = whole;",
"   }",
"",
"   //Negative numbers are altered.",
"   if(isNegative) {",
"      result ='-' + result;",
"   }",
"   //Convert the String value to Float.",
"   resultFloat = parseFloat(result); ",
"",
"",
"   return resultFloat;",
"",
"}",
"",
""
]
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"ProjectileInterpolator",
              "@toField":"setTextValues",
              "@toNode":"ValueDisplayer"
            }
          },
          { "Transform":
            {
              "@translation":[0.0,-0.7,0.0],
              "-children":[
                { "Collision":
                  {
                    "-children":[
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-texture":
                                  { "ImageTexture":
                                    {
                                      "@url":["grass_1.jpg","https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/grass_1.jpg","https://www.web3d.org/WorkingGroups/media/textures/nature/grass_1.jpg"]
                                    }
                                  },
                                "-textureTransform":
                                  { "TextureTransform":
                                    {
                                      "@scale":[8,4]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "ElevationGrid":
                              {
                                "@height":[-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75,-0.75],
                                "@xDimension":4,
                                "@xSpacing":40,
                                "@zSpacing":25
                              }
                            }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "@translation":[0,0,12.5],
              "-children":[
                { "Transform":
                  {
                    "@DEF":"BallTransform",
                    "-children":[
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[1,0,0]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "Sphere":
                              {
                                "@radius":1.5
                              }
                            }
                        }
                      },
                      { "Viewpoint":
                        {
                          "@description":"BallView",
                          "@position":[0,10,70]
                        }
                      },
                      { "TouchSensor":
                        {
                          "@DEF":"HitSensor"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          { "TimeSensor":
            {
              "@DEF":"Timer",
              "@cycleInterval":3.5
            }
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Timer",
              "@toField":"set_fraction",
              "@toNode":"ProjectileInterpolator"
            }
          },
          { "ROUTE":
            {
              "@fromField":"touchTime",
              "@fromNode":"HitSensor",
              "@toField":"set_startTime",
              "@toNode":"Timer"
            }
          },
          { "ROUTE":
            {
              "@fromField":"isActive",
              "@fromNode":"HitSensor",
              "@toField":"reset",
              "@toNode":"ValueDisplayer"
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"ProjectileInterpolator",
              "@toField":"set_translation",
              "@toNode":"BallTransform"
            }
          },
          { "Script":
            {
              "@DEF":"TimeConverter",
              "@directOutput":true,
              "field": [
                {
                  "@name":"TimerNode",
                  "@accessType":"initializeOnly",
                  "@type":"SFNode",
                  "-children":[
                    { "TimeSensor":
                      {
                        "@USE":"Timer"
                      }
                    }
                  ]
                },
                {
                  "@name":"setTime",
                  "@accessType":"inputOnly",
                  "@type":"SFFloat"
                }
              ],
              "#sourceCode":[
"",
"",
"ecmascript:",
"function initialize() {",
"}",
"",
"function setTime(inputTime, timeEvent) {",
"   TimerNode.cycleInterval = inputTime;",
"}",
"",
""
]
            }
          },
          { "ROUTE":
            {
              "@fromField":"currentValueFloat",
              "@fromNode":"TimeCycle",
              "@toField":"setTime",
              "@toNode":"TimeConverter"
            }
          }
        ]
    }
  }
}