当前位置: 代码迷 >> 综合 >> Cesium 设置实体要素闪烁
  详细解决方案

Cesium 设置实体要素闪烁

热度:73   发布时间:2023-12-17 03:38:07.0

 设置要素闪烁:

//id-要素实体id,second-闪烁时间
SetEntityFlicker(id, second) {let entity = viewer.entities.getById(id);if (!entity) return;let x = 1;let flog = true;let fs = [];let callback = new Cesium.CallbackProperty(() => {if (flog) {x = x - 0.02;if (x <= 0) {flog = false;}} else {x = x + 0.02;if (x >= 1) {flog = true;}}return x >= 0.5;}, false);if (entity.billboard) {entity.billboard.show = callback;fs.push(entity.billboard);}if (entity.box) {entity.box.show = callback;fs.push(entity.box);}if (entity.corridor) {entity.corridor.show = callback;fs.push(entity.corridor);}if (entity.cylinder) {entity.cylinder.show = callback;fs.push(entity.cylinder);}if (entity.ellipse) {entity.ellipse.show = callback;fs.push(entity.ellipse);}if (entity.ellipsoid) {entity.ellipsoid.show = callback;fs.push(entity.ellipsoid);}if (entity.label) {entity.label.show = callback;fs.push(entity.label);}if (entity.model) {entity.model.show = callback;fs.push(entity.model);}if (entity.path) {entity.path.show = callback;fs.push(entity.path);}if (entity.plane) {entity.plane.show = callback;fs.push(entity.plane);}if (entity.point) {entity.point.show = callback;fs.push(entity.point);}if (entity.polygon) {entity.polygon.show = callback;fs.push(entity.polygon);}if (entity.polyline) {entity.polyline.show = callback;fs.push(entity.polyline);}if (entity.polylineVolume) {entity.polylineVolume.show = callback;fs.push(entity.polylineVolume);}if (entity.rectangle) {entity.rectangle.show = callback;fs.push(entity.rectangle);}if (entity.wall) {entity.wall.show = callback;fs.push(entity.wall);}setTimeout(function () {fs.forEach((f) => {f.show = true;});}, second * 1000);}

设置要素停止闪烁:

  SetEntityStopFlicker(id) {let entity = viewer.entities.getById(id);if (!entity) return;if (entity.billboard) {entity.billboard.show = true;}if (entity.box) {entity.box.show = true;}if (entity.corridor) {entity.corridor.show = true;}if (entity.cylinder) {entity.cylinder.show = true;}if (entity.ellipse) {entity.ellipse.show = true;}if (entity.ellipsoid) {entity.ellipsoid.show = true;}if (entity.label) {entity.label.show = true;}if (entity.model) {entity.model.show = true;}if (entity.path) {entity.path.show = true;}if (entity.plane) {entity.plane.show = true;}if (entity.point) {entity.point.show = true;}if (entity.polygon) {entity.polygon.show = true;}if (entity.polyline) {entity.polyline.show = true;}if (entity.polylineVolume) {entity.polylineVolume.show = true;}if (entity.rectangle) {entity.rectangle.show = true;}if (entity.wall) {entity.wall.show = true;}}