translate-on-down.vwf.yaml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 translate behavior (on down)
  14. ##
  15. ## @name translate-on-down.vwf
  16. ## @namespace
  17. ---
  18. extends:
  19. http://vwf.example.com/node3.vwf
  20. properties:
  21. ## Translate vector
  22. ##
  23. ## @name translate-on-down.vwf#translate_vector
  24. ## @property
  25. translate-vector: [ 0, 1, 0 ]
  26. ## Translate value
  27. ##
  28. ## @name translate-on-down.vwf#translate_value
  29. ## @property
  30. translate_value: 0
  31. methods:
  32. ## Move function. Updates component translation
  33. ##
  34. ## @name translate-on-down.vwf#move
  35. ## @function
  36. ##
  37. ## @returns undefined
  38. move:
  39. scripts:
  40. - |
  41. var initialPosition;
  42. this.initialize = function() {
  43. }
  44. this.pointerDown = function( pointerInfo, pickInfo ) {
  45. initialPosition = this.translation;
  46. this.move( true );
  47. this["translate_value"] = 1;
  48. }
  49. this.pointerUp = function( pointerInfo, pickInfo ) {
  50. this.move( false );
  51. this["translate_value"] = 0;
  52. }
  53. this.move = function( down ){
  54. if ( down ){
  55. var newPos = [
  56. initialPosition[0] + this["translate-vector"][0],
  57. initialPosition[1] + this["translate-vector"][1],
  58. initialPosition[2] + this["translate-vector"][2],
  59. ];
  60. this.translation = newPos;
  61. } else {
  62. this.translation = initialPosition;
  63. }
  64. } //@ sourceURL=translate-on-down.vwf