Hello, I have encountered a problem, the content is: I want to make the radius of a cylinder change dynamically. I inherited and rewritten the primitive update method, and it succeeded. But a new problem occurred: the picture material I posted on the cylinder could not be displayed normally. It is a white opaque cylinder, if I comment the material settings, it will show the default red. I don’t know why, please help me find the reason, thank you very much. The code content is as follows:
function changeCylinderPrimitive(options) {
this.length = options.length;
this.topRadius = options.topRadius;
this.bottomRadius = options.bottomRadius;
}
changeCylinderPrimitive.prototype.getGeometry = function () {
return new Cesium.CylinderGeometry({
length: this.length,
topRadius: this.topRadius,
bottomRadius: this.bottomRadius
});
};
changeCylinderPrimitive.prototype.update = function (frameState) {
var geometry = this.getGeometry();
if (!geometry) {
return;
}
this._primitive = new Cesium.Primitive({
geometryInstances: new Cesium.GeometryInstance({
geometry: geometry,
}),
releaseGeometryInstances: false,
modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-90,20,500)),
appearance: new Cesium.MaterialAppearance({
material: new Cesium.Material({
fabric: {
type: ‘Image’,
uniforms: {
image: ‘./data/circle.png’,
},
}
}),
faceForward: true
})
});
var primitive=this._primitive
primitive.update(frameState);
};
var pr=new changeCylinderPrimitive({
length: 500,
topRadius: 1000,
bottomRadius: 1000
})
viewer.scene.primitives.add(pr)