Dad72 Posted February 1, 2014 Share Posted February 1, 2014 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 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 1, 2014 Author Share Posted February 1, 2014 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.3Move Axis Y => 6.30.107990675891862090.10799067589186209Move Axis Y => nullMove Axis Y => 0.48Move Axis Y => 3.5344375434211606Move 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() } }; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.