# 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 an instruction ## ## @name instruction.vwf ## @namespace --- extends: http://vwf.example.com/node.vwf properties: ## Instruction text ## ## @name instruction.vwf#instructionText ## @property instructionText: "" ## Action text ## ## @name instruction.vwf#actionText ## @property actionText: "" ## The search string used to find a node3 that represents the transform that the camera will move to at the ## beginning of this instruction ## ## @name instruction.vwf#cameraPoseRef ## @property cameraPoseRef: ## Active boolean ## ## @name instruction.vwf#active ## @property active: set: | this.active = value; value: false methods: ## Method that navigates to the camera pose and fires the ## ## @name instruction.vwf#begin ## @method begin: ## Method that performs all the generic actions to close out the instruction and prepare for the next ## ## @name instruction.vwf#complete ## @method complete: events: ## The event that is fired when the instruction is begun ## ## @name instruction.vwf#entered ## @event entered: ## The event that is fired when the user has completed the current step ## ## @name instruction.vwf#exited ## @event exited: scripts: - | this.begin = function() { // If a camera pose has been specified for this instruction, move the camera to it if ( this.cameraPoseRef ) { var cameraPoseSearchResults = this.find( this.cameraPoseRef ); if ( cameraPoseSearchResults && cameraPoseSearchResults.length ) { var newCameraPose = cameraPoseSearchResults[ 0 ]; if ( newCameraPose.translation && newCameraPose.quaternion ) { var scene = this.find( "/" )[ 0 ]; var camera = scene.camera; if ( camera ) { var duration = 2; camera.translateTo( newCameraPose.translation, duration ); camera.quaterniateTo( newCameraPose.quaternion, duration ); } else console.error( "Could not find camera - make sure the scene derives from navScene.vwf or another component " + "that defines a valid camera" ); } else console.error( "Camera pose '" + this.cameraPoseRef + "' is not a valid node3" ); } else console.error( "Could not find camera pose: " + this.cameraPoseRef + " - will not move camera" ); } // Fire event signifying that instruction has been entered this.entered( this.instructionText, this.actionText ); } this.complete = function() { this.exited(); } //@ sourceURL=instruction.vwf