Rotating BoxGraphics

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

I would like a BoxGraphics object NOT oriented with cardinal directions. Ideally I'd like to pass Cesium something like the AxisAlignedBoundingBox and have it draw that.

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

//I'd like to give the dimensions property 2 cartesians and have it draw my box between them, and have the box oriented between those 2 points

box = viewer.entities.add({
              name: 'Blue box',
              position: Cesium.Cartesian3.fromDegrees(lng, lat, altitude),
              box: {
                  dimensions: new Cesium.Cartesian3(length, width, height),
                  material: Cesium.Color.BLUE
              }
          });

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

I'm trying to draw boxes which are a crude representation of cars in parking spots, and the boxes can be oriented any way (not limited to cardinal dirs)

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

Version 1.41, windows, chrome

Ok, I think I figured it out myself...have to add orientation object yourself, and it does rotate the box. Simple, but not obvious....like most of software dev.

var position = Cesium.Cartesian3.fromDegrees(lng, lat, altitude);
          var heading = Cesium.Math.toRadians(45);
    var pitch = 0;
    var roll = 0;
    var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
    var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

          box = viewer.entities.add({
              name: 'Blue box',
              position: position,
              orientation: orientation,
              box: {
                  dimensions: new Cesium.Cartesian3(length, width, height),
                  material: Cesium.Color.BLUE
              }
          });

Hey there!

You’re right, using the entity’s orientation property would be the way to accomplish this. The explanation is hidden away in the 3D Models section of our Entity Tutorial, so yes it was a bit non-obvious.

Thanks,

Gabby