viro
viro copied to clipboard
is there anyway to zoom in Viro360Images ?
Environment
Please provide the following information about your environment:
- Development OS: Windows
- Device OS & Version: What Android OS version (6.0)
- Version: 2.14.0
- Device(s): Samsung Galaxy S6
Description
I need to add a pinch gesture to zoom in Viro360Images ,I've already managed to implement the rotation via panning , and I added a gesture that targets the position value of the camera but it's not working the way I expected.
this.camera.setNativeProps({ position:[ 0 , 0 , -newZoomLevel ] }) I expected to at least be able to change the position of the camera but it doesn't function as it suppose to
Hi, never tried for a Viro360Images, but used a onPinch for an image.
<ViroImage source={require('...')}
scale={[1, 1, 1].map(x => x * this.state.pinchStateGlobal)}
onPinch={this._onPinch}
/>
the function :
_onPinch(pinchState, scaleFactor, source) {
console.log(e);
if(pinchState == 2) {
this.setState({
pinchStateGlobal: scaleFactor,
});
}
}
the constructor :
constructor(props) {
super(props);
this._onPinch = this._onPinch.bind(this)
this.state = {
pinchStateGlobal: 1
};
}
This way, the onPinch() function will update the pinchStateGlobal in the state. As the scale of the image depends of the pinchStateGlobal, it will scale up or down. Worked for a basic image, hope it will help your for the 360 version
@FrancoisBourree scale
and onPinch
are not in the props of Viro360Image
this would be a great feature to have, I have seen users have the expectation to touch pan and pinch zoom on content like this.
You can adjust fieldOfView property of ViroCamera component, which will give you the expected result.