# Copyright 2012 United States Government, as represented by the Secretary of Defense, Under
# Secretary of Defense (Personnel & Readiness).
# 
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
# 
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.

--- 
extends: http://vwf.example.com/node3.vwf
implements:
- http://vwf.example.com/spin-on-move.vwf
methods:
  createGeometry:
  deleteGeometry:
properties:
  spin-axis: [ 1, 0, 0 ]
  spin-rate: 100
  spin-inputDim: "xy"
scripts:
- |
  this.initialize = function() {
    //console.info( "initialize rotationX.vwf" );
  }
  this.createGeometry = function() {
    if ( this.parent.ttPoints ) {
      var pos = [];
      var faces;
      pos.push( this.parent.ttPositions[34][0] );
      pos.push( this.parent.ttPositions[34][1] ); // 0       
      pos.push( this.parent.ttPositions[34][2] );

      pos.push( this.parent.ttPositions[35][0] );
      pos.push( this.parent.ttPositions[35][1] ); // 1       
      pos.push( this.parent.ttPositions[35][2] );
      
      pos.push( this.parent.ttPositions[37][0] );
      pos.push( this.parent.ttPositions[37][1] ); // 2       
      pos.push( this.parent.ttPositions[37][2] );
      
      pos.push( this.parent.ttPositions[36][0] );
      pos.push( this.parent.ttPositions[36][1] ); // 3   
      pos.push( this.parent.ttPositions[36][2] ); 
      
      faces = [ 0, 3, 1, 1, 3, 2 ];
      
      pos.push( this.parent.ttPositions[33][0] );
      pos.push( this.parent.ttPositions[33][1] ); // 4       
      pos.push( this.parent.ttPositions[33][2] );

      pos.push( this.parent.ttPositions[32][0] );
      pos.push( this.parent.ttPositions[32][1] ); // 5       
      pos.push( this.parent.ttPositions[32][2] );
      
      pos.push( this.parent.ttPositions[38][0] );
      pos.push( this.parent.ttPositions[38][1] ); // 6       
      pos.push( this.parent.ttPositions[38][2] );
      
      pos.push( this.parent.ttPositions[39][0] );
      pos.push( this.parent.ttPositions[39][1] ); // 7   
      pos.push( this.parent.ttPositions[39][2] );   

      faces.push( 4, 7, 5, 5, 7, 6 );
      
      pos.push( this.parent.ttPositions[44][0] );
      pos.push( this.parent.ttPositions[44][1] ); // 8       
      pos.push( this.parent.ttPositions[44][2] );

      pos.push( this.parent.ttPositions[45][0] );
      pos.push( this.parent.ttPositions[45][1] ); // 9       
      pos.push( this.parent.ttPositions[45][2] );
      
      pos.push( this.parent.ttPositions[43][0] );
      pos.push( this.parent.ttPositions[43][1] ); // 10       
      pos.push( this.parent.ttPositions[43][2] );
      
      pos.push( this.parent.ttPositions[42][0] );
      pos.push( this.parent.ttPositions[42][1] ); // 11   
      pos.push( this.parent.ttPositions[42][2] );   

      faces.push( 8, 11, 9, 9, 11, 10 );        

      pos.push( this.parent.ttPositions[47][0] );
      pos.push( this.parent.ttPositions[47][1] ); // 12       
      pos.push( this.parent.ttPositions[47][2] );

      pos.push( this.parent.ttPositions[46][0] );
      pos.push( this.parent.ttPositions[46][1] ); // 13       
      pos.push( this.parent.ttPositions[46][2] );
      
      pos.push( this.parent.ttPositions[40][0] );
      pos.push( this.parent.ttPositions[40][1] ); // 14       
      pos.push( this.parent.ttPositions[40][2] );
      
      pos.push( this.parent.ttPositions[41][0] );
      pos.push( this.parent.ttPositions[41][1] ); // 15   
      pos.push( this.parent.ttPositions[41][2] );   

      faces.push( 12, 15, 13, 13, 15, 14 );

      pos.push( this.parent.ttPositions[39][0] );
      pos.push( this.parent.ttPositions[39][1] ); // 16       
      pos.push( this.parent.ttPositions[39][2] );

      pos.push( this.parent.ttPositions[54][0] );
      pos.push( this.parent.ttPositions[54][1] ); // 17       
      pos.push( this.parent.ttPositions[54][2] );
      
      pos.push( this.parent.ttPositions[53][0] );
      pos.push( this.parent.ttPositions[53][1] ); // 18       
      pos.push( this.parent.ttPositions[53][2] );
      
      pos.push( this.parent.ttPositions[33][0] );
      pos.push( this.parent.ttPositions[33][1] ); // 19   
      pos.push( this.parent.ttPositions[33][2] );   

      faces.push( 16, 19, 17, 17, 19, 18 ); 

      pos.push( this.parent.ttPositions[55][0] );
      pos.push( this.parent.ttPositions[55][1] ); // 20       
      pos.push( this.parent.ttPositions[55][2] );

      pos.push( this.parent.ttPositions[47][0] );
      pos.push( this.parent.ttPositions[47][1] ); // 21       
      pos.push( this.parent.ttPositions[47][2] );
      
      pos.push( this.parent.ttPositions[41][0] );
      pos.push( this.parent.ttPositions[41][1] ); // 22       
      pos.push( this.parent.ttPositions[41][2] );
      
      pos.push( this.parent.ttPositions[52][0] );
      pos.push( this.parent.ttPositions[52][1] ); // 23   
      pos.push( this.parent.ttPositions[52][2] );   

      faces.push( 20, 23, 21, 21, 23, 22 ); 

      pos.push( this.parent.ttPositions[50][0] );
      pos.push( this.parent.ttPositions[50][1] ); // 24       
      pos.push( this.parent.ttPositions[50][2] );

      pos.push( this.parent.ttPositions[49][0] );
      pos.push( this.parent.ttPositions[49][1] ); // 25       
      pos.push( this.parent.ttPositions[49][2] );
      
      pos.push( this.parent.ttPositions[35][0] );
      pos.push( this.parent.ttPositions[35][1] ); // 26       
      pos.push( this.parent.ttPositions[35][2] );
      
      pos.push( this.parent.ttPositions[37][0] );
      pos.push( this.parent.ttPositions[37][1] ); // 27   
      pos.push( this.parent.ttPositions[37][2] );   

      faces.push( 24, 27, 25, 25, 27, 26 );

      pos.push( this.parent.ttPositions[43][0] );
      pos.push( this.parent.ttPositions[43][1] ); // 28       
      pos.push( this.parent.ttPositions[43][2] );

      pos.push( this.parent.ttPositions[48][0] );
      pos.push( this.parent.ttPositions[48][1] ); // 29       
      pos.push( this.parent.ttPositions[48][2] );
      
      pos.push( this.parent.ttPositions[51][0] );
      pos.push( this.parent.ttPositions[51][1] ); // 30       
      pos.push( this.parent.ttPositions[51][2] );
      
      pos.push( this.parent.ttPositions[45][0] );
      pos.push( this.parent.ttPositions[45][1] ); // 31   
      pos.push( this.parent.ttPositions[45][2] );   

      faces.push( 28, 31, 29, 29, 31, 30 );
      
      var surface = {
        "extends": "http://vwf.example.com/node3.vwf",
        "type": "mesh/definition",
        "properties": { 
          "meshDefinition": { "positions": pos, "faces": faces, "color": [ 255, 0, 0 ], },
        },
      };
      
      this.children.create( "rotateX", surface );
    }    
  } 
  this.deleteGeometry = function() {
    if ( this.rotateX ) {
      this.children.delete( this.rotateX );
    }
  }  //@ sourceURL=rotationX.vwf