viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

WorldAlignment = gravityAndHeading #118

Closed domvon closed 6 years ago

domvon commented 6 years ago

Is there a way to initialize the Viro AR experience to be like ARKit's ARConfiguration.WorldAlignment = gravityAndHeading , aligned to North-South? Is this exposed in some way, at least for iOS? Thx.

VikAdvani commented 6 years ago

Hi @domvon, currently we don't expose this API. But I added this to our backlog and will update this issue when we launch it.

domvon commented 6 years ago

Yes, exposing this would be amazingly useful for any GPS-based app. Otherwise these apps cannot align the Viro axes to the real-world axes, unless there is another way to do this that is escaping us. Thx.

domvon commented 6 years ago

Btw, Unity lets you find the true north heading, in relation to the Unity world space. If we could do that in Viro, this could be another way to solve the world alignment problem. Looking forward to hear your thoughts on this. Thx.

achuvm commented 6 years ago

Hi @domvon,

Since we're based on React Native, you can consider using something like this custom module that gives you the user's current heading: https://github.com/yonahforst/react-native-heading which comes from the device's compass. With that information, you can then rotate your world by the inverse of that heading to align your objects North.

Let us know if you need help with that (there are also a few other community-built compasses).

Andy

domvon commented 6 years ago

Thanks, but that heading would only be valid if obtained exactly at the time the Viro world space is initialized, and only if its accuracy is good. After that the device will likely have moved around, and any heading info has no relation with the Viro world space anymore, and so we don’t know by what angle to rotate the Viro world space. Does that make sense? Maybe I am missing something...Thx

achuvm commented 6 years ago

Hi @domvon,

Sorry for the delayed response.

You can also try to use it in conjunction with the getCameraOrientationAsync call here: https://docs.viromedia.com/docs/viroarscene#methods which will return you the camera's current orientation. Then if you take the 'y' rotation in conjunction with the heading, then you'll get your offset from the original rotation.

Andy

achuvm commented 6 years ago

Hi @domvon,

Our latest release (https://docs.viromedia.com/docs/releases) now has this feature:

See the worldAlignment prop on the ViroARSceneNavigator (iOS only): https://docs.viromedia.com/docs/viroarscenenavigator#props

Let us know if you have any other issues!

domvon commented 6 years ago

Hi @achuvm , we just saw that, this is awesome! Thanks so much!

achuvm commented 6 years ago

No problem!

We're looking forward to seeing what you build with the platform!

dam00n commented 6 years ago

Closing this issue as solution was provided in latest update.

randomtoni commented 5 years ago

Hello, excellent discussion here. Is there a way of getting the same alignment reference on Android?

Foxu97 commented 4 years ago

Hi how can be te worldAligment feature reached on Android device?

skizzo commented 1 year ago

+1, how can this be achieved on Android?