# 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 translate behavior (on down) ## ## @name translate-on-down.vwf ## @namespace --- extends: http://vwf.example.com/node3.vwf properties: ## Translate vector ## ## @name translate-on-down.vwf#translate_vector ## @property translate-vector: [ 0, 1, 0 ] ## Translate value ## ## @name translate-on-down.vwf#translate_value ## @property translate_value: 0 methods: ## Move function. Updates component translation ## ## @name translate-on-down.vwf#move ## @function ## ## @returns undefined move: scripts: - | var initialPosition; this.initialize = function() { } this.pointerDown = function( pointerInfo, pickInfo ) { initialPosition = this.translation; this.move( true ); this["translate_value"] = 1; } this.pointerUp = function( pointerInfo, pickInfo ) { this.move( false ); this["translate_value"] = 0; } this.move = function( down ){ if ( down ){ var newPos = [ initialPosition[0] + this["translate-vector"][0], initialPosition[1] + this["translate-vector"][1], initialPosition[2] + this["translate-vector"][2], ]; this.translation = newPos; } else { this.translation = initialPosition; } } //@ sourceURL=translate-on-down.vwf