facebookarchive / react-360

Create amazing 360 and VR content using React
https://facebook.github.io/react-360
Other
8.73k stars 1.23k forks source link

LiveEnvCamera doesn't work in Oculus Browser #358

Open tlakomy opened 6 years ago

tlakomy commented 6 years ago

Description

I think it's probably a bug, although I'm not sure if it's intended to work in the first place - I'm trying to use LiveEnvCamera to show the camera feed to the user. It obviously doesn't work on desktop, on mobile (Samsung Galaxy S7 Edge) works as intended but on a headset I'm seeing only blackness.

Expected behavior

LiveEnvCamera should show a camera feed to the user in Oculus Browser

Actual behavior

LiveEnvCamera does not show the user a camera feed when using Oculus Browser

Reproduction

My sample test component:

import React from 'react';
import {
  AppRegistry,
  asset,
  Pano,
  Text,
  View,
  LiveEnvCamera,
} from 'react-vr';

export default class HelloVR extends React.Component {
  render() {
    return (
      <View>
        <LiveEnvCamera />
        <Text
          style={{
            backgroundColor: '#777879',
            fontSize: 0.8,
            fontWeight: '400',
            layoutOrigin: [0.5, 0.5],
            paddingLeft: 0.2,
            paddingRight: 0.2,
            textAlign: 'center',
            textAlignVertical: 'center',
            transform: [{translate: [0, 0, -3]}],
          }}>
          hello
        </Text>
      </View>
    );
  }
};

AppRegistry.registerComponent('HelloVR', () => HelloVR);

Solution

I'd like to confirm whether I'm doing something work or it's not supposed to work in the first place :)

Additional Information

tlakomy commented 6 years ago

@larrylin28 I spent couple of hours debugging this and I've found where the bug is.

In LiveEnvCamera.js there's a following constraints object:

const constraints = {
      video: {facingMode: {ideal: 'environment'}},
    };

which gets COMPLETELY ignored by a react-vr app and it always returns the front camera. That's why the user will always see the blackness in a headset. This can be easily verified by raising the phone in GearVR headset a little so that the light can actually come in.