ClippingPlanesEditor error in Cesium Ion SDK

Hi Team,

I’m using ClippingPlanesEditor class from Cesium Ion SDK to clip the Cesium.Model.

When I execute the code below, it properly clips the Cesium.Model instance initially.

Let’ say this function is called ‘activateClippingTool’ which clips the instance.
The code below is part of the code of the function.

        let rightPlane = new Cesium.ClippingPlane(
            new Cesium.Cartesian3(
                Math.cos(planeRotation1) * statusRegion,
                Math.sin(planeRotation1) * statusRegion,
                0.0
            ),
            params.distance.right * statusRegion
        );
        rightPlane.id = 'right';

        const _clippingPlanes = new Cesium.ClippingPlaneCollection({
            planes: [
                rightPlane ,
            ],
            enabled: params.clipping,
            unionClippingRegions: params.region, // when true, clips outside
            edgeWidth: 0.6,
            edgeColor: Cesium.Color.RED.withAlpha(0.5),
            movePlanesToOrigin: false
        });


        this.clipping_target.clippingPlanes.enabled = params.clipping;

        //Generates plane mouse handler and activate
        this._clippingPlanesEditor = new Cesium.ClippingPlanesEditor({
            scene: this._viewer.scene,
            clippingPlanes: this.clipping_target.clippingPlanes,
            movePlanesToOrigin: false,
            // pixelSize: new Cesium.Cartesian2(100, 100),
            maximumSizeInMeters: new Cesium.Cartesian2(1000000, 1000000)
        });

However, when I want to update the angle(‘planeRotation1’) of the clipping plane editor, I remove the and clipping plane editor and the existing clipping planes which will be populated to clipping plane editor by using the function ‘deactivateClippingTool’ below, then activate the ‘activateClippingTool’ function again with a new ‘planeRotation1’ value.

(I’m doing this way because I was not able to implement the way using callback property to update the normal vector of the clipping planes since it was causing errors. It seems that it was clashing with the code in clipping plane editor.)

    deactivateClippingTool() {
        if (this.clipping_target.clippingPlanes instanceof Cesium.ClippingPlaneCollection) {
            this.clipping_target.clippingPlanes.enabled = false;
            this.clipping_target.clippingPlanes = null;
        }

        if (this._clippingPlanesEditor.active === true) {
            this._clippingPlanesEditor.deactivate();
            this._clippingPlanesEditor = null;
        }

    }

The weird thing is the error only happens when it is targeting Cesium.Model(which is stored in ‘this.clipping_target’). It won’t give a rendering error when the target is Cesium.CesiumTileset.

Please give me any suggestion to solve this issue.
We need to keep using Cesium.Model as it has more flexibility on changing the appearance.

Best,
Hiroshi

Any advice?

In other words, I can also ask the question in this way, “How can I change the normal vector of the clipping plane asynchronously?”