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

rotate camera infinitely #302

Closed frntendev closed 6 years ago

frntendev commented 7 years ago

Hello, what is the best way to rotate camera infinitely at the first of project?

andrewimm commented 7 years ago

Can you explain a little more what you're trying to do? Do you just want the camera to rotate constantly without stopping?

If so, you can use the empty render() method in your client.js file. The camera is just a Three.js object, so you could do something like vr.camera.rotation.y = SPEED * TIME_SINCE_APP_STARTED, where SPEED is some multiplier that determines how fast the camera rotates (in Radians / ms) and TIME_SINCE_APP_STARTED is the current time in ms, minus some time you took before the vr.start() call.

onggunhao commented 7 years ago

As of the current React-VR version (1.4), there is both scene and camera. Which one should we use? vr.scene.rotation.y = SPEED * TIME_SINCE_APP_STARTED vr.camera().rotation.y = SPEED * TIME_SINCE_APP_STARTED

When I run this using vr.camera().rotation.y, it does not seem to work.

For reference:

import {VRInstance} from 'react-vr-web';

function init(bundle, parent, options) {
  const vr = new VRInstance(bundle, 'dataVR', parent, {
    // Add custom options here

    ...options,
  });
  vr.render = function() {
    // Any custom behavior you want to perform on each frame goes here
    vr.scene.rotation.y = -0.2
  };
  // Begin the animation loop
  vr.start();
  return vr;
}

window.ReactVR = {init};
andrewimm commented 6 years ago

Could be implemented with custom controls scheme in React 360

fihirwe commented 5 years ago

Could you please elaborate on that.. I used either vr.camera.rotation.y= n or vr.scene.rotation.y=n but nothing seems to work.. any help?

yogiprsetya commented 4 years ago

Could you please elaborate on that.. I used either vr.camera.rotation.y= n or vr.scene.rotation.y=n but nothing seems to work.. any help?

vr.scene.rotation.y work on me.

You can console the vr to know what inside.