0

I am trying to translate object in space, and I have this function which should translate object, its stored in .js file

 JSC3D.Matrix3x4.prototype.translate = function(tx, ty, tz) {
this.m03 += tx;
this.m13 += ty;
this.m23 += tz;
 };

but in another js file I am trying to implement real numbers and to move object, how can I call this function and change its parameters ?

commandos2389
  • 175
  • 1
  • 10

1 Answers1

0
JSC3D.Matrix3x4.prototype.translate = function(tx, ty, tz) {

var t=0;
var g=0;
var h=0;

 t = parseFloat(document.getElementById('translate_x').value);
 g = parseFloat(document.getElementById('translate_y').value);
 h = parseFloat(document.getElementById('translate_z').value);
console.log(t);

    if(t!=0 || g!=0 || h!=0)
    {

        console.log(this.m03);
        this.m03 += tx;
        this.m13 += ty;
        this.m23 += tz;
        tx=t;
        ty=g;
        tz=h;
        this.m03 += tx;
       this.m13 += ty;
       this.m23 += tz;
   }
   else
   {
     this.m03 += tx;
     this.m13 += ty;
     this.m23 += tz;
   }
};
commandos2389
  • 175
  • 1
  • 10
  • also this in another file viewer.onmousedown = function(x, y, button, depth, mesh) { if(button == 0/*left button down*/ && mesh != null) { // create a new material with a different color (blue for example) var newMat = new JSC3D.Material('', 0, 0x000080, 0, true); // set the new material to the selected mesh mesh.setMaterial(newMat); // tell viewer to render a new frame viewer.update(); – commandos2389 Sep 11 '15 at 21:32