xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Add a high precision getter for picked position #101

Open csvurt opened 9 years ago

csvurt commented 9 years ago

Currently the picked position is limited to 8 bits per axis due to WebGL color buffer limitations. While this is typically enough for small models things get less and less accurate as bounding box sizes increase. Accurate results are important for things like object placement in large scenes (eg. when clicking on a large ground plane to place an object there).

Because rendering to floating point buffers is iffy under the current WebGL spec we can't rely on it to replace the uint color buffer that we currently use.

We should add a second getter for picked position that returns a high precision result through some other means (eg. ray intersection in JS or multiple render passes of the picked object). Because this is potentially a slow operation we should look into using Promises to return the result.

Normals are always unit vectors so they have a possible error of 0.0078 units when encoded to 8 bits, which should be good enough for most applications.

Originating problem is described in #60

wherget commented 9 years ago

I believe this is affecting us in COMPASS as well, so that's a definitive +1 from me for this.