3D tiles with primitives

I have a google photorealistic 3D tiles layer and i want to load a primitive GPS point collection. The collection loads but doesnt seem to clamp to the 3D tile surface. Is there a workaround for this? it seems to be clamping to the original ellipsoid rather than the 3D tile itself, unable to find a way to make this work

Are you trying to display this in CesiumJS? (If so, I’d probably move this thread to the right section). There are several functionalities that are related to “clamping” in various forms. More specific hints could probably be given based on a more detailed technical description of the goal or the current approach, or (preferably) a sandcastle that illustrates the issue that you’re facing.

Hey, yeah im using this with cesium js
So far i have got a solution which half works

export default function useGpsPoints(viewer, isViewerReady, gpsData) {

  const collectionRef = useRef(null);


useEffect(() => {

if (!viewer || !isViewerReady || !gpsData) return;

const scene = viewer.scene;

const globe = viewer.scene.globe;

const points = gpsData?.pastGPSPoints || [];

if (!points.length) return;




if (collectionRef.current) {

scene.primitives.remove(collectionRef.current);

collectionRef.current = null;

    }




const collection = new Cesium.PointPrimitiveCollection();

collection.id = "gpsPoints";




points.forEach(p => {

if (!p.latitude || !p.longitude) return;

const cartographic = Cesium.Cartographic.fromDegrees(

p.longitude,

p.latitude

      );




// Sample the height from the current globe state

const height = globe.getHeight(cartographic) || 0;




const position = Cesium.Cartesian3.fromRadians(

cartographic.longitude,

cartographic.latitude,

height + 2

      );




collection.add({

position: position,

pixelSize: 5,

color: Cesium.Color.CYAN,

outlineColor: Cesium.Color.BLACK,

outlineWidth: 1,

disableDepthTestDistance: Number.POSITIVE_INFINITY,

      });

    });




scene.primitives.add(collection);

collectionRef.current = collection;

return () => {

if (collectionRef.current) {

scene.primitives.remove(collectionRef.current);

collectionRef.current = null;

      }

    };

  }, [viewer, isViewerReady, gpsData]);

}

and i say half works because sometimes the points are just not clamped to the actual 3d tiles when it first loads up

this is just a snippet of how i am loading up the 3D tile layer


if (!isOffline) {

try {

const tileset = await Cesium.createGooglePhotorealistic3DTileset();

tileset.allTilesLoaded.addEventListener(() => {

setIsViewerReady(true); // this triggers the usegps point

          });

scene.primitives.add(tileset);

        } catch (error) {

showErrorToast(error.message || "Failed to load 3D tileset");

        }

      }

    }

wondering if this is the right direction or if there is an easier way of doing this?

This seems like something which will take a long load time and computationally expensive perhaps, is there a better option to do what i am trying to achieve?

There certainly are several known issues about the performance of clamping (and the underlying functionality, “picking”). There also are some efforts in flight about how to improve the performance. But linking to all these issues and PRs here would probably not be helpful. If you have a specific sandcastle, maybe someone can give hints for workarounds.