{ "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":"TextureAngleViewer.x3d"
          },
          {
            "@name":"description",
            "@content":"View a given texture from different angles to judge readability, example use is a QR code."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"23 April 2013"
          },
          {
            "@name":"modified",
            "@content":"25 November 2024"
          },
          {
            "@name":"TODO",
            "@content":"color mapper in scene for varying Background contrast"
          },
          {
            "@name":"TODO",
            "@content":"second X-axis angle slider"
          },
          {
            "@name":"Image",
            "@content":"TextureAngleViewer36degrees.png"
          },
          {
            "@name":"Image",
            "@content":"images/QrNpsEduCode.png"
          },
          {
            "@name":"reference",
            "@content":"http://qr.nps.edu"
          },
          {
            "@name":"reference",
            "@content":"https://zxing.appspot.com/generator"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/TextureMapping/TextureAngleViewer.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"31 August 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":[
          {
            "#comment":"================================"
          },
          { "WorldInfo":
            {
              "@title":"Texture Angle Viewer"
            }
          },
          { "Background":
            {
              "@skyColor":[0.72549,1,0.721569]
            }
          },
          { "Viewpoint":
            {
              "@description":"Texture angle viewer",
              "@position":[0,0,11]
            }
          },
          { "NavigationInfo":
            {
              "@DEF":"NavigationInfoFinal",
              "@type":["NONE"]
            }
          },
          {
            "#comment":"<NavigationInfo DEF='NavigationInfoDebug' type='\"EXAMINE\" \"ANY\"'/>"
          },
          {
            "#comment":"================================"
          },
          { "Transform":
            {
              "@translation":[0,3.6,0],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@DEF":"AngleOutputText",
                          "@string":["Texture angle viewer"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"],
                                "@size":0.7
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0.2,0.4,0.8]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          {
            "#comment":"================================"
          },
          { "Anchor":
            {
              "@description":"this QR code links to http://qr.nps.edu",
              "@url":["http://qr.nps.edu"],
              "-children":[
                { "Transform":
                  {
                    "@DEF":"ImageTransform",
                    "-children":[
                      { "Shape":
                        {
                          "-children":[
                            {
                              "#comment":"TODO add a single geometry node here"
                            }
                          ],
                          "-geometry":
                            { "IndexedFaceSet":
                              {
                                "@coordIndex":[1,0,2,3,0,-1],
                                "-coord":
                                  { "Coordinate":
                                    {
                                      "@point":[-3,-3,0,3,-3,0,3,3,0,-3,3,0,-3,-3,0]
                                    }
                                  }
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                    }
                                  },
                                "-texture":
                                  { "ImageTexture":
                                    {
                                      "@url":["images/QrNpsEduCode.png","https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/TextureMapping/images/QrNpsEduCode.png"]
                                    }
                                  }
                              }
                            }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "#comment":"================================"
          },
          { "Transform":
            {
              "@DEF":"SliderSituated",
              "@translation":[0,-3.6,0],
              "-children":[
                { "Transform":
                  {
                    "@DEF":"SliderKnobTransform",
                    "-children":[
                      { "PlaneSensor":
                        {
                          "@DEF":"SliderPlaneSensor",
                          "@description":"select and drag to change angle values",
                          "@maxPosition":[3,0],
                          "@minPosition":[-3,0]
                        }
                      },
                      { "Transform":
                        {
                          "@rotation":[0,0,1,1.570796],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Cylinder":
                                    {
                                      "@DEF":"SliderKnob",
                                      "@height":0.2,
                                      "@radius":0.2
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@DEF":"Metals13Appearance",
                                      "-material":
                                        { "Material":
                                          {
                                            "@ambientIntensity":0.25641,
                                            "@diffuseColor":[0.222308,0.15428,0],
                                            "@specularColor":[0.882653,0.860832,0.687861],
                                            "-children":[
                                              {
                                                "#comment":"Universal Media Library: Metals 13"
                                              }
                                            ]
                                          }
                                        }
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      }
                    ]
                  }
                },
                {
                  "#comment":"SliderBar does not rotate or drag with SliderKnob"
                },
                { "Transform":
                  {
                    "@DEF":"SliderBar",
                    "@rotation":[0,0,1,1.570796],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Cylinder":
                              {
                                "@height":6,
                                "@radius":0.05
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@USE":"Metals13Appearance"
                              }
                            }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "#comment":"================================"
          },
          { "Script":
            {
              "@DEF":"SliderScript",
              "field": [
                {
                  "@name":"set_translation",
                  "@accessType":"inputOnly",
                  "@appinfo":"input provided by SliderKnobTransform PlaneSensor output",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"angle",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat",
                  "@value":0.0
                },
                {
                  "@name":"y",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat",
                  "@value":0.0
                },
                {
                  "@name":"rotation_changed",
                  "@accessType":"outputOnly",
                  "@appinfo":"output provided for ImageTransform rotation",
                  "@type":"SFRotation"
                },
                {
                  "@name":"translation_changed",
                  "@accessType":"outputOnly",
                  "@appinfo":"output provided for SliderKnobTransform translation",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"angleMFString_changed",
                  "@accessType":"outputOnly",
                  "@appinfo":"output provided for degrees of rotation in Text node",
                  "@type":"MFString"
                },
                {
                  "@name":"tracePrint",
                  "@accessType":"initializeOnly",
                  "@appinfo":"console output for debugging",
                  "@type":"SFBool",
                  "@value":true
                }
              ],
              "-children":[
                {
                  "#comment":"Note that trackPoint_changed events represent unclamped intersection points on plane surface. Browsers can interpret drags off of the surface in various ways. Note that translation_changed events are clamped by minPosition/maxPosition and thus may be preferable."
                }
              ],
              "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function set_translation (eventValue)",
"{",
"   x = eventValue.x;",
"   if (tracePrint)",
"   {",
"      Browser.println ('========================');",
"      Browser.println ('                  x=' + x);",
"   }",
"   // clamp values to prevent overrun/underrun, in case minPosition/maxPosition fail",
"   if (x >  3.0) x =  3.0;",
"   if (x < -3.0) x = -3.0;",
"",
"   translation_changed = eventValue;",
"   angle = Math.round(x * 90.0 / 3.0);",
"   rotation_changed = new SFRotation (0, 1, 0, angle * Math.PI / 180.0);",
"   var angleString = angle.toString() + ' degrees'; // JavaScript string",
"",
"// angleMFString_changed = new MFString (new SFString(angleString)); // only works in InstantReality",
"   angleMFString_changed = new MFString (angleString); // works in several players but not all",
"// angleMFString_changed = [ angleString ]; // Use JavaScript string array instead of MFString doesn't work",
"",
"   if (tracePrint)",
"   {",
"      Browser.println ('          clamped x=' + x);",
"      Browser.println ('    set_translation=' + eventValue);",
"      Browser.println ('translation_changed=' + translation_changed.toString() + ', rotation_changed=' + rotation_changed.toString());",
"      Browser.println (''angle=' + angle + ', angleString=' + angleString + ', angleMFString_changed=' + angleMFString_changed.toString());",
"   }",
"/*",
"example console excerpt:",
"========================",
"                  x=-0.05248255282640457",
"          clamped x=-0.05248255282640457",
"    set_translation=-0.05248255282640457 0 0",
"translation_changed=-0.05248255282640457 0 0, rotation_changed=0 1 0 -0.03490658503988659",
"angle=-2, angleString=-2 degrees, angleMFString_changed=-2 degrees",
"========================",
"*/",
"}",
"",
""
]
            }
          },
          { "ROUTE":
            {
              "@fromField":"translation_changed",
              "@fromNode":"SliderPlaneSensor",
              "@toField":"set_translation",
              "@toNode":"SliderScript"
            }
          },
          { "ROUTE":
            {
              "@fromField":"translation_changed",
              "@fromNode":"SliderScript",
              "@toField":"translation",
              "@toNode":"SliderKnobTransform"
            }
          },
          { "ROUTE":
            {
              "@fromField":"rotation_changed",
              "@fromNode":"SliderScript",
              "@toField":"rotation",
              "@toNode":"ImageTransform"
            }
          },
          { "ROUTE":
            {
              "@fromField":"angleMFString_changed",
              "@fromNode":"SliderScript",
              "@toField":"string",
              "@toNode":"AngleOutputText"
            }
          }
        ]
    }
  }
}