{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.2",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.2.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"WaypointInterpolatorExample.x3d"
          },
          {
            "@name":"description",
            "@content":"Example set of waypoints, plus either leg durations or speed(s), which demonstrates resulting position/orientation interpolation. Motion can be stopped/started by placing mouse over orange TouchSensor Box. A HiddenViewpoint also exists under the coordinate axes. Trace values are printed in the browser console."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman, Curtis Blais, Jeff Weekley, Jane Wu"
          },
          {
            "@name":"created",
            "@content":"6 April 2001"
          },
          {
            "@name":"modified",
            "@content":"23 August 2023"
          },
          {
            "@name":"Image",
            "@content":"WaypointInterpolatorExample.png"
          },
          {
            "@name":"warning",
            "@content":"Cortona bug: TimeSensor set_cycleInterval has no effect, effectively ignoring routed totalDuration. Workaround: view calculated value for totalDuration, then set it in TimeSensor manually."
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorExample.x3d"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../../license.html"
          },
          {
            "@name":"translated",
            "@content":"26 March 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":[
          {
            "#comment":"======================================"
          },
          {
            "#comment":"To use WaypointInterpolator in your scene, copy/paste this definition verbatim first."
          },
          { "WorldInfo":
            {
              "@title":"WaypointInterpolatorExample.x3d"
            }
          },
          { "ExternProtoDeclare":
            {
              "@name":"WaypointInterpolator",
              "@appinfo":"Reads waypoints and legSpeeds/legDurations/defaultSpeed to provide a customizable position/orientation interpolator.",
              "@url":["../../../Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d#WaypointInterpolator","https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d#WaypointInterpolator","../../../Savage/Tools/Animation/WaypointInterpolatorPrototype.wrl#WaypointInterpolator","https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.wrl#WaypointInterpolator"],
              "-children":[
                {
                  "#comment":"Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec)"
                },
                {
                  "#comment":"interpolation fields"
                },
                {
                  "#comment":"display-related fields"
                }
              ],
              "field": [
                {
                  "@name":"description",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Short description of what is animated by this WaypointInterpolator.",
                  "@type":"SFString"
                },
                {
                  "@name":"waypoints",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Waypoints being traversed with interpolation of intermediate positions and orientations.",
                  "@type":"MFVec3f"
                },
                {
                  "@name":"add_waypoint",
                  "@accessType":"inputOnly",
                  "@appinfo":"Add another single waypoint to array of waypoints recalculate interpolator values.",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"set_waypoints",
                  "@accessType":"inputOnly",
                  "@appinfo":"Replace all waypoints recalculate interpolator values.",
                  "@type":"MFVec3f"
                },
                {
                  "@name":"pitchUpDownForVerticalWaypoints",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Whether to pitch child geometry (such as a vehicle) up or down to match vertical slope",
                  "@type":"SFBool"
                },
                {
                  "@name":"legSpeeds",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Units m/sec. If used, array lengths for legSpeeds and legDurations must be one less than number of waypoints.",
                  "@type":"MFFloat"
                },
                {
                  "@name":"legDurations",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Units in seconds. If used, array lengths for legSpeeds and legDurations must be one less than number of waypoints.",
                  "@type":"MFTime"
                },
                {
                  "@name":"defaultSpeed",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Units m/sec.",
                  "@type":"SFFloat"
                },
                {
                  "@name":"turningRate",
                  "@accessType":"initializeOnly",
                  "@appinfo":"turningRate (degrees/second) also determines standoff distance prior to waypoint where turn commences. If 0 turns are instantaneous.",
                  "@type":"SFFloat"
                },
                {
                  "@name":"totalDuration",
                  "@accessType":"outputOnly",
                  "@appinfo":"Output calculation summing all leg durations, useful for setting TimeSensor cycleInterval. Units in seconds.",
                  "@type":"SFTime"
                },
                {
                  "@name":"set_fraction",
                  "@accessType":"inputOnly",
                  "@appinfo":"exposed PositionInterpolator and OrientationInterpolator setting",
                  "@type":"SFFloat"
                },
                {
                  "@name":"position_changed",
                  "@accessType":"outputOnly",
                  "@appinfo":"exposed PositionInterpolator setting",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"orientation_changed",
                  "@accessType":"outputOnly",
                  "@appinfo":"exposed OrientationInterpolator setting",
                  "@type":"SFRotation"
                },
                {
                  "@name":"lineColor",
                  "@accessType":"inputOutput",
                  "@appinfo":"default color for non-active line segments",
                  "@type":"SFColor"
                },
                {
                  "@name":"highlightSegmentColor",
                  "@accessType":"inputOutput",
                  "@appinfo":"active segment highlight color",
                  "@type":"SFColor"
                },
                {
                  "@name":"transparency",
                  "@accessType":"inputOutput",
                  "@appinfo":"1.0 is completely transparent, 0.0 is completely opaque.",
                  "@type":"SFFloat"
                },
                {
                  "@name":"labelDisplayMode",
                  "@accessType":"initializeOnly",
                  "@appinfo":"allowed values: none; waypoints (produce labels at each waypoint); or interpolation (produce single moving label at interpolator time course speed location)",
                  "@type":"SFString"
                },
                {
                  "@name":"heightLabel",
                  "@accessType":"initializeOnly",
                  "@appinfo":"allowed values: altitude depth (negate Y value) none",
                  "@type":"SFString"
                },
                {
                  "@name":"labelOffset",
                  "@accessType":"initializeOnly",
                  "@appinfo":"heightLabel relative location",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"labelFontSize",
                  "@accessType":"initializeOnly",
                  "@appinfo":"heightLabel text size",
                  "@type":"SFFloat"
                },
                {
                  "@name":"labelColor",
                  "@accessType":"initializeOnly",
                  "@appinfo":"heightLabel text color",
                  "@type":"SFColor"
                },
                {
                  "@name":"traceEnabled",
                  "@accessType":"initializeOnly",
                  "@appinfo":"enable console output to trace script computations and prototype progress",
                  "@type":"SFBool"
                },
                {
                  "@name":"outputInitializationComputations",
                  "@accessType":"initializeOnly",
                  "@appinfo":"Output the number of waypoints totalDistance and totalDuration to console upon initialization",
                  "@type":"SFBool"
                },
                {
                  "@name":"verticalDropLineColor",
                  "@accessType":"inputOutput",
                  "@appinfo":"default color for vertical drop-line segments",
                  "@type":"SFColor"
                },
                {
                  "@name":"verticalDropLineTransparency",
                  "@accessType":"inputOutput",
                  "@appinfo":"1.0 is completely transparent, 0.0 is completely opaque.",
                  "@type":"SFFloat"
                }
              ]
            }
          },
          {
            "#comment":"======================================"
          },
          {
            "#comment":"Here is another interesting prototype authoring tool."
          },
          { "ExternProtoDeclare":
            {
              "@name":"HiddenViewpoint",
              "@appinfo":"Hidden viewpoint becomes active (binds) upon pointer selection to reveal an interesting view with an optionally label",
              "@url":["../../../Savage/Tools/Animation/HiddenViewpointPrototype.x3d#HiddenViewpoint","https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/HiddenViewpointPrototype.x3d#HiddenViewpoint","../../../Savage/Tools/Animation/HiddenViewpointPrototype.wrl#HiddenViewpoint","https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/HiddenViewpointPrototype.wrl#HiddenViewpoint"],
              "field": [
                {
                  "@name":"position",
                  "@accessType":"inputOutput",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"rotation",
                  "@accessType":"inputOutput",
                  "@type":"SFRotation"
                },
                {
                  "@name":"sensorRadius",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"activate",
                  "@accessType":"inputOnly",
                  "@type":"SFBool"
                },
                {
                  "@name":"label",
                  "@accessType":"inputOutput",
                  "@type":"MFString"
                },
                {
                  "@name":"labelOffset",
                  "@accessType":"inputOutput",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"labelFontSize",
                  "@accessType":"initializeOnly",
                  "@type":"SFFloat"
                },
                {
                  "@name":"labelColor",
                  "@accessType":"inputOutput",
                  "@type":"SFColor"
                }
              ]
            }
          },
          {
            "#comment":"======================================"
          },
          {
            "#comment":"Example instance follows prototype declaration"
          },
          { "Viewpoint":
            {
              "@description":"WaypointInterpolator example",
              "@orientation":[1,0,0,-0.3],
              "@position":[-1,5,13]
            }
          },
          { "Viewpoint":
            {
              "@description":"Above, looking down",
              "@orientation":[1,0,0,-1.57],
              "@position":[0,15,-5]
            }
          },
          { "Inline":
            {
              "@DEF":"CoordinateAxes",
              "@url":["../../../Savage/Tools/Authoring/CoordinateAxes.x3d","https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.x3d","https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.x3d","../../../Savage/Tools/Authoring/CoordinateAxes.wrl","https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.wrl","https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.wrl"]
            }
          },
          {
            "#comment":"10 second default cycleInterval should get overridden by 25.3 second computed totalDuration."
          },
          { "TimeSensor":
            {
              "@DEF":"Clock",
              "@cycleInterval":10.0,
              "@loop":true
            }
          },
          { "ProtoInstance":
            {
              "@name":"WaypointInterpolator",
              "@DEF":"TrackBuilder",
              "fieldValue": [
                {
                  "@name":"description",
                  "@value":"TrackBuilder"
                },
                {
                  "@name":"waypoints",
                  "@value":[-5,0,0,5,2,0,5,5,-10,4.9,2,-10,-5,0,-10,-5,0,0,-5.5,0,1.5,-7,0.5,2,-8,0,0,-5,0,0]
                },
                {
                  "@name":"pitchUpDownForVerticalWaypoints",
                  "@value":false
                },
                {
                  "@name":"legDurations",
                  "@value":[1,2,3,1,2,3,1,2,3]
                },
                {
                  "@name":"legSpeeds",
                  "@value":[2,4,2,2,4,1,1,1,1]
                },
                {
                  "@name":"defaultSpeed",
                  "@value":5
                },
                {
                  "@name":"turningRate",
                  "@value":90
                },
                {
                  "@name":"lineColor",
                  "@value":[1,0,0]
                },
                {
                  "@name":"highlightSegmentColor",
                  "@value":[0.2,0.2,1]
                },
                {
                  "@name":"transparency",
                  "@value":0
                },
                {
                  "@name":"labelDisplayMode",
                  "@value":"interpolation"
                },
                {
                  "@name":"heightLabel",
                  "@value":"altitude"
                },
                {
                  "@name":"labelOffset",
                  "@value":[0,1.2,0]
                },
                {
                  "@name":"labelFontSize",
                  "@value":0.5
                },
                {
                  "@name":"labelColor",
                  "@value":[0.3,0.9,0.3]
                },
                {
                  "@name":"traceEnabled",
                  "@value":false
                },
                {
                  "@name":"outputInitializationComputations",
                  "@value":true
                }
              ],
              "-children":[
                {
                  "#comment":"Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec)"
                }
              ]
            }
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"set_fraction",
              "@toNode":"TrackBuilder"
            }
          },
          { "ROUTE":
            {
              "@fromField":"totalDuration",
              "@fromNode":"TrackBuilder",
              "@toField":"set_cycleInterval",
              "@toNode":"Clock"
            }
          },
          { "Transform":
            {
              "@DEF":"TrackingTransform",
              "-children":[
                {
                  "#comment":"Always align initial geometry with X axis"
                },
                { "Group":
                  {
                    "-children":[
                      {
                        "#comment":"Point cone along X-axis"
                      },
                      { "Transform":
                        {
                          "@rotation":[0,0,1,-1.57],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Cone":
                                    {
                                      "@bottomRadius":0.4
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@DEF":"ConeAppearance",
                                      "-material":
                                        { "Material":
                                          {
                                            "@diffuseColor":[0.8,0.8,0.2]
                                          }
                                        }
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      },
                      { "Transform":
                        {
                          "@translation":[0,0.1,0],
                          "-children":[
                            { "Shape":
                              {
                                "-geometry":
                                  { "Cone":
                                    {
                                      "@bottomRadius":0.1,
                                      "@height":0.8
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"ConeAppearance"
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      },
                      { "Viewpoint":
                        {
                          "@description":"Ride on",
                          "@orientation":[0,1,0,-1.57],
                          "@position":[-4,1,0]
                        }
                      },
                      { "Viewpoint":
                        {
                          "@description":"Ride alongside",
                          "@position":[0,0,5]
                        }
                      },
                      { "Viewpoint":
                        {
                          "@description":"Ride in front",
                          "@orientation":[0,1,0,1.57],
                          "@position":[4,1,0]
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          { "ROUTE":
            {
              "@fromField":"position_changed",
              "@fromNode":"TrackBuilder",
              "@toField":"translation",
              "@toNode":"TrackingTransform"
            }
          },
          { "ROUTE":
            {
              "@fromField":"orientation_changed",
              "@fromNode":"TrackBuilder",
              "@toField":"rotation",
              "@toNode":"TrackingTransform"
            }
          },
          {
            "#comment":"floor employs TouchSensor.isOver to stop/start animation"
          },
          { "Group":
            {
              "@DEF":"FloorAndToggleMarker",
              "-children":[
                { "Transform":
                  {
                    "@translation":[0,-0.1,-5],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Box":
                              {
                                "@size":[10,0.1,10]
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@DEF":"FloorAppearance",
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[0.1,0.8,0.9]
                                    }
                                  }
                              }
                            }
                        }
                      }
                    ]
                  }
                },
                {
                  "#comment":"starting point marker toggles playback"
                },
                { "Transform":
                  {
                    "@translation":[-5,0,0],
                    "-children":[
                      { "TouchSensor":
                        {
                          "@DEF":"TouchBox",
                          "@description":"Touch box to toggle playback"
                        }
                      },
                      { "ROUTE":
                        {
                          "@fromField":"isOver",
                          "@fromNode":"TouchBox",
                          "@toField":"enabled",
                          "@toNode":"Clock"
                        }
                      },
                      { "Shape":
                        {
                          "-geometry":
                            { "Box":
                              {
                                "@DEF":"TogglePlayback",
                                "@size":[0.1,0.8,0.1]
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "@DEF":"OrangeAppearance",
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[0.8,0.5,0.2]
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "Transform":
                        {
                          "@translation":[0,1.4,0],
                          "-children":[
                            { "Billboard":
                              {
                                "-children":[
                                  { "Shape":
                                    {
                                      "-geometry":
                                        { "Text":
                                          {
                                            "@string":["isOver","toggles","motion","off/on"],
                                            "-fontStyle":
                                              { "FontStyle":
                                                {
                                                  "@justify":["MIDDLE","MIDDLE"],
                                                  "@size":0.3
                                                }
                                              }
                                          }
                                        },
                                      "-appearance":
                                        { "Appearance":
                                          {
                                            "@USE":"OrangeAppearance"
                                          }
                                        }
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      },
                      {
                        "#comment":"Illuminate bottom of floor for HiddenViewpoint clarity"
                      },
                      { "PointLight":
                        {
                          "@location":[0,-6,0],
                          "@radius":10
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "#comment":"Example instance of clickable viewpoint prototype"
          },
          { "ProtoInstance":
            {
              "@name":"HiddenViewpoint",
              "@DEF":"TestHiddenViewpointPrototype",
              "fieldValue": [
                {
                  "@name":"position",
                  "@value":[0,-0.5,0]
                },
                {
                  "@name":"rotation",
                  "@value":[0,1,0,2.5]
                },
                {
                  "@name":"sensorRadius",
                  "@value":1
                },
                {
                  "@name":"label",
                  "@value":["HiddenViewpoint","test works!"]
                },
                {
                  "@name":"labelOffset",
                  "@value":[1,-1.25,0]
                },
                {
                  "@name":"labelFontSize",
                  "@value":0.4
                },
                {
                  "@name":"labelColor",
                  "@value":[1,0,0]
                }
              ]
            }
          }
        ]
    }
  }
}