<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'>
  <head>
    <meta content='WheelsRearLeftPrototype.x3d' name='title'/>
    <meta content='This prototype performs the movement to raise and lower rear left wheels and axle. The clickable axle triggers an animation.' name='description'/>
    <meta content='Etsuko Lippi' name='creator'/>
    <meta content='18 October 2001' name='created'/>
    <meta content='20 October 2019' name='modified'/>
    <meta content='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearLeftPrototype.x3d' name='identifier'/>
    <meta content='rear left wheel Prototype, gear up and down animation' name='subject'/>
    <meta content='../../license.html' name='license'/>
  </head>
  <Scene>
    <WorldInfo title='WheelsRearLeftPrototype.x3d'/>
    <ProtoDeclare name='WheelsRearLeft'>
      <ProtoInterface>
        <field accessType='inputOnly' appinfo='boolean eventIn: true = wheels up false = wheels down.' name='gearup' type='SFBool'/>
        <field accessType='inputOnly' name='animationStartTime' type='SFTime'/>
        <field accessType='outputOnly' name='gearupOut' type='SFBool'/>
        <field accessType='initializeOnly' name='traceEnabled' type='SFBool' value='false'/>
      </ProtoInterface>
      <ProtoBody>
        <Group>
          <Transform DEF='WheelsRearTransform' center='0 3.8 0'>
            <Transform DEF='WheelsRearAxleTransform' center='0.02 0.2 1.72'>
              <Group>
                <!-- wheels axis connecting to fuselage -->
                <Transform DEF='WheelTransform' scale='1.2 1.2 1.2'>
                  <Transform scale='0.3 0.3 0.3'>
                    <Transform rotation='0 1 0 1.571'>
                      <Shape DEF='wheel'>
                        <Appearance>
                          <Material DEF='black1' diffuseColor='0 0 0' shininess='0.125' specularColor='0.2 0.2 0.2'/>
                        </Appearance>
                        <Extrusion creaseAngle='3.14' crossSection='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' spine='0 0 1.30 0 .494 1.196 0 .923 .923 0 1.196 .494 0 1.30 0.00 0 1.196 -.494 0 .923 -.923 0 .494 -1.196 0 0.00 -1.30 0 -.494 -1.196 0 -.923 -.923 0 -1.196 -.494 0 -1.30 0 0 -1.196 .494 0 -.923 .923 0 -.494 1.196 0 0.00 1.30'/>
                      </Shape>
                      <Shape DEF='inside_wheel'>
                        <Appearance DEF='white1'>
                          <Material diffuseColor='1 1 1'/>
                        </Appearance>
                        <Extrusion crossSection='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' spine='0 0 1.30 0 .494 1.196 0 .923 .923 0 1.196 .494 0 1.30 0.00 0 1.196 -.494 0 .923 -.923 0 .494 -1.196 0 0.00 -1.30 0 -.494 -1.196 0 -.923 -.923 0 -1.196 -.494 0 -1.30 0 0 -1.196 .494 0 -.923 .923 0 -.494 1.196 0 0.00 1.30'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='0 1 0 1.571'>
                      <Shape>
                        <Appearance USE='white1'/>
                        <Extrusion crossSection='-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' spine='0 0 1.30 0 .494 1.196 0 .923 .923 0 1.196 .494 0 1.30 0.00 0 1.196 -.494 0 .923 -.923 0 .494 -1.196 0 0.00 -1.30 0 -.494 -1.196 0 -.923 -.923 0 -1.196 -.494 0 -1.30 0 0 -1.196 .494 0 -.923 .923 0 -.494 1.196 0 0.00 1.30'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='0 1 0 1.571'>
                      <Shape>
                        <Appearance>
                          <Material diffuseColor='0 0.25 0.5'/>
                        </Appearance>
                        <Extrusion crossSection='-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' spine='0 0 1.30 0 .494 1.196 0 .923 .923 0 1.196 .494 0 1.30 0.00 0 1.196 -.494 0 .923 -.923 0 .494 -1.196 0 0.00 -1.30 0 -.494 -1.196 0 -.923 -.923 0 -1.196 -.494 0 -1.30 0 0 -1.196 .494 0 -.923 .923 0 -.494 1.196 0 0.00 1.30'/>
                      </Shape>
                    </Transform>
                  </Transform>
                  <Transform translation='0 0 0.30'>
                    <Inline DEF='Hub' url='"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"'/>
                  </Transform>
                  <Transform translation='0 0 -0.30'>
                    <Inline USE='Hub'/>
                  </Transform>
                  <TouchSensor DEF='WheelTouchSensor' description='pointer spins wheel'/>
                  <TimeSensor DEF='Clock' cycleInterval='0.5' enabled='false' loop='true'/>
                  <OrientationInterpolator DEF='WheelInterpolator' key='0 0.5 1.0' keyValue='0 0 1 0.0 0 0 1 3.14 0 0 1 6.28'/>
                  <ROUTE fromField='isOver' fromNode='WheelTouchSensor' toField='set_enabled' toNode='Clock'/>
                  <ROUTE fromField='fraction_changed' fromNode='Clock' toField='set_fraction' toNode='WheelInterpolator'/>
                  <ROUTE fromField='value_changed' fromNode='WheelInterpolator' toField='set_rotation' toNode='WheelTransform'/>
                </Transform>
              </Group>
              <Group>
                <Transform DEF='JointsAxisAndAssistantsTest'>
                  <Group DEF='JointsAxisAndAssistants'>
                    <Transform rotation='-0.13 0.98 -0.13 1.59' scale='0.1 0.1 0.1' translation='0 0.15 1.55'>
                      <!-- Joint center -->
                      <Shape>
                        <Appearance DEF='AxleColor'>
                          <Material ambientIntensity='0.3' diffuseColor='0.3 0.3 0.3' shininess='0.20' specularColor='0.50 0.50 0.60'/>
                        </Appearance>
                        <Extrusion DEF='joint' creaseAngle='2.5' crossSection='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' spine='-2.5 1.5 0 -2.5 1 0 -2 0 0 -2 0 0 -1.5 -1 0 -0.5 -1.5 0 0.5 -1.5 0 1.5 -1.5 0 2 -1.0 0'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='-0.13 0.98 -0.13 1.59' scale='0.07 0.07 0.07' translation='0.30 0.15 1.55'>
                      <!-- Joint side -->
                      <Shape>
                        <Appearance USE='AxleColor'/>
                        <Extrusion USE='joint'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='-0.13 0.98 -0.13 1.59' scale='0.07 0.07 0.07' translation='-0.30 0.15 1.55'>
                      <!-- Joint side -->
                      <Shape>
                        <Appearance USE='AxleColor'/>
                        <Extrusion USE='joint'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='1 0 0 1.57' scale='0.7 0.7 0.7' translation='0 0 0.5'>
                      <!-- Wheel connected axis. (black) -->
                      <Shape>
                        <Appearance USE='AxleColor'/>
                        <Cylinder height='1.0' radius='0.1'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='1 0 0 1.57' scale='0.7 0.7 0.7' translation='0 0 0.65'>
                      <!-- The second axis. (black) -->
                      <Shape>
                        <Appearance USE='AxleColor'/>
                        <Cylinder height='0.4' radius='0.25'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='1 0 0 1.57' scale='0.7 0.7 0.7' translation='0 0 1.1'>
                      <!-- assistant axle for rear wheel(white) -->
                      <Shape>
                        <Appearance>
                          <Material diffuseColor='1.0 1.0 1.0'/>
                        </Appearance>
                        <Cylinder height='1' radius='0.3'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='1 0 0 1.57' scale='0.7 0.7 0.7' translation='0.3 0 1.1'>
                      <!-- assistant axle for rear wheel(white) -->
                      <Shape>
                        <Appearance DEF='AssistantAxleColor'>
                          <Material diffuseColor='1.0 1.0 1.0'/>
                        </Appearance>
                        <Cylinder height='1' radius='0.3'/>
                      </Shape>
                    </Transform>
                    <Transform rotation='1 0 0 1.57' scale='0.7 0.7 0.7' translation='-0.3 0 1.1'>
                      <!-- assistant axle for rear wheel(white) -->
                      <Shape>
                        <Appearance USE='AssistantAxleColor'/>
                        <Cylinder height='1' radius='0.3'/>
                      </Shape>
                    </Transform>
                  </Group>
                </Transform>
              </Group>
            </Transform>
            <Transform>
              <Group DEF='RearAxles'>
                <Transform rotation='1 0 0 0.44' scale='0.7 0.7 0.7' translation='0 1.05 2.15'>
                  <!-- main axle for rear wheels (white) -->
                  <Shape>
                    <Appearance USE='AssistantAxleColor'/>
                    <Box size='0.5 3 0.5'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.7 0.7 0.7' translation='0.3 0.8 2'>
                  <!-- assistant axle for rear wheel (white) -->
                  <Shape>
                    <Appearance USE='AssistantAxleColor'/>
                    <Cylinder radius='0.2'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.7 0.7 0.7' translation='0.3 1.5 2.3'>
                  <!-- assistant axle for rear wheel (white) -->
                  <Shape>
                    <Appearance USE='AssistantAxleColor'/>
                    <Cylinder radius='0.3'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.7 0.7 0.7' translation='-0.3 0.8 2'>
                  <!-- assistant axle for rear wheel (white) -->
                  <Shape>
                    <Appearance USE='AssistantAxleColor'/>
                    <Cylinder radius='0.2'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.7 0.7 0.7' translation='-0.3 1.5 2.3'>
                  <!-- assistant axle for rear wheel (white) -->
                  <Shape>
                    <Appearance USE='AssistantAxleColor'/>
                    <Cylinder radius='0.3'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.5 0.5 0.5' translation='-0.3 0.2 1.72'>
                  <!-- assistant axis under axle (black) -->
                  <Shape>
                    <Appearance USE='AxleColor'/>
                    <Cylinder height='0.7' radius='0.2'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.5 0.5 0.5' translation='0 0.2 1.72'>
                  <!-- assistant axis under axle (black) -->
                  <Shape>
                    <Appearance USE='AxleColor'/>
                    <Cylinder height='0.7' radius='0.2'/>
                  </Shape>
                </Transform>
                <Transform rotation='1 0 0 0.44' scale='0.5 0.5 0.5' translation='0.3 0.2 1.72'>
                  <!-- assistant axis under axle (black) -->
                  <Shape>
                    <Appearance USE='AxleColor'/>
                    <Cylinder height='0.7' radius='0.2'/>
                  </Shape>
                </Transform>
              </Group>
            </Transform>
            <Script DEF='GearUpDownScript'>
              <field accessType='inputOnly' appinfo='eventIn: boolean true: wheels up false: wheels down' name='gearup' type='SFBool'/>
              <field accessType='outputOnly' name='gearupOut' type='SFBool'/>
              <field accessType='outputOnly' name='keyValue' type='MFRotation'/>
              <field accessType='outputOnly' name='keyValue2' type='MFRotation'/>
              <field accessType='initializeOnly' name='kV1' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV1Second' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV2' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV2Second' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV3' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV3Second' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV4' type='SFRotation'/>
              <field accessType='initializeOnly' name='kV4Second' type='SFRotation'/>
              <field accessType='inputOnly' name='set_fraction' type='SFFloat'/>
              <field accessType='inputOnly' name='animationStartTime' type='SFTime'/>
              <field accessType='outputOnly' name='clockStartTime' type='SFTime'/>
              <field accessType='initializeOnly' name='traceEnabled' type='SFBool'/>
              <IS>
                <connect nodeField='gearup' protoField='gearup'/>
                <connect nodeField='animationStartTime' protoField='animationStartTime'/>
                <connect nodeField='gearupOut' protoField='gearupOut'/>
                <connect nodeField='traceEnabled' protoField='traceEnabled'/>
              </IS>
              <![CDATA[
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.95, 0.21), 1.62);
      	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), 1.22);
        kV4Second = new SFRotation(new SFVec3f (-0.21, -0.21, 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 ('[WheelsRearLeftPrototype] ' + outputString);
}
]]>
            </Script>
            <OrientationInterpolator DEF='GearUpDownInterpolator' key='0 0.5 0.75 1.0' keyValue='0 1 0 0.0 0 1 0 0.44 0 1 0 1.22 0.21 0.95 0.21 1.62'/>
            <OrientationInterpolator DEF='GearUpDownInterpolator2' key='0 0.25 0.5 1.0' keyValue='0 0 1 0.0 0 0 1 0.44 0 0 1 0.80 -0.21 -0.21 0.95 1.62'/>
            <TimeSensor DEF='ClockAxleGearUpDownFirst' cycleInterval='4'/>
            <TimeSensor DEF='ClockAxleGearUpDownSecond' cycleInterval='8'/>
            <ROUTE fromField='clockStartTime' fromNode='GearUpDownScript' toField='set_startTime' toNode='ClockAxleGearUpDownFirst'/>
            <ROUTE fromField='clockStartTime' fromNode='GearUpDownScript' toField='set_startTime' toNode='ClockAxleGearUpDownSecond'/>
            <ROUTE fromField='gearupOut' fromNode='GearUpDownScript' toField='set_enabled' toNode='ClockAxleGearUpDownFirst'/>
            <ROUTE fromField='gearupOut' fromNode='GearUpDownScript' toField='set_enabled' toNode='ClockAxleGearUpDownSecond'/>
            <ROUTE fromField='keyValue' fromNode='GearUpDownScript' toField='set_keyValue' toNode='GearUpDownInterpolator'/>
            <ROUTE fromField='keyValue2' fromNode='GearUpDownScript' toField='set_keyValue' toNode='GearUpDownInterpolator2'/>
            <ROUTE fromField='fraction_changed' fromNode='ClockAxleGearUpDownFirst' toField='set_fraction' toNode='GearUpDownInterpolator'/>
            <ROUTE fromField='fraction_changed' fromNode='ClockAxleGearUpDownSecond' toField='set_fraction' toNode='GearUpDownInterpolator2'/>
            <ROUTE fromField='fraction_changed' fromNode='ClockAxleGearUpDownFirst' toField='set_fraction' toNode='GearUpDownScript'/>
            <ROUTE fromField='value_changed' fromNode='GearUpDownInterpolator' toField='set_rotation' toNode='WheelsRearAxleTransform'/>
            <ROUTE fromField='value_changed' fromNode='GearUpDownInterpolator2' toField='set_rotation' toNode='WheelsRearTransform'/>
          </Transform>
        </Group>
      </ProtoBody>
    </ProtoDeclare>
    <Background skyColor='0.7 0.7 0.7'/>
    <Anchor description='WheelsRearLeftExample' parameter='"target=_blank"' url='"WheelsRearLeftExample.wrl" "../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearLeftExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearLeftExample.wrl" "WheelsRearLeftExample.x3d" "../../AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearLeftExample.x3d" "https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/WheelsRearLeftExample.x3d"'>
      <Shape>
        <Text string='"WheelsRearLeftPrototype" "is a prototype definition file" "" "To see an example scene" "click on this text and view" "WheelsRearLeftExample"'>
          <FontStyle justify='"MIDDLE" "MIDDLE"'/>
        </Text>
        <Appearance/>
      </Shape>
    </Anchor>
  </Scene>
</X3D>