添加效果前后对比:
关键代码:
/**
* 水流粒子,目前支持向上或者向下的效果
* @param {Number} x
* @param {Number} y
* @param {Number} z
* @param {Number} options
* @example
* options = {
* color: Cesium.Color.AZURE,
* emissionRate: 5, //影响水流速度
* direction: "upword",
* heightReference : Cesium.HeightReference.RELATIVE_TO_GROUND
* }
*/
renderWaterParticle(x, y, z, options = {
}) {
options = this.defaultParticleOptions(options);
if (options.heightReference === Cesium.HeightReference.RELATIVE_TO_GROUND) {
//获取当前位置的地形高程
const terrainHeight = this._viewer.scene.globe.getHeight(Cesium.Cartographic.fromDegrees(x, y));
z += terrainHeight;
}
const translationOffset = Cesium.Matrix4.fromTranslation(this.particlesOffset, new Cesium.Matrix4())