{ "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":"CrossHairPrototype.x3d"
          },
          {
            "@name":"description",
            "@content":"Prototype for a heads-up display (HUD) crosshair showing center of screen, useful for assessing lookAt point."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"1 February 2003"
          },
          {
            "@name":"modified",
            "@content":"28 November 2019"
          },
          {
            "@name":"subject",
            "@content":"crosshair display"
          },
          {
            "@name":"identifier",
            "@content":"https://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../../license.html"
          },
          {
            "@name":"translated",
            "@content":"04 January 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":"CrossHairPrototype.x3d"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"CrossHair",
              "@appinfo":"CrossHair prototype provides a heads-up display (HUD) crosshair at the view center, which is useful for assessing NavigationInfo lookAt point",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"enabled",
                      "@accessType":"initializeOnly",
                      "@appinfo":"whether CrossHair prototype is enabled or not",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"set_enabled",
                      "@accessType":"inputOnly",
                      "@appinfo":"control whether enabled/disabled",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"markerColor",
                      "@accessType":"inputOutput",
                      "@appinfo":"color of CrossHair marker",
                      "@type":"SFColor",
                      "@value":[0.3,0.3,0.8]
                    },
                    {
                      "@name":"scale",
                      "@accessType":"inputOutput",
                      "@appinfo":"size of CrossHair in meters",
                      "@type":"SFVec3f",
                      "@value":[1,1,1]
                    },
                    {
                      "@name":"positionOffsetFromCamera",
                      "@accessType":"inputOutput",
                      "@appinfo":"distance in front of HUD viewpoint",
                      "@type":"SFVec3f",
                      "@value":[0,0,-3]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Switch":
                      {
                        "@DEF":"ShowSwitch",
                        "@whichChoice":-1,
                        "-children":[
                          { "Group":
                            {
                              "-children":[
                                { "ProximitySensor":
                                  {
                                    "@DEF":"WhereSensor",
                                    "@size":[1000000000,1000000000,1000000000],
                                    "IS": {
                                        "connect": [
                                          {
                                            "@nodeField":"enabled",
                                            "@protoField":"enabled"
                                          }
                                        ]
                                    }
                                  }
                                },
                                { "Transform":
                                  {
                                    "@DEF":"CameraLocation",
                                    "-children":[
                                      { "Transform":
                                        {
                                          "@DEF":"CameraOffset",
                                          "IS": {
                                              "connect": [
                                                {
                                                  "@nodeField":"translation",
                                                  "@protoField":"positionOffsetFromCamera"
                                                },
                                                {
                                                  "@nodeField":"scale",
                                                  "@protoField":"scale"
                                                }
                                              ]
                                          },
                                          "-children":[
                                            { "Shape":
                                              {
                                                "-geometry":
                                                  { "IndexedLineSet":
                                                    {
                                                      "@coordIndex":[0,1,-1,2,3,-1],
                                                      "-coord":
                                                        { "Coordinate":
                                                          {
                                                            "@point":[0,1,0,0,-1,0,1,0,0,-1,0,0]
                                                          }
                                                        }
                                                    }
                                                  },
                                                "-appearance":
                                                  { "Appearance":
                                                    {
                                                      "-material":
                                                        { "Material":
                                                          {
                                                            "@DEF":"CircleMaterial",
                                                            "@diffuseColor":[0,0,0],
                                                            "IS": {
                                                                "connect": [
                                                                  {
                                                                    "@nodeField":"emissiveColor",
                                                                    "@protoField":"markerColor"
                                                                  }
                                                                ]
                                                            }
                                                          }
                                                        }
                                                    }
                                                  }
                                              }
                                            }
                                          ]
                                        }
                                      },
                                      { "Group":
                                        {
                                          "-children":[
                                            { "Script":
                                              {
                                                "@DEF":"EnabledScript",
                                                "field": [
                                                  {
                                                    "@name":"enabled",
                                                    "@accessType":"initializeOnly",
                                                    "@type":"SFBool"
                                                  },
                                                  {
                                                    "@name":"set_enabled",
                                                    "@accessType":"inputOnly",
                                                    "@type":"SFBool"
                                                  },
                                                  {
                                                    "@name":"whichChoice",
                                                    "@accessType":"outputOnly",
                                                    "@type":"SFInt32"
                                                  }
                                                ],
                                                "IS": {
                                                    "connect": [
                                                      {
                                                        "@nodeField":"enabled",
                                                        "@protoField":"enabled"
                                                      },
                                                      {
                                                        "@nodeField":"set_enabled",
                                                        "@protoField":"set_enabled"
                                                      }
                                                    ]
                                                },
                                                "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function initialize ()",
"{",
"\tif (enabled) whichChoice =  0;",
"\telse                        whichChoice = -1;",
"//\tBrowser.println ('enabled=' + enabled + ', whichChoice=' + whichChoice);",
"}",
"",
"function set_enabled (value, timestamp)",
"{",
"\tif (value) whichChoice =  0;",
"\telse       whichChoice = -1;",
"//\tBrowser.println ('set_enabled=' + value + ', whichChoice=' + whichChoice);",
"}",
"",
""
]
                                              }
                                            },
                                            { "ROUTE":
                                              {
                                                "@fromField":"isActive",
                                                "@fromNode":"WhereSensor",
                                                "@toField":"set_enabled",
                                                "@toNode":"EnabledScript"
                                              }
                                            },
                                            { "ROUTE":
                                              {
                                                "@fromField":"whichChoice",
                                                "@fromNode":"EnabledScript",
                                                "@toField":"whichChoice",
                                                "@toNode":"ShowSwitch"
                                              }
                                            }
                                          ]
                                        }
                                      }
                                    ]
                                  }
                                }
                              ]
                            }
                          }
                        ]
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"position_changed",
                        "@fromNode":"WhereSensor",
                        "@toField":"set_translation",
                        "@toNode":"CameraLocation"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"orientation_changed",
                        "@fromNode":"WhereSensor",
                        "@toField":"set_rotation",
                        "@toNode":"CameraLocation"
                      }
                    }
                  ]
              }
            }
          },
          {
            "#comment":"========================"
          },
          { "NavigationInfo":
            {
              "@speed":10,
              "@type":"\"FLY\" \"ANY\""
            }
          },
          { "ProtoInstance":
            {
              "@name":"CrossHair",
              "fieldValue": [
                {
                  "@name":"enabled",
                  "@value":true
                },
                {
                  "@name":"markerColor",
                  "@value":[1,0.5,0]
                },
                {
                  "@name":"scale",
                  "@value":[1,1,1]
                },
                {
                  "@name":"positionOffsetFromCamera",
                  "@value":[0,0,-3]
                }
              ]
            }
          },
          { "Group":
            {
              "@DEF":"TextMenu",
              "-children":[
                { "Transform":
                  {
                    "-children":[
                      { "Anchor":
                        {
                          "@description":"CrossHair Example",
                          "@parameter":["target=_blank"],
                          "@url":["CrossHairExample.x3d","https://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairExample.x3d","CrossHairExample.wrl","https://savage.nps.edu/Savage/Tools/HeadsUpDisplays/CrossHairExample.wrl"],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["CrossHairPrototype is a","prototype definition file.","Click text to see","CrossHairExample"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@justify":["MIDDLE","MIDDLE"],
                                            "@size":0.8
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "-material":
                                        { "Material":
                                          {
                                            "@diffuseColor":[0.8,0.8,0.4]
                                          }
                                        }
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
    }
  }
}