All Questions

Tagged with
88 questions
Filter by
Sorted by
Tagged with
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...