The geometric energy added by the Primitive can not change the property?

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

The geometric energy added by the Primitive can not change the property?

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

  viewer.scene.primitives.add(new Cesium.Primitive({
          geometryInstances: new Cesium.GeometryInstance({
                geometry: new Cesium.PolygonGeometry({
                polygonHierarchy : new Cesium.PolygonHierarchy(
                  Cesium.Cartesian3.fromDegreesArray([
                    -72.0, 40.0,
                    -70.0, 35.0,
                    -75.0, 30.0,
                    -70.0, 30.0,
                    -68.0, 40.0
                  ])
                ),
                 extrudedHeight: 300000
              })
          }),
          appearance: new Cesium.EllipsoidSurfaceAppearance({
            aboveGround: false,
            material: WaterMaterial
          }),
          show: true
     }))

As shown in the code, I add a PolygonGeometry,But I can't dynamically change the value of extrudedHeight,

I tried to dynamically change the value of extrudedHeight with the Cesium.CallbackProperty() method,But it doesn't work。

I hope the teacher can help me solve the problem,Thanks!
                                                        
                                                           Liu from China.

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

I want to change the extrudedHeight property dynamically.Primitive must be used.Because of the use of material.

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

Hi Liu,

Here is an example of how to use Cesium.CallbackProperty.

You would do the following:

    extrudedHeight : new Cesium.CallbackProperty(function(time, result) {

        // Get the value for extruded height

        return extrudedHeight;

    }, false)

is “geometric energy” a custom property? If so, you can access the value like this:

 var propertyValues = entity.properties.getValue(viewer.clock.currentTime);

 propertyValues.custom_property;

Thanks,

Gabby

Hi Gabby,

I changed my code:

var extrudedHeightCallback = 5000;

scene.primitives.add(new Cesium.Primitive({

geometryInstances: new Cesium.GeometryInstance({

geometry: new Cesium.PolygonGeometry({

polygonHierarchy : new Cesium.PolygonHierarchy(

Cesium.Cartesian3.fromDegreesArray([

-72.0, 40.0,

-70.0, 35.0,

-75.0, 30.0,

-70.0, 30.0,

-68.0, 40.0

])

),

extrudedHeight: new Cesium.CallbackProperty(function(time, result) {

// Get the value for extruded height

console.log(result);

return extrudedHeightCallback += 50;

}, false)

})

}),

appearance: new Cesium.EllipsoidSurfaceAppearance({

aboveGround: false,

material: WaterMaterial

}),

show: true

}))

This does not work,I think it might be that I used Primitive, not Entity,The use of CallbackProperty in Entity is successful,But Primitive can’t do it?

Thanks,

Liu

My mistake, I didn’t see that you were using a Primitive. What we do under the hood for entities is create a new primitive when a relevant value is updated, and destroy the old primitive.

var newExtrudedHeight = extrudedHeight + 50;

primitives.remove(oldPrimitive);

oldPrimitive.destroy();

// create the new primitive with the newExtrudedHeight

You’ll want to put the above block in an function that updates with the simulation time, see Clock.onTick.

Thanks,

Gabby