How to detect Gear VR input signals in React VR mode?

I am trying to create a web application using React VR and launch it using Samsung Gear VR.

I could not see the default white dot (VR pointer) in VR mode in my scene. Therefore, methods such as "onInput" and "onClick" do not work. The same methods work very well if I watch the same scene outside of VR mode - even using the browser provided in Gear VR.

Am I missing something? How to access these methods in VR mode in Gear VR?

Sample code that works fine in a regular web browser (including Gear VR), but not when I'm in VR.

<Text
    style={{
        // backgroundColor: '#777879',
        fontSize: 0.2,
        transform: [{translate: [0, 0, -5]}],
        color: this.state.textColor
    }}
    onEnter={() => this.setState({textColor: 'gold'})}
    onExit={() => this.setState({textColor: 'white'})}>
    This text will turn gold when you look at it.
</Text>
+4
source share
1 answer

raycaster:

:

<project root>/vr/client.js.   init SimpleRaycaster.

const SimpleRaycaster = {
    getType: () => "simple",
    getRayOrigin: () => [0, 0, 0],
    getRayDirection: () => [0, 0, -1],
    drawsCursor: () => true
};

function init(bundle, parent, options) {

//...

init cursorVisibility: visible raycaster raycasters:

function init(bundle, parent, options) {
  const vr = new VRInstance(bundle, 'Example', parent, {
      raycasters: [
          SimpleRaycaster // Add SimpleRaycaster to the options
      ],
      cursorVisibility: "visible", // Add cursorVisibility
      enableHotReload: true,
    ...options,
  });
  vr.render = function() {
    // Any custom behavior you want to perform on each frame goes here
  };
  // Begin the animation loop
  vr.start();
  return vr;
}

window.ReactVR = {init};

. .

+6

Source: https://habr.com/ru/post/1678157/


All Articles