aframe
aframe copied to clipboard
Bug(Camera): On camera zoom camera aspect has wrong values when Aframe is embeded #HighPriority
Description: I'm a développer working currently with Aframe library. I have to handle zoom and fov with an Aframe camera. My problem is when i use Aframe camera and when i set the zoom, the display aspect is strongly wrong. I have see a PR this morning talking about that, this is a bug on camera, because when the developper set the camera aspect it's strongly wrong to take window.heigh and window.width. It's also wrong when set camera aspect with data.aspect and not registring it on schema because it makes people able to pass variables into data.aspect but with getting a warn. My opinion is that data.aspect should be registred in schema and that aspect has to be dynamicly set when embeded. You can test it, by pull Aframe v0.4.0 and by changing camera fov and zoom. I think this should be quickly fixed because it's break some feature like zoom.
- A-Frame Version: v0.4.0
- Platform/Device: All Platform
- Reproducible Code Snippet or Demo URL [highly encouraged]:
This is the PR that i highly recomend to merge: https://github.com/aframevr/aframe/pull/2216 .
Should aspect be part of the schema? Is there any case you want to have an aspect ratio other than the viewport?
cc @maissani
Sorry for the long time with no responses. Aspect should be on schema as long as you store it with data.aspect:
- The first reason is because everyone can set aspect by using aspect attribute because you made it accessible, it will just trigger a warn. My opinion is that when you made it accessible, you should made it public, if you dont want to made it accessible you should do not use public variables or methods.
- The second reason is that it's a good entry point to create effect like speed , fat effects etc....
Aspect Ration should be Always set dynamicly:
- when embeded, because when you are in a embeded mode you can have a viewport that is not reflecting to the real viewport: This made default Aframe Behavior breaking ( Aspect Ratio will not display at the right value )
If the camera aspect ratio won't be different than the viewport (in the embedded case we still use the viewport size) we should then remove aspectRatio
from the schema and change it internally on the component whenever the viewport size changes. I don't think we should rely on the aspect ratio to create any effects. It will be pretty jarring on VR mode
Hey guys, sorry for necroposting, I've just faced the same issue. Without diving deep into the science, here is dirty quick hack to just make things work:
window.addEventListener("wheel", (event) => {
if (event.target.localName.toLowerCase() !== 'canvas') return;
const item = document.getElementById("imageTourCamera");
const delta = event.wheelDelta / 120 / 10;
let mycam = item.getAttribute("camera");
// HERE IT IS
mycam.aspect = item.getObject3D('camera').aspect;
mycam.zoom = mycam.zoom + delta;
item.setAttribute("camera", mycam);
});
Tested at Aframe 1.4.2