I have a MaterialProperty
for entity:
MyMaterialProperty.prototype.getValue = function(time, result) {
if (!Cesium.defined(result)) {
result = {};
}
result.image = this.url;
result.time = ((performance.now() - this._time) % this.duration) / this.duration;
return result;
}
// ...
czm_material czm_getMaterial(czm_materialInput materialInput)\n\
{\n\
czm_material material = czm_getDefaultMaterial(materialInput);\n\
vec2 st = materialInput.st;\n\
vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));\n\
material.alpha = colorImage.a;\n\
material.diffuse = colorImage.rgb * 1.5 ;\n\
return material;\n\
}
The key is result.time = ((performance.now() - this._time) % this.duration) / this.duration
which make it animation.
But now I have a large GeoJSON dataset that is significantly impacting the performance of the entity. Therefore, I would like to use Primitives
to address this issue.
appearance: new Cesium.PolylineMaterialAppearance({
material: new Cesium.Material({
fabric: {
uniforms: {
image: imgUrl,
transparent: true
},
source: `czm_material czm_getMaterial(czm_materialInput materialInput)\n\
{\n\
czm_material material = czm_getDefaultMaterial(materialInput);\n\
vec2 st = materialInput.st;\n\
float time = mod(czm_frameNumber / 60.0, 3000.0) / 3000.0;\n\
vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));\n\
material.alpha = colorImage.a;\n\
material.diffuse = colorImage.rgb * 1.5 ;\n\
return material;\n\
}`
}
})
})
Without property, I use float time = mod(czm_frameNumber / 60.0, 3000.0) / 3000.0;
to make it animation. But it do not work .