# 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.

## The component representation of a scale behavior (on move)
## 
## @name blockly/controller.vwf
## @namespace

--- 
extends:
  http://vwf.example.com/node3/animation.vwf
properties:
  blockly_executing: false
  blockly_xml: "<xml></xml>"
  blockly_code:
    set: |
      if ( this.blockly_code != value ) {
        this.blockly_code = value;
        this.blocklyCodeChanged( value );
      }
    value: 0
  blockly_topBlockCount:
    set: |
      if ( this.blockly_topBlockCount != value ) {
        this.blockly_topBlockCount = value;
        this.topBlockCountChanged( value );
      }
    value: 0
  blockly_blockCount:
    set: |
      if ( this.blockly_blockCount != value ) {
        this.blockly_blockCount = value;
        this.blockCountChanged( value );
      }
    value: 0
  blockly_allowedBlocks:   
    set: |
      if ( this.blockly_allowedBlocks != value ) {
        this.blockly_allowedBlocks = value;
        this.allowedBlocksChanged( value );
      }
    value: 20
  blockly_toolbox:
  blockly_defaultXml:
methods:
  getWorldXYVector:
  blocklyClear:
events:
  blocklyStarted:
  blocklyExecuted:
  blocklyErrored:
  blocklyStopped:
  blocklyBlockAdded:
  blocklyBlockRemoved:
  blocklyCodeChanged:
  topBlockCountChanged:
  blockCountChanged:
  allowedBlocksChanged:
  blocklyVisibleChanged:
scripts:
- |
    this.getWorldXYVector = function( x, y ) {

      var dir = goog.vec.Vec3.create();
      var moveVectorInCameraFrame = goog.vec.Vec4.createFromValues( x, y, 0, 1 );
      var camWorldRotMat = goog.vec.Mat4.createFromArray( this.worldTransform );
      camWorldRotMat[ 12 ] = 0;
      camWorldRotMat[ 13 ] = 0;
      camWorldRotMat[ 14 ] = 0;

      dir = goog.vec.Mat4.multVec4( camWorldRotMat, moveVectorInCameraFrame, dir );
      dir[ 2 ] = 0;

      goog.vec.Vec3.normalize( dir, dir ); 
      return dir;

    } //@ sourceURL=blockly-controller.vwf