LightingShadow.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ; (function (Cesium) {
  2. checkSkyScenery(Cesium);
  3. /**
  4. * @description: 日照阴影效果模拟
  5. * @param {*} _viewer
  6. * @param {*} _speed:变化速率
  7. * @return {*}
  8. */
  9. function LightingShadow(_viewer, _speed) {
  10. // 赋值
  11. this.viewer = _viewer;
  12. this._speed = _speed;
  13. this.open();
  14. }
  15. Object.defineProperties(LightingShadow.prototype, {
  16. speed: {
  17. get: function () {
  18. return this._speed
  19. },
  20. set: function (e) {
  21. this._speed = e
  22. this.viewer.clock.multiplier = e
  23. }
  24. },
  25. })
  26. LightingShadow.prototype.open = function () {
  27. // 保留
  28. this.enableLighting = this.viewer.scene.globe.enableLighting
  29. this.shadows = this.viewer.shadows
  30. this.multiplier = this.viewer.clock.multiplier
  31. this.viewer.scene.globe.enableLighting = true;
  32. this.viewer.shadows = true;
  33. this.viewer.clock.multiplier = Cesium.defaultValue(this.speed, 5000);
  34. }
  35. LightingShadow.prototype.close = function () {
  36. this.viewer.scene.globe.enableLighting = this.enableLighting
  37. this.viewer.shadows = this.shadows
  38. this.viewer.clock.multiplier = this.multiplier
  39. }
  40. Cesium.LightingShadow = LightingShadow
  41. }(SkyScenery));