-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't read camera World pose in AR mode #4412
Comments
It should work. Provide link to simple example to reproduce. |
Sorry need to reopen. Was using cached code that worked around the issue. https://xr.andrew.cmu.edu/x/refactor/ Code snippet:
|
More info, possibly related problem. The end result being that camera reported position (in e.g. pose-listener Component for getting camera world pose change events) is the opposite of what it should be on iOS devices. This may be a result of WebXR code or WebXR polyfill in the Firefox-webxr (Fennec) viewer... since this is the code that is unique to iOS |
I'm seeing what looks like the same lack of tracking on a Samsung S9 in a bigger 8th Wall project I'm naively PoCing over to vanilla a-Frame 1.0.3/4 sans-8th-Wall- the A-Scene and basic functionality works when 8W is stripped off, and in default static/locked-view mode things interact, but in AR I completely lose my view-groundplane-intersection reticle, meaning either
Not sure if I'll have the open R&D time to look much further into it, tho, beyond noting that it doesn't "just work" (didn't expect it to per se, but it's a lot closer to working than I expected, and this seems like one of the main points of failure) and VR exhibits similar symptoms to AR. Would it be reasonable to suspect this is a tangent to mrdoob/three.js#15347 and the root cause is that within an AR session, even the THREE camera is not actually continuously updated (as I've also observed in an independent test) and therefore some other mechanism must be used to dig out the underlying viewer reference frame? |
@riebling probably better to contact 8th wall folks. @riebling Your example is still pretty complicated to investigate. I see a lot of 3rd components pulled in. Below there's a simple example reporting world position and rotation of the camera. Tested on desktop, Rift, Quest, phone; Code: https://glitch.com/edit/#!/instinctive-vaulted-regnosaurus?path=index.html:27:85 If you can reproduce the issue based on the code above I'm happy to look a it. Otherwise it's probably caused by ar.js / 8th wall integrations or other 3rd party components that you might be using. I recommend reporting the issue in the ar.js or 8th wall repos. |
Ok; I've stripped my project down to only A-Frame 1.0.4, A-Frame Extras (likely not needed), 1 script making use of the cursor component on the camera to trace an object along the groundplane, and a basic (nearly empty) component registration script. https://dev.nextnowagency.com/camera_ray_test/ Expected behavior:
Observed behavior:
|
New, even more minimal demo 100% confirming issues in AR/VR with most Object3D .getWorld* calls on the https://dev.nextnowagency.com/camera_world_test/ Expected behavior:
Observed behavior:
edit: corrected affected calls claim; also tagging @dmarcos |
Is the example I provided not working for you? https://instinctive-vaulted-regnosaurus.glitch.me/ |
Right now glitch appears to be stalling (both code and demo), but that might just be ambient office network issues on my end atm. I did take a peek at the code before setting up my demos, tho, and at a quick glance it looked like what was set to be reported were just the basic object3d properties, not the world getters. In my tests, the transform properties are just fine, it's the getters that return static defaults in VR/AR. Will let you know if I can actually get at your demo again later. |
Ok; @dmarcos I remixed your example just adding the logging for the getWorld* call outputs. Seeing the same issue as in my demos: as soon as AR/VR is entered, they become default-looking values as opposed to following the actual transform properties. |
I don't understand the problem. In your link all values change on 2D mode (using keyboard) and when in VR mode (Firefox + Oculus Rift). Not sure what you mean by https://glitch.com/edit/#!/lace-fern-ghost?path=index.html:71:39 |
Also FWIW it looks like the OP's reference link also explicitly deals with the getWorldPosition and getWorldQuaternion calls, not the world matrix used in your sample. |
@NNskelly I see in your logs that the code provided in the example above is working as expected. You're getting world position and rotation. Is that correct? Below the component complete code if you are having issues with glitch. Can you confirm that the code is working as expected (use code as is, don't mix it to minimize noise)?
|
@NNskelly FYI, getWorld* methods don't work in immersive mode. More info on mrdoob/three.js#18448 You can use the provided code |
The lines labelled "Position" and "Rotation" are from your demo at https://instinctive-vaulted-regnosaurus.glitch.me/ using data derived from The lines in my screenshot labeled World Position, World Quaternion and World Heading are coming from lines I added in my remix https://sparkling-moored-basket.glitch.me/ .
The added lines retrieve the world transform parameters via the Object3D .getWorldPosition, .getWorldQuaternion and .getWorldDirection calls. The OP observed and cited in their reference link that .getWorldPosition and .getWorldQuaternion were not returning valid data in VR mode, and my earliest observations showed that .getWorldDirection also was not returning valid data. All 3 seem to fail specifically in VR/AR mode on mobile, although I have not deep-tested their behavior on mobile outside VR/AR (it's a bit harder to use the stock A-Frame keyboard controls on mobile). And by "fail" I mean that the World Position from getWorldPosition, listed as I concede that it is technically possible to use alternate methods to acquire a valid world position for the camera, but the issue report, as twice stated and variously demonstrated, is that in VR/AR mode, at least on mobile, at least when querying the el.object3d of the A-Frame camera, the specific calls getWorldPosition, getWorldQuaternion, and getWorldDirection (all documented on https://threejs.org/docs/#api/en/core/Object3D as being valid and intended ways to get the world coordinates of an object) do not return data consistent with the effective functioning position of the queried object. I have not proven that this issue is specific to A-Frame's particular use of the THREE camera, indeed I suspect it isn't. |
I have been solving a similar problem. I needed to get a point in front of camera using aframe API. But the challege was when the experience were on VR mode(fullscreen) and playing on movile or headset. In this context the management of the current camera is absolutely controlled by WebXR. With WebXR THREE applies headset pose to the object3D internally. You only can use the matrixWorld of the three camera to access the camera world reference data, other properties or methods are not correct. In the case of aframe you must access to the object3D of the aframe camera entity and manage its matrixWorld. It is the only method to get correct information of the position/rotation/scale of the camera that it is move by the sensors of a movile or of a AR/VR goggles when the play is on VR/AR mode. I use to get the in front of Camera Position With WebXR Headset Pose: const distanceFromCamera = 250; // the depth in the screen, what ever you need const threeSceneCamera = <THREE.PerspectiveCamera>AFRAME.scenes[0].camera; inFrontOfCameraPosition.applyMatrix4( threeSceneCamera.matrixWorld ); return { x: inFrontOfCameraPosition.x, y: inFrontOfCameraPosition.y, z: inFrontOfCameraPosition.z }; |
FYI, if you are not using a camera rig you can retrieve the world position of the camera from the camera entity in both VR and desktop: document.querySelector('a-scene').camera.el.getAttribute('position'); The matrixWorld that should be used is the one in the camera entity object3D: document.querySelector('a-scene').camera.el.object3D.matrixWorld |
AFRAME.scenes[0].camera In my case, I am using a-cursor in mobile but in a headset (for example Meta Quest2) not. The only way that resolve my necesity in VR or AR is to use directly the camera matrixWorld. |
AFRAME.scenes[0].camera and document.querySelector('a-scene').camera.el.object3D should be different. Former is the THREE.PerspectiveCamera and latter is the entity that contains the camera (THREE.PerspectiveCamera is a child). A-Frame applies the WebXR pose to the camera entity, not the THREE camera. In most scenarios using the camera.matrixWorld will be equivalent but keep in mind that you're tapping into the internals and that could break in the future. That's why I recommend using cameraEl.object3D.matrixWorld instead. |
I have finally used this option that get the position in front of the Aframe camera at a defined distace. It works in all the situations that I have tested, even using look-controls or in vr mode with Quest 2 or in ar mode with a mobile. const getInFrontOfCameraPosition = ( distanceFromCamera) => {
}; Thank you marcos by your tips. |
I have the doubt, what would be better or faster to get the camera: option 1: const aSceneCameraEntity = document.querySelector('a-scene').camera.el; |
The technique for getting camera pose described here:
https://github.com/aframevr/aframe/blob/master/docs/components/camera.md#reading-world-position-or-rotation-of-the-camera
doesn't seem to work when in AR mode. (It used to work in all modes before A-Frame version 1.0) The reported world coordinates don't change with changes to device rotation (or translation, I think also), even though the camera's translation and rotation relative to the 3d scene elements clearly do. The technique for getting position and rotation of the camera (non-"world") on that page still works.
Maybe it's intentionally disabled in efforts to more fully support WebXR. Maybe AR mode implies that world coordinates are undefined?
The text was updated successfully, but these errors were encountered: