Results 1 to 4 of 4

Thread: Problems with the J3DIMath.js library used in demos

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    4

    Problems with the J3DIMath.js library used in demos

    There are several tutorials which use the J3DI.js and J3DIMath.js libraries, for example: http://www.khronos.org/webgl/wiki/Tutorial

    There are problems I found (with some help) with this library. I'm not sure where I should be posting these bugs so I'll put them here:

    In J3DIMath.js in J3DIMatrix4.prototype.lookat() the following code:
    Code :
        matrix.$matrix.m11 = xx;
        matrix.$matrix.m12 = xy;
        matrix.$matrix.m13 = xz;
        matrix.$matrix.m14 = 0;
     
        matrix.$matrix.m21 = yx;
        matrix.$matrix.m22 = yy;
        matrix.$matrix.m23 = yz;
        matrix.$matrix.m24 = 0;
     
        matrix.$matrix.m31 = zx;
        matrix.$matrix.m32 = zy;
        matrix.$matrix.m33 = zz;
        matrix.$matrix.m34 = 0;

    must be changed to:

    Code :
        matrix.$matrix.m11 = xx;
        matrix.$matrix.m12 = yx;
        matrix.$matrix.m13 = zx;
        matrix.$matrix.m14 = 0;
     
        matrix.$matrix.m21 = xy;
        matrix.$matrix.m22 = yy;
        matrix.$matrix.m23 = zy;
        matrix.$matrix.m24 = 0;
     
        matrix.$matrix.m31 = xz;
        matrix.$matrix.m32 = yz;
        matrix.$matrix.m33 = zz;
        matrix.$matrix.m34 = 0;

    In J3DIVector3.prototype.cross(), J3DIVector3.prototype.combine() and probably others, variables are used after they are changed when temporary values should be used to store the original values.

    I'm posting this here because it has wasted a lot of my time trying to find the problem. If anyone knows where these should go, let me know. Hope it helps someone.

  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    8

    Re: Problems with the J3DIMath.js library used in demos

    manixrock,

    I know exactly what you mean. The last 3 days I spent on that problem exclusively. I even wrote an interactive website to test the effects of what happens when I calculate the matrices in different order.
    The worse thing is, I knew about your post and I was in the belief, that I had changed the function. Turned out I had the file twice on my computer.

    What a realization.

    peace,
    einSelbst

  3. #3

    Re: Problems with the J3DIMath.js library used in demos


  4. #4
    Junior Member
    Join Date
    Aug 2011
    Posts
    1

    Re: Problems with the J3DIMath.js library used in demos

    I'm no expert JS coder, but isn't there also a problem with the cross product function? Currently it's as follows:

    Code :
    J3DIVector3.prototype.cross = function(v)
    {
        this[0] =  this[1] * v[2] - this[2] * v[1];
        this[1] = -this[0] * v[2] + this[2] * v[0];
        this[2] =  this[0] * v[1] - this[1] * v[0];
    }

    Shouldn't it instead be:
    Code :
    J3DIVector3.prototype.cross = function(v)
    {
        var x =  this[1] * v[2] - this[2] * v[1];
        var y = -this[0] * v[2] + this[2] * v[0];
        var z =  this[0] * v[1] - this[1] * v[0];
        this[0] = x;
        this[1] = y; 
        this[2] = z;
     
    }

Similar Threads

  1. Replies: 3
    Last Post: 04-29-2011, 08:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •