My problem is that I am hard of thinking.
Please could someone suggest how I should modify the code below to use the getOrCreateEntity method?
My problem is that I am hard of thinking.
Please could someone suggest how I should modify the code below to use the getOrCreateEntity method?
Hi Hugh,
Take a look at the 3D Models example for adding model entities, The path pat would be something like:
path : {
show : true,
leadTime : 0,
trailTime : 60,
width : 10,
resolution : 1,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.3,
color : Cesium.Color.PALEGOLDENROD
})
``
Thanks,
Gabby
Thanks Gabby,
I had got myself into a knot, trying to use .getOrCreateEntity as a direct replacement for .add. It hadn’t occurred to me that it would return an entity, of which I could then set the properties. I know that now, but I must have been too tired to read the plain Engish in the API documentation!
What I am trying to achieve is avoiding creating multiple copies of an entity. If I create (.add) an entity with an id of ‘ThatThing’, I can subsequently use:
var q = new Cesium.Entity;
q = viewer.entities.getById(‘ThatThing’);
console.log(q);
``
which I can see in the Chrome console as an entity having various properties. If I try to use the .contains method
var q = new Cesium.Entity;
q = viewer.entities.getById(‘ThatThing’);
var y = viewer.entities.contains(q);
console.log(y);
``
it gives a message: entity is required.
I’m not a lot further forward.
I think you want to do something like the following:
var entity = viewer.entities.getOrCreateEntity(‘ThatThing’);
// set the entity properties
entity.model.minimumPixelSize = 64;
``
Note that most entity properties will be a Property type or a Graphics type, so you’ll need to access them accordingly.
Thanks,
Gabby