viro icon indicating copy to clipboard operation
viro copied to clipboard

is there anyway to zoom in Viro360Images ?

Open Ashkan-Oliaie opened this issue 5 years ago • 3 comments

Environment

Please provide the following information about your environment:

  1. Development OS: Windows
  2. Device OS & Version: What Android OS version (6.0)
  3. Version: 2.14.0
  4. 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

Ashkan-Oliaie avatar Jun 15 '19 20:06 Ashkan-Oliaie

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 avatar Jun 27 '19 14:06 FrancoisBourree

@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.

impaler avatar Jul 09 '19 05:07 impaler

You can adjust fieldOfView property of ViroCamera component, which will give you the expected result.

sanoopks avatar Dec 07 '22 11:12 sanoopks