viro icon indicating copy to clipboard operation
viro copied to clipboard

ViroReact ViroARImageMarker disable marker content if target is invisible and show when target isvisible

Open kanaseranjit opened this issue 5 years ago • 9 comments

ViroARImageMarker content should show on target is visible. That is working fine.

But once the target is not visible then hide the marker content immediately.

kanaseranjit avatar Feb 13 '20 07:02 kanaseranjit

You could maybe check out the anchor status, from the anchor object that you get when OnAnchorFound is called. "trackingMethod" could maybe work:

"The current tracking method used to keep track of the Image Marker Anchor. It can be one of the following values: "notTracking" - image marker hasn't yet been found "tracking" - image marker is actively being tracked "lastKnownPose" - image marker isn't currently being tracked but instead rendered based on its last known pose"

And then change the "visible" prop on your object accordingly?

https://docs.viromedia.com/docs/viroarscene#anchor

HedwigAR avatar Feb 13 '20 09:02 HedwigAR

@HedwigAR Doesn't this only work for Android though?

jinkoay avatar Feb 13 '20 19:02 jinkoay

Thankyou @HedwigAR for your valuable reply

We are startup developers so we are not sure how to implement those status. Project's deadline is about to end but not able to overcone this scenario.

Will you please provide some sample code. In anchorfound and anchorupdate events we are not also able to get "Anchor"parameter. while trying to get it we are getting it as undefined.

We are developing Viroreact application on windows operating system. Application for android devices.

Application is created by steps into below URL: https://docs.viromedia.com/docs/quick-start-windows

kanaseranjit avatar Feb 17 '20 16:02 kanaseranjit

Thankyou @HedwigAR for your valuable reply

We are startup developers so we are not sure how to implement those status. Project's deadline is about to end but not able to overcone this scenario.

Will you please provide some sample code. In anchorfound and anchorupdate events we are not also able to get "Anchor"parameter. while trying to get it we are getting it as undefined.

We are developing Viroreact application on windows operating system. Application for android devices.

Application is created by steps into below URL: https://docs.viromedia.com/docs/quick-start-windows

kanaseranjit avatar Feb 17 '20 16:02 kanaseranjit

So my guess would be something like

<ViroARScene onAnchorFound=(anchor)=>{this.yourFunction}>

yourFunction(anchor){
  if(anchor.trackingMethod === "lastKnownPose"){
  
  }
}

HedwigAR avatar Feb 17 '20 16:02 HedwigAR

@HedwigAR does anchor tracking methods support IOS

Please reply m in urgent need.

ControlAndC avatar Apr 17 '20 19:04 ControlAndC

@ControlAndC No, it's Android only

AliKHODR avatar May 28 '20 14:05 AliKHODR

a

So my guess would be something like

<ViroARScene onAnchorFound=(anchor)=>{this.yourFunction}>

yourFunction(anchor){
  if(anchor.trackingMethod === "lastKnownPose"){
  
  }
}

Don't work. I tried doing this at first only. But after visible=False, I couldn't see the image anymore.

kkumawa1 avatar Mar 17 '21 22:03 kkumawa1

For future reference: The onAnchorFound function runs on IOS only when the target is visible.

So for IOS, simply set a timer and on every onAnchorUpdated clear the timer and set it again. The code inside the timer will execute when the ImageMarker is not visible (same with lastKnownPose), and the code outside the timer but inside if (anchor.trackingMethod === undefined) { } will act as a "tracking" equivalent on IOS.

P.S. It's a good idea to throttle the function that runs onAnchorUpdated, otherwise it runs too many times, like once per frame.

YasinKuralay avatar Oct 20 '21 09:10 YasinKuralay