viro icon indicating copy to clipboard operation
viro copied to clipboard

how can i render 360image using gyroscope?

Open sjt145 opened this issue 6 years ago • 7 comments

  • [x] Review the documentation: https://docs.viromedia.com/
  • [x] Search for existing issues: https://github.com/viromedia/viro
  • [x] Use the latest ViroReact release: https://docs.viromedia.com/docs/releases

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version:IOS version 12.1
  3. Version: ViroReact 2.9.1 and React Native 57
  4. Device(s): Iphone SE

Description

I have developed an app viewing viromedia documentation for VR360 Photo tour just like the viromedia app... But they havent given any component to render 360image as shown in viromedia app for 360Photo tour... I need to intergrate same functionality for my app...so is there any example for 360Photo tour in react-viro... please provide with code as I am new to Viromedia...

Thank you

sjt145 avatar Feb 11 '19 06:02 sjt145

i also need to integrate 360 Photo tour in my app, but can't able to find any solution for that is there any example for integrating 360 photo tour using react viro

Nishit-Chauhan avatar Feb 11 '19 08:02 Nishit-Chauhan

Hi any update on it? it would be great if someone from the community can shed some lights on it? we are also looking forward for the similar features

jack-solutions avatar Feb 18 '19 10:02 jack-solutions

i have seen in the viromedia app demos, one of the demo has 360 view of image when you move the phone to different direction, but to implement that there is no function listed in the documentation, any help would be appreciated

jack-solutions avatar Feb 18 '19 10:02 jack-solutions

Hi @sjt145 , I don't know if I understood perfectly what you need, but in the documentation of ViroMedia, contrary to what you said, there is a component to render 360 images:

https://docs.viromedia.com/docs/viro360image

tks

renatocsare avatar Mar 19 '19 17:03 renatocsare

this is how I've been using it

renderImage() {
    return (
      <ViroScene>
        <Viro360Image source={ require('./res/360picture.jpg')} />
      </ViroScene>
    )
  }

render() {
  return (
   <ViroVRSceneNavigator
     vrModeEnabled={false}
     hdrEnabled={true}
     initialScene={{scene: this.renderImage.bind(this) }}
   /> );
}

RinorDreshaj avatar May 07 '19 11:05 RinorDreshaj

Hi Gaes

is there a way to get X,Y,Z position of Viro360Image ? can we zoom in or zoom out panorama ?

adamnurdin01 avatar Jul 16 '20 00:07 adamnurdin01

1. 360 Image rotation using gyroscope

import {
  gyroscope,
  SensorTypes,
  setUpdateIntervalForType,
} from 'react-native-sensors';

Create these variables

const cameraRef = useRef(null);  /* Camera component ref props variable */
const giroInterval = Platform.OS == 'ios' ? 16.7 : 10.99;
const cameraRotationXRef = useRef(0);
const cameraRotationYRef = useRef(0);

You can call this function to listen gyroscope and update the camera rotation

const gyroSubscription = () => {
    setUpdateIntervalForType(SensorTypes.gyroscope, giroInterval);
    return gyroscope.subscribe(({x, y, z, timestamp}) => {
        const nx = parseFloat(x.toFixed(3));
        const ny = parseFloat(y.toFixed(3));
        /* Vertical movement */
        if (nx > 0) {
          /* Moving to top */
          let newRotX = cameraRotationXRef.current + nx;
          cameraRotationXRef.current = newRotX;
          const rot = [
            cameraRotationXRef.current,
            cameraRotationYRef.current,
            0,
          ];
          if (cameraRef.current)
            cameraRef.current.setNativeProps({rotation: rot});          
        } else {
          /* Moving to bottom */
          /* An adjustment to stop automatic movement of panoramic image to left because of gyrscope always returns x,y,z value */
          if (nx < -0.05) {
            let newRotX = cameraRotationXRef.current + nx;
            cameraRotationXRef.current = newRotX;
            const rot = [
              cameraRotationXRef.current,
              cameraRotationYRef.current,
              0,
            ];
            if (cameraRef.current)
              cameraRef.current.setNativeProps({rotation: rot});            
          }
        }

        /* Horizontal movement */ 
        if (ny > 0) {
          /*  Moving to left */ 
          /*  An adjustment to stop automatic movement of crib to left because of gyrscope always returns x,y,z value */ 
          if (ny > 0.05) {
            let newRotY = cameraRotationYRef.current + ny;
            cameraRotationYRef.current = newRotY;
            const rot = [
              cameraRotationXRef.current,
              cameraRotationYRef.current,
              0,
            ];
            if (cameraRef.current)
              cameraRef.current.setNativeProps({rotation: rot});
          }
        } else {
          /* Moving to right */
          let newRotY = cameraRotationYRef.current + ny;
          cameraRotationYRef.current = newRotY;
          const rot = [
            cameraRotationXRef.current,
            cameraRotationYRef.current,
            0,
          ];
          if (cameraRef.current)
            cameraRef.current.setNativeProps({rotation: rot});
        }
    });
  };

This is the camera component

<ViroCamera
    rotation={[0, 0, 0]}
    position={[0, 0, 0]}
    ref={cameraRef}
    fieldOfView={fov}
  />

2. Zooming in Viro360Image

You can use fieldOfView property of ViroCamera component.

sanoopks avatar Dec 07 '22 13:12 sanoopks