Jump to content

BABYLON.Manipulator position is null


Dad72
 Share

Recommended Posts

hi,

 

I have a problem that is quite strange. I used script "Manipulator" of Babylon and when I select an object and that I moved, the first movement of 1px retrieves well the positions of the object. But in the second px of movement i have a "null" value. My model start at the position Y 6.3 and has a null value immediately the first movement.

Here is what I have in the console:

 

 

And here is the code of this or found the problem.

     BABYLON.Manipulator.prototype._mouveObjectFromVector = function (vector, evt) {        var vFromRay = this._getMouseRay(evt.clientX, evt.clientY - 33, this.mouseInfo.onDownObject);        var vToRay = this._getMouseRay(this.mouseInfo.movePosX, this.mouseInfo.movePosY, this.mouseInfo.onDownObject);        var iDiff = vToRay.origin.subtract(vFromRay.origin);        var distance = BABYLON.Vector3.Distance(vFromRay.origin, vToRay.origin);                console.log(this.mesh.position[vector]); // Error                if (iDiff[vector] > 0) {                                    this.mesh.position[vector] -= distance * this.positiopnMeshMulti; // Error            this.manipulate.position[vector] -= distance * this.positiopnMeshMulti;            this.pickedPoint[vector] -= distance * this.positiopnMeshMulti;                    }        else {                        this.mesh.position[vector] += distance * this.positiopnMeshMulti; // Error            this.manipulate.position[vector] += distance * this.positiopnMeshMulti;            this.pickedPoint[vector] += distance * this.positiopnMeshMulti;        }    };
 

Can you explain to me what is happening please. Thanks

Link to comment
Share on other sites

I discovered what could cause the problem of value 'null': 6.30.10****.10**** on the position.y  (axis X and Z: no probleme)

There are several comma then a null value, and then it restarts at 0.
 

Start Move Axis Y  => 6.3

Move Axis Y           => 6.30.107990675891862090.10799067589186209
Move Axis Y           => null
Move Axis Y           => 0.48
Move Axis Y           => 3.5344375434211606
Move Axis Y           => 3.75

 

 
Then I understood that it was minimum 2 digit after the comma. I have therefore put 6.31 my model on the Y-axis and it solved the problem, as by magic.
 
Fixe:
BABYLON.Manipulator.prototype._mouveObjectFromVector = function (vector, evt) {        var vFromRay = this._getMouseRay(evt.clientX, evt.clientY  - 33, this.mouseInfo.onDownObject);        var vToRay = this._getMouseRay(this.mouseInfo.movePosX, this.mouseInfo.movePosY, this.mouseInfo.onDownObject);        var iDiff = vToRay.origin.subtract(vFromRay.origin);        var distance = BABYLON.Vector3.Distance(vFromRay.origin, vToRay.origin);         this.mesh.position["x"] = parseFloat(this.mesh.position.x); // Add line        this.mesh.position["y"] = parseFloat(this.mesh.position.y); // Add line        this.mesh.position["z"] = parseFloat(this.mesh.position.z); // Add line        if (iDiff[vector] > 0) {                                    this.mesh.position[vector] -= parseFloat(parseFloat(distance) * this.positiopnMeshMulti); // Add parseFloat()             this.manipulate.position[vector] -= parseFloat(parseFloat(distance) * this.positiopnMeshMulti); // Add parseFloat()             this.pickedPoint[vector] -= parseFloat(parseFloat(distance) * this.positiopnMeshMulti); // Add parseFloat()                     }        else {                        this.mesh.position[vector] += parseFloat(parseFloat(distance) * this.positiopnMeshMulti); // Add parseFloat()             this.manipulate.position[vector] += parseFloat(parseFloat(distance) * this.positiopnMeshMulti); // Add parseFloat()             this.pickedPoint[vector] += parseFloat(parseFloat(distance) * this.positiopnMeshMulti); // Add parseFloat()         }    };
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...