Perspective projection problems when scaling

I am working on a demonstration of rendering perspective projections using javascript, I recently added perspective projection, and it works as if I were zooming in.

Here is a picture of this strange behavior:
enter image description here

Notice how the meshes gather at a point.

So, I doubt that in two things the other scaling formulas that I use are incorrect or something that I do not understand in the mathematics of perspective forecasts.

For scaling, I just have the global variable window.scaleFactor , which I multiply with each point:

 Point.prototype.projection = function(matrix){ var point = $M([[this.x *window.scaleFactor],[this.y * window.scaleFactor],[this.z * window.scaleFactor],[1]]); var projection = matrix.x(point); return new Point(projection.e(1,1)/projection.e(4,1) + window.panX,projection.e(2,1)/projection.e(4,1) + window.panY,0); } 

So, anyway, or if the scaling calculation is related to the point of view?

Here you can try the demo: http://ahmedkotb.0fees.net/3d/projection_demo.html

EDIT: you can zoom in using the mouse wheel and rotate by dragging it onto the canvas ... Also I have not tested this except for chrome, sorry for that.

Any illustration would be appreciated, thanks.

+4
source share
1 answer

I think the problem is this: when you zoom in, some of your lines get closer to the camera, and you don't crop them (lines). The artifact that I see is typical of non-clipping projection. Solution: Fix your lines or use another 3D rendering library that will be clamped for you.

+3
source

All Articles