instruction.vwf.yaml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 an instruction
  14. ##
  15. ## @name instruction.vwf
  16. ## @namespace
  17. ---
  18. extends: http://vwf.example.com/node.vwf
  19. properties:
  20. ## Instruction text
  21. ##
  22. ## @name instruction.vwf#instructionText
  23. ## @property
  24. instructionText: ""
  25. ## Action text
  26. ##
  27. ## @name instruction.vwf#actionText
  28. ## @property
  29. actionText: ""
  30. ## The search string used to find a node3 that represents the transform that the camera will move to at the
  31. ## beginning of this instruction
  32. ##
  33. ## @name instruction.vwf#cameraPoseRef
  34. ## @property
  35. cameraPoseRef:
  36. ## Active boolean
  37. ##
  38. ## @name instruction.vwf#active
  39. ## @property
  40. active:
  41. set: |
  42. this.active = value;
  43. value: false
  44. methods:
  45. ## Method that navigates to the camera pose and fires the
  46. ##
  47. ## @name instruction.vwf#begin
  48. ## @method
  49. begin:
  50. ## Method that performs all the generic actions to close out the instruction and prepare for the next
  51. ##
  52. ## @name instruction.vwf#complete
  53. ## @method
  54. complete:
  55. events:
  56. ## The event that is fired when the instruction is begun
  57. ##
  58. ## @name instruction.vwf#entered
  59. ## @event
  60. entered:
  61. ## The event that is fired when the user has completed the current step
  62. ##
  63. ## @name instruction.vwf#exited
  64. ## @event
  65. exited:
  66. scripts:
  67. - |
  68. this.begin = function() {
  69. // If a camera pose has been specified for this instruction, move the camera to it
  70. if ( this.cameraPoseRef ) {
  71. var cameraPoseSearchResults = this.find( this.cameraPoseRef );
  72. if ( cameraPoseSearchResults && cameraPoseSearchResults.length ) {
  73. var newCameraPose = cameraPoseSearchResults[ 0 ];
  74. if ( newCameraPose.translation && newCameraPose.quaternion ) {
  75. var scene = this.find( "/" )[ 0 ];
  76. var camera = scene.camera;
  77. if ( camera ) {
  78. var duration = 2;
  79. camera.translateTo( newCameraPose.translation, duration );
  80. camera.quaterniateTo( newCameraPose.quaternion, duration );
  81. }
  82. else
  83. console.error( "Could not find camera - make sure the scene derives from navScene.vwf or another component " +
  84. "that defines a valid camera" );
  85. }
  86. else
  87. console.error( "Camera pose '" + this.cameraPoseRef + "' is not a valid node3" );
  88. }
  89. else
  90. console.error( "Could not find camera pose: " + this.cameraPoseRef + " - will not move camera" );
  91. }
  92. // Fire event signifying that instruction has been entered
  93. this.entered( this.instructionText, this.actionText );
  94. }
  95. this.complete = function() {
  96. this.exited();
  97. } //@ sourceURL=instruction.vwf