sway-on-click.vwf.yaml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2012 United States Government, as represented by the Secretary of Defense, Under
  2. # Secretary of Defense (Personnel & Readiness).
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. # in compliance with the License. You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software distributed under the License
  10. # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  11. # or implied. See the License for the specific language governing permissions and limitations under
  12. # the License.
  13. ## The component representation of a sway behavior (on click)
  14. ##
  15. ## @name sway-on-click.vwf
  16. ## @namespace
  17. ---
  18. extends:
  19. http://vwf.example.com/node3.vwf
  20. properties:
  21. ## Whether the component is swaying
  22. ##
  23. ## @name sway-on-click.vwf#sway-swaying
  24. ## @property
  25. sway-swaying:
  26. set: |
  27. if ( value && ! this["sway-start"] ) {
  28. this["sway-start"] = this.time;
  29. this.sway();
  30. } else if ( ! value && this["sway-start"] ) {
  31. this["sway-start"] = null;
  32. }
  33. get: |
  34. return !! this["sway-start"];
  35. ## Sway rate
  36. ##
  37. ## @name sway-on-click.vwf#sway-rate
  38. ## @property
  39. sway-rate: 1
  40. ## Sway axis
  41. ##
  42. ## @name sway-on-click.vwf#sway-axis
  43. ## @property
  44. sway-axis: [ 0, 1, 0 ]
  45. ## Sway start
  46. ##
  47. ## @name sway-on-click.vwf#sway-start
  48. ## @property
  49. sway-start: null
  50. methods:
  51. ## Sway function. Updates component rotations and calls future sway
  52. ##
  53. ## @name sway-on-click.vwf#sway
  54. ## @function
  55. ##
  56. ## @returns undefined
  57. sway:
  58. scripts:
  59. - |
  60. this.pointerClick = function() {
  61. // this["sway-swaying"] = ! this["sway-swaying"];
  62. }
  63. this.sway = function() {
  64. var start = this["sway-start"];
  65. if ( start ) {
  66. this.rotateBy( [ this["sway-axis"][0], this["sway-axis"][1], this["sway-axis"][2], Math.cos( this.time - start ) * Math.PI / 2 ], 0 );
  67. this.future( 0.05 ).sway();
  68. }
  69. } //@ sourceURL=sway-on-click.vwf