jquery jPhysics-3D

Discussion in 'jQuery' started by Sleeping Troll, May 10, 2009.

  1. #1
    I am modifying jPhysics for 3D resolution, but getting error in code that I can't figure? Any help appreciated.

    
    
    jQuery.fn.physics = function(params) {
    
     this.each(function(i){
    
      //Defaults for first time (without physics properties) (when not in 'params')
    
      if (!this.position) {
    
       if (!params.position) this.position = new $.Vector(0,0,0);
    
       if (!params.velocity) this.velocity = new $.Vector(0,0,0);
    
       if (!params.acceleration) this.acceleration = new $.Vector(0,0,0);
    
       if (!params.minPosition) this.minPosition = new $.Vector(-Infinity,-Infinity,-Infinity);
    
       if (!params.maxPosition) this.maxPosition = new $.Vector(Infinity,Infinity,-Infinity);
    
       if (!params.minVelocity) this.minVelocity = new $.Vector(-Infinity,-Infinity,-Infinity);
    
       if (!params.maxVelocity) this.maxVelocity = new $.Vector(Infinity,Infinity,-Infinity);
    
       if (!params.minAcceleration) this.minAcceleration = new $.Vector(-Infinity,-Infinity,-Infinity);
    
       if (!params.maxAcceleration) this.maxAcceleration = new $.Vector(Infinity,Infinity,-Infinity);
    
       if (!params.mass) this.mass = 1;
    
       this.style.position = 'absolute';
    
      }
    
      //Use 'params' where possible
    
      if (params.position) this.position = params.position;
    
      if (params.velocity) this.velocity = params.velocity;
    
      if (params.acceleration) this.acceleration = params.acceleration;
    
      if (params.minPosition) this.minPosition = params.minPosition;
    
      if (params.maxPosition) this.maxPosition = params.maxPosition;
    
      if (params.minVelocity) this.minVelocity = params.minVelocity;
    
      if (params.maxVelocity) this.maxVelocity = params.maxVelocity;
    
      if (params.minAcceleration) this.minAcceleration = params.minAcceleration;
    
      if (params.maxAcceleration) this.maxAcceleration = params.maxAcceleration;
    
      if (params.mass) this.mass = params.mass;
    
      this.style.left = Math.round(this.position[0])+'px';
    
      this.style.top = Math.round(this.position[1])+'px';
    
      [COLOR="Red"]this.style.z-index = Math.round(this.position[2]);//this line throws "syntax error"[/COLOR]
     });
    
     return this;
    
    };
    
    
    
    
    Code (markup):
    I am thinking the "-" in z-index is being parsed as an operator? If this is the case, how do I work around it?
     
    Sleeping Troll, May 10, 2009 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Hi,

    try this:
    this.style.zIndex = Math.round(this.position[2]);
    Code (markup):
    Regards
     
    koko5, May 10, 2009 IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yup, that did it, hmm... let's see CSS, W3C standard, z-index... I wish they would create some standards for themselves!
    Thx!
    Just in case you did not know, I just figured out why, z-index returns "auto" for a value of 0, zIndex returns 0
     
    Sleeping Troll, May 10, 2009 IP