We are having issues with Three.js in combination with a global view. This could be related to the following issue:
In global scenes, the precision of 32-bit floating point arithmetic is not sufficient for visualizations that go beyond global scale (i.e. country scale to city scale). When zooming the view beyond a certain scale, geometries will appear to wobble or jitter, and generally appear displaced. The same applies to local scenes where geometries are far away from the origin of the coordinate system.
described in here:
There is no WebGL example, neither a Threejs example (preferable). In my opinion this is a real lack of documentation (as for me, it is not obvious how to do it).
Could I please get an example.
If you can replicate the issue you're running into in a sample I'd be happy to to take a look at it and see if I can help.
I'm not sure where to begin though. I assume you're asking for a sample of this, from the docs:
- Pick a local origin position, approximately at the center of your data.
- Subtract the local origin position from all positional data (vertex data, uniforms, etc.) before passing it into WebGL.
- Also subtract the local origin from the translational part of the view transformation matrix.
My feeling is that the first two bullets are fairly straightforward: pick a point at roughly the center of your data, transform it into rende coordinates, and subtract it from every vertex that you plan to use to create Three.js geometries.
I'm not completely sure about the third bullet, but I guess that you're meant to subtract your local origin, in render coordinates, from elements 13, 14, and 15 (ie the last three elements) in the view transformation matrix, which is the output of externalRenderers.renderCoordinateTransformAt.
In the first example, the sample picks a point in render coordinates that is close to the geometry being rendered (done in the first few lines of 'initData') and subtracts this from the vertex positions before they are uploaded to the GPU (search for 'Subtract local origin coordinates' in the sample). By also subtracting the local origin translation from the view transformation matrix before rendering that specific geometry (done in 'render' in the sample), the vertices are rendered in the correct position while avoiding precision issues.
In the second example the local origin (named ‘dragOriginTransform’) is being updated and applied to the geometry in ‘updateDrag’, and subtracted from the view matrix in ‘updateCamera’.