loaders.gl icon indicating copy to clipboard operation
loaders.gl copied to clipboard

tiles: transform is not applied on boundingVolume of type 'region'

Open Avnerus opened this issue 3 years ago • 4 comments

Hi! I was trying out a 3D Tiles point cloud prepared using Entwine. It used a boundingVolume of type 'region'. I noticed that I am unable to transform the tileset (for example bring it to 0,0,0) due to the transform not being applied here. I did find an old version where it seems that transforms are applied also in the 'region' scenario. Is there any reason for this? Thank you! (cc: @dryabinin-actionengine , @ibgreen)

Avnerus avatar Dec 07 '21 19:12 Avnerus

https://github.com/CesiumGS/3d-tiles/tree/main/specification#transforms

..., except when tile.boundingVolume.region is defined

belom88 avatar Dec 08 '21 07:12 belom88

Thanks @belom88! OK that specifies that a tile does not intrinsically contain a transform matrix when its boundingVolume is 'region'. However, my interest is in manipulating the boundingVolume from the outside, using the modelMatrix property (so I can move the tileset to 0,0,0, not being forced to fly the camera to the geo-coordinates). Shouldn't there be a way to do it? Or is there another way? It is because of this line that modelMatrix eventually trickles down to all of the tiles' transform. I tested this and adding the transform to the boundingSphere allowed me to move the tileset. It didn't allow me to rotate it though, because it's a sphere...

Avnerus avatar Dec 08 '21 08:12 Avnerus

@Avnerus can I close this issue?

belom88 avatar Feb 07 '22 12:02 belom88

Hi, well I believe this is not resolved yet. I promised to submit a PR but didn't get around to it yet. Just to document, we were planning to replicate this logic in CesiumJS:

  // A region bounding volume is not transformed by the transform in the tileset JSON,
  // but may be transformed by additional transforms applied in Cesium.
  // This is why the transform is calculated as the difference between the initial transform and the current transform.
  transform = Matrix4.multiplyTransformation(
    transform,
    Matrix4.inverseTransformation(initialTransform, scratchTransform),
    scratchTransform
  );

In loaders.gl, I think it would work if we multiplied the region by the transform argument, which is in effect computedTransform and then by the invert of initialTransform , negating any transform that may have existed (by mistake) in the json.

Avnerus avatar Feb 07 '22 15:02 Avnerus