I'm looking to convert screen coordinates (from event.clientX, event.clientY) on jQuery mousemove, to world coordinates in my isometric WebGL project. I'm, also using gl-matrix.

I initialise my viewport with;

JavaScript

gl.viewport(0, 0, width, height)

where width and height are $(window).width() and $(window).height() respectively

The bounds are calculated as such;

JavaScript

left = -width / 2;
right = width / 2;
bottom = -height / 2;
top = height / 2;

The orthographic projection matrix is set up as such;

I then make the projection isometric by rotating the projection matrix to a pitch of Math.asin(1 / Math.sqrt(3)) and a yaw of Math.PI / 4.

With some cubes placed randomly on a grid, it looks like this: View screenshot[^]

So given any (x, y) from (0, 0) to (width, height), how can I calculate the world coordinate, given that an object in the very centre of the scene is (0, 0, 0) in world coordinates?

If I understand what you're trying to do, it's impossible. You are trying to convert a 2D screen location (x,y) into a 3D world location (x', y', z'). All world points along a line of sight share the same screen location. The initial projection destroyed the "depth" information, and you can never recover it.

Given an orthographic projection rotated to (1/sqrt(3), pi/4, 0) to make it isometric, the rotation can be used to directly calculate the screen point's corresponding world point, I'm just not sure what that calculation is.

Forget about rotation for a moment. Let's consider a simple orthographic projection along the z axis, so the x and y screen coordinates map to world x and y (with appropriate scaling). What I am saying is that the world points (x,y,0) and (x,y,1) and (x,y,2) etc all map to the same screen point. From the screen coordinates, there is no way to recover the "depth" dimension, in this example the z direction. In a rotated projection, the same thing applies to whatever the "line of sight" direction happens to be. Looking at your random cubes example, every point on a visible face of a cube shares a screen point with a point on a hidden face (and an infinite number of others in front and behind along that line of sight).

In a rotated projection, the same thing applies to whatever the "line of sight" direction happens to be.

Looking at your random cubes example, every point on a visible face of a cube shares a screen point with a point on a hidden face (and an infinite number of others in front and behind along that line of sight).