Talk:K3D JavaScript Canvas Library

Please email if you have questions or concerns. Jsalsman (discuss • contribs) 01:04, 24 July 2011 (UTC)

Textures Render Incorrectly When Object Is Rotated
Maybe it is a problem with my code and not the rendering functionality but I have generated a box with a texture on it. The texture is basically a even grid dividing the face into 9 squares.

When the box is rendered dead-on (i.e. angles are all 0, 90, 180 or 360) then the texture appears correct.

However, when the box is rotated to some odd angle (not a multiple of 0, 90, 180 or 360) the texture appears incorrect.

From what I can see, it seems that the face is rendered properly but then the texture is applied linearly not taking the 3D perspective of the face into account.

For example, if you are looking at one of the sides of the box dead-on then it appears as a square. As the box is rotated into the screen, the bottom edge appears to remain the same size but the top edge reduces in size giving the illusion that it is further away (into the screen) from the viewer. Thus the face becomes a trapazoid.

However, it appears that the texture on such a object does not do this. The texture seems to be applied as if the object was flat, using the smaller edge for scaling. The larger edge then uses more of the texture as necessary. This means that while the face has become a trapazoid, the texture has not.

Here is a link to a picture that shows the issues...



Are there any fixes for this planned?

My code is as follows:

Best Regards,

Lord Ashes

P.S. Otherwise this is a create piece of code...keep up the great work!