|
@@ -14432,6 +14432,8 @@ function WebGLAnimation() {
|
|
|
|
|
|
function WebGLAttributes( gl, capabilities ) {
|
|
|
|
|
|
+ var isWebGL2 = capabilities.isWebGL2;
|
|
|
+
|
|
|
var buffers = new WeakMap();
|
|
|
|
|
|
function createBuffer( attribute, bufferType ) {
|
|
@@ -14506,7 +14508,7 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if ( capabilities.isWebGL2 ) {
|
|
|
+ if ( isWebGL2 ) {
|
|
|
|
|
|
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
|
array, updateRange.offset, updateRange.count );
|
|
@@ -23024,15 +23026,43 @@ function WebXRManager( renderer, gl ) {
|
|
|
|
|
|
if ( controller === undefined ) {
|
|
|
|
|
|
- controller = new Group();
|
|
|
- controller.matrixAutoUpdate = false;
|
|
|
- controller.visible = false;
|
|
|
+ controller = {};
|
|
|
+ controllers[ id ] = controller;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( controller.targetRay === undefined ) {
|
|
|
+
|
|
|
+ controller.targetRay = new Group();
|
|
|
+ controller.targetRay.matrixAutoUpdate = false;
|
|
|
+ controller.targetRay.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return controller.targetRay;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ this.getControllerGrip = function ( id ) {
|
|
|
+
|
|
|
+ var controller = controllers[ id ];
|
|
|
+
|
|
|
+ if ( controller === undefined ) {
|
|
|
|
|
|
+ controller = {};
|
|
|
controllers[ id ] = controller;
|
|
|
|
|
|
}
|
|
|
|
|
|
- return controller;
|
|
|
+ if ( controller.grip === undefined ) {
|
|
|
+
|
|
|
+ controller.grip = new Group();
|
|
|
+ controller.grip.matrixAutoUpdate = false;
|
|
|
+ controller.grip.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return controller.grip;
|
|
|
|
|
|
};
|
|
|
|
|
@@ -23044,7 +23074,17 @@ function WebXRManager( renderer, gl ) {
|
|
|
|
|
|
if ( controller ) {
|
|
|
|
|
|
- controller.dispatchEvent( { type: event.type } );
|
|
|
+ if ( controller.targetRay ) {
|
|
|
+
|
|
|
+ controller.targetRay.dispatchEvent( { type: event.type } );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( controller.grip ) {
|
|
|
+
|
|
|
+ controller.grip.dispatchEvent( { type: event.type } );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -23054,8 +23094,19 @@ function WebXRManager( renderer, gl ) {
|
|
|
|
|
|
inputSourcesMap.forEach( function ( controller, inputSource ) {
|
|
|
|
|
|
- controller.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
|
- controller.visible = false;
|
|
|
+ if ( controller.targetRay ) {
|
|
|
+
|
|
|
+ controller.targetRay.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
|
+ controller.targetRay.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( controller.grip ) {
|
|
|
+
|
|
|
+ controller.grip.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
|
+ controller.grip.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} );
|
|
|
|
|
@@ -23169,7 +23220,18 @@ function WebXRManager( renderer, gl ) {
|
|
|
|
|
|
if ( controller ) {
|
|
|
|
|
|
- controller.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
|
+ if ( controller.targetRay ) {
|
|
|
+
|
|
|
+ controller.targetRay.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( controller.grip ) {
|
|
|
+
|
|
|
+ controller.grip.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
inputSourcesMap.delete( inputSource );
|
|
|
|
|
|
}
|
|
@@ -23185,7 +23247,17 @@ function WebXRManager( renderer, gl ) {
|
|
|
|
|
|
if ( controller ) {
|
|
|
|
|
|
- controller.dispatchEvent( { type: 'connected', data: inputSource } );
|
|
|
+ if ( controller.targetRay ) {
|
|
|
+
|
|
|
+ controller.targetRay.dispatchEvent( { type: 'connected', data: inputSource } );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( controller.grip ) {
|
|
|
+
|
|
|
+ controller.grip.dispatchEvent( { type: 'connected', data: inputSource } );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -23364,23 +23436,50 @@ function WebXRManager( renderer, gl ) {
|
|
|
|
|
|
var inputSource = inputSources[ i ];
|
|
|
|
|
|
+ var inputPose = null;
|
|
|
+ var gripPose = null;
|
|
|
+
|
|
|
if ( inputSource ) {
|
|
|
|
|
|
- var inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );
|
|
|
+ if ( controller.targetRay ) {
|
|
|
|
|
|
- if ( inputPose !== null ) {
|
|
|
+ inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );
|
|
|
|
|
|
- controller.matrix.fromArray( inputPose.transform.matrix );
|
|
|
- controller.matrix.decompose( controller.position, controller.rotation, controller.scale );
|
|
|
- controller.visible = true;
|
|
|
+ if ( inputPose !== null ) {
|
|
|
|
|
|
- continue;
|
|
|
+ controller.targetRay.matrix.fromArray( inputPose.transform.matrix );
|
|
|
+ controller.targetRay.matrix.decompose( controller.targetRay.position, controller.targetRay.rotation, controller.targetRay.scale );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( controller.grip && inputSource.gripSpace ) {
|
|
|
+
|
|
|
+ gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );
|
|
|
+
|
|
|
+ if ( gripPose !== null ) {
|
|
|
+
|
|
|
+ controller.grip.matrix.fromArray( gripPose.transform.matrix );
|
|
|
+ controller.grip.matrix.decompose( controller.grip.position, controller.grip.rotation, controller.grip.scale );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( controller.targetRay ) {
|
|
|
+
|
|
|
+ controller.targetRay.visible = inputPose !== null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- controller.visible = false;
|
|
|
+ if ( controller.grip ) {
|
|
|
+
|
|
|
+ controller.grip.visible = gripPose !== null;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|