# All Questions

88
questions

**0**

votes

**1**answer

20 views

### WebGL Combined Camera Rotations

Why is it that when I multiply a rotation matrix with the camera matrix -
let rotation = m.mult4(m.rotateX(xRads)),m.rotateY(yRads)));
camera = m.mult4(rotation,camera);
I get incorrect rotation. But ...

**0**

votes

**0**answers

49 views

### How to set forward direction using lookAt matrix?

I have a WebGL 3D scene set up with a single mesh and a camera. I can translate/rotate both correctly (it appears so in testing, anyway).
Now I would like to be able to set the 'forward' direction of ...

**0**

votes

**0**answers

28 views

### Why is my WebGL 3D to 2D projection giving wrong result?

I'm writing a WebGL application that needs to be able to project a 3D point to the camera's field of view (in the [-1 .. 1] range when within the field of view).
Most of the time my code works fine, ...

**2**

votes

**1**answer

350 views

### Normals transformation for Back-Face culling

Starting from this lesson here: WebGL 3D Perspective I am triyng to implement Back-Face culling no magic.
I am computing on the fly the face normals in object space. After that, I am setting the ...

**0**

votes

**1**answer

145 views

### In WebGL, can I use a matrix to draw an object offset in screen space?

I have a simple object that draws a 3d gizmo at 0, 0, 0. If the camera is centered on 0, 0, 0, then it draws the gizmo at the center of the screen.
I would like to "lift" this gizmo and ...

**0**

votes

**1**answer

53 views

### Why won't my transformation matrix translate the points?

I have been trying to use my own matrices in WebGL (2d at the moment). My main reference is webglfundamentals.com. I multiply a 360-degree rotation with a (1, -1) scale, (-142, 6) translation, and a ...

**0**

votes

**2**answers

313 views

### Three.js bounding rectangle of a plane relative to viewport and near plane clipping issue

This is a general WebGL issue but for the sake of clarity I'll be using three.js to demonstrate my problem here.
Let's say I have a plane and a perspective camera. I'm trying to get the bounding ...

**3**

votes

**1**answer

702 views

### Rotating an axis of rotation in webgl

So I am not sure if my question is more of a programming question, more of a pure math question, or equally both.
Short version: I have a rotating sphere in webgl, but it isn't rotating the way I ...

**0**

votes

**1**answer

206 views

### WebGL 2D Canvas Point convert to 3D world point

I have a problem with my code or I expect the wrong value. What I want to achieve is to convert 2D points from canvas to 3D world space point.
If I understand correctly, I should always get the same ...

**1**

vote

**1**answer

66 views

### Confused about GLSL vector matrix multiplication order

I have a matrix that gives you screen coordinates when you plug a vec2 into it.
It produces results like this:
I can invert the matrix, and plug in mouse coordinates and use that to allow you to ...

**2**

votes

**1**answer

999 views

### How to calculate screen coordinates after transformations?

I am trying to solve a question related to transformation of coordinates in 3-D space but not sure how to approach it.
Lets a vertex point named P is drawn at the origin with a 4x4 transformation ...

**0**

votes

**0**answers

183 views

### WebGL: obtain canvas coordinates for each vertex

Is it possible to know the canvas coordinates for each vertex in a 3D model already rendered with webgl?
Can it be done by using a GLSL-script or with pure javascript?
The question points to pick a ...

**1**

vote

**1**answer

3k views

### How to scale a texture in webgl?

I have a texture of size 800x600. How do I scale it on a webgl <canvas> at another size and keep the original aspect ratio? Assuming that the drawing buffer and the canvas have the same ...

**1**

vote

**1**answer

96 views

### ViewMatrix calculation messes up models

I have a WebGL application which renders an array of cubes, each with a different height. To size them I use the transformation matrix to scale the cubes. I also have a camera, which can be moved with ...

**3**

votes

**1**answer

1k views

### Trying to draw shapes in screen-space coordinates using an orthographic projection with WebGL (regl)

Using regl I'm trying to implement a very simple drawRect() function that will eventually be able to pass an x, y, width, height in screen space (with origin 0,0 at top left corner of the screen)
...