-
Notifications
You must be signed in to change notification settings - Fork 3.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
Problem with orthographic camera #48
Comments
You're ABSOLUTELY right :) I'll fixed it right now^^ BABYLON.Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
result.m[0] = 2.0 / (right - left);
result.m[1] = result.m[2] = result.m[3] = 0;
result.m[5] = 2.0 / (top - bottom);
result.m[4] = result.m[6] = result.m[7] = 0;
result.m[10] = -1.0 / (znear - zfar);
result.m[8] = result.m[9] = result.m[11] = 0;
result.m[12] = (left + right) / (left - right);
result.m[13] = (top + bottom) / (bottom - top);
result.m[14] = znear / (znear - zfar);
result.m[15] = 1.0;
}; |
Thank you David :) Anyway, do you know why I can't have an orthographic camera on X or Y axis looking at my scene ? |
Strange...could you share you code so I can try to find the issue? |
Nothing fancy here. Here is my code : var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);
var scene = new BABYLON.Scene(engine);
// Camera on Y axis looking at (0,0,0)
var camera = new BABYLON.FreeCamera("Cam", new BABYLON.Vector3(0,-10,0), scene);
camera.setTarget(new BABYLON.Vector3.Zero());
var box = BABYLON.Mesh.CreateBox("box", 1, scene);
box.position = new BABYLON.Vector3(1, 0, 0);
var renderFunction = function () {
scene.render();
};
engine.runRenderLoop(renderFunction);
camera.attachControl(canvas); When I execute this code, nothing is displayed. I have to attach a control to the camera and rotate the view to see my scene. |
Ohh I know this bug :) This is related to maths^^ camera.setTarget(new BABYLON.Vector3(0, 0, 0.001)); |
Perfect, it's working great :) Thank you !! |
Hi !
I wanted to create an orthographic camera (for a 2d view of a 3d scene) with a Camera, but I detected a little issue in Camera.getProjectionMatrix line 61 : I think this._projectionMatrix is missing as last parameter.
Moreover, I cannot have a correct orthographic camera on Y axis looking on (0,0,0). On Z axis, it works great, but the display is weird on axis X or Y. I thought the problem was in the function Matrix.OrthoOffCenterLHToRef, but I can't find it...
Can you help me ?
The text was updated successfully, but these errors were encountered: