# 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 sway behavior (on click) ## ## @name sway-on-click.vwf ## @namespace --- extends: http://vwf.example.com/node3.vwf properties: ## Whether the component is swaying ## ## @name sway-on-click.vwf#sway-swaying ## @property sway-swaying: set: | if ( value && ! this["sway-start"] ) { this["sway-start"] = this.time; this.sway(); } else if ( ! value && this["sway-start"] ) { this["sway-start"] = null; } get: | return !! this["sway-start"]; ## Sway rate ## ## @name sway-on-click.vwf#sway-rate ## @property sway-rate: 1 ## Sway axis ## ## @name sway-on-click.vwf#sway-axis ## @property sway-axis: [ 0, 1, 0 ] ## Sway start ## ## @name sway-on-click.vwf#sway-start ## @property sway-start: null methods: ## Sway function. Updates component rotations and calls future sway ## ## @name sway-on-click.vwf#sway ## @function ## ## @returns undefined sway: scripts: - | this.pointerClick = function() { // this["sway-swaying"] = ! this["sway-swaying"]; } this.sway = function() { var start = this["sway-start"]; if ( start ) { this.rotateBy( [ this["sway-axis"][0], this["sway-axis"][1], this["sway-axis"][2], Math.cos( this.time - start ) * Math.PI / 2 ], 0 ); this.future( 0.05 ).sway(); } } //@ sourceURL=sway-on-click.vwf