|
21246 | 21246 | var standingMatrix = new Matrix4(); |
21247 | 21247 | var standingMatrixInverse = new Matrix4(); |
21248 | 21248 |
|
21249 | | - var options = { frameOfReferenceType: 'stage' }; |
| 21249 | + var frameOfReferenceType = 'stage'; |
21250 | 21250 |
|
21251 | 21251 | if ( typeof window !== 'undefined' && 'VRFrameData' in window ) { |
21252 | 21252 |
|
@@ -21422,12 +21422,17 @@ |
21422 | 21422 |
|
21423 | 21423 | }; |
21424 | 21424 |
|
21425 | | - this.setDevice = function ( _device, _options ) { |
| 21425 | + this.setDevice = function ( value ) { |
21426 | 21426 |
|
21427 | | - if ( _device !== undefined ) device = _device; |
21428 | | - if ( _options !== undefined ) options = _options; |
| 21427 | + if ( value !== undefined ) device = value; |
21429 | 21428 |
|
21430 | | - animation.setContext( _device ); |
| 21429 | + animation.setContext( value ); |
| 21430 | + |
| 21431 | + }; |
| 21432 | + |
| 21433 | + this.setFrameOfReferenceType = function ( value ) { |
| 21434 | + |
| 21435 | + frameOfReferenceType = value; |
21431 | 21436 |
|
21432 | 21437 | }; |
21433 | 21438 |
|
|
21439 | 21444 |
|
21440 | 21445 | this.getCamera = function ( camera ) { |
21441 | 21446 |
|
| 21447 | + var userHeight = frameOfReferenceType === 'stage' ? 1.6 : 0; |
| 21448 | + |
21442 | 21449 | if ( device === null ) { |
21443 | 21450 |
|
21444 | | - camera.position.set( 0, 1.6, 0 ); |
| 21451 | + camera.position.set( 0, userHeight, 0 ); |
21445 | 21452 | return camera; |
21446 | 21453 |
|
21447 | 21454 | } |
|
21453 | 21460 |
|
21454 | 21461 | // |
21455 | 21462 |
|
21456 | | - if ( options.frameOfReferenceType === 'stage' ) { |
| 21463 | + if ( frameOfReferenceType === 'stage' ) { |
21457 | 21464 |
|
21458 | 21465 | var stageParameters = device.stageParameters; |
21459 | 21466 |
|
|
21463 | 21470 |
|
21464 | 21471 | } else { |
21465 | 21472 |
|
21466 | | - standingMatrix.makeTranslation( 0, 1.6, 0 ); |
| 21473 | + standingMatrix.makeTranslation( 0, userHeight, 0 ); |
21467 | 21474 |
|
21468 | 21475 | } |
21469 | 21476 |
|
|
21515 | 21522 |
|
21516 | 21523 | standingMatrixInverse.getInverse( standingMatrix ); |
21517 | 21524 |
|
21518 | | - if ( options.frameOfReferenceType === 'stage' ) { |
| 21525 | + if ( frameOfReferenceType === 'stage' ) { |
21519 | 21526 |
|
21520 | 21527 | cameraL.matrixWorldInverse.multiply( standingMatrixInverse ); |
21521 | 21528 | cameraR.matrixWorldInverse.multiply( standingMatrixInverse ); |
|
21621 | 21628 | var device = null; |
21622 | 21629 | var session = null; |
21623 | 21630 |
|
21624 | | - var frameOfRef = null; |
| 21631 | + var frameOfReference = null; |
| 21632 | + var frameOfReferenceType = 'stage'; |
21625 | 21633 |
|
21626 | 21634 | var pose = null; |
21627 | 21635 |
|
|
21630 | 21638 |
|
21631 | 21639 | function isPresenting() { |
21632 | 21640 |
|
21633 | | - return session !== null && frameOfRef !== null; |
21634 | | - |
| 21641 | + return session !== null && frameOfReference !== null; |
21635 | 21642 |
|
21636 | 21643 | } |
21637 | 21644 |
|
@@ -21677,10 +21684,10 @@ |
21677 | 21684 |
|
21678 | 21685 | }; |
21679 | 21686 |
|
21680 | | - this.setDevice = function ( _device ) { |
| 21687 | + this.setDevice = function ( value ) { |
21681 | 21688 |
|
21682 | | - if ( _device !== undefined ) device = _device; |
21683 | | - if ( _device instanceof XRDevice ) gl.setCompatibleXRDevice( _device ); |
| 21689 | + if ( value !== undefined ) device = value; |
| 21690 | + if ( value instanceof XRDevice ) gl.setCompatibleXRDevice( value ); |
21684 | 21691 |
|
21685 | 21692 | }; |
21686 | 21693 |
|
|
21700 | 21707 |
|
21701 | 21708 | } |
21702 | 21709 |
|
21703 | | - this.setSession = function ( _session, _options ) { |
| 21710 | + this.setFrameOfReferenceType = function ( value ) { |
| 21711 | + |
| 21712 | + frameOfReferenceType = value; |
| 21713 | + |
| 21714 | + }; |
| 21715 | + |
| 21716 | + this.setSession = function ( value ) { |
21704 | 21717 |
|
21705 | | - session = _session; |
| 21718 | + session = value; |
21706 | 21719 |
|
21707 | 21720 | if ( session !== null ) { |
21708 | 21721 |
|
|
21712 | 21725 | session.addEventListener( 'end', onSessionEnd ); |
21713 | 21726 |
|
21714 | 21727 | session.baseLayer = new XRWebGLLayer( session, gl ); |
21715 | | - session.requestFrameOfReference( _options.frameOfReferenceType ).then( function ( _frameOfRef ) { |
| 21728 | + session.requestFrameOfReference( frameOfReferenceType ).then( function ( value ) { |
21716 | 21729 |
|
21717 | | - frameOfRef = _frameOfRef; |
| 21730 | + frameOfReference = value; |
21718 | 21731 |
|
21719 | 21732 | renderer.setFramebuffer( session.baseLayer.framebuffer ); |
21720 | 21733 |
|
|
21799 | 21812 |
|
21800 | 21813 | function onAnimationFrame( time, frame ) { |
21801 | 21814 |
|
21802 | | - pose = frame.getDevicePose( frameOfRef ); |
| 21815 | + pose = frame.getDevicePose( frameOfReference ); |
21803 | 21816 |
|
21804 | 21817 | if ( pose !== null ) { |
21805 | 21818 |
|
|
21842 | 21855 |
|
21843 | 21856 | if ( inputSource ) { |
21844 | 21857 |
|
21845 | | - var inputPose = frame.getInputPose( inputSource, frameOfRef ); |
| 21858 | + var inputPose = frame.getInputPose( inputSource, frameOfReference ); |
21846 | 21859 |
|
21847 | 21860 | if ( inputPose !== null ) { |
21848 | 21861 |
|
|
0 commit comments