EricHunag Posted October 6, 2015 Share Posted October 6, 2015 I am currently working on a 2D game, the camera is not moving (locked)... so I need to use <orthographic projection> of the camera, like to that used starling(flash framework). Which camera should I use to achieve this effect in babylonJS? thank`s everyone~ Quote Link to comment Share on other sites More sharing options...
desMaker Posted October 6, 2015 Share Posted October 6, 2015 Hi, try this one: var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 500, 1), scene);camera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;camera.orthoTop = 500;camera.orthoBottom = -500;camera.orthoLeft = -500;camera.orthoRight = 500;var ratio = window.innerWidth / window.innerHeight ;var zoom = camera.orthoTop;var newWidth = zoom * ratio;camera.orthoLeft = -Math.abs(newWidth);camera.orthoRight = newWidth;camera.orthoBottom = -Math.abs(zoom);camera.setTarget(new BABYLON.Vector3.Zero());scene.activeCamera = camera; MrVR 1 Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 6, 2015 Share Posted October 6, 2015 Hello, You can use a freecamera and set an orthographic mode :var mm = new BABYLON.FreeCamera("minimap", new BABYLON.Vector3(0,100,0), this.game.scene);mm.setTarget(new BABYLON.Vector3(0.1,0.1,0.1));// Activate the orthographic projectionmm.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;//These values are required for using an orthographic mode,// and represents the coordinates of the square containing all the camera view.// this.size is the size of our arenamm.orthoLeft = -this.size/2;mm.orthoRight = this.size/2;mm.orthoTop = this.size/2;mm.orthoBottom = -this.size/2; MrVR 1 Quote Link to comment Share on other sites More sharing options...
EricHunag Posted October 6, 2015 Author Share Posted October 6, 2015 thanks~everyone~ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.