ozRocker Posted May 14, 2017 Share Posted May 14, 2017 Has anyone ever re-created a MapBox (or other mapping api) camera in Babylon.js? I've found a project in Three.js that recreates the MapBox camera by updating the camera projection matrix and world matrix: https://github.com/peterqliu/threebox/blob/master/src/Camera/CameraSync.js There is this kind of code that access the camera world matrix but I'm not sure how to do that in Babylon.js: this.camera.projectionMatrix = utils.makePerspectiveMatrix(fov, this.map.transform.width / this.map.transform.height, 1, farZ); var cameraWorldMatrix = new THREE.Matrix4(); var cameraTranslateZ = new THREE.Matrix4().makeTranslation(0,0,cameraToCenterDistance); var cameraRotateX = new THREE.Matrix4().makeRotationX(this.map.transform._pitch); var cameraRotateZ = new THREE.Matrix4().makeRotationZ(this.map.transform.angle); // Unlike the Mapbox GL JS camera, separate camera translation and rotation out into its world matrix // If this is applied directly to the projection matrix, it will work OK but break raycasting cameraWorldMatrix .premultiply(cameraTranslateZ) .premultiply(cameraRotateX) .premultiply(cameraRotateZ); this.camera.matrixWorld.copy(cameraWorldMatrix); Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.