package Savage.AircraftFixedWing.F18BlueAngelUnitedStates;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.EnvironmentalEffects.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Interpolation.*;
import org.web3d.x3d.jsail.Networking.*;
import org.web3d.x3d.jsail.PointingDeviceSensor.*;
import org.web3d.x3d.jsail.Scripting.*;
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> This prototype performs to raise and lower rear right wheels and axle. The clickable axle triggers an animation. </p>
 <p> Related links: Catalog page <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightPrototypeIndex.html" target="_blank">WheelsRearRightPrototype</a>,  source <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightPrototype.java">WheelsRearRightPrototype.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="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightPrototype.x3d">WheelsRearRightPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> This prototype performs to raise and lower rear right wheels and axle. The clickable axle triggers an animation. </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Etsuko Lippi </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 18 October 2001 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 20 October 2019 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> X3D-Edit 3.2, <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> identifier </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightPrototype.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> subject </i> </td>
			<td> rear right wheel, animation of gear up and down, Prototype </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/../../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 Etsuko Lippi
 */

public class WheelsRearRightPrototype
{
	/** Default constructor to create this object. */
	public WheelsRearRightPrototype ()
	{
	  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_0)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("WheelsRearRightPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("This prototype performs to raise and lower rear right wheels and axle. The clickable axle triggers an animation."))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Etsuko Lippi"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("18 October 2001"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("20 October 2019"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_SUBJECT    ).setContent("rear right wheel, animation of gear up and down, Prototype"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setTitle("WheelsRearRightPrototype.x3d"))
    .addChild(new ProtoDeclare("WheelsRearRight").setName("WheelsRearRight")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("gearup").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("boolean eventIn: true = wheels up false = wheels down."))
        .addField(new field().setName("animationStartTime").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INPUTONLY))
        .addField(new field().setName("gearupOut").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
        .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(false)))
      .setProtoBody(new ProtoBody()
        .addChild(new Group()
          .addChild(new Transform("WheelsRearTransform").setCenter(0.0,3.8,0.0)
            .addChild(new Transform("WheelsRearAxleTransform").setCenter(0.02,0.2,1.72)
              .addChild(new Group()
                .addComments(" wheels axis connecting to fuselage ")
                .addChild(new Transform("WheelTransform").setScale(1.2,1.2,1.2)
                  .addChild(new Transform().setScale(0.3,0.3,0.3)
                    .addChild(new Transform().setRotation(0.0,1.0,0.0,1.571)
                      .addChild(new Shape("wheel")
                        .setAppearance(new Appearance()
                          .setMaterial(new Material("black1").setDiffuseColor(0.0,0.0,0.0).setShininess(0.125).setSpecularColor(0.2,0.2,0.2)))
                        .setGeometry(new Extrusion().setCreaseAngle(3.14).setCrossSection(new MFVec2f(new double[] {0.00,1.30,.494,1.196,.923,.923,1.196,.494,1.30,0.00,1.196,-.494,.923,-.923,.494,-1.196,0.00,-1.30})).setSpine(new MFVec3f(new double[] {0.0,0.0,1.30,0.0,.494,1.196,0.0,.923,.923,0.0,1.196,.494,0.0,1.30,0.00,0.0,1.196,-.494,0.0,.923,-.923,0.0,.494,-1.196,0.0,0.00,-1.30,0.0,-.494,-1.196,0.0,-.923,-.923,0.0,-1.196,-.494,0.0,-1.30,0.0,0.0,-1.196,.494,0.0,-.923,.923,0.0,-.494,1.196,0.0,0.00,1.30}))))
                      .addChild(new Shape("inside_wheel")
                        .setAppearance(new Appearance("white1")
                          .setMaterial(new Material().setDiffuseColor(1.0,1.0,1.0)))
                        .setGeometry(new Extrusion().setCrossSection(new MFVec2f(new double[] {0.00,1.30,0.10,1.30,0.10,0.00,0.10,-1.30,0.00,-1.30,0.00,0.00,0.00,1.30})).setSpine(new MFVec3f(new double[] {0.0,0.0,1.30,0.0,.494,1.196,0.0,.923,.923,0.0,1.196,.494,0.0,1.30,0.00,0.0,1.196,-.494,0.0,.923,-.923,0.0,.494,-1.196,0.0,0.00,-1.30,0.0,-.494,-1.196,0.0,-.923,-.923,0.0,-1.196,-.494,0.0,-1.30,0.0,0.0,-1.196,.494,0.0,-.923,.923,0.0,-.494,1.196,0.0,0.00,1.30})))))
                    .addChild(new Transform().setRotation(0.0,1.0,0.0,1.571)
                      .addChild(new Shape()
                        .setAppearance(new Appearance().setUSE("white1"))
                        .setGeometry(new Extrusion().setCrossSection(new MFVec2f(new double[] {-0.10,1.30,0.00,1.30,0.00,0.00,0.00,-1.30,-0.10,-1.30,-0.10,0.00,-0.10,1.30})).setSpine(new MFVec3f(new double[] {0.0,0.0,1.30,0.0,.494,1.196,0.0,.923,.923,0.0,1.196,.494,0.0,1.30,0.00,0.0,1.196,-.494,0.0,.923,-.923,0.0,.494,-1.196,0.0,0.00,-1.30,0.0,-.494,-1.196,0.0,-.923,-.923,0.0,-1.196,-.494,0.0,-1.30,0.0,0.0,-1.196,.494,0.0,-.923,.923,0.0,-.494,1.196,0.0,0.00,1.30})))))
                    .addChild(new Transform().setRotation(0.0,1.0,0.0,1.571)
                      .addChild(new Shape()
                        .setAppearance(new Appearance()
                          .setMaterial(new Material().setDiffuseColor(0.0,0.25,0.5)))
                        .setGeometry(new Extrusion().setCrossSection(new MFVec2f(new double[] {-0.30,1.30,-0.10,1.30,-0.10,0.00,-0.10,-1.30,-0.30,-1.30,-0.30,0.00,-0.30,1.30})).setSpine(new MFVec3f(new double[] {0.0,0.0,1.30,0.0,.494,1.196,0.0,.923,.923,0.0,1.196,.494,0.0,1.30,0.00,0.0,1.196,-.494,0.0,.923,-.923,0.0,.494,-1.196,0.0,0.00,-1.30,0.0,-.494,-1.196,0.0,-.923,-.923,0.0,-1.196,-.494,0.0,-1.30,0.0,0.0,-1.196,.494,0.0,-.923,.923,0.0,-.494,1.196,0.0,0.00,1.30}))))))
                  .addChild(new Transform().setTranslation(0.0,0.0,0.30)
                    .addChild(new Inline("Hub").setUrl(new String[] {"Hub.wrl","https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/Hub.wrl","Hub.x3d","https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/Hub.x3d"})))
                  .addChild(new Transform().setTranslation(0.0,0.0,-0.30)
                    .addChild(new Inline().setUSE("Hub")))
                  .addChild(new TouchSensor("WheelTouchSensor").setDescription("pointer spins wheel"))
                  .addChild(new TimeSensor("Clock").setCycleInterval(0.5).setEnabled(false).setLoop(true))
                  .addChild(new OrientationInterpolator("WheelInterpolator").setKey(new double[] {0.0,0.5,1.0}).setKeyValue(new MFRotation(new double[] {0.0,0.0,1.0,0.0,0.0,0.0,1.0,3.14,0.0,0.0,1.0,6.28})))
                  .addChild(new ROUTE().setFromNode("WheelTouchSensor").setFromField("isOver").setToNode("Clock").setToField("set_enabled"))
                  .addChild(new ROUTE().setFromNode("Clock").setFromField("fraction_changed").setToNode("WheelInterpolator").setToField("set_fraction"))
                  .addChild(new ROUTE().setFromNode("WheelInterpolator").setFromField("value_changed").setToNode("WheelTransform").setToField("set_rotation"))))
              .addChild(new Group()
                .addChild(new Transform("JointsAxisAndAssistantsTest")
                  .addChild(new Group("JointsAxisAndAssistants")
                    .addChild(new Transform().setRotation(-0.13,0.98,-0.13,1.59).setScale(0.1,0.1,0.1).setTranslation(0.0,0.15,1.55)
                      .addComments(" Joint center ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance("AxleColor")
                          .setMaterial(new Material().setAmbientIntensity(0.3).setDiffuseColor(0.3,0.3,0.3).setShininess(0.20).setSpecularColor(0.50,0.50,0.60)))
                        .setGeometry(new Extrusion("joint").setCreaseAngle(2.5).setCrossSection(new MFVec2f(new double[] {0.00,1.30,.494,1.196,.923,.923,1.196,.494,1.30,0.00,1.196,-.494,.923,-.923,.494,-1.196,0.00,-1.30,-.494,-1.196,-.923,-.923,-1.196,-.494,-1.30,-0.00,-1.196,.494,-.923,.923,-.494,1.196,0.00,1.30})).setSpine(new MFVec3f(new double[] {-2.5,1.5,0.0,-2.5,1.0,0.0,-2.0,0.0,0.0,-2.0,0.0,0.0,-1.5,-1.0,0.0,-0.5,-1.5,0.0,0.5,-1.5,0.0,1.5,-1.5,0.0,2.0,-1.0,0.0})))))
                    .addChild(new Transform().setRotation(-0.13,0.98,-0.13,1.59).setScale(0.07,0.07,0.07).setTranslation(0.30,0.15,1.55)
                      .addComments(" Joint side ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance().setUSE("AxleColor"))
                        .setGeometry(new Extrusion().setUSE("joint"))))
                    .addChild(new Transform().setRotation(-0.13,0.98,-0.13,1.59).setScale(0.07,0.07,0.07).setTranslation(-0.30,0.15,1.55)
                      .addComments(" Joint side ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance().setUSE("AxleColor"))
                        .setGeometry(new Extrusion().setUSE("joint"))))
                    .addChild(new Transform().setRotation(1.0,0.0,0.0,1.57).setScale(0.7,0.7,0.7).setTranslation(0.0,0.0,0.5)
                      .addComments(" Wheel connected axis. (black) ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance().setUSE("AxleColor"))
                        .setGeometry(new Cylinder().setHeight(1.0).setRadius(0.1))))
                    .addChild(new Transform().setRotation(1.0,0.0,0.0,1.57).setScale(0.7,0.7,0.7).setTranslation(0.0,0.0,0.65)
                      .addComments(" The second axis. (black) ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance().setUSE("AxleColor"))
                        .setGeometry(new Cylinder().setHeight(0.4).setRadius(0.25))))
                    .addChild(new Transform().setRotation(1.0,0.0,0.0,1.57).setScale(0.7,0.7,0.7).setTranslation(0.0,0.0,1.1)
                      .addComments(" assistant axle for rear wheel(white) ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance()
                          .setMaterial(new Material().setDiffuseColor(1.0,1.0,1.0)))
                        .setGeometry(new Cylinder().setHeight(1).setRadius(0.3))))
                    .addChild(new Transform().setRotation(1.0,0.0,0.0,1.57).setScale(0.7,0.7,0.7).setTranslation(0.3,0.0,1.1)
                      .addComments(" assistant axle for rear wheel(white) ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance("AssistantAxleColor")
                          .setMaterial(new Material().setDiffuseColor(1.0,1.0,1.0)))
                        .setGeometry(new Cylinder().setHeight(1).setRadius(0.3))))
                    .addChild(new Transform().setRotation(1.0,0.0,0.0,1.57).setScale(0.7,0.7,0.7).setTranslation(-0.3,0.0,1.1)
                      .addComments(" assistant axle for rear wheel(white) ")
                      .addChild(new Shape()
                        .setAppearance(new Appearance().setUSE("AssistantAxleColor"))
                        .setGeometry(new Cylinder().setHeight(1).setRadius(0.3))))))))
            .addChild(new Transform()
              .addChild(new Group("RearAxles")
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.7,0.7,0.7).setTranslation(0.0,1.05,2.15)
                  .addComments(" main axle for rear wheels (white) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AssistantAxleColor"))
                    .setGeometry(new Box().setSize(0.5,3.0,0.5))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.7,0.7,0.7).setTranslation(0.3,0.8,2.0)
                  .addComments(" assistant axle for rear wheel (white) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AssistantAxleColor"))
                    .setGeometry(new Cylinder().setRadius(0.2))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.7,0.7,0.7).setTranslation(0.3,1.5,2.3)
                  .addComments(" assistant axle for rear wheel (white) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AssistantAxleColor"))
                    .setGeometry(new Cylinder().setRadius(0.3))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.7,0.7,0.7).setTranslation(-0.3,0.8,2.0)
                  .addComments(" assistant axle for rear wheel (white) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AssistantAxleColor"))
                    .setGeometry(new Cylinder().setRadius(0.2))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.7,0.7,0.7).setTranslation(-0.3,1.5,2.3)
                  .addComments(" assistant axle for rear wheel (white) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AssistantAxleColor"))
                    .setGeometry(new Cylinder().setRadius(0.3))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.5,0.5,0.5).setTranslation(-0.3,0.2,1.72)
                  .addComments(" assistant axis under axle (black) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AxleColor"))
                    .setGeometry(new Cylinder().setHeight(0.7).setRadius(0.2))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.5,0.5,0.5).setTranslation(0.0,0.2,1.72)
                  .addComments(" assistant axis under axle (black) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AxleColor"))
                    .setGeometry(new Cylinder().setHeight(0.7).setRadius(0.2))))
                .addChild(new Transform().setRotation(1.0,0.0,0.0,0.44).setScale(0.5,0.5,0.5).setTranslation(0.3,0.2,1.72)
                  .addComments(" assistant axis under axle (black) ")
                  .addChild(new Shape()
                    .setAppearance(new Appearance().setUSE("AxleColor"))
                    .setGeometry(new Cylinder().setHeight(0.7).setRadius(0.2))))))
            .addChild(new Script("GearUpDownScript").setSourceCode("""
ecmascript:

function gearup(value, timeStamp) {
  
 if (value == true)       //Gear Up
 {
      	tracePrint ('[GearUp] ' );
      	tracePrint ('value = ' + value);
      	gearupOut = true;    	
      
      	kV1 = new SFRotation (new SFVec3f (0, -1, 0), 0.0);  
     	kV2 = new SFRotation (new SFVec3f (0, -1, 0), 0.44);
      	kV3 = new SFRotation(new SFVec3f (0, -1, 0), 1.22);
        kV4 = new SFRotation(new SFVec3f (0.21, -0.96, -0.19), 1.72);
      	keyValue = new MFRotation(kV1, kV2, kV3, kV4);  

	kV1Second = new SFRotation (new SFVec3f (0, 0, -1), 0.0);  
     	kV2Second = new SFRotation (new SFVec3f (0, 0, -1), 0.44);
      	kV3Second = new SFRotation(new SFVec3f (0, 0, -1), 0.80);
        kV4Second = new SFRotation(new SFVec3f (-0.21, 0.18, -0.95), 1.62);
      	keyValue2 = new MFRotation(kV1Second, kV2Second, kV3Second, kV4Second);  
      	//tracePrint ('[keyValue = ]' + keyValue);      
  
 }
 else        //Gear Down
 {
      	tracePrint ('[GearDown] ' );
      	tracePrint ('value = ' + value);
      	gearupOut = true;
     	
      	keyValue = new MFRotation(kV4, kV3, kV2, kV1);  
        keyValue2 = new MFRotation(kV4Second, kV3Second, kV2Second, kV1Second);  
      	//tracePrint ('[keyValue = ]' + keyValue);             
 }
 
}

function set_fraction (value, timeStamp)
{
	//tracePrint('time fraction = ' + value);
}

function animationStartTime(value, timeStamp)
{	
	tracePrint('The Start Time is: ' + value);
	clockStartTime = value;
}

function tracePrint (outputString)
{
	if (traceEnabled) Browser.println ('[WheelsRearRightPrototype] ' + outputString);
}
""")
              .addField(new field().setName("gearup").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("eventIn: boolean true: wheels up false: wheels down"))
              .addField(new field().setName("gearupOut").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("keyValue").setType(field.TYPE_MFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("keyValue2").setType(field.TYPE_MFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("kV1").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV1Second").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV2").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV2Second").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV3").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV3Second").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV4").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("kV4Second").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .addField(new field().setName("set_fraction").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY))
              .addField(new field().setName("animationStartTime").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INPUTONLY))
              .addField(new field().setName("clockStartTime").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .setIS(new IS()
                .addConnect(new connect().setNodeField("gearup").setProtoField("gearup"))
                .addConnect(new connect().setNodeField("animationStartTime").setProtoField("animationStartTime"))
                .addConnect(new connect().setNodeField("gearupOut").setProtoField("gearupOut"))
                .addConnect(new connect().setNodeField("traceEnabled").setProtoField("traceEnabled"))))
            .addChild(new OrientationInterpolator("GearUpDownInterpolator").setKey(new double[] {0.0,0.5,0.75,1.0}).setKeyValue(new MFRotation(new double[] {0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.44,0.0,1.0,0.0,1.22,0.21,0.95,0.21,1.62})))
            .addChild(new OrientationInterpolator("GearUpDownInterpolator2").setKey(new double[] {0.0,0.25,0.5,1.0}).setKeyValue(new MFRotation(new double[] {0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.44,0.0,0.0,1.0,0.80,-0.21,-0.21,0.95,1.62})))
            .addChild(new TimeSensor("ClockAxleGearUpDownFirst").setCycleInterval(4))
            .addChild(new TimeSensor("ClockAxleGearUpDownSecond").setCycleInterval(8))
            .addChild(new ROUTE().setFromNode("GearUpDownScript").setFromField("clockStartTime").setToNode("ClockAxleGearUpDownFirst").setToField("set_startTime"))
            .addChild(new ROUTE().setFromNode("GearUpDownScript").setFromField("clockStartTime").setToNode("ClockAxleGearUpDownSecond").setToField("set_startTime"))
            .addChild(new ROUTE().setFromNode("GearUpDownScript").setFromField("gearupOut").setToNode("ClockAxleGearUpDownFirst").setToField("set_enabled"))
            .addChild(new ROUTE().setFromNode("GearUpDownScript").setFromField("gearupOut").setToNode("ClockAxleGearUpDownSecond").setToField("set_enabled"))
            .addChild(new ROUTE().setFromNode("GearUpDownScript").setFromField("keyValue").setToNode("GearUpDownInterpolator").setToField("set_keyValue"))
            .addChild(new ROUTE().setFromNode("GearUpDownScript").setFromField("keyValue2").setToNode("GearUpDownInterpolator2").setToField("set_keyValue"))
            .addChild(new ROUTE().setFromNode("ClockAxleGearUpDownFirst").setFromField("fraction_changed").setToNode("GearUpDownInterpolator").setToField("set_fraction"))
            .addChild(new ROUTE().setFromNode("ClockAxleGearUpDownSecond").setFromField("fraction_changed").setToNode("GearUpDownInterpolator2").setToField("set_fraction"))
            .addChild(new ROUTE().setFromNode("ClockAxleGearUpDownFirst").setFromField("fraction_changed").setToNode("GearUpDownScript").setToField("set_fraction"))
            .addChild(new ROUTE().setFromNode("GearUpDownInterpolator").setFromField("value_changed").setToNode("WheelsRearAxleTransform").setToField("set_rotation"))
            .addChild(new ROUTE().setFromNode("GearUpDownInterpolator2").setFromField("value_changed").setToNode("WheelsRearTransform").setToField("set_rotation"))))))
    .addChild(new Background().setSkyColor(new MFColor(new double[] {0.7,0.7,0.7})))
    .addChild(new Anchor().setDescription("WheelsRearRightExample").setParameter(new String[] {"target=_blank"}).setUrl(new String[] {"WheelsRearRightExample.wrl","../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightExample.wrl","https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightExample.wrl","WheelsRearRightExample.x3d","../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightExample.x3d","https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearRightExample.x3d"})
      .addChild(new Shape()
        .setGeometry(new Text().setString(new String[] {"WheelsRearRightPrototype","is a prototype definition file","","To see an example scene","click on this text and view","WheelsRearRightExample"})
          .setFontStyle(new FontStyle().setJustify(FontStyle.JUSTIFY_MIDDLE_MIDDLE)))
        .setAppearance(new Appearance()))));
            }
            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 WheelsRearRightPrototype 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 WheelsRearRightPrototype().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.AircraftFixedWing.F18BlueAngelUnitedStates.WheelsRearRightPrototype\" 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.AircraftFixedWing.F18BlueAngelUnitedStates.WheelsRearRightPrototype self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

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