navscene.vwf.yaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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 navigation scene
  14. ##
  15. ## @name navscene.vwf
  16. ## @namespace
  17. ---
  18. extends: http://vwf.example.com/scene.vwf
  19. properties:
  20. ## Navigation mode. Default value is 'walk.' Other options include 'orbit' and 'none.'
  21. ##
  22. ## @name navscene.vwf#navmode
  23. ## @property
  24. navmode:
  25. set: |
  26. switch ( value ) {
  27. case "walk":
  28. case "orbit":
  29. case "none":
  30. if ( this.setNavMode ) {
  31. this.setNavMode( value );
  32. }
  33. this.navmode = value;
  34. break;
  35. }
  36. value: "walk"
  37. ## Orbit radius
  38. ##
  39. ## @name navscene.vwf#orbitRadius
  40. ## @property
  41. orbitRadius: -1
  42. ## A node.vwf#find search pattern identifying the object to orbit.
  43. ##
  44. ## @name navscene.vwf#orbitObjectPattern
  45. ## @property
  46. orbitObjectPattern: "sceneCenter"
  47. ## Rotation speed. At a speed of 1, will take 4 seconds to go around 360 degrees.
  48. ##
  49. ## @name navscene.vwf#rotationSpeed
  50. ## @property
  51. rotationSpeed: 1.0
  52. ## Translation speed
  53. ##
  54. ## @name navscene.vwf#translationSpeed
  55. ## @property
  56. translationSpeed: 1.0
  57. ## Maximum speed
  58. ##
  59. ## @name navscene.vwf#maxSpeed
  60. ## @property
  61. maxSpeed: 500
  62. ## Drag mode move boolean. Default value is false.
  63. ##
  64. ## @name navscene.vwf#dragModeMove
  65. ## @property
  66. dragModeMove: false
  67. events:
  68. keyUp:
  69. keyDown:
  70. pointerDown:
  71. pointerUp:
  72. pointerMove:
  73. pointerOut:
  74. pointerWheel:
  75. methods:
  76. ## Updates scene
  77. ##
  78. ## @name navscene.vwf#update
  79. ## @function
  80. ##
  81. ## @returns undefined
  82. update:
  83. ## Gets camera at vector
  84. ##
  85. ## @name navscene.vwf#getCameraAt
  86. ## @function
  87. ##
  88. ## @returns camera at vector
  89. getCameraAt:
  90. ## For internal use only - needs to be public for future calls
  91. ##
  92. ## @name navscene.vwf#disableViewSideNav
  93. ## @function
  94. ##
  95. ## @returns undefined
  96. disableViewSideNav:
  97. ## For internal use only - needs to be public for future calls
  98. ##
  99. ## @name navscene.vwf#setNavMode
  100. ## @function
  101. ##
  102. ## @returns undefined
  103. setNavMode:
  104. scripts:
  105. - |
  106. var counter = 1;
  107. var _piDiv180 = Math.PI / 180;
  108. var _180DivPI = 180 / Math.PI;
  109. var _2PI = 2 * Math.PI;
  110. var _85 = 85.0 * _piDiv180;
  111. var _10 = 10.0 * _piDiv180;
  112. var phi, theta;
  113. this.initialize = function() {
  114. this.input = {
  115. futureActive: function() {
  116. return ( this.lookActive || this.moveActive || this.button1Down || this.button2Down || this.keysAreDown() );
  117. },
  118. timeSinceLastEvent: function() { return this.time - this.pointerEventTime; },
  119. timeSinceDownEvent: function() { return this.time - this.pointerDownTime; },
  120. pointerDelta: function() {
  121. if ( this.pointerInfo && this.lastPointerInfo ) {
  122. return [ (this.lastPointerInfo.position[0] - this.pointerInfo.position[0]) * 50,
  123. (this.lastPointerInfo.position[1] - this.pointerInfo.position[1]) * 50
  124. ];
  125. }
  126. return undefined;
  127. },
  128. keysAreDown: function() { return ( this.keyInfo && Object.keys( this.keyInfo.keysDown ).length > 0 ); },
  129. keyInfo: undefined,
  130. pointerInfo: undefined,
  131. lastPointerInfo: undefined,
  132. pickInfo: undefined,
  133. lastPickInfo: undefined,
  134. pointerDownTime: undefined,
  135. pointerEventTime: undefined,
  136. lookActive: false,
  137. moveActive: false,
  138. look: [ 0, 0 ],
  139. move: [ 0, 0 ],
  140. button1Down: false,
  141. button2Down: false,
  142. turnLeftDown: false,
  143. turnRightDown: false,
  144. lastUpdateTime: undefined,
  145. lastInputTime: undefined,
  146. };
  147. // Wait until the queue resumes to set the navigation mode, so that we are sure that the camera has been
  148. // created
  149. // TODO: When we can assume that initialize doesn't complete until all created nodes are in place, this
  150. // will no longer need to be a future call because we will be able to assume that the camera exists
  151. // Disable view-side navigation so navscene.vwf can do the navigation
  152. this.future( 0 ).disableViewSideNav();
  153. this.future( 0 ).setNavMode( this.navmode );
  154. }
  155. this.timeElapsed = function() {
  156. var timeElapsed = this.time - this.input.lastInputTime;
  157. if ( !this.input.lastInputTime || timeElapsed > 1 ) {
  158. timeElapsed = 1;
  159. }
  160. return timeElapsed;
  161. }
  162. this.disableViewSideNav = function() {
  163. if ( this.camera )
  164. this.camera.navmode = "none";
  165. }
  166. this.setNavMode = function( mode ) {
  167. if (!this.activeCameraComp) {
  168. this.getActiveCamera();
  169. }
  170. if ( this.activeCameraComp ) {
  171. switch( mode ) {
  172. case "orbit":
  173. if ( this.orbitObjectPattern ) {
  174. this.find( this.orbitObjectPattern, function( orbitObject ) {
  175. this.activeCameraComp.lookAt = orbitObject.id;
  176. this.updateRadius();
  177. } );
  178. }
  179. break;
  180. default:
  181. this.activeCameraComp.lookAt = "";
  182. break;
  183. }
  184. }
  185. }
  186. this.changeNavMode = function( state ) {
  187. if ( state == 1 ) {
  188. if ( this.navmode == "walk" ) this.navmode = "orbit";
  189. else if ( this.navmode == "orbit" ) this.navmode = "walk";
  190. }
  191. }
  192. this.raiseOrZoomIn = function( state ) {
  193. var active = this.input.futureActive();
  194. if ( this.navMode == "walk" ) {
  195. this.cameraZ( 1.0 );
  196. } else if ( this.navMode == "orbit" ) {
  197. this.zoom( true );
  198. }
  199. this.input.button1Down = state;
  200. if ( state && !active ) {
  201. this.future( 0.1 ).update();
  202. }
  203. }
  204. this.lowerOrZoomOut = function( state ) {
  205. var active = this.input.futureActive();
  206. if ( this.navMode == "walk" ) {
  207. this.cameraZ( -1.0 );
  208. } else if ( this.navMode == "orbit" ) {
  209. this.zoom( false );
  210. }
  211. this.input.button2Down = state;
  212. if ( state && !active ) {
  213. this.future( 0.1 ).update();
  214. }
  215. }
  216. this.pointerIsDown = function() {
  217. if ( this.input && this.input.pointerInfo ) {
  218. var bInfo = this.input.pointerInfo.buttons;
  219. if ( bInfo ) {
  220. return bInfo.left || bInfo.right || bInfo.middle;
  221. }
  222. }
  223. return false;
  224. }
  225. this.pointerDown = function( parms, pickInfo ){
  226. this.input.lastPointerInfo = undefined;
  227. this.input.pointerInfo = parms;
  228. this.input.lastPickInfo = undefined;
  229. this.input.pickInfo = pickInfo;
  230. this.input.pointerDownTime = this.time;
  231. this.input.lastInputTime = this.time;
  232. }
  233. this.pointerUp = function( parms, pickInfo ){
  234. this.input.lastPointerInfo = this.input.pointerInfo;
  235. this.input.pointerInfo = undefined;
  236. this.input.lastPickInfo = this.input.pickInfo;
  237. this.input.pickInfo = undefined;
  238. this.input.lastInputTime = this.time;
  239. }
  240. this.pointerMove = function( parms, pickInfo ){
  241. this.input.pointerEventTime = this.time;
  242. this.input.lastPointerInfo = this.input.pointerInfo;
  243. this.input.pointerInfo = parms;
  244. this.input.lastPickInfo = this.input.pickInfo;
  245. this.input.pickInfo = pickInfo;
  246. if ( this.pointerIsDown() /* && this.input.pointerEventTime - this.input.pointerDownTime > 6 */ ) {
  247. var active = this.input.futureActive();
  248. var delta = this.input.pointerDelta();
  249. var valid = this.navmode == "none" ? false : true;
  250. if ( valid && !active ) {
  251. this.future( 1/30 ).update();
  252. }
  253. }
  254. this.input.lastInputTime = this.time;
  255. }
  256. this.pointerOut = function( parms ){
  257. this.input.lastPointerInfo = this.input.pointerInfo;
  258. this.input.pointerInfo = undefined;
  259. this.input.lastPickInfo = this.input.pickInfo;
  260. this.input.pickInfo = undefined;
  261. this.input.lastInputTime = this.time;
  262. }
  263. this.pointerWheel = function( parms, pickInfo ) {
  264. this.input.pointerEventTime = this.time;
  265. this.input.lastPointerInfo = this.input.pointerInfo;
  266. this.input.pointerInfo = parms;
  267. this.input.lastPickInfo = this.input.pickInfo;
  268. this.input.pickInfo = pickInfo;
  269. if (!this.activeCameraComp) {
  270. this.getActiveCamera();
  271. }
  272. if ( this.activeCameraComp ) {
  273. var cameraPos = this.activeCameraComp.translation;
  274. var cameraAt = this.getCameraAt();
  275. if ( this.orbitRadius == -1 || this.input.pointerEventTime - this.input.lastUpdateTime > 0.5 ) {
  276. this.updateRadius();
  277. }
  278. cameraAt = goog.vec.Vec3.scale(
  279. cameraAt,
  280. this.input.pickInfo.wheel.deltaY * -1,
  281. cameraAt
  282. );
  283. if ( goog.vec.Vec3.magnitudeSquared( cameraAt ) > goog.vec.EPSILON ) {
  284. this.activeCameraComp.translation = goog.vec.Vec3.add(
  285. this.activeCameraComp.translation,
  286. goog.vec.Vec3.scale(
  287. goog.vec.Vec3.normalize( cameraAt, cameraAt ),
  288. this.distance(),
  289. cameraAt
  290. ),
  291. cameraAt
  292. );
  293. }
  294. }
  295. this.input.lastInputTime = this.time;
  296. }
  297. this.keyDown = function( parms ) {
  298. var active = this.input.futureActive();
  299. // capture the event input locally
  300. this.input.keyInfo = $.extend(true, {}, parms);;
  301. // store the current Time
  302. this.input.lastInputTime = this.time;
  303. // call future.update if update was not currently occurring
  304. if ( !active ) {
  305. this.future( 0.1 ).update();
  306. }
  307. }
  308. this.keyUp = function( parms ) {
  309. this.input.keyInfo = $.extend(true, {}, parms);
  310. if ( Object.keys( parms.keysDown ).length == 0 ){
  311. this.handleKeyDown();
  312. }
  313. this.input.lastInputTime = this.time;
  314. }
  315. this.handleKeyDown = function() {
  316. if (!this.activeCameraComp) {
  317. this.getActiveCamera();
  318. }
  319. if ( this.activeCameraComp ) {
  320. var deltaZ = 0;
  321. var kd = $.extend(true, {}, this.input.keyInfo.keysDown, this.input.keyInfo.keysUp);
  322. this.input.look = [ 0, 0 ];
  323. this.input.move = [ 0, 0 ];
  324. var temp;
  325. for ( var keyPress in kd ) {
  326. switch ( Number( kd[ keyPress ].code ) ) {
  327. case 87: //w
  328. case 38: //up
  329. this.input.move[1] += 1;
  330. break;
  331. case 83: //s
  332. case 40: //down
  333. this.input.move[1] += -1;
  334. break;
  335. case 37: // left
  336. case 65: //a
  337. this.input.move[0] += -1;
  338. break;
  339. case 39: // right
  340. case 68: //d
  341. this.input.move[0] += 1;
  342. break;
  343. case 81: // q
  344. this.input.look[0] += -1;
  345. break;
  346. case 69: // e
  347. this.input.look[0] += 1;
  348. break;
  349. case 90: // z
  350. temp = this.logger.enabled;
  351. this.logger.enabled = true;
  352. this.logger.info( "translation: [ " + Array.prototype.slice.call( this.activeCameraComp.translation ) + " ]" );
  353. this.logger.info( " quaternion: [ " + Array.prototype.slice.call( this.activeCameraComp.quaternion ) + " ]" );
  354. this.logger.info( " rotation: [ " + Array.prototype.slice.call( this.activeCameraComp.rotation ) + " ]" );
  355. this.logger.info( " transform: [ " + Array.prototype.slice.call( this.activeCameraComp.transform ) + " ]" );
  356. this.logger.info( " worldTransform: [ " + Array.prototype.slice.call( this.activeCameraComp.worldTransform ) + " ]" );
  357. this.logger.enabled = temp;
  358. break;
  359. case 88: // x
  360. break;
  361. case 82: // r
  362. deltaZ += 1.0;
  363. break;
  364. case 67: // c
  365. deltaZ += - 1.0;
  366. break;
  367. default:
  368. break;
  369. }
  370. }
  371. this.input.keyInfo.keysUp = {};
  372. if ( this.input.look[0] != 0 || this.input.look[1] != 0 ) {
  373. this.look( this.input.look[0], this.input.look[1] );
  374. }
  375. if ( this.input.move[0] != 0 || this.input.move[1] != 0 ) {
  376. this.move( this.input.move[0], this.input.move[1] );
  377. }
  378. if ( deltaZ != 0 ) {
  379. if ( this.navmode == "walk" ) {
  380. this.cameraZ( deltaZ );
  381. }
  382. }
  383. }
  384. }
  385. this.onMove = function( x, y ) {
  386. if ( Math.abs( x ) < 0.1 && Math.abs( y ) < 0.1 ) {
  387. if ( this.input.moveActive ) {
  388. this.input.moveActive = false;
  389. this.input.move = [ 0, 0 ];
  390. }
  391. return;
  392. }
  393. this.input.move = [ x, y ];
  394. var active = this.input.futureActive();
  395. if ( !this.input.moveActive ) {
  396. this.input.moveActive = true;
  397. this.move( x, y );
  398. }
  399. if ( !active ) {
  400. this.future( 0.1 ).update();
  401. }
  402. }
  403. this.move = function( x, y ) {
  404. if ( this.navmode == "walk" ) {
  405. this.translate( x, y );
  406. } else if ( this.navmode == "orbit" ) {
  407. this.orbit( x, y );
  408. }
  409. }
  410. this.onLook = function( x, y ) {
  411. if ( Math.abs( x ) < 0.1 && Math.abs( y ) < 0.1 ) {
  412. if ( this.input.lookActive ) {
  413. this.input.lookActive = false;
  414. this.input.look = [ 0, 0 ];
  415. }
  416. return;
  417. }
  418. this.input.look = [ x, y ];
  419. var active = this.input.futureActive();
  420. if ( !this.input.lookActive ) {
  421. this.input.lookActive = true;
  422. this.look( x, y );
  423. }
  424. if ( !active ) {
  425. this.future( 0.1 ).update();
  426. }
  427. }
  428. this.look = function( x, y ) {
  429. if (!this.activeCameraComp)
  430. this.getActiveCamera();
  431. if ( this.activeCameraComp ) {
  432. if ( this.input.pointerInfo && this.input.pointerInfo.modifiers.ctrl ) {
  433. if ( y != 0 ) { this.activeCameraComp.rotateBy( [ 1, 0, 0, -y * this.angularDistance() ], 0 ) }
  434. } else {
  435. if ( x != 0 ) { this.activeCameraComp.rotateBy( [ 0, 0, 1, -x * this.angularDistance() ], 0 ) }
  436. }
  437. }
  438. }
  439. this.zoom = function( dirIn ) {
  440. if (!this.activeCameraComp) {
  441. this.getActiveCamera();
  442. }
  443. if ( this.activeCameraComp ) {
  444. var camerapos = this.activeCameraComp.translation;
  445. var camerarot = this.getCameraAt();
  446. var yinc = 0;
  447. var xinc = 0;
  448. var zinc = 0;
  449. var speed = this.distance();
  450. if ( !dirIn ) speed = -speed;
  451. yinc = yinc + parseFloat( camerarot[1] ) * speed;
  452. xinc = xinc + parseFloat( camerarot[0] ) * speed;
  453. if ( this.orbitRadius == -1 || this.time - this.input.lastUpdateTime > 0.5 ) {
  454. this.updateRadius();
  455. }
  456. if ( xinc != 0 || yinc != 0 ) {
  457. var origX, origY, origZ;
  458. var x, y, z, atBounds = false;
  459. origX = camerapos[0];
  460. origY = camerapos[1];
  461. origZ = camerapos[2];
  462. x = origX + xinc * this.distance() * mult;
  463. y = origY + yinc * this.distance() * mult;
  464. z = origZ;
  465. var ratioHR = camerapos[2] / this.orbitRadius;
  466. zinc = Math.sqrt( Math.pow( x-origX, 2 ) + Math.pow( y-origY, 2 ) ) * ratioHR;
  467. if ( parms.wheelDeltaY > 0 ) zinc *= -1;
  468. z = origZ + zinc;
  469. this.activeCameraComp.translation = [ x, y, z ];
  470. }
  471. }
  472. }
  473. this.distance = function(){
  474. var dist = this.translationSpeed * 10 * this.timeElapsed();
  475. return dist;
  476. }
  477. this.angularDistance = function() {
  478. // Should take 4 seconds to go around 360 degrees
  479. var dist = this.rotationSpeed * 90 * this.timeElapsed();
  480. return dist;
  481. }
  482. this.cameraZ = function( dir ) {
  483. if (!this.activeCameraComp) this.getActiveCamera();
  484. if ( this.activeCameraComp ) {
  485. var pos = this.activeCameraComp.translation;
  486. this.activeCameraComp.translation = [ pos[0], pos[1], pos[2] + ( this.distance() * dir ) ];
  487. }
  488. }
  489. this.updateRadius = function() {
  490. var pos = this.activeCameraComp.translation || [ 1, 1, 1 ];
  491. var oldRadius = this.orbitRadius;
  492. // Assuming the orbit center is the origin, the radius is just the length of the line segment from the
  493. // origin to the active camera component
  494. this.orbitRadius = Math.sqrt( (pos[0] * pos[0]) + (pos[1] * pos[1]) + (pos[2] * pos[2]) );
  495. var dist2D = Math.sqrt( (pos[0] * pos[0]) + (pos[1] * pos[1]) );
  496. phi = Math.acos( pos[2] / this.orbitRadius );
  497. if ( 0 <= pos[0] ) theta = Math.asin( pos[1]/dist2D );
  498. else theta = Math.PI - Math.asin( pos[1]/dist2D );
  499. this.input.lastUpdateTime = this.time;
  500. }
  501. this.orbit = function( xDelta, yDelta ){
  502. if (!this.activeCameraComp) this.getActiveCamera();
  503. if ( this.activeCameraComp ) {
  504. this.updateRadius();
  505. var pixelToRadian = _2PI * this.angularDistance() / 360;
  506. var phiDelta = -yDelta * pixelToRadian;
  507. var thetaDelta = -xDelta * pixelToRadian;
  508. phi = phi - phiDelta;
  509. theta = theta - thetaDelta;
  510. if ( theta >= _2PI ) theta -= _2PI;
  511. else if ( theta < 0 ) theta += _2PI;
  512. if ( phi > _85 ) phi = _85;
  513. else if ( phi < _10 ) phi = _10;
  514. // Spherical to Cartesian
  515. var x = this.orbitRadius * Math.sin( phi ) * Math.cos( theta );
  516. var y = this.orbitRadius * Math.sin( phi ) * Math.sin( theta );
  517. var z = this.orbitRadius * Math.cos( phi );
  518. this.activeCameraComp.translation = [ x, y, z ];
  519. }
  520. }
  521. this.getCameraAt = function() {
  522. var camRotMat = this.activeCameraComp.rotationMatrix;
  523. return goog.vec.Vec3.createFromValues( camRotMat[4], camRotMat[5], camRotMat[6] );
  524. }
  525. this.getCameraUp = function() {
  526. var camRotMat = this.activeCameraComp.rotationMatrix;
  527. return goog.vec.Vec3.createFromValues( camRotMat[8], camRotMat[9], camRotMat[10] );
  528. }
  529. this.getCameraRight = function() {
  530. var camRotMat = this.activeCameraComp.rotationMatrix;
  531. return goog.vec.Vec3.createFromValues( camRotMat[0], camRotMat[1], camRotMat[2] );
  532. }
  533. this.getCameraVec = function( x, y, z ) {
  534. var camRotMat = this.activeCameraComp.rotationMatrix;
  535. var camAt = goog.vec.Mat4.multVec4(
  536. camRotMat,
  537. goog.vec.Vec4.createFromValues( x, y, z, 1 ),
  538. goog.vec.Vec3.create()
  539. );
  540. return camAt;
  541. }
  542. this.translate = function( x, y ) {
  543. if (!this.activeCameraComp)
  544. this.getActiveCamera();
  545. if ( this.activeCameraComp ) {
  546. var trans = this.getCameraVec( x, y, 0 );
  547. trans[2] = 0;
  548. if ( goog.vec.Vec3.magnitudeSquared( trans ) > goog.vec.EPSILON ) {
  549. // TODO: Clean this up - right now the two vectors are added together and both vectors are replaced
  550. // w/ the result. That's probably not the desired behavior.
  551. this.activeCameraComp.translation = goog.vec.Vec3.add(
  552. this.activeCameraComp.translation,
  553. goog.vec.Vec3.scale(
  554. goog.vec.Vec3.normalize( trans, trans ),
  555. this.distance(),
  556. trans
  557. ),
  558. trans
  559. );
  560. }
  561. }
  562. }
  563. this.update = function() {
  564. if ( this.input ) {
  565. var delta = this.input.pointerDelta();
  566. var pi = this.input.pointerInfo;
  567. if ( delta ) {
  568. if ( this.pointerIsDown() ) {
  569. if ( this.input.pointerInfo.buttons.left ) {
  570. var pi = this.input.pointerInfo;
  571. switch( this.navmode ) {
  572. case "orbit":
  573. this.orbit( delta[0], delta[1] );
  574. break;
  575. case "walk":
  576. if ( this.dragModeMove )
  577. this.move( (pi.position[0]*2.0)-1,(pi.position[1]*2.0)-1 );
  578. else
  579. this.look( (pi.position[0]*2.0)-1,(pi.position[1]*2.0)-1 );
  580. break;
  581. }
  582. }
  583. }
  584. if ( this.input.lookActive ) {
  585. this.look( (pi.position[0]*2.0)-1,(pi.position[1]*2.0)-1 );
  586. }
  587. if ( this.input.moveActive ) {
  588. this.move( (pi.position[0]*2.0)-1,(pi.position[1]*2.0)-1 );
  589. }
  590. }
  591. if ( this.input.keysAreDown() ) {
  592. this.handleKeyDown();
  593. }
  594. if ( this.input.button1Down ) {
  595. if ( this.navMode == "walk" ) {
  596. this.cameraZ( 1.0 );
  597. } else if ( this.navMode == "orbit" ) {
  598. this.zoom( true );
  599. }
  600. }
  601. if ( this.input.button2Down ) {
  602. if ( this.navMode == "walk" ) {
  603. this.cameraZ( -1.0 );
  604. } else if ( this.navMode == "orbit" ) {
  605. this.zoom( false );
  606. }
  607. }
  608. if ( this.input.futureActive() ) {
  609. this.future( 0.1 ).update();
  610. }
  611. }
  612. this.input.lastInputTime = this.time;
  613. } //@ sourceURL=navscene.vwf