Hey, I’m pretty new to Babylon.js and I’m trying to convert some of my web AR projects using Aframe/Three.js to Babylon.js. But I’m running into some problems and I’m pretty certain it has to do with the camera, though I could be way off. I used a ProjectionMatrix to set a PerspectiveCamera and then update it in my old projects.
//init will be changed once i get the camera data
var camera = new THREE.PerspectiveCamera(50, window.innerWidth/ window.innerHeight, 1, 10000);
camera.lookAt( 0, 0, 0 );
...
...
...
//changed once I got the data from the tracker.
camera.fov = fov;
camera.aspect = newAspect;
camera.near = near;
camera.far = far;
camera.updateProjectionMatrix();
I saw a couple of similar projects that had set up their cameras like this but it isn’t quite giving me the results I need.
var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 0, new BABYLON.Vector3(0, 0, 0), scene);
camera.setPosition(new BABYLON.Vector3(0, 0, 0.001));
camera.noRotationConstraint=true;
camera.attachControl(canvas, true);
...
...
... //this part seems redundant if I'm getting all that info from the ProjectionMatrix and setting it afterwards anyways
camera.fov = fov
camera.minZ = 10;
camera.maxZ = 10000;
camera.freezeProjectionMatrix( new BABYLON.Matrix.FromArray(ProjectionMatrix));
I had to scroll back on the mouse wheel to even see the cube and it still is off and way too big.Whereas in my old project, it is spot on.
The 2 meshes have the exact same world matrix and both cameras are giving the same exact Projection matrix. The only thing I updated in the project was any Three.js code to the equivalent Babylon.js code so everything else should be working the same. The only thing I couldn’t really find exact equivalence to, between the two, is the camera setup.
All of this leads me to believe I’m just royally screwing up the camera in the scene, though I know it could be a whole slew of other things. I’m just trying to cross some stuff off my list.
Any clues to what is the best camera setup that matches the Three.js I have at the beginning? Sorry for the ramble, if I need to clarify anything let me know. Any help is appreciated. Thanks!