When I double-click in one place in the scene, the grid disappears, and how to make a smooth transition
sounds impossible to know without a Playground to repro ?
Hey strelok93,
function runDeg(coordsmesh, coordspoint) {
var a, b;
var firstCoords = coordsmesh, secondCoords = coordspoint;
a = firstCoords[0] - secondCoords[0];
b = firstCoords[1] - secondCoords[1];
var rad = Math.arcctg(a / b);
console.log(rad)
var deg = rad * 180 / Math.PI;
if (firstCoords[1] >= secondCoords[1]) {
var deg = rad * 180 / Math.PI - 180;
}
return deg;
}
On your second click at the same point, coordmesh and coordspoint are equal. Ergo, rad = undefined. Ergo, rotation of the mesh is NaN. Thus, making the mesh disappear.
A simple equality check should fix the problem.
if(personage.position.x !=pickResult.pickedPoint.x && personage.position.z!=pickResult.pickedPoint.z)
{
dengil = runDeg([personage.position.x, personage.position.z], clcPos)
personage.rotation.y = -(dengil - 90) * (Math.PI / 180);
personage.position.x = clcPos[0];
personage.position.z = clcPos[1];
}
1 Like
Thank you
1 Like