{ "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":"IntegerTriggerExample.x3d"
          },
          {
            "@name":"description",
            "@content":"An IntegerTrigger node controls the display of colored text."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman and Leonard Daly"
          },
          {
            "@name":"created",
            "@content":"1 March 2008"
          },
          {
            "@name":"modified",
            "@content":"25 August 2023"
          },
          {
            "@name":"reference",
            "@content":"KelpTank.x3d"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/IntegerTriggerExample.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":"IntegerTriggerExample.x3d"
            }
          },
          { "Background":
            {
              "@skyColor":[1,1,1]
            }
          },
          { "Viewpoint":
            {
              "@description":"Select text to change color",
              "@position":[0,0,6]
            }
          },
          { "Switch":
            {
              "@DEF":"SwitchColoredTextGroups",
              "@whichChoice":0,
              "-children":[
                { "Group":
                  {
                    "-children":[
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[1,0,0]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "Text":
                              {
                                "@DEF":"MessageText",
                                "@string":["Select these words","to change color"],
                                "-fontStyle":
                                  { "FontStyle":
                                    {
                                      "@justify":["MIDDLE","BEGIN"]
                                    }
                                  }
                              }
                            }
                        }
                      },
                      {
                        "#comment":"TransparentBox makes selection of Text using TouchSensor easier for user"
                      },
                      { "Shape":
                        {
                          "@DEF":"TransparentBox",
                          "-geometry":
                            { "Box":
                              {
                                "@size":[6,2,0.02]
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@transparency":1
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "TouchSensor":
                        {
                          "@DEF":"Touch1",
                          "@description":"touch to activate"
                        }
                      }
                    ]
                  }
                },
                {
                  "#comment":"Reuse Text geoemetry, paired with different Material colors"
                },
                { "Group":
                  {
                    "-children":[
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[0,1,1]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "Text":
                              {
                                "@USE":"MessageText"
                              }
                            }
                        }
                      },
                      { "Shape":
                        {
                          "@USE":"TransparentBox"
                        }
                      },
                      { "TouchSensor":
                        {
                          "@DEF":"Touch2",
                          "@description":"touch to activate"
                        }
                      }
                    ]
                  }
                },
                { "Group":
                  {
                    "-children":[
                      { "Shape":
                        {
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[0.7,0.7,0]
                                    }
                                  }
                              }
                            },
                          "-geometry":
                            { "Text":
                              {
                                "@USE":"MessageText"
                              }
                            }
                        }
                      },
                      { "Shape":
                        {
                          "@USE":"TransparentBox"
                        }
                      },
                      { "TouchSensor":
                        {
                          "@DEF":"Touch3",
                          "@description":"touch to activate"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "#comment":"IntegerTrigger nodes used to switch child shapes, must use separate one for each output value"
          },
          { "IntegerTrigger":
            {
              "@DEF":"Filter1",
              "@integerKey":1
            }
          },
          { "IntegerTrigger":
            {
              "@DEF":"Filter2",
              "@integerKey":2
            }
          },
          { "IntegerTrigger":
            {
              "@DEF":"Filter3",
              "@integerKey":0
            }
          },
          { "ROUTE":
            {
              "@fromField":"isActive",
              "@fromNode":"Touch1",
              "@toField":"set_boolean",
              "@toNode":"Filter1"
            }
          },
          { "ROUTE":
            {
              "@fromField":"isActive",
              "@fromNode":"Touch2",
              "@toField":"set_boolean",
              "@toNode":"Filter2"
            }
          },
          { "ROUTE":
            {
              "@fromField":"isActive",
              "@fromNode":"Touch3",
              "@toField":"set_boolean",
              "@toNode":"Filter3"
            }
          },
          { "ROUTE":
            {
              "@fromField":"triggerValue",
              "@fromNode":"Filter1",
              "@toField":"whichChoice",
              "@toNode":"SwitchColoredTextGroups"
            }
          },
          { "ROUTE":
            {
              "@fromField":"triggerValue",
              "@fromNode":"Filter2",
              "@toField":"whichChoice",
              "@toNode":"SwitchColoredTextGroups"
            }
          },
          { "ROUTE":
            {
              "@fromField":"triggerValue",
              "@fromNode":"Filter3",
              "@toField":"whichChoice",
              "@toNode":"SwitchColoredTextGroups"
            }
          }
        ]
    }
  }
}