# 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 spin behavior (on click) ## ## @name spin-on-click.vwf ## @namespace --- extends: http://vwf.example.com/node3.vwf properties: ## Whether the component is spinning ## ## @name spin-on-click.vwf#spin-spinning ## @property spin-spinning: set: | if ( value && ! this["spin-spinning"] ) { // starting this["spin-spinning"] = true; // set the internal value this.spin(); // run the first step and schedule the next one } else if ( ! value && this["spin-spinning"] ) { // stopping this["spin-spinning"] = false; // set the internal value } value: false ## Spin rate ## ## @name spin-on-click.vwf#spin-rate ## @property spin-rate: 1 ## Spin axis ## ## @name spin-on-click.vwf#spin-axis ## @property spin-axis: [ 0, 1, 0 ] methods: ## Spin function. Updates component rotations and calls future spin ## ## @name spin-on-click.vwf#spin ## @function ## ## @returns undefined spin: | if ( this["spin-spinning"] ) { // if enabled var axis = this["spin-axis"]; this.rotateBy( [ axis[0], axis[1], axis[2], this["spin-rate"], 0 ] ); this.future( 0.05 ).spin(); // schedule the next step } scripts: - | this.pointerClick = function( pointerInfo ) { if ( pointerInfo.button == "left" ) { this["spin-spinning"] = ! this["spin-spinning"]; // ... toggle the enabled flag } }