viromedia / viro

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

Clear ArScene #513

Closed Cchumi closed 5 years ago

Cchumi commented 5 years ago

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: iOS 12.1
  3. Version: ViroReact 2.13 and React Native 0.57.8
  4. Device(s): iPhone 7

Description

I need to reset the ARscene. I have a 2d ui button and when I click on it I want to clear all existing AR element to start a new AR capture

Reproducible Demo

img_539f18c917e6-1

dam00n commented 5 years ago

resetARSession(resetTracking: boolean, removeAnchors:boolean)

iOS Only

Call this function to reset the ARSession with a combination of the two flags:resetTracking - if true, the scene will realign with the camera's position and orientation.removeAnchors - if true, the anchors will all be removed (onAnchorRemoved will be called on the ViroARScene). It's recommended to also set removeAnchor to true if resetTracking is also set to true.

https://docs.viromedia.com/v2.3.0/docs/viroarscenenavigator

Cchumi commented 5 years ago

Hi thanks I see this function but my app is divided in 2 files.

App.js which contain arscenenavigator and 2D button ui. And another js file which contain all my Arscene imagetarget and viromarker.

If I call this function in my app.js on the on press callback from my touchhighlight it don’t erase the scene.

Perhaps I don’t use it the right way ..?

Cchumi commented 5 years ago

How can I use this method in my parent class.

What I understand in the doc is I need to call this method from my scene which is located in my child class.

achuvm commented 5 years ago

Hi @Cchumi,

Because of how react-native works, there's not a great way to do this, but one way you can do it is to pass a new prop into your ViroARSceneNavigator and check for it in your scene. If the prop is changed, then you invoke the function. You can also use state management frameworks like Redux or Flux to help with this (and respond appropriately to the state changes).

You can pass props like this: https://docs.viromedia.com/docs/scene-navigation#passing-props-from-scene-to-scene

Thanks,

Cchumi commented 5 years ago

Hey sorry for the late answer but a great thanks really :).

I don"t know how to use it before but now I understand the concept.

fixed-term-tylernguyen commented 5 years ago

Did you ever figure out how to implement this?