12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- this.enter = function() {
-
-
- var parentTaskArray = this.find( "parent::element(*,'http://vwf.example.com/lesson/task.vwf')" );
- if ( parentTaskArray.length ) {
- var parentTask = parentTaskArray[ 0 ];
- this.scene = parentTask.scene;
- }
-
- if ( this.cameraPoseRef ) {
- var cameraPoseSearchResults = this.find( this.cameraPoseRef );
- if ( cameraPoseSearchResults && cameraPoseSearchResults.length ) {
- var newCameraPose = cameraPoseSearchResults[ 0 ];
- if ( newCameraPose.translation && newCameraPose.quaternion ) {
- if ( this.scene ) {
- var camera = this.scene.camera;
- if ( camera ) {
- var duration = 2;
- camera.worldTransformTo( newCameraPose.worldTransform, duration);
- this.in(duration).cameraTransformComplete();
- } else {
- console.error( "Could not find camera - to move the 3D camera using cameraPose, make sure the " +
- "scene derives from navScene.vwf or another component that defines a valid camera" );
- }
- } else {
- console.error( "Scene property is not set - must be set for task to find camera to move" );
- }
- } 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" );
- }
- }
- this.status = "entered";
-
- this.entering( this.text );
-
- this.taskIndex = null;
- if ( this.subtasks && this.subtasks.length ) {
- this.next();
- }
-
- }
- this.next = function() {
-
-
- if ( this.taskIndex == null )
- this.taskIndex = 0;
- else {
- var oldSubtask = this.subtasks[ this.taskIndex ];
- oldSubtask.completed = oldSubtask.events.flush( this );
- oldSubtask.exit();
- this.taskIndex++;
- }
-
-
- if ( this.taskIndex < this.subtasks.length ) {
- var newSubtask = this.subtasks[ this.taskIndex ];
- newSubtask.enter();
- newSubtask.completed = newSubtask.events.add( function() { this.in(0).next(); }, this );
- }
- else
- this.completed();
-
- }
- this.exit = function() {
-
-
-
- this.exiting();
- this.status = "inactive";
- }
- this.completed = function() {
- this.status = "completed";
- }
|