Unable to rotate a model

I am trying to implement a simple viewer where a 3d model will rotate 5 degrees clockwise when it is clicked on by the right mouse button. I thought this would be as simple as updating the orientation of the entity but this fails with “RangeError: Invalid array length”

I have found several posts along similar lines but it looks like the referenced sandbox examples are no longer valid. For example How can I, simply, rotate a model entity?

        const entity = viewer.entities.values[0];
        if (entity) {
            heading = heading + 5;
            if (heading > 360) heading = 0;
            const newHeading = Cesium.Math.toRadians(heading);
            const pitch = 0;
            const roll = 0;
            const hpr = new Cesium.HeadingPitchRoll(newHeading, pitch, roll);
            const orientation = Cesium.Transforms.headingPitchRollQuaternion(
            entity.orientation = orientation;

Hi there,

You may want to take a look at the Entity Property system.

For instance, I think a callback property would work best for your case. Here’s and example rotating a model entity.