Re-using data from a sampledPositionProperty for Walls.

451 views
Skip to first unread message

HughN

unread,
Nov 23, 2017, 2:27:15 PM11/23/17
to cesium-dev

I've been going round and round in circles with this...

In simple terms, how do I draw a wall under the path of a moving entity? The code below shows how the entity is defined.

var entity = viewer.entities.add(
{
//Set the entity availability to the same interval as the simulation time.
availability : new Cesium.TimeIntervalCollection([new Cesium.TimeInterval(
      {
  start : start,     stop  : stop
      }
 )
 ]),

   //Use our computed positions - a sampledPositionProperty
position : position,
                                // viewer.trackedEntity = entity,
//compute orientation - a sampledProperty
orientation     : heading,
HeightReference :  Cesium.HeightReference.NONE,

//Load the Cesium plane model to represent the entity
model : {
uri : '../../SampleData/models/CesiumAir/Cesium_Air.gltf',
minimumPixelSize : 64
},

//Show the path as a pink line sampled in 1 second increments.
path : {
resolution : 1,
material   : new Cesium.PolylineGlowMaterialProperty(
    {
glowPower : 0.1, color     : Cesium.Color.RED
    }
    ),
width    : 3,
leadTime :0
},
wall: {
show         : true
material : Cesium.Color.BLUE.withAlpha(0.5), outline : true, outlineColor : Cesium.Color.BLACK
      }
}
);

The 'wall' property added (in blue) must be missing something as nothing is shown. I have taken that from the details of WallGraphics in the API documentation.

Any suggestions as to how this could be achieved would be gratefully received.

Thanks,

Hugh

Gabby Getz

unread,
Nov 27, 2017, 4:42:09 PM11/27/17
to cesium-dev
Hi Hugh,

For reference, here's the wall sandcastle example. I would add the wall as it's own separate entity, like so:

viewer.entities.add({
    wall : {
        positions: // list of wall positions
material : Cesium.Color.BLUE.withAlpha(0.5), outline : true, outlineColor : Cesium.Color.BLACK
    }
});

Secondly, do you want the wall to be static? If so, you should just be able to set the positions property to the list of the computed positions. Otherwise, I'm not sure exactly what behavior you want. Could you provide an example?

Thanks,
Gabby

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hugh Neve

unread,
Nov 28, 2017, 3:11:24 AM11/28/17
to cesiu...@googlegroups.com
Hi Gabby,

I want the wall to appear underneath a moving entity, but only trailing it.

Thanks,

Hugh

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/DY_JSSE5CK4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.

Gabby Getz

unread,
Nov 29, 2017, 5:13:41 PM11/29/17
to cesium-dev
Ok, I see. I think your best bet would be to keep a list of the wall positions, and update it in a callbackProperty with the current position of the moving entity. Something like this:

var wallPositions = [];
function updateWallPositions(time) {
    var position = entity.position.getValue(time);
    wallPositions.push(position);
    return wallPositions;
}

viewer.entities.add({
    wall : {
        positions: new Cesium.CallbackProperty(updateWallPositions, false),
material : Cesium.Color.BLUE.withAlpha(0.5), outline : true, outlineColor : Cesium.Color.BLACK
    }
});

Hugh Neve

unread,
Nov 30, 2017, 1:18:41 PM11/30/17
to cesiu...@googlegroups.com
Aha! Genius!

Thank you.

jorbin

unread,
Dec 6, 2017, 9:40:37 PM12/6/17
to cesium-dev
Hi, Grabby

the wall follows the plane trace with your example, but an error occurred in the end. by the way, the plane trace data comes from czml path example of Sandcastle. how can I avoid or hide this error? thanks.

Thanks
Jorbin  

Cannot read property 'x' of undefined,maybe it occurs on computePositions()
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/DY_JSSE5CK4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.

Gabby Getz

unread,
Dec 8, 2017, 3:41:33 PM12/8/17
to cesium-dev
Hi Jorbin,

I have a working Sandcastle example with loading CZML here. If you are having more problems, please provide a code example so we can figure out the issue.

Thanks!
Gabby

berg...@gmail.com

unread,
Feb 3, 2019, 10:29:27 AM2/3/19
to cesium-dev
I also used this approach, but with an impact on performance.

When and how often is the CallBack invoked?

I decided to create a timer (that fires once a second) outside the Cesium rendering loop to add a position to the wall for each entity in the viewer. Better performance.

Can I use SampledPositionProperty for the wall positions?
Do I need to set the entity availability property for this?
The SampledPositionProperty did not seem to work - even with availability set. Only re-assigning the complete array of positions works (which I think yields in a performance overhead).

Any suggestions on best approach?

I.e. re-assgining complete position array?
Use SampledPositionProperty? (and how)


Omar Shehata

unread,
Feb 6, 2019, 5:19:50 PM2/6/19
to cesium-dev
Remember that Cesium's time dynamic properties are time-based, not tick-based. So there is no frame rate for how often a CallbackProperty is invoked. It depends entirely on how often this property is getting evaluated (it could be anywhere from 0 times per frame to multiple times per frame). Our discussion in this thread has more explanation:


Feel free to start a new thread with a Sandcastle of your working solution that re-assigns the complete array of positions, and I'd be happy to take a look and see if there's a way to speed that up.

artille...@gmail.com

unread,
Nov 6, 2019, 9:02:28 AM11/6/19
to cesium-dev
Hi Gabby,

I ran the working Sandcastle example but the animation crashed at the end of the position. I looked at the error log but had no clue as to why it ran smoothly until the end of the track. Could you take look?

Thanks.
Reply all
Reply to author
Forward
0 new messages