Adding custom options to EllipsoidGeometry

I'm trying to add new options to EllipsoidGeometry like so:

var viewer = new Cesium.Viewer(...);
viewer.entities.add({
   name: 'SomeEntity',
   position: Cesium.Cartesian3.fromDegrees(0.0, 0.0, 0.0),
   ellipsoid: {
      radii: new Cesium.Cartesian3(10, 10, 10),
      newOption1: 'blob1',
      newOption2: 'blob2'
   }
});

I would then like to use newOption1 and newOption2 inside Workers/createEllipsoidGeometry.js. The EllipsoidGeometry constructor accepts an options parameter. I would like for newOption1 and newOption2 to be accessible from options, like so:

function EllipsoidGeometry(options) {
   console.log(options.newOption1);
}

I am having trouble figuring out how to get the new options to be passed through. Any help or guidance would be appreciated.

My goal for this is to use the new options to manipulate the geometry. The options will be things like min/max range from center, min/max az/el. This will allow me to create a partial ellipsoid volume.

Thanks,
Steven

Hi Steven,

The ellipsoid constructor only sets standard properties. However, you can either store your new attributes in the ellipsoid’s id property, or add them once the ellipsoid is already constructed. Entities can be manipulated like any Javascript object – you can add whatever new properties you’d like, the constructor just won’t do it for you.

Hope that helps,

  • Rachel

Rachel,

Thanks for the reply. I realize I wasn't very clear with my question. I am actually trying to modify the source code so that I can pass in custom options to the constructor. For those interested, I was able to get this working (at least a prototype, haven't completed it yet). The key was updating EllipsoidGeometryUpdater._onEntityPropertyChanged to add the new option, and then updating the pack/unpack functions of EllipsoidGeometry.

Thanks again.
Steven

Steven,

I’m glad you figured it out. Lots of people have been asking for this feature. Any chance you can open a pull request to have it officially added to Cesium?

Thanks!

Matt

Matt,

Yes, I was one of them who was asking for it :slight_smile: I finally got some time to try it myself. Assuming I get permission to release the code mods (I'm doing this work under a contract), I would be happy to submit a pull request. I need to finish it first however, so it will probably be a few weeks until I have it wrapped up.

-Steven

Wonderful! Thanks, Steven. If you haven’t seen it, you may want to checkout our contributor’s guide: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md

Don’t hesitate to let us know how we can help!

Thanks,

  • Rachel

Just a quick update: I have this working and hope to get permission to release it soon.