node3.vwf.yaml 2.7 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. ## Cesium base 3d object component
  14. ##
  15. ## @name cesium.vwf
  16. ## @namespace
  17. ---
  18. extends: http://vwf.example.com/node.vwf
  19. implements:
  20. - http://vwf.example.com/animation.vwf
  21. properties:
  22. visible: true
  23. position: [ 0, 0, 0 ]
  24. color: [ 255, 255, 255, 1 ]
  25. modelMatrix:
  26. methods:
  27. translateBy:
  28. translateTo:
  29. scripts:
  30. - |
  31. this.translationFromValue = function( value ) {
  32. return value && value.length >= 3 ? value : goog.vec.Vec3.create();
  33. }
  34. this.translateBy = function( translation, duration ) {
  35. var pos = this.position;
  36. var startPosition = goog.vec.Vec3.createFloat32FromArray( pos );
  37. var deltaPosition = goog.vec.Vec3.createFloat32FromArray( translation );
  38. var stopPosition = goog.vec.Vec3.add(
  39. startPosition,
  40. deltaPosition,
  41. goog.vec.Vec3.create()
  42. );
  43. if( duration > 0 ) {
  44. this.animationDuration = duration;
  45. this.animationUpdate = function( time, duration ) {
  46. this.position = goog.vec.Vec3.lerp(
  47. startPosition, stopPosition,
  48. time >= duration ? 1 : time / duration,
  49. goog.vec.Vec3.create()
  50. );
  51. }
  52. this.animationPlay();
  53. }
  54. else {
  55. this.position = stopPosition;
  56. }
  57. }
  58. this.translateTo = function( translation, duration ) {
  59. var pos = this.position;
  60. var startPosition = goog.vec.Vec3.createFloat32FromArray( pos );
  61. var stopPosition = goog.vec.Vec3.createFloat32FromArray( translation );
  62. var deltaPosition = goog.vec.Vec3.subtract(
  63. startPosition,
  64. stopPosition,
  65. goog.vec.Vec3.create()
  66. );
  67. if( duration > 0 ) {
  68. this.animationDuration = duration;
  69. this.animationUpdate = function( time, duration ) {
  70. this.position = goog.vec.Vec3.lerp(
  71. startPosition, stopPosition,
  72. time >= duration ? 1 : time / duration,
  73. goog.vec.Vec3.create()
  74. );
  75. }
  76. this.animationPlay();
  77. }
  78. else {
  79. this.position = stopPosition;
  80. }
  81. } //@ sourceURL=cesium.node3.vwf