|
@@ -21121,6 +21121,26 @@ function WebGLUtils( gl, extensions ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * @author mrdoob / http://mrdoob.com/
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+function Group() {
|
|
|
|
+
|
|
|
|
+ Object3D.call( this );
|
|
|
|
+
|
|
|
|
+ this.type = 'Group';
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
+
|
|
|
|
+ constructor: Group,
|
|
|
|
+
|
|
|
|
+ isGroup: true
|
|
|
|
+
|
|
|
|
+} );
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author greggman / http://games.greggman.com/
|
|
* @author greggman / http://games.greggman.com/
|
|
@@ -21457,6 +21477,13 @@ function WebVRManager( renderer ) {
|
|
this.enabled = false;
|
|
this.enabled = false;
|
|
this.userHeight = 1.6;
|
|
this.userHeight = 1.6;
|
|
|
|
|
|
|
|
+ this.getController = function ( id ) {
|
|
|
|
+
|
|
|
|
+ console.warn( 'WebVRManager: getController() not yet implemented.' );
|
|
|
|
+ return new Group();
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
this.getDevice = function () {
|
|
this.getDevice = function () {
|
|
|
|
|
|
return device;
|
|
return device;
|
|
@@ -21647,13 +21674,16 @@ function WebXRManager( renderer ) {
|
|
var session = null;
|
|
var session = null;
|
|
|
|
|
|
var frameOfRef = null;
|
|
var frameOfRef = null;
|
|
|
|
+ var inputSources = [];
|
|
|
|
|
|
var pose = null;
|
|
var pose = null;
|
|
|
|
+ var controllers = {};
|
|
|
|
|
|
function isPresenting() {
|
|
function isPresenting() {
|
|
|
|
|
|
return session !== null && frameOfRef !== null;
|
|
return session !== null && frameOfRef !== null;
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
@@ -21674,6 +21704,23 @@ function WebXRManager( renderer ) {
|
|
|
|
|
|
this.enabled = false;
|
|
this.enabled = false;
|
|
|
|
|
|
|
|
+ this.getController = function ( id ) {
|
|
|
|
+
|
|
|
|
+ var controller = controllers[ id ];
|
|
|
|
+
|
|
|
|
+ if ( controller === undefined ) {
|
|
|
|
+
|
|
|
|
+ controller = new Group();
|
|
|
|
+ controller.matrixAutoUpdate = false;
|
|
|
|
+
|
|
|
|
+ controllers[ id ] = controller;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return controller;
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
this.getDevice = function () {
|
|
this.getDevice = function () {
|
|
|
|
|
|
return device;
|
|
return device;
|
|
@@ -21690,18 +21737,30 @@ function WebXRManager( renderer ) {
|
|
|
|
|
|
//
|
|
//
|
|
|
|
|
|
|
|
+ function onSessionEvent( event ) {
|
|
|
|
+
|
|
|
|
+ var controller = controllers[ inputSources.indexOf( event.inputSource ) ];
|
|
|
|
+ if ( controller ) controller.dispatchEvent( { type: event.type } );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function onSessionEnd () {
|
|
|
|
+
|
|
|
|
+ renderer.setFramebuffer( null );
|
|
|
|
+ animation.stop();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
this.setSession = function ( value, options ) {
|
|
this.setSession = function ( value, options ) {
|
|
|
|
|
|
session = value;
|
|
session = value;
|
|
|
|
|
|
if ( session !== null ) {
|
|
if ( session !== null ) {
|
|
|
|
|
|
- session.addEventListener( 'end', function () {
|
|
|
|
-
|
|
|
|
- renderer.setFramebuffer( null );
|
|
|
|
- animation.stop();
|
|
|
|
-
|
|
|
|
- } );
|
|
|
|
|
|
+ session.addEventListener( 'select', onSessionEvent );
|
|
|
|
+ session.addEventListener( 'selectstart', onSessionEvent );
|
|
|
|
+ session.addEventListener( 'selectend', onSessionEvent );
|
|
|
|
+ session.addEventListener( 'end', onSessionEnd );
|
|
|
|
|
|
session.baseLayer = new XRWebGLLayer( session, gl );
|
|
session.baseLayer = new XRWebGLLayer( session, gl );
|
|
session.requestFrameOfReference( options.frameOfReferenceType ).then( function ( value ) {
|
|
session.requestFrameOfReference( options.frameOfReferenceType ).then( function ( value ) {
|
|
@@ -21715,6 +21774,17 @@ function WebXRManager( renderer ) {
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ inputSources = session.getInputSources();
|
|
|
|
+
|
|
|
|
+ session.addEventListener( 'inputsourceschange', function () {
|
|
|
|
+
|
|
|
|
+ inputSources = session.getInputSources();
|
|
|
|
+ console.log( inputSources );
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
};
|
|
};
|
|
@@ -21782,28 +21852,49 @@ function WebXRManager( renderer ) {
|
|
|
|
|
|
pose = frame.getDevicePose( frameOfRef );
|
|
pose = frame.getDevicePose( frameOfRef );
|
|
|
|
|
|
- var layer = session.baseLayer;
|
|
|
|
- var views = frame.views;
|
|
|
|
|
|
+ if ( pose !== null ) {
|
|
|
|
+
|
|
|
|
+ var layer = session.baseLayer;
|
|
|
|
+ var views = frame.views;
|
|
|
|
|
|
- for ( var i = 0; i < views.length; i ++ ) {
|
|
|
|
|
|
+ for ( var i = 0; i < views.length; i ++ ) {
|
|
|
|
|
|
- var view = views[ i ];
|
|
|
|
- var viewport = layer.getViewport( view );
|
|
|
|
- var viewMatrix = pose.getViewMatrix( view );
|
|
|
|
|
|
+ var view = views[ i ];
|
|
|
|
+ var viewport = layer.getViewport( view );
|
|
|
|
+ var viewMatrix = pose.getViewMatrix( view );
|
|
|
|
|
|
- var camera = cameraVR.cameras[ i ];
|
|
|
|
- camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
|
|
|
|
- camera.projectionMatrix.fromArray( view.projectionMatrix );
|
|
|
|
- camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
|
|
|
|
|
|
+ var camera = cameraVR.cameras[ i ];
|
|
|
|
+ camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );
|
|
|
|
+ camera.projectionMatrix.fromArray( view.projectionMatrix );
|
|
|
|
+ camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
|
|
|
|
|
|
- if ( i === 0 ) {
|
|
|
|
|
|
+ if ( i === 0 ) {
|
|
|
|
|
|
- cameraVR.matrix.copy( camera.matrix );
|
|
|
|
|
|
+ cameraVR.matrix.copy( camera.matrix );
|
|
|
|
|
|
- // HACK (mrdoob)
|
|
|
|
- // https://github.com/w3c/webvr/issues/203
|
|
|
|
|
|
+ // HACK (mrdoob)
|
|
|
|
+ // https://github.com/w3c/webvr/issues/203
|
|
|
|
|
|
- cameraVR.projectionMatrix.copy( camera.projectionMatrix );
|
|
|
|
|
|
+ cameraVR.projectionMatrix.copy( camera.projectionMatrix );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ for ( var i = 0; i < inputSources.length; i ++ ) {
|
|
|
|
+
|
|
|
|
+ var inputSource = inputSources[ i ];
|
|
|
|
+ var inputPose = frame.getInputPose( inputSource, frameOfRef );
|
|
|
|
+
|
|
|
|
+ if ( inputPose !== null && controllers[ i ] ) {
|
|
|
|
+
|
|
|
|
+ var controller = controllers[ i ];
|
|
|
|
+ controller.matrix.elements = inputPose.gripMatrix;
|
|
|
|
+ controller.matrix.decompose( controller.position, controller.rotation, controller.scale );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -25773,26 +25864,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
-/**
|
|
|
|
- * @author mrdoob / http://mrdoob.com/
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-function Group() {
|
|
|
|
-
|
|
|
|
- Object3D.call( this );
|
|
|
|
-
|
|
|
|
- this.type = 'Group';
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-Group.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
-
|
|
|
|
- constructor: Group,
|
|
|
|
-
|
|
|
|
- isGroup: true
|
|
|
|
-
|
|
|
|
-} );
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author mrdoob / http://mrdoob.com/
|
|
*/
|
|
*/
|