提交 6a9b1ec6 编写于 作者: B Brian Peiris

Allow multiple sensors, exclude phantom Carboard

上级 5b72603a
...@@ -9,18 +9,46 @@ THREE.VRControls = function ( object, onError ) { ...@@ -9,18 +9,46 @@ THREE.VRControls = function ( object, onError ) {
var vrInputs = []; var vrInputs = [];
function filterInvalidDevices( devices ) {
var
OculusDeviceId = 'HMDInfo-dev-0x421e7eb800',
CardboardDeviceId = 'HMDInfo-dev-0x421e7ecc00';
// Exclude Cardboard position sensor if Oculus exists.
var oculusDevices = devices.filter( function ( device ) {
return device.deviceId === OculusDeviceId;
} );
if ( oculusDevices.length >= 1 ) {
return devices.filter( function ( device ) {
return device.deviceId !== CardboardDeviceId;
} );
} else {
return devices;
}
}
function gotVRDevices( devices ) { function gotVRDevices( devices ) {
for ( var i = 0; i < devices.length; i ++ ) { devices = filterInvalidDevices( devices );
var device = devices[ i ]; for ( var i = 0; i < devices.length; i ++ ) {
if ( device instanceof PositionSensorVRDevice ) { if ( devices[ i ] instanceof PositionSensorVRDevice ) {
vrInputs.push( devices[ i ] ); vrInputs.push( devices[ i ] );
break; // We keep the first we encounter
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册