-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Description
Environment:
"expo": "~52.0.46",
"react-native": "0.76.9",
"@reactvision/react-viro": "^2.43.0",
Expo development prebuild (attached to physical Samsung s23)
I have an ARScene with some ARText. As you can see the position values are all different, yet the Text shows up right on top of each other at the exact same spot no matter how much I change the xyz values. I have also tried wrapping all of the text in nodes with different positions and same issue. The ViroSphere also will not move anywhere no matter what the position values.
Any ideas how to make position work, or is this a known bug? If so what version would I roll back to in order to get working AR.
export default function ArTestView() {
const router = useRouter();
useEffect(() => {
setSceneKey((prev) => prev + 1);
(async () => {
console.log('Checking AR support on device...');
try {
const result = await isARSupportedOnDevice();
console.log('Supported result:', result.isARSupported);
} catch (err) {
console.error(err);
}
})();
}, []);
const HelloWorldSceneAR = () => {
const [text, setText] = useState('Initializing AR...');
const [trackingState, setTrackingState] = useState(ViroTrackingStateConstants.TRACKING_UNAVAILABLE);
const [trackingReason, setTrackingReason] = useState(
ViroARTrackingReasonConstants.TRACKING_REASON_INSUFFICIENT_FEATURES
);
ViroMaterials.createMaterials({
orbMaterial: {
lightingModel: 'Constant', // makes it glow without shading
diffuseColor: '#00ffcc',
writesToDepthBuffer: true,
},
});
function handleTrackingUpdated(state: any, reason: ViroTrackingReason) {
console.log('handleTrackingUpdated', { state, reason });
setTrackingState(state);
setTrackingReason(reason);
}
return (
<ViroARScene onTrackingUpdated={handleTrackingUpdated}>
{trackingState == ViroTrackingStateConstants.TRACKING_NORMAL &&
trackingReason == ViroARTrackingReasonConstants.TRACKING_REASON_NONE ? (
<>
<ViroNode position={[0, 0, -3]}>
<ViroSphere
position={[0, 0, 0]} // 1 meter in front of camera
radius={0.1} // size of the orb
materials={['orbMaterial']}
/>
</ViroNode>
<ViroText
text="Left"
position={[-1, 0, -2]} // 1m left, 2m forward
scale={[0.5, 0.5, 0.5]}
style={{ color: 'white', backgroundColor: 'rgba(0,255,0,0.5)' }}
/>
<ViroText
text="Right"
position={[1, 0, -2]} // 1m right, 2m forward
scale={[0.5, 0.5, 0.5]}
style={{ color: 'black', backgroundColor: 'rgba(255,0,0,0.5)' }}
/>
<ViroText
text="Center"
position={[0, 0, -2]} // directly forward, 4m away
scale={[0.5, 0.5, 0.5]}
style={{ color: 'yellow', backgroundColor: 'rgba(0,0,255,0.5)' }}
/>
</>
) : (
<ViroText
text="BAD TRACKING"
position={[0, 0, 0]}
scale={[0.5, 0.5, 0.5]}
style={{ color: 'white', backgroundColor: 'rgba(0,255,0,0.5)' }}
/>
)}
</ViroARScene>
);
};
return (
<View style={{ flex: 1 }}>
<ViroARSceneNavigator
autofocus={true}
initialScene={{
scene: HelloWorldSceneAR,
}}
style={styles.f1}
/>
<Button
title="Close AR"
onPress={() => {
// Navigate back to previous page
router.back();
}}
/>
</View>
);
}
var styles = StyleSheet.create({
f1: { flex: 1 },
helloWorldTextStyle: {
fontFamily: 'Arial',
fontSize: 30,
color: '#ffffff',
textAlignVertical: 'center',
textAlign: 'center',
},
});
Metadata
Metadata
Assignees
Labels
No labels