xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
728 stars 287 forks source link

[FEATURE SUGGESTION] Technique to allow individual objects to be dynamically transformed anywhere in double-precision WCS #1321

Open xeolabs opened 10 months ago

xeolabs commented 10 months ago

Problem

Currently we are unable to move individual objects long distances within xeokit's double-precision 3D world coordinate system. This is because they need to stay more or less within the bounds of their RTC (relative-to-center) tiles, where their geometries are able to have the requisite single-precision coordinates as offsets from the RTC tile center. This is neccessary to support xeokit's ability to render double-precision coordinates on today's GPUs, which are single-precision, without rendering jitter.

Idea

For each mesh, store an integer ID in the VBO or data texture that identifies which RTC tile it is currently in. When we update the transform for that mesh such that it moves the mesh into another RTC tile, then update that ID.

The VBO or data texture layer would then be rendered once for each distinct ID value that occurs within it, each time updating the RTC view matrix according. At each render, only the meshes whose IDs match the RTC for the current view matrix. This is effectively culling those meshes that don't belong to the current RTC render.

The downside is that layers would get rendered multiple times. However, if there is not a huge number of RTC tiles occupied at any moment, then this could be viable. The VBO/data texture layers would need to keep counts of how many meshes are in each RTC tile, so we can avoid needlessly rendering layers.

The modeling transform matrices for the meshes would also need to be dynamically modified for their meshes' RTC tile origins, by post-concatenating a subtraction-translation, so that they are effectively then relative to the RTC tile origin.

paireks commented 6 months ago

Is it something we want to add to v2 some day or maybe design v3 in a way that already such feature will be possible? Cause it looks like a pretty big change to me. Or maybe I overexaggerate :)

xeolabs commented 6 months ago

Yes, I think this is something for V3. Definitely hard to retrofit to V2.

Let's keep this ticket here though, to track the general idea.