package Savage.Tools.Animation;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Lighting.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Networking.*;
import org.web3d.x3d.jsail.PointingDeviceSensor.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Text.*;
import org.web3d.x3d.jsail.Time.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> 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. </p>
 <p> Related links: Catalog page <a href="../../../../Tools/Animation/WaypointInterpolatorExampleIndex.html" target="_blank">WaypointInterpolatorExample</a>,  source <a href="../../../../Tools/Animation/WaypointInterpolatorExample.java">WaypointInterpolatorExample.java</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>, and <a href="https://www.web3d.org/x3d/content/X3dTooltips.html" target="_blank">X3D Tooltips</a>. </p>
	<table style="color:black; border:0px solid; border-spacing:10px 0px;">
        <caption>Scene Meta Information</caption>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center; padding:10px 0px;"><i>meta tags</i></td>
			<td style="text-align:left;   padding:10px 0px;">&nbsp; Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="../../../../Tools/Animation/WaypointInterpolatorExample.x3d">WaypointInterpolatorExample.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> 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. </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Don Brutzman, Curtis Blais, Jeff Weekley, Jane Wu </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 6 April 2001 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 23 August 2023 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> Image </i> </td>
			<td> <a href="../../../../Tools/Animation/WaypointInterpolatorExample.png">WaypointInterpolatorExample.png</a> </td>
		</tr>
		<tr style="color:burntorange">
			<td style="text-align:right; vertical-align: text-top;"> <i> warning </i> </td>
			<td> Cortona bug: TimeSensor set_cycleInterval has no effect, effectively ignoring routed totalDuration. Workaround: view calculated value for totalDuration, then set it in TimeSensor manually. </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> identifier </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorExample.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorExample.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> X3D-Edit 4.0, <a href="https://www.web3d.org/x3d/tools/X3D-Edit" target="_blank">https://www.web3d.org/x3d/tools/X3D-Edit</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../Tools/Animation/../../license.html">../../license.html</a> </td>
		</tr>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;" colspan="2">  &nbsp; </td>
		</tr>
	</table>

	<p>
		This program uses the
		<a href="https://www.web3d.org/specifications/java/X3DJSAIL.html" target="_blank">X3D Java Scene Access Interface Library (X3DJSAIL)</a>.
		It has been produced using the 
		<a href="https://www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">X3dToJava.xslt</a>
		stylesheet
	       (<a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">version control</a>)
                which is used to create Java source code from an original <code>.x3d</code> model.
	</p>

	* @author Don Brutzman, Curtis Blais, Jeff Weekley, Jane Wu
 */

public class WaypointInterpolatorExample
{
	/** Default constructor to create this object. */
	public WaypointInterpolatorExample ()
	{
	  initialize();
	}

	/** Create and initialize the X3D model for this object. */
	public final void initialize()
	{
            try { // catch-all
  x3dModel = new X3D().setProfile(X3D.PROFILE_IMMERSIVE).setVersion(X3D.VERSION_3_2)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("WaypointInterpolatorExample.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("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."))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Don Brutzman, Curtis Blais, Jeff Weekley, Jane Wu"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("6 April 2001"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("23 August 2023"))
    .addMeta(new meta().setName(meta.NAME_IMAGE      ).setContent("WaypointInterpolatorExample.png"))
    .addMeta(new meta().setName(meta.NAME_WARNING    ).setContent("Cortona bug: TimeSensor set_cycleInterval has no effect, effectively ignoring routed totalDuration. Workaround: view calculated value for totalDuration, then set it in TimeSensor manually."))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorExample.x3d"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addComments(" ====================================== ")
    .addComments(" To use WaypointInterpolator in your scene, copy/paste this definition verbatim first. ")
    .addChild(new WorldInfo().setTitle("WaypointInterpolatorExample.x3d"))
    .addChild(new ExternProtoDeclare("WaypointInterpolator").setName("WaypointInterpolator").setAppinfo("Reads waypoints and legSpeeds/legDurations/defaultSpeed to provide a customizable position/orientation interpolator.").setUrl(new String[] {"../../../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"})
      .addComments(" Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec) ")
      .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Short description of what is animated by this WaypointInterpolator."))
      .addField(new field().setName("waypoints").setType(field.TYPE_MFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Waypoints being traversed with interpolation of intermediate positions and orientations."))
      .addField(new field().setName("add_waypoint").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Add another single waypoint to array of waypoints recalculate interpolator values."))
      .addField(new field().setName("set_waypoints").setType(field.TYPE_MFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Replace all waypoints recalculate interpolator values."))
      .addField(new field().setName("pitchUpDownForVerticalWaypoints").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Whether to pitch child geometry (such as a vehicle) up or down to match vertical slope"))
      .addField(new field().setName("legSpeeds").setType(field.TYPE_MFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Units m/sec. If used, array lengths for legSpeeds and legDurations must be one less than number of waypoints."))
      .addField(new field().setName("legDurations").setType(field.TYPE_MFTIME).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Units in seconds. If used, array lengths for legSpeeds and legDurations must be one less than number of waypoints."))
      .addField(new field().setName("defaultSpeed").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Units m/sec."))
      .addField(new field().setName("turningRate").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("turningRate (degrees/second) also determines standoff distance prior to waypoint where turn commences. If 0 turns are instantaneous."))
      .addField(new field().setName("totalDuration").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("Output calculation summing all leg durations, useful for setting TimeSensor cycleInterval. Units in seconds."))
      .addComments(" interpolation fields ")
      .addField(new field().setName("set_fraction").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("exposed PositionInterpolator and OrientationInterpolator setting"))
      .addField(new field().setName("position_changed").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("exposed PositionInterpolator setting"))
      .addField(new field().setName("orientation_changed").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("exposed OrientationInterpolator setting"))
      .addComments(" display-related fields ")
      .addField(new field().setName("lineColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("default color for non-active line segments"))
      .addField(new field().setName("highlightSegmentColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("active segment highlight color"))
      .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("1.0 is completely transparent, 0.0 is completely opaque."))
      .addField(new field().setName("labelDisplayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("allowed values: none; waypoints (produce labels at each waypoint); or interpolation (produce single moving label at interpolator time course speed location)"))
      .addField(new field().setName("heightLabel").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("allowed values: altitude depth (negate Y value) none"))
      .addField(new field().setName("labelOffset").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("heightLabel relative location"))
      .addField(new field().setName("labelFontSize").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("heightLabel text size"))
      .addField(new field().setName("labelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("heightLabel text color"))
      .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("enable console output to trace script computations and prototype progress"))
      .addField(new field().setName("outputInitializationComputations").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Output the number of waypoints totalDistance and totalDuration to console upon initialization"))
      .addField(new field().setName("verticalDropLineColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("default color for vertical drop-line segments"))
      .addField(new field().setName("verticalDropLineTransparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("1.0 is completely transparent, 0.0 is completely opaque.")))
    .addComments(" ====================================== ")
    .addComments(" Here is another interesting prototype authoring tool. ")
    .addChild(new ExternProtoDeclare("HiddenViewpoint").setName("HiddenViewpoint").setAppinfo("Hidden viewpoint becomes active (binds) upon pointer selection to reveal an interesting view with an optionally label").setUrl(new String[] {"../../../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"})
      .addField(new field().setName("position").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("rotation").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("sensorRadius").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("activate").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY))
      .addField(new field().setName("label").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("labelOffset").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("labelFontSize").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("labelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT)))
    .addComments(" ====================================== ")
    .addComments(" Example instance follows prototype declaration ")
    .addChild(new Viewpoint().setDescription("WaypointInterpolator example").setOrientation(1.0,0.0,0.0,-0.3).setPosition(-1.0,5.0,13.0))
    .addChild(new Viewpoint().setDescription("Above, looking down").setOrientation(1.0,0.0,0.0,-1.57).setPosition(0.0,15.0,-5.0))
    .addChild(new Inline("CoordinateAxes").setUrl(new String[] {"../../../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"}))
    .addComments(" 10 second default cycleInterval should get overridden by 25.3 second computed totalDuration. ")
    .addChild(new TimeSensor("Clock").setCycleInterval(10.0).setLoop(true))
    .addChild(new ProtoInstance("WaypointInterpolator", "TrackBuilder").setContainerField("children")
      .addFieldValue(new fieldValue().setName("description").setValue("TrackBuilder"))
      .addComments(" Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec) ")
      .addFieldValue(new fieldValue().setName("waypoints").setValue(new MFVec3f(new MFVec3f(new double[] {-5.0,0.0,0.0,5.0,2.0,0.0,5.0,5.0,-10.0,4.9,2.0,-10.0,-5.0,0.0,-10.0,-5.0,0.0,0.0,-5.5,0.0,1.5,-7.0,0.5,2.0,-8.0,0.0,0.0,-5.0,0.0,0.0}))))
      .addFieldValue(new fieldValue().setName("pitchUpDownForVerticalWaypoints").setValue(false))
      .addFieldValue(new fieldValue().setName("legDurations").setValue(new double[] {1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0}))
      .addFieldValue(new fieldValue().setName("legSpeeds").setValue(new double[] {2.0,4.0,2.0,2.0,4.0,1.0,1.0,1.0,1.0}))
      .addFieldValue(new fieldValue().setName("defaultSpeed").setValue(5))
      .addFieldValue(new fieldValue().setName("turningRate").setValue(90))
      .addFieldValue(new fieldValue().setName("lineColor").setValue(new SFColor(1.0,0.0,0.0)))
      .addFieldValue(new fieldValue().setName("highlightSegmentColor").setValue(new SFColor(0.2,0.2,1.0)))
      .addFieldValue(new fieldValue().setName("transparency").setValue(0))
      .addFieldValue(new fieldValue().setName("labelDisplayMode").setValue("interpolation"))
      .addFieldValue(new fieldValue().setName("heightLabel").setValue("altitude"))
      .addFieldValue(new fieldValue().setName("labelOffset").setValue(new SFVec3f(0.0,1.2,0.0)))
      .addFieldValue(new fieldValue().setName("labelFontSize").setValue(0.5))
      .addFieldValue(new fieldValue().setName("labelColor").setValue(new SFColor(0.3,0.9,0.3)))
      .addFieldValue(new fieldValue().setName("traceEnabled").setValue(false))
      .addFieldValue(new fieldValue().setName("outputInitializationComputations").setValue(true)))
    .addChild(new ROUTE().setFromNode("Clock").setFromField("fraction_changed").setToNode("TrackBuilder").setToField("set_fraction"))
    .addChild(new ROUTE().setFromNode("TrackBuilder").setFromField("totalDuration").setToNode("Clock").setToField("set_cycleInterval"))
    .addChild(new Transform("TrackingTransform")
      .addComments(" Always align initial geometry with X axis ")
      .addChild(new Group()
        .addComments(" Point cone along X-axis ")
        .addChild(new Transform().setRotation(0.0,0.0,1.0,-1.57)
          .addChild(new Shape()
            .setGeometry(new Cone().setBottomRadius(0.4))
            .setAppearance(new Appearance("ConeAppearance")
              .setMaterial(new Material().setDiffuseColor(0.8,0.8,0.2)))))
        .addChild(new Transform().setTranslation(0.0,0.1,0.0)
          .addChild(new Shape()
            .setGeometry(new Cone().setBottomRadius(0.1).setHeight(0.8))
            .setAppearance(new Appearance().setUSE("ConeAppearance"))))
        .addChild(new Viewpoint().setDescription("Ride on").setOrientation(0.0,1.0,0.0,-1.57).setPosition(-4.0,1.0,0.0))
        .addChild(new Viewpoint().setDescription("Ride alongside").setPosition(0.0,0.0,5.0))
        .addChild(new Viewpoint().setDescription("Ride in front").setOrientation(0.0,1.0,0.0,1.57).setPosition(4.0,1.0,0.0))))
    .addChild(new ROUTE().setFromNode("TrackBuilder").setFromField("position_changed").setToNode("TrackingTransform").setToField("translation"))
    .addChild(new ROUTE().setFromNode("TrackBuilder").setFromField("orientation_changed").setToNode("TrackingTransform").setToField("rotation"))
    .addComments(" floor employs TouchSensor.isOver to stop/start animation ")
    .addChild(new Group("FloorAndToggleMarker")
      .addChild(new Transform().setTranslation(0.0,-0.1,-5.0)
        .addChild(new Shape()
          .setGeometry(new Box().setSize(10.0,0.1,10.0))
          .setAppearance(new Appearance("FloorAppearance")
            .setMaterial(new Material().setDiffuseColor(0.1,0.8,0.9)))))
      .addComments(" starting point marker toggles playback ")
      .addChild(new Transform().setTranslation(-5.0,0.0,0.0)
        .addChild(new TouchSensor("TouchBox").setDescription("Touch box to toggle playback"))
        .addChild(new ROUTE().setFromNode("TouchBox").setFromField("isOver").setToNode("Clock").setToField("enabled"))
        .addChild(new Shape()
          .setGeometry(new Box("TogglePlayback").setSize(0.1,0.8,0.1))
          .setAppearance(new Appearance("OrangeAppearance")
            .setMaterial(new Material().setDiffuseColor(0.8,0.5,0.2))))
        .addChild(new Transform().setTranslation(0.0,1.4,0.0)
          .addChild(new Billboard()
            .addChild(new Shape()
              .setGeometry(new Text().setString(new String[] {"isOver","toggles","motion","off/on"})
                .setFontStyle(new FontStyle().setJustify(FontStyle.JUSTIFY_MIDDLE_MIDDLE).setSize(0.3)))
              .setAppearance(new Appearance().setUSE("OrangeAppearance")))))
        .addComments(" Illuminate bottom of floor for HiddenViewpoint clarity ")
        .addChild(new PointLight().setLocation(0.0,-6.0,0.0).setRadius(10))))
    .addComments(" Example instance of clickable viewpoint prototype ")
    .addChild(new ProtoInstance("HiddenViewpoint", "TestHiddenViewpointPrototype").setContainerField("children")
      .addFieldValue(new fieldValue().setName("position").setValue(new SFVec3f(0.0,-0.5,0.0)))
      .addFieldValue(new fieldValue().setName("rotation").setValue(new SFRotation(0.0,1.0,0.0,2.5)))
      .addFieldValue(new fieldValue().setName("sensorRadius").setValue(1))
      .addFieldValue(new fieldValue().setName("label").setValue(new String[] {"HiddenViewpoint","test works!"}))
      .addFieldValue(new fieldValue().setName("labelOffset").setValue(new SFVec3f(1.0,-1.25,0.0)))
      .addFieldValue(new fieldValue().setName("labelFontSize").setValue(0.4))
      .addFieldValue(new fieldValue().setName("labelColor").setValue(new SFColor(1.0,0.0,0.0)))));
            }
            catch (Exception ex)
            {       
                System.err.println ("*** Further hints on X3DJSAIL errors and exceptions at");
                System.err.println ("*** https://www.web3d.org/specifications/java/X3DJSAIL.html");
                throw (ex);
            }
	}
	// end of initialize() method

	/** The initialized model object, created within initialize() method. */
	private X3D x3dModel;

	/** 
	 * Provide a 
	 * <a href="https://dzone.com/articles/java-copy-shallow-vs-deep-in-which-you-will-swim" target="_blank">shallow copy</a>
	 * of the X3D model.
	 * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html">X3D</a>
	 * @return WaypointInterpolatorExample model
	 */
	public X3D getX3dModel()
	{	  
		return x3dModel;
	}
	   
    /** 
     * Default main() method provided for test purposes, uses CommandLine to set global ConfigurationProperties for this object.
     * @param args array of input parameters, provided as arguments
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#handleArguments-java.lang.String:A-">X3D.handleArguments(args)</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#validationReport--">X3D.validationReport()</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html">CommandLine</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html#USAGE">CommandLine.USAGE</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html">ConfigurationProperties</a>
     */
    public static void main(String args[])
    {
        System.out.println("Build this X3D model, showing validation diagnostics...");
        X3D thisExampleX3dModel = new WaypointInterpolatorExample().getX3dModel();
//      System.out.println("X3D model construction complete.");
	
        // next handle command line arguments
        boolean hasArguments = (args != null) && (args.length > 0);
        boolean validate = true; // default
        boolean argumentsLoadNewModel = false;
        String  fileName = new String();

        if (args != null)
        {
                for (String arg : args)
                {
                        if (arg.toLowerCase().startsWith("-v") || arg.toLowerCase().contains("validate"))
                        {
                                validate = true; // making sure
                        }
                        if (arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3D) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_CLASSICVRML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3DB) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_VRML97) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_EXI) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_GZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_ZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_HTML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_XHTML))
                        {
                                argumentsLoadNewModel = true;
                                fileName = arg;
                        }
                }
        }
        if      (argumentsLoadNewModel)
                System.out.println("WARNING: \"Savage.Tools.Animation.WaypointInterpolatorExample\" model invocation is attempting to load file \"" + fileName + "\" instead of simply validating itself... file loading ignored.");
        else if (hasArguments) // if no arguments provided, this method produces usage warning
                thisExampleX3dModel.handleArguments(args);
	
        if (validate)
        {
            //  System.out.println("--- TODO fix duplicated outputs ---"); // omit when duplicated outputs problem is solved/refactored
		String validationResults = thisExampleX3dModel.validationReport();
            //  System.out.println("-----------------------------------"); // omit when duplicated outputs problem is solved/refactored
                System.out.print("Savage.Tools.Animation.WaypointInterpolatorExample self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

                // experimental: test X3DJSAIL output files
                // Tools/Animation/WaypointInterpolatorExample_JavaExport.* file validation is checked when building X3D Example Archives
                String filenameX3D  = "Tools/Animation/WaypointInterpolatorExample_JavaExport.x3d"; 
                String filenameX3DV = "Tools/Animation/WaypointInterpolatorExample_JavaExport.x3dv"; 
                String filenameJSON = "Tools/Animation/WaypointInterpolatorExample_JavaExport.json";
                thisExampleX3dModel.toFileX3D        (filenameX3D);
                thisExampleX3dModel.toFileClassicVRML(filenameX3DV);
// TODO         thisExampleX3dModel.toFileJSON       (filenameJSON);
        }
    }
}
