Gyroscope sensor

From iphone when i first click it show Dis Nan, but when i remove my finger and then clicked again in the screen it show numbers.
and some time it show numbers.

from desktop most of the time it show numbers. but some time it show Dis Nan.

so from iphone if you touch and move your finger back and forth do you get number?

From most of the time first click on the screen it show Dis Nan, and when you drag left , right it will not show numbers at all, you need to click again and then it will work good and it will show numbers.
but also there is situation that it will work and will show numbers from the first touch.

Try this one
Touch Test ver 4.zpp (188.1 KB)

If you get any Nan then run it in windows zapper app and take a photo of the debug data

it show Dis Nan.
and from desktop most time it work good.d3

is this data from after you moved your mouse?
because the X Data and the lastX Data should not be the same.

d4
this data come from only one click on the mouse, and i remove my finger and do not change the position of the mouse

Ok do a click and move. the data will change just like when you would touch the iphone screen.

d5
i click in the screen and drag top with the mouse

Ok try this zpp file
Touch Test ver 5.zpp (1.5 MB)

from iphone it change the number, not at all the view .
from desktop it work , but some times it change number witohut changing the view, mean i am clicking on the screen, and drag left and right, it change numbers, but not changing view at all .

That’s all the code. we added one part at a time. there should be no reason it shouldn’t work all the time on both desktop and iphone.

We are going to have to talk with the zapper guys. Maybe they can see something I don’t.
@Seb @George Hay guys any Ides on whats up here?

We will have to wait on them now.
which is ok because it’s the end of my work day and I’m just about to leave soon. I’ll check in tomorrow to see if they say anything.

Steve

Thank you dear, thank you a lot for your time .
let wait and see…

Have a good day ahead there.

1 Like

Hi @eliaskhs,

We have received your support ticket and have replied to you on there.

Will let you know in this thread if we get it sorted @stevesanerd.

Thanks,

George

1 Like

Hello thank you for your respond .
replayed.

Finaly with the help of the support team we fond the solution
this is the code.

var mObj = symbol.nodes.Photo_Sphere; //the node or object you want to rotate
var lastX : number // This is needed for storing distance between frames.
var lastY : number // This is needed for storing distance between frames.
const rotSpeed = 100; // Constant to be multiplied by movement on the plane to determine how fast the object will rotate.

// This function activates when the user moves thier finger on surface covered by the parent plane object.
parent.on(“pointermove”, (_e)=> {
let _distX = _e.localPosition[0] - lastX; // how much we’ve moved between frames.
let _distY = (_e.localPosition[1] *-1) - lastY; // how much we’ve moved between frames.

let _rot = mObj.rotation();                 // Get current rotation so we can alter one axis.


_rot[1] += _distX * rotSpeed;    // change the rotation based on distance, multiplied by desired speed factor.

// _rot[0] += _distY * rotSpeed; // change the rotation based on distance, multiplied by desired speed factor.

mObj.rotation(_rot);            // Set the nodes rotation to the new rotation.

lastX = _e.localPosition[0];  // record where the user is touching the screen this frame for next time they move.
lastY = _e.localPosition[1] * -1;  // record where the user is touching the screen this frame for next time they move.

});

// This function is also necessary to get the initial position of the users touch.
parent.on(“pointerenter”, (_e)=> {
lastX = _e.localPosition[0]; // Set initial position when user touches the screen.
lastY = _e.localPosition[1] * -1; // Set initial position when user touches the screen.
});

1 Like

Ok so why does the code work for me and others but not you?

Steve

Hi @eliaskhs and @stevesanerd,

The problem that we found was that if the first value from the pointer down function was returned as NaN (which it sometimes was), then the rotation script would not work and the whole project was void.

The work around, is to change the parent.on(“pointerdown”) function to a parent.on(“pointerenter”) therefor saving an actual value every time the project is interacted with for the first time.

PointerEnter

Glad we figured this out!

George

2 posts were split to a new topic: Check if the device has gyro functionality

Hay George,
Sorry I was on Holiday. So I am just now getting back to this.
So first I want to say I didn’t write the code. I edited it from code that @bradleycox255 had on the 2d towards camera post.

I guess I don’t understand why I didn’t get any errors with any of my devices or pc zapper app?
Both @bradleycox255 zpp file and my edited code worked. So why did @eliaskhs get NaN errors?

Steve

1 Like