0

http://jsfiddle.net/eho5g2go/

 var offset=10000000;
...
 camera.position.set(offset,offset,400);
 mesh.position.set(offset-300,offset,0);
 camera.lookAt(mesh.position);
...
animate();

The variable "offset", it is used to indicate the position of the camera and mesh. If you set its value to 100000000, then get strange behavior during the animation And if you set 10000000, then everything is fine

Why so? How is it possible to specify the position of objects with coordinates more than 100000000, for example?

Ni55aN
  • 63
  • 1
  • 9

1 Answers1

0

These numbers are a bit smaller than I would have expected, but I think I can safely assume this is a classical floating point precision error problem.

Computers are generally not very good at very large or very small numbers when using floating point arithmetic.

I can really only suggest you scale your scene appropriately to keep the numbers in a more reasonable range.

See https://stackoverflow.com/a/26090323/868679 for a related answer

Edit: After reading http://www.songho.ca/opengl/gl_projectionmatrix.html#perspective it can been seen that the near and far values you use for your projection camera matrix can effect precision errors. To reduce the error, keep your near and far values as close as possible.

Community
  • 1
  • 1
Brendan Annable
  • 2,637
  • 24
  • 37
  • In my case, the values of far and near no influence on the the problem. All the matter in large values of vertex coordinates. http://jsfiddle.net/eho5g2go/4/ http://jsfiddle.net/eho5g2go/5/ – Ni55aN Feb 15 '15 at 07:36