viromedia / viro

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

onClick not working when object is out of close range #777

Open tpol47 opened 5 years ago

tpol47 commented 5 years ago

Environment

Please provide the following information about your environment:

  1. Development OS: macOS Mojave
  2. Device OS & Version: iOS 13.1.3
  3. Version: react-viro version 2.17.0, react-native 0.59.9
  4. Device(s): iPhone 7 and 2017 iPad

Description

I created an onClick function for a 3d object, however this function only works whenever I am in close distance to the object. Even if the object is very visible, if I am not right next to the object the onClick function does not work. I've tried this on both an iPhone 7 as well as a newer iPad and they both encounter the same issue. This issue has also come up when I've experimented with other 3d models. IMG_0429 ^The onClick does not work from this distance

IMG_0430 ^However it does work from this distance

Reproducible Demo

'use strict';

import React, { Component } from 'react';

import {StyleSheet, Alert} from 'react-native';

import { ViroARScene, ViroARImageMarker, ViroARTrackingTargets, Viro3DObject, ViroMaterials, } from 'react-viro';

export default class HelloWorldSceneAR extends Component {

constructor() { super(); this.onClick = this.onClick.bind(this); }

onClick() { Alert.alert("We just Clicked the image!"); }

render() { return (

);

} }

ViroMaterials.createMaterials({ herodog: { diffuseTexture: require('./res/Herodog_UV-0.jpg'), }, });

ViroARTrackingTargets.createTargets({ "targetOne" : { source : require('./res/Test2.jpg'), orientation : "Up", physicalWidth : 1 // real world width in meters }, })

module.exports = HelloWorldSceneAR;

jacklj commented 4 years ago

I'm having the same issue; it seems related to https://github.com/viromedia/viro/issues/785, because if I swipe on the object when it's far away, then the onClick fires. Did you make any progress with it?