Intersection Test using Dynamic Position of Bounding Sphere

1. A concise explanation of the problem you’re experiencing.

I have a moving bounding sphere that I would like to do an intersection test with. I can get the bounding sphere to dynamically update with positional data but I cannot achieve an intersection test. The result I get is undefined. However, if the bounding sphere and ray is fixed, I can get a result back.

Is there a better way to achieve this or modify the code below?

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

// center is cartesian3

var ray = new Cesium.Ray(center, Cesium.Cartesian3.UNIT_Z);

setInterval(function()

{

var posDynamic = ent.position.getValue(viewer.clock.currentTime);

var boundSphere = new Cesium.BoundingSphere(posDynamic, radius*1000);

boundSphere.center = posDynamic;

var intersection = Cesium.IntersectionTests.raySphere(ray, boundSphere);

console.log(intersection); // RESULT IS UNDEFINED

}, 100);

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I would like to tell if a moving bounding sphere intersects with the fixed ray.

4. The Cesium version you’re using, your operating system and browser.

I’m surprised this isn’t working, given that this isn’t a dynamic bounding sphere, you’re simply creating a new bounding sphere every time you need to do the intersection test.

Why do you set boundingSphere.center in addition to setting it in the BoundingSphere constructor?

Are you visualizing the bounding sphere and the ray to make sure a collision there is expected? If you can put together a Sandcastle showing the issue we can open a GitHub issue to log this as a bug.