Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Is there a way to access the Camera rotation inside a component? #62

Closed
nikgraf opened this issue Mar 4, 2017 · 3 comments
Closed

Is there a way to access the Camera rotation inside a component? #62

nikgraf opened this issue Mar 4, 2017 · 3 comments

Comments

@nikgraf
Copy link

nikgraf commented Mar 4, 2017

Description

I was trying to manipulate a flight in space based on where the person looks. Todo that I need camera.getWorldDirection(). Is there a way to get access to the camera within a component?

@amberroy
Copy link
Contributor

amberroy commented Mar 4, 2017

No you cannot access the camera directly within a React component, as the camera is on the runtime / three.js side of things. So you would need a Native Module or get a reference to the camera from the VRInstance in client.js (more on that in Issue #43)

@andrewimm
Copy link
Contributor

If you just want the orientation of the camera (say, to make items move with it), we provide a utility called VrHeadModel which receives updates from a Native Module.

import {VrHeadModel} from 'react-vr';

const position = VrHeadModel.positionOfHeadMatrix();
const rotation = VrHeadModel.rotationOfHeadMatrix();
const horizFov = VrHeadModel.horizontalFov();
const vertFov = VrHeadModel.verticalFov();

It uses our internal MatrixMath module to produce these results, creating basic JS arrays containing the data from these vectors / matrices.

@nikgraf
Copy link
Author

nikgraf commented Mar 14, 2017

Holy cow 🐮 … this is amazing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants