{ "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":"ViewpointGroupPrototype.x3d"
          },
          {
            "@name":"description",
            "@content":"ViewpointGroup contains Viewpoint and ViewpointGroup nodes, allowing nested lists and viewpoint scoping in viewpoint lists. This is a developmental example for potential specification improvement. It is needed because (a) currently specified rules for X3D/VRML node binding state that behavior of child Viewpoints beneath Switch/LOD/etc. is undefined, and (b) browser viewpoint list display behavior is undefined."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"29 October 2003"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"warning",
            "@content":"this prototype is for development purposes only, do not override native player support for ViewpointGroup"
          },
          {
            "@name":"reference",
            "@content":"ViewpointListViewpointGroupProse.html"
          },
          {
            "@name":"reference",
            "@content":"ViewpointGroupExample.x3d"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/navigation.html#Viewpoint"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/technicalinfo/specifications/vrml97/part1/nodesRef.html#Viewpoint"
          },
          {
            "@name":"subject",
            "@content":"ViewpointGroup Viewpoint"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupPrototype.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 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":"ViewpointGroupPrototype.x3d"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"ViewpointGroup",
              "@appinfo":"warning: developmental prototype for X3D v3.2 node do not override native support!",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"children",
                      "@accessType":"inputOutput",
                      "@appinfo":"[Viewpoint | ViewpointGroup] only",
                      "@type":"MFNode",
                      "-children":[
                        {
                          "#comment":"initialized at runtime, default is empty array of Viewpoint/ViewpointGroup nodes."
                        }
                      ]
                    },
                    {
                      "@name":"description",
                      "@accessType":"inputOutput",
                      "@appinfo":"Text description or navigation hint to be displayed for this ViewpointGroup.",
                      "@type":"SFString"
                    },
                    {
                      "@name":"displayed",
                      "@accessType":"inputOutput",
                      "@appinfo":"Whether this ViewpointGroup description is displayed in current viewpoint list.",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"center",
                      "@accessType":"inputOutput",
                      "@appinfo":"Position offset from origin of local coordinate system.",
                      "@type":"SFVec3f",
                      "@value":[0,0,0]
                    },
                    {
                      "@name":"radius",
                      "@accessType":"initializeOnly",
                      "@appinfo":"[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.",
                      "@type":"SFFloat",
                      "@value":10
                    },
                    {
                      "@name":"set_radius",
                      "@accessType":"inputOnly",
                      "@appinfo":"[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.",
                      "@type":"SFFloat"
                    },
                    {
                      "@name":"retainUserOffsets",
                      "@accessType":"inputOutput",
                      "@appinfo":"Whether viewpoint needs to retain (true) or rezero (false) any prior user navigation offsets from defined viewpoint position orientation.",
                      "@type":"SFBool",
                      "@value":true
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Group":
                      {
                        "-children":[
                          { "ProximitySensor":
                            {
                              "@DEF":"ProximityZone",
                              "@size":[20,20,20],
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"center",
                                      "@protoField":"center"
                                    }
                                  ]
                              }
                            }
                          },
                          { "Switch":
                            {
                              "@DEF":"ViewpointsSwitch",
                              "@whichChoice":0,
                              "-children":[
                                { "Group":
                                  {
                                    "IS": {
                                        "connect": [
                                          {
                                            "@nodeField":"children",
                                            "@protoField":"children"
                                          }
                                        ]
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          { "Switch":
                            {
                              "@DEF":"HoldExposedFields",
                              "@whichChoice":-1,
                              "-children":[
                                {
                                  "#comment":"WorldInfo not used because title field is accessType initializeOnly"
                                },
                                { "Anchor":
                                  {
                                    "@DEF":"DescriptionHolder",
                                    "IS": {
                                        "connect": [
                                          {
                                            "@nodeField":"description",
                                            "@protoField":"description"
                                          }
                                        ]
                                    }
                                  }
                                },
                                { "ProximitySensor":
                                  {
                                    "@DEF":"DisplayedHolder",
                                    "IS": {
                                        "connect": [
                                          {
                                            "@nodeField":"enabled",
                                            "@protoField":"displayed"
                                          }
                                        ]
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          { "Script":
                            {
                              "@DEF":"UnbindingControlScript",
                              "@directOutput":true,
                              "field": [
                                {
                                  "@name":"isActive",
                                  "@accessType":"inputOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"ProximityZone",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFNode",
                                  "-children":[
                                    { "ProximitySensor":
                                      {
                                        "@USE":"ProximityZone"
                                      }
                                    }
                                  ]
                                },
                                {
                                  "@name":"radius",
                                  "@accessType":"initializeOnly",
                                  "@appinfo":"[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.",
                                  "@type":"SFFloat"
                                },
                                {
                                  "@name":"set_radius",
                                  "@accessType":"inputOnly",
                                  "@appinfo":"[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.",
                                  "@type":"SFFloat"
                                },
                                {
                                  "@name":"viewpointsSwitch",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFNode",
                                  "-children":[
                                    { "Switch":
                                      {
                                        "@USE":"ViewpointsSwitch"
                                      }
                                    }
                                  ]
                                },
                                {
                                  "@name":"descriptionHolder",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFNode",
                                  "-children":[
                                    { "Anchor":
                                      {
                                        "@USE":"DescriptionHolder"
                                      }
                                    }
                                  ]
                                },
                                {
                                  "@name":"displayedHolder",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFNode",
                                  "-children":[
                                    { "ProximitySensor":
                                      {
                                        "@USE":"DisplayedHolder"
                                      }
                                    }
                                  ]
                                },
                                {
                                  "@name":"description",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFString"
                                },
                                {
                                  "@name":"displayed",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFBool",
                                  "@value":true
                                },
                                {
                                  "@name":"traceEnabled",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFBool",
                                  "@value":false
                                }
                              ],
                              "-children":[
                                {
                                  "#comment":"use node holders to work around VRML 97 Script exposedField restriction"
                                }
                              ],
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"radius",
                                      "@protoField":"radius"
                                    },
                                    {
                                      "@nodeField":"set_radius",
                                      "@protoField":"set_radius"
                                    }
                                  ]
                              },
                              "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function initialize ()",
"{",
"\t// since Viewpoints remain on binding stack as before,",
"\t// no initialization action is necessary when implemented natively.",
"\tdescription = descriptionHolder.description;",
"\tdisplayed = displayedHolder.enabled;",
"\ttracePrint ('displayed=' + displayed);",
"\tif (!displayed) viewpointsSwitch.whichChoice = -1;",
"\tset_radius (radius);",
"",
"\t// typecheck valid children nodes:",
"\ttracePrint ('viewpointsSwitch.choice.length=' + viewpointsSwitch.choice.length);",
"\tif (viewpointsSwitch.choice.length >= 1)",
"\t\tfor (i=0; i >= viewpointsSwitch.choice.length; i)",
"\t\t{",
"\t\t\t// how to check type?",
"\t\t\t// if (viewpointsSwitch.choice[i].____ etc.)",
"\t\t\t// once type checked, warn if Viewpoint position outside proximity box size",
"\t\t}",
"\ttracePrint ('... initialize() complete');",
"}",
"function isActive (activeValue)",
"{",
"\t// Most likely, viewpoint list actions will be controlled by browser.",
"",
"\t// If viewpoint list is exposed via SAI, could do things here",
"\t// such as setting ViewpointGroup.description as browser label.",
"",
"\t// Current action:  switch child Viewpoints in/out of scope.",
"\ttracePrint ('activeValue=' + activeValue);",
"",
"\ttracePrint ('displayed=' + displayed);",
"\tif (!displayed) return;",
"",
"\tif (activeValue) viewpointsSwitch.whichChoice =  0;",
"\telse             viewpointsSwitch.whichChoice = -1;",
"",
"\ttracePrint ('viewpointsSwitch.whichChoice=' + viewpointsSwitch.whichChoice);",
"}",
"function set_radius (value, timestamp)",
"{",
"\tradius = value;",
"\tProximityZone.size.x = 2 * radius;",
"\tProximityZone.size.y = 2 * radius;",
"\tProximityZone.size.z = 2 * radius;",
"\ttracePrint ('set_radius (' + value + '), radius=' + radius + ', ProximityZone.size=' + ProximityZone.size);",
"}",
"",
"function tracePrint(outputString)",
"{",
"\tif (traceEnabled) Browser.println ('[ViewpointGroup' + description + ']' + outputString);",
"}",
"function alwaysPrint(outputString)",
"{",
"\tBrowser.println ('[ViewpointGroup' + description + ']' + outputString);",
"}",
"",
""
]
                            }
                          },
                          { "ROUTE":
                            {
                              "@fromField":"isActive",
                              "@fromNode":"ProximityZone",
                              "@toField":"isActive",
                              "@toNode":"UnbindingControlScript"
                            }
                          }
                        ]
                      }
                    }
                  ]
              }
            }
          },
          {
            "#comment":"===============Example=============="
          },
          { "NavigationInfo":
            {
              "@type":["FLY","ANY"]
            }
          },
          { "Anchor":
            {
              "@description":"ViewpointGroupExample",
              "@parameter":["target=_blank"],
              "@url":["ViewpointGroupExample.x3d","https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupExample.x3d","ViewpointGroupExample.wrl","https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupExample.wrl"],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["ViewpointGroupPrototype","defines a prototype","Click on this text to see","ViewpointGroupExample scene"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"],
                                "@size":0.5
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[1,1,0.2]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "Viewpoint":
            {
              "@description":"inside scope: ViewpointGroup",
              "@position":[0,0,5]
            }
          },
          { "Viewpoint":
            {
              "@description":"outside scope: ViewpointGroup",
              "@position":[0,0,12]
            }
          }
        ]
    }
  }
}