I'm creating particlesystem to generate clouds / fog / snow above Globe. This works fine when I use this code:
var particles = new Cesium.PointPrimitiveCollection(); // in fact this is not yett used. When I use this adding the particles, they do not show up.
//var particles = new Cesium.BillboardCollection(),
function Clouds(lat, lon, height) {
var positions = [Cesium.Cartographic.fromDegrees(lon, lat)];
var promise = Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, positions);
Cesium.when(promise, function (updatedPositions) {
height = height + updatedPositions[0].height;
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(lon, lat, height));
var particleSystem = viewer.scene.primitives.add(new Cesium.ParticleSystem({
image: viewModel.image,
startColor: Cesium.Color.GREY.withAlpha(0.3),
endColor: Cesium.Color.GREY.withAlpha(0.01),
startScale: viewModel.startScale,
endScale: viewModel.endScale,
minimumLife: viewModel.minimumLife,
maximumLife: viewModel.maximumLife,
minimumSpeed: viewModel.minimumSpeed,
maximumSpeed: viewModel.maximumSpeed,
minimumWidth: viewModel.particleSize,
minimumHeight: viewModel.particleSize,
maximumWidth: viewModel.particleSize,
maximumHeight: viewModel.particleSize,
minimumMass: viewModel.minimumMass,
maximumMass: viewModel.maximumMass,
rate: viewModel.rate, // Particles per second.
bursts: [
new Cesium.ParticleBurst({ time: 5.0, minimum: 300, maximum: 500 }),
new Cesium.ParticleBurst({ time: 10.0, minimum: 50, maximum: 100 }),
new Cesium.ParticleBurst({ time: 15.0, minimum: 200, maximum: 300 })
],
lifeTime: viewModel.lifeTime,
loop: viewModel.loop,
spin: viewModel.spin,
emitter: viewModel.emitter,
modelMatrix: modelMatrix,
fly: viewModel.fly,
forces: [applyGravity]
}));
//This is the trick I want to use just like billboard fading away when the distance from the camera changes. How to do this with the particles?
//particleSystem.translucencyByDistance = billboard.translucencybydistance;
//particleSystem.distanceDisplayCondition = billboard.distancedisplaycondition;
//particleSystem.scalebydistance = billboard.scalebydistance;
});
viewer.scene.primitives.add(particles);
}
I want to fade out the particle clouds when the camera is moving away from them.
Cesium 1.38. Windows 10 on Chrome