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
737 stars 291 forks source link

Add AnnotationsPlugin surfaceOffset configuration #304

Closed xeolabs closed 4 years ago

xeolabs commented 4 years ago

Allow AnnotationsPlugin to be configured with an amount to offset each Annotation from its Entity surface, with 0.3 being the offset's default value.

This is useful when the Annotation is occludable, which is when it is hidden when occluded by other objects. When occludable, there is potential for the Annotation#worldPos to become visually embedded within the surface of its Entity when viewed from a distance. This happens as a result of limited GPU accuracy GPU accuracy, especially when the near and far view-space clipping planes, specified by Perspective#near and Perspective#far, or Ortho#near and Perspective#far, are far away from each other.

Offsetting the Annotation may ensure that it does become visually embedded within the surface of its Entity. We may also prevent this by keeping the distance between the view-space clipping planes to a minimum. In general, a good default value for Perspective#far and Ortho#far is around 2.000.

const annotations = new AnnotationsPlugin(viewer, {
    //...
    surfaceOffset: 0.3 // Or greater, if the Annotation gets obscurred by its surface
});
xeolabs commented 4 years ago

Fixed in master and npm @xeokit/xeokit-sdk 0.9.998