change polyline positions dynamically error

Hi

I’m trying to change polyline positions dynamically,

i added billboard and polyline with billboardcollection and polylinecollection

the billboard position is [100,200],

there is two polyline connect with this billboard
polyline one position [[100,200],[105,205],[110,210]]
polyline two position [[97,84],[100,200]]

my operation logic has three step
first step: mouse left down to pick billboard
second step: change billboard position and two polyline first or last positions coordinate dynamic with mouse move
final step: mouse left up to get final position with billboard and polylines

here is my core logic to handle mouse move event to update positions

const endPosition = event.endPosition;
const cartesian3 = cesiumStore.getMouseCartesian3(endPosition);
const billboard = topologyEditContext.draggedBillboard!;
billboard.position = cartesian3;
topologyEditContext.dragEntityRelatedLine!.forEach(item => {
  const isStart = item.isStart;
  const polyline = item.polyline;
  const cartesian3Arr: Cesium.Cartesian3[] = cloneDeep(polyline.positions);
  if (isStart) {
    cartesian3Arr[0] = cartesian3;
  } else {
    cartesian3Arr[cartesian3Arr.length - 1] = cartesian3;
  }
  polyline.positions = cartesian3Arr;
});

the operation result look like this

i just change the first or last item on a new polyline cartesian3Arr deepcloned from original polyline postions. not change the positions length
but sometimes when i drag billboard then move mouse i got this error

and there is another question is that sometimes after i dragging billboard, all positions has been changed but all polyline is disappear, when i dragging billboard again, the polyline display again

Hi @Kuromi,

Thanks for your post an apologies for the slow response.

Thanks for providing a clear description of the problem you encountered. Could you go one step further by preparing an example that reproduces the issue using our sandcastle tool https://sandcastle.cesium.com/ ? This will make it much easier for us to understand what is precisely happening and come up with a solution.

Thanks,
Luke

Hi @Luke_McKinstry

Thanks for your reply! I really appreciate your time.

Here is the sandcastle example link SandCastle

In sandCastle i didn’t reproduces the error, In my local dev envrionment, it’s just happen sometimes , not all the time

And another issue is after i drag the billboard in sometimes, all polyline will disappear, then i drag again , the polyline is display again

Hope for your reply!

Hi @Luke_McKinstry

Following up on my last comment here. I provided the sandcastle you requested. Any further thoughts on this?

Best regards

Hi @Kuromi ,

Thanks for following up by creating a sandcastle example.

The error indicates that the way you are changing the position of the point on the polyline is causing problems because the size of the data is changing such that it no longer fits within the buffer that is used to pass its position info to the renderer. As an alternative, when the polyline position is edited, could you do an operation where you basically remove the old polyline from the collection and add a new one with the new positions?

Thanks,
Luke

Hi @Luke_McKinstry
I tried the approach you suggested and it can be implemented, but changing it in my business scenario is very complicated because it involves other things as well

I don’t quite understand why changing one element of a coordinate array would cause a change in the size of the coordinates, because I haven’t changed the length of the array.

And it’s an occasional issue that doesn’t happen every time

Do you have any other good suggestions?
Thanks