Experience-Monks / orbit-controls

generic controls for orbiting a target in 3D
http://jam3.github.io/orbit-controls/
MIT License
110 stars 17 forks source link

Sometimes things go wonky #5

Open mattdesl opened 8 years ago

mattdesl commented 8 years ago

Occasionally with orbit-controls, when you drag way up and then left or right, the scene will appear "flipped" like everything is inverted somehow. http://jam3.github.io/orbit-controls/

At first I thought this was because I'm using wireframes (i.e. no point of reference for depth), but I saw it a while back with a solid mesh where there was no question that it should not look like that.

It's hard to reproduce and I'm not sure what is causing it, so it might be a tricky bug to track down. :smile:

525c1e21-bd67-4735-ac99-b4b0e5262290 commented 8 years ago

Reproduced by utilising an EPSILON of Math.pow(2, -50)

The problem arises when controls or cameras utilise an EPSILON small enough to allow matrices to be passed to gl-mat4/invert having both 1) non-zero determinants and 2) cells whose inverted values explode to infinity when stuffed into Float32Arrays.

new Float32Array([Math.pow(2, 127)])
// [1.7014118346046923e+38]

new Float32Array([Math.pow(2, 128)])
// [Infinity]

new Float64Array([Math.pow(2, 127)])
// [1.7014118346046923e+38]

new Float64Array([Math.pow(2, 128)])
//[3.402823669209385e+38]