首页 > 解决方案 > 有没有办法为 react-viro 360-image 组件添加垂直旋转平移?

问题描述

我需要为我一直在 react-native 开发的应用程序添加垂直旋转平移到 react-viro 相机,在两个月内我还没有找到解决这个问题的方法,这是我的第一次应用程序开发经验,是否可行让它以任何方式工作?

根据https://github.com/viromedia/viro/issues/103,我设法添加了水平旋转和错误的垂直旋转, 他们在这里说垂直平移触发了一些我无法解决的错误问题处理。

 setPanAndZoom=(gesture,isPanning)=>{

    // this.setState({panning:true});

    let distanceX=gesture.x0-gesture.moveX;
    let normalVectorX=distanceX/this.screenWidth;
    let newAngleX=normalVectorX*this.rotateSensivity;

    let distanceY=gesture.y0-gesture.moveY;
    let normalVectorY=distanceY/this.screenWidth;
    let newAngleY=normalVectorY*this.rotateSensivity;



    if(isPanning){
            this.camera.setNativeProps({
                rotation:[this.currentAngleY+newAngleY,this.currentAngleX+newAngleX,0]
            })
    } else
        {
             this.currentAngleX=this.currentAngleX+newAngleX;
             this.currentAngleY=this.currentAngleY+newAngleY;
    }
}







     this.pan=PanResponder.create({
        onStartShouldSetPanResponder:()=>{
            return true
        },
        onPanResponderMove:(event,gesture)=>{
            this.setPanAndZoom(gesture,true)
        },
        onPanResponderRelease:(event,gesture)=>{

            this.setPanAndZoom(gesture,false)

        },

    })

正如他们自己所说,垂直旋转似乎并不完美

标签: javascriptreactjsreact-native

解决方案


推荐阅读