const initFireTool = () => { const viewer = getEarthHelper().viewer; fireTool = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point, Cesium.ClampMode.Ground); // 监听火焰点是否绘制完成 绘制完成后开始添加粒子 fireTool.drawEvt.addEventListener((res: any) => { setCanvasCursor(); movableBox.hide(); res.object.show = false; const fireEntry = viewer.entities.add({ position: res.object.position }); const particlePrimitive = new Cesium.ParticleSystem({ image: fire, startColor: new Cesium.Color(1, 1, 1, 1), endColor: new Cesium.Color(0.5, 0, 0, 0), startScale: viewModel.startScale, endScale: viewModel.endScale, minimumParticleLife: viewModel.minimumParticleLife, maximumParticleLife: viewModel.maximumParticleLife, minimumSpeed: viewModel.minimumSpeed, maximumSpeed: viewModel.maximumSpeed, imageSize: new Cesium.Cartesian2(viewModel.particleSize, viewModel.particleSize), emissionRate: viewModel.emissionRate, lifetime: 6.0, // 循环是否开启 loop: true, emitter: new Cesium.ConeEmitter(Cesium.Math.toRadians(45.0)), sizeInMeters: true, }); particleSystem = viewer.scene.primitives.add(particlePrimitive); primitivesCollection.push(particlePrimitive); viewer.scene.preUpdate.addEventListener((scene: any, time: any) => { particleSystem.modelMatrix = computeModelMatrix(fireEntry, time); particleSystem.emitterModelMatrix = computeEmitterModelMatrix(); }); }); };
fireTool.activate(); //开始图上选点 火焰是在可见范围内的,且高于地形,浏览器没有任何报错或警告