{ "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":"UserInteractivitySensorNodes.x3d"
          },
          {
            "@name":"description",
            "@content":"A collection of all of the user interactivity sensor nodes: TouchSensor, PlaceSensor, CylinderSensor, SphereSensor, KeySensor, and StringSensor."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"30 April 2005"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"rights",
            "@content":"Copyright 2006, Daly Realism and Don Brutzman"
          },
          {
            "@name":"Image",
            "@content":"UserInteractivitySensorNodes.png"
          },
          {
            "@name":"Image",
            "@content":"UserInteractivitySensorNodesModified.png"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter08UserInteractivity/UserInteractivitySensorNodes.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"17 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":"UserInteractivitySensorNodes.x3d"
            }
          },
          { "Viewpoint":
            {
              "@description":"User interactivity sensor nodes",
              "@position":[0,0,12]
            }
          },
          { "Background":
            {
              "@DEF":"BackgroundDefault",
              "@groundColor":[0.2,0.4,0.6],
              "@skyColor":[0.2,0.4,0.6]
            }
          },
          { "Background":
            {
              "@DEF":"BackgroundTouchCone",
              "@skyColor":[0.5,0.7,0.9]
            }
          },
          { "Transform":
            {
              "@translation":[0,4,0],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["Sensor node examples"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"],
                                "@size":1.5
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@DEF":"DefaultMaterial",
                                "@diffuseColor":[0.8,0.6,0.4]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "@translation":[0,1,0],
              "-children":[
                { "Transform":
                  {
                    "@translation":[-6,0,0],
                    "-children":[
                      { "TouchSensor":
                        {
                          "@DEF":"DefaultTouchSensor",
                          "@description":"click to activate TouchSensor bind alternate Background"
                        }
                      },
                      { "Shape":
                        {
                          "-geometry":
                            { "Cone":
                              {
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@DEF":"RedAppearance",
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[1,0.2,0.2]
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "Transform":
                        {
                          "@translation":[0,-2,0],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["Touch","Sensor"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@DEF":"JustifyMiddle",
                                            "@justify":["MIDDLE","MIDDLE"]
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"RedAppearance"
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      },
                      { "ROUTE":
                        {
                          "@fromField":"isActive",
                          "@fromNode":"DefaultTouchSensor",
                          "@toField":"set_bind",
                          "@toNode":"BackgroundTouchCone"
                        }
                      }
                    ]
                  }
                },
                { "Transform":
                  {
                    "@DEF":"TransformBox",
                    "@translation":[-2,0,0],
                    "-children":[
                      { "PlaneSensor":
                        {
                          "@DEF":"DefaultPlaneSensor",
                          "@description":"drag Box to activate PlaneSensor"
                        }
                      },
                      { "Shape":
                        {
                          "-geometry":
                            { "Box":
                              {
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@DEF":"GreenAppearance",
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[0.2,1,0.2]
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "Transform":
                        {
                          "@translation":[0,-2,0],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["Plane","Sensor"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"JustifyMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"GreenAppearance"
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      },
                      { "ROUTE":
                        {
                          "@fromField":"offset",
                          "@fromNode":"DefaultPlaneSensor",
                          "@toField":"set_translation",
                          "@toNode":"TransformBox"
                        }
                      }
                    ]
                  }
                },
                { "Transform":
                  {
                    "@DEF":"TransformCylinder",
                    "@translation":[2,0,0],
                    "-children":[
                      { "CylinderSensor":
                        {
                          "@DEF":"DefaultCylinderSensor",
                          "@description":"drag to activate CylinderSensor"
                        }
                      },
                      { "Shape":
                        {
                          "-geometry":
                            { "Cylinder":
                              {
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-texture":
                                  { "ImageTexture":
                                    {
                                      "@DEF":"ReferenceTexture",
                                      "@url":["../Chapter05AppearanceMaterialTextures/ImageTextureFigure18.1X3dSpecification.png","../Chapter05AppearanceMaterialTextures/ImageTextureFigure18.1X3dSpecification.gif","https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter05AppearanceMaterialTextures/ImageTextureFigure18.1X3dSpecification.png","https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter05AppearanceMaterialTextures/ImageTextureFigure18.1X3dSpecification.gif"]
                                    }
                                  },
                                "-material":
                                  { "Material":
                                    {
                                      "@DEF":"DarkBlue",
                                      "@diffuseColor":[0,0,0.9]
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "Transform":
                        {
                          "@translation":[0,-2,0],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["Cylinder","Sensor"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"JustifyMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "-material":
                                        { "Material":
                                          {
                                            "@USE":"DarkBlue"
                                          }
                                        }
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      },
                      { "ROUTE":
                        {
                          "@fromField":"rotation_changed",
                          "@fromNode":"DefaultCylinderSensor",
                          "@toField":"set_rotation",
                          "@toNode":"TransformCylinder"
                        }
                      }
                    ]
                  }
                },
                { "Transform":
                  {
                    "@DEF":"TransformSphere",
                    "@translation":[6,0,0],
                    "-children":[
                      { "SphereSensor":
                        {
                          "@DEF":"DefaultSphereSensor",
                          "@description":"click to activate SphereSensor"
                        }
                      },
                      { "Shape":
                        {
                          "-geometry":
                            { "Sphere":
                              {
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-texture":
                                  { "ImageTexture":
                                    {
                                      "@USE":"ReferenceTexture"
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "Transform":
                        {
                          "@DEF":"SphereSensorText",
                          "@translation":[0,-2,0],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["Sphere","Sensor"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"JustifyMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "-material":
                                        { "Material":
                                          {
                                            "@DEF":"GreyMaterial"
                                          }
                                        }
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      },
                      { "ROUTE":
                        {
                          "@fromField":"rotation_changed",
                          "@fromNode":"DefaultSphereSensor",
                          "@toField":"set_rotation",
                          "@toNode":"TransformSphere"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          { "Group":
            {
              "-children":[
                { "Transform":
                  {
                    "@translation":[-4,-3,0],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Text":
                              {
                                "@DEF":"KeyText",
                                "@string":["?"],
                                "-fontStyle":
                                  { "FontStyle":
                                    {
                                      "@USE":"JustifyMiddle"
                                    }
                                  }
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@DEF":"LightBrownAppearance",
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[1,0.862745,0.141176]
                                    }
                                  }
                              }
                            }
                        }
                      }
                    ]
                  }
                },
                { "Transform":
                  {
                    "@translation":[-2,-3,0],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Text":
                              {
                                "@DEF":"StringText",
                                "@string":["Press keys then <Enter>"],
                                "-fontStyle":
                                  { "FontStyle":
                                    {
                                      "@justify":["BEGIN","MIDDLE"]
                                    }
                                  }
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@USE":"LightBrownAppearance"
                              }
                            }
                        }
                      }
                    ]
                  }
                },
                { "KeySensor":
                  {
                    "@DEF":"DefaultKeySensor"
                  }
                },
                { "StringSensor":
                  {
                    "@DEF":"DefaultStringSensor"
                  }
                },
                { "Script":
                  {
                    "@DEF":"KeyboardProcessor",
                    "field": [
                      {
                        "@name":"keyInput",
                        "@accessType":"inputOnly",
                        "@type":"SFString"
                      },
                      {
                        "@name":"finalTextInput",
                        "@accessType":"inputOnly",
                        "@type":"SFString"
                      },
                      {
                        "@name":"enteredTextInput",
                        "@accessType":"inputOnly",
                        "@type":"SFString"
                      },
                      {
                        "@name":"keyOutput",
                        "@accessType":"outputOnly",
                        "@type":"MFString"
                      },
                      {
                        "@name":"stringOutput",
                        "@accessType":"outputOnly",
                        "@type":"MFString"
                      }
                    ],
                    "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function keyInput (inputValue)",
"{",
"//  Browser.println ('keyInput=' + inputValue); // console output",
"    keyOutput = new MFString (inputValue); // type conversion",
"}",
"function finalTextInput (inputValue)",
"{",
"//  Browser.println ('finalText=' + inputValue); // console output",
"    stringOutput = new MFString (inputValue); // type conversion",
"}",
"function enteredTextInput (inputValue)",
"{",
"    Browser.println ('enteredText=' + inputValue); // console output",
"}",
"",
""
]
                  }
                },
                { "ROUTE":
                  {
                    "@fromField":"keyPress",
                    "@fromNode":"DefaultKeySensor",
                    "@toField":"keyInput",
                    "@toNode":"KeyboardProcessor"
                  }
                },
                { "ROUTE":
                  {
                    "@fromField":"finalText",
                    "@fromNode":"DefaultStringSensor",
                    "@toField":"finalTextInput",
                    "@toNode":"KeyboardProcessor"
                  }
                },
                { "ROUTE":
                  {
                    "@fromField":"enteredText",
                    "@fromNode":"DefaultStringSensor",
                    "@toField":"enteredTextInput",
                    "@toNode":"KeyboardProcessor"
                  }
                },
                { "ROUTE":
                  {
                    "@fromField":"keyOutput",
                    "@fromNode":"KeyboardProcessor",
                    "@toField":"string",
                    "@toNode":"KeyText"
                  }
                },
                { "ROUTE":
                  {
                    "@fromField":"stringOutput",
                    "@fromNode":"KeyboardProcessor",
                    "@toField":"string",
                    "@toNode":"StringText"
                  }
                }
              ]
            }
          }
        ]
    }
  }
}