Record the perspective data when playing 360 video


I want to record the perspective data when playing 360 video. I saw VideoDome has a rotation accessor, and I thought that saves the degree of rotating the perspective. However, after I rotated the perspective, I found that rotation accessor remained (0, 0, 0). So I wonder if there is anything that I can track the perspective data.

Hi yuxin,

By “perspective data,” do you mean the direction the user is looking at times throughout the video? If so, I think the rotation you’re looking for is on the camera, not on the VideoDome. If that’s what you’re looking for, saving off a time-series of the camera’s orientation might give you what you need.

Thanks. That is what I mean. So could you please tell me how to get the camera’s orientation? Because I tried cameraDirection, cameraRotation, and rotation properties of camera, and none of these is the camera’s orientation.

Hey @yuxin

This might be worth checking out:

It allows you to provide a ray that defaults to starting from the camera position and they casts out from that position in the forward direction.

Thanks. But I am using ArcRotateCamera which doesn’t have this method. Does ArcRotateCamera have similar method?

ArcRotateCamera inherits from TargetCamera, which has the method, so you should be able to use it on an ArcRotateCamera. If you add the code


does it log out the direction the camera is pointing? If not, can you create a Playground with a repro? Thanks!

Thanks for help. I tried this method, but after I move the orientation, there is no change between two logs.

Please check the Playground repo:

Okay, I think I know what you’re going for. Does the following illustrate the right behavior?

If you check the console log, you should see a value being logged out constantly that changes when the camera’s orientation moves. To record which direction the user was looking in, all you should have to do is collect that data over time and eventually save it in a file somewhere. If this is what you were trying to do, I think the piece you were missing was line 20, where I add the logging code to an onBeforeRenderObservable so that it will be called repeatedly. createScene is called only once, when the application starts up, so any code that appears in there (or, equivalently, where createScene is called from) will only be executed once. You want to check the camera’s orientation repeatedly over time, so you need to add your code to an observable so that it’s run every time the scene renders a new frame. Hope this is helpful!

Got it! Thanks a lot!