Reputation: 2858
Composing a scene in React VR is somewhat cumbersome because you're always stuck in 1st person view which makes it hard to judge the depth at which objects are placed.
By default the camera is placed at [0, 0, 0]
coords, I'd like to know if there's a way to control that. Couldn't find anything in the docs but I know they're incomplete. If it's possible it could pave the way towards a dedicated editor like aframe has.
Upvotes: 2
Views: 874
Reputation: 5172
Adding to the answers here.
In order to move the position of the camera, you can use a custom ThreeJS camera and add it to your scene, this way you can leave your VR elements untouched
const vr = new VRInstance(bundle,"ReactVR",parent, {
camera:customCamera,/*your custom threeJS camera*/
...options,
});
Your custom camera could be like
import { PerspectiveCamera } from "three";
const VIEW_ANGLE = 60;
const ASPECT = document.body.clientWidth / document.body.clientHeight;
const NEAR = 0.1;
const FAR = 10000;
const camera = new PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
camera.name = "Custom3JSCamera";
camera.position.set(0,0,5);
export default camera;
Upvotes: 2
Reputation: 452
You can use transform to change camera place, this should give you a similar effect as on your screen:
<View style={{
transform: [
{translate: [-20, -10, -20]},
],
}}>
Upvotes: 1
Reputation: 13233
For background information, in A-Frame, you can change to any camera you want or move the active camera wherever:
<a-scene>
<a-entity position="0 0 -5"><a-entity id="camera1" camera="active: true"></a-entity>
<a-entity position="5 0 5"><a-entity id="camera2" camera="active: false"></a-entity>
</a-scene>
<script>
document.querySelector('#camera2').setAttribute('camera', 'active', true);
</script>
Upvotes: 1