Correct Rotation

The structure is like this

Camera has a parent node,Gyro control Camera rotation.
The following code will make the camera rotate to the current angle of the gyroscope

            var x = pc.math.DEG_TO_RAD * this.beta;
            var y = pc.math.DEG_TO_RAD * this.alpha;
            var z = pc.math.DEG_TO_RAD * -this.gamma;
            var c1 = Math.cos( x / 2 );
            var c2 = Math.cos( y / 2 );
            var c3 = Math.cos( z / 2 );
            var s1 = Math.sin( x / 2 );
            var s2 = Math.sin( y / 2 );
            var s3 = Math.sin( z / 2 );
            var q0 = new pc.Quat(
                s1 * c2 * c3 + c1 * s2 * s3,
                c1 * s2 * c3 - s1 * c2 * s3,
                c1 * c2 * s3 - s1 * s2 * c3,
                c1 * c2 * c3 + s1 * s2 * s3
            var q1 = new pc.Quat(-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5)); // - PI/2 around the x-axis
            var q2 = new pc.Quat();

This code is triggered after 2 seconds,so…I need to correct the spin beating at this time

Now the effect is this,Please use your mobile device to open it,Wait for two seconds

See 2 seconds after a clear beating(Try to correct the rotation)
This is my code

            ///////////////The problem is here//////////////////
            this.jzEA = this.jzEA || pc.Vec3.ZERO;
                this.www = false;
                this.jzEA = q0.getEulerAngles().clone();
                // this.jzEA.scale(-1);
            //Correct rotation
            ///////////////The problem is here(end)//////////////////

However, this correction does not seem correct, how to modify?

@yaustar Can you help me, may not be very clear description

Project is private so I can’t see the code.

What do you want to happen when the user opens the app?

it’s good now!!!!Public project:joy_cat:

Why do you have the 2 second delay before you start rotating the view? If you are waiting for loading, it would make more sense to have a loading screen and then the user enters the experience.

Otherwise, the user will see the room but it doesn’t feel like it is interactive until the loading has finished which is a poor user experience.

What you are looking to do is to match the initial view angle and offset it by the mobile orientation when the loading has finished.

Not necessarily 2 seconds, 2 seconds is a slow process, in 2 seconds I need to Camera correction to 2 seconds offset

But this correction is wrong

Yes, all I have to do is to cache the camera’s angle in 2 seconds and then correct the camera

What are you loading for 2 seconds?

For example, the current condition is not 2 seconds, but users turn on the gyroscope.The gyroscope is disabled by default. When the user manually turns on the gyroscope, the camera rotation is controlled by the gyroscope used, so it will be offset when the user turns it on. So I need correction

When the user turns on the gyroscope to correct the camera’s offset ,not 2 seconds ,How to do it? :hushed:

On what devices do users need to turn on the gyroscope? On my project, it’s virtually instant. No user interaction required.

In regards to the offset, you need to negate the rotation on the gyro in relation to the initial angle of the camera.

Honestly, I think it be easier to do a fade up from black when you think the device and scene is ready over what you have now.

@yaustar Thanks for your reply!

A switch on the UI controls turning on the gyroscope.

like this

You see this very understand(Please use mobile device to open)

Is not this correct?

oh! @yaustar The problem of calibration has now been solved, but there is a problem with the rotation of the gyroscope。

You can look at the demo below(Please use mobile device to open and click on the UI ‘gyroscope’)

this code:

It seems this is really a headache thing :tired_face: