1. A concise explanation of the problem you’re experiencing.
I’m creating particlesystem to generate clouds / fog / snow above Globe. This works fine when I use this code:
var viewModel = {
rate: 50,
gravity: -0.5,
minimumLife: 1.0,
maximumLife: 50.0,
minimumSpeed: 0,
maximumSpeed: 0,
startScale: 0,
endScale: 40.0,
particleSize: 20.0,
minimumMass: 0.00000001,
maximumMass: 0.0001,
image: ‘models/clouds/cumulus1.png’,
minimumWidth: 10,
maximumWidth: 20,
minimumHeight: 10,
maximumHeight: 20,
lifeTime: 5.0,
loop: true,
spin: true,
emitter: new Cesium.SphereEmitter(100),
fly: true,
show: true
};
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
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);
}
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I want to fade out the particle clouds when the camera is moving away from them.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.38. Windows 10 on Chrome