viro
viro copied to clipboard
onRotate prop work only every second attempt
<ViroARSceneNavigator
initialScene={{
scene: RenderScene,
}}
style={styles.arView}
viroAppProps={{
isReady,
onQuadPress,
}}
/>
<ViroARScene
onTrackingUpdated={onTrackingUpdated}
anchorDetectionTypes="PlanesHorizontal"
onCameraARHitTest={onCameraARHitTest}
>
<ViroAmbientLight
color={'#fff'}
influenceBitMask={1}
intensity={500}
/>
<ViroDirectionalLight color="#ffffff" direction={[0, -1, -0.2]} />
<ViroBox
ref={viroBox}
rotation={rotation}
onRotate={onRotate}
position={[0, 0, -3]}
/>
</ViroARScene>
const [rotation, setRotation] = useState([0, 0, 0]);
const viroBox = useRef(null);
const onRotate = (rotateState, rotationFactor, source) => {
console.log('rotateState', rotateState);
if (rotateState == 3) {
setRotation(old => {
return [
old[0],
old[1] + rotationFactor,
old[2],
]
});
return;
}
viroBox.current.setNativeProps({
rotation: [
rotation[0],
rotation[1] + rotationFactor,
rotation[2],
],
});
};
The cube rotates on every second attempt. How can I make the onRotate prop run every time?
Project create from starter-kit
"dependencies": {
"@viro-community/react-viro": "2.21.1",
"lottie-react-native": "^5.1.3",
"react": "17.0.2",
"react-native": "0.65.1",
"react-native-get-random-values": "^1.8.0",
"uuid": "^8.3.2"
},
onRotate don't work on Xiaomi phones (Redmi Note 10) engine - arcore
Hi @illi-homz I'm experiencing the same issue on Xiaomi Redmi Note 10. I've kind a made this issue less painful by the following way: I've explicitelly set the rotationPivot position to [0, 0, 0] on the node i am trying to rotate to.
With this setup I went down from 8 to 12 unsucessfull attempts to rotate to 2 to 4 attempts. Tested like 100times on development and release builds
Not a proper fix just an improvement...
@illi-homz . I figured out that on react-native 0.67.5 and viro-react 2.23.0 all events works for me. Even onPinch and onRotate works really well on every device I've tesed and had issues before. I have to notice that it works good only if I have Bitcode enabled in Xcode for the whole project and every pods, same with proguard on android. Hope this helps.