cesium-version.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //兼容不同版本cesium,补充官方删除更改的方法或类名 by mars3d.cn
  2. //兼容1.73(2020-9-1)删除的方法
  3. Cesium.BingMapsApi = { defaultKey: "" };
  4. Cesium.MapboxApi = { defaultAccessToken: "" };
  5. //兼容1.67(2020-3-3)删除的方法
  6. if (!Cesium.defineProperties) Cesium.defineProperties = Object.defineProperties;
  7. if (!Cesium.isArray) Cesium.isArray = Array.isArray;
  8. //兼容1.62(2019-10-01)改名的方法
  9. if (!Cesium.Matrix4.getMatrix3)
  10. Cesium.Matrix4.getMatrix3 = Cesium.Matrix4.getRotation;
  11. if (!Cesium.TileMapServiceImageryProvider)
  12. Cesium.TileMapServiceImageryProvider =
  13. Cesium.createTileMapServiceImageryProvider;
  14. if (!Cesium.createTileMapServiceImageryProvider) {
  15. Cesium.createTileMapServiceImageryProvider = function (options) {
  16. return new Cesium.TileMapServiceImageryProvider(options);
  17. };
  18. }
  19. //兼容1.50 (2018-10-01)版本更改了名称,造成部分3dtiles可能会出现加载不上导致渲染停止的错误。
  20. //错误说明为:RuntimeError: Unsupported glTF Extension: KHR_technique_webgl
  21. //原因:KHR_technique_webgl扩展新版Cesium已经不支持的缘故,需要升级一下gltf数据,使用KHR_techniques_webgl扩展即可(注意多了一个s)。
  22. try {
  23. // var fixGltf = function (gltf) {
  24. // if (!gltf.extensionsUsed || !gltf.extensionsUsed.indexOf || !gltf.extensionsRequired) {
  25. // return;
  26. // }
  27. // var v = gltf.extensionsUsed.indexOf('KHR_technique_webgl');
  28. // if (v == -1) return;
  29. // // 中招了。。
  30. // var t = gltf.extensionsRequired.indexOf('KHR_technique_webgl');
  31. // gltf.extensionsRequired.splice(t, 1, 'KHR_techniques_webgl');
  32. // gltf.extensionsUsed.splice(v, 1, 'KHR_techniques_webgl');
  33. // gltf.extensions = gltf.extensions || {};
  34. // gltf.extensions['KHR_techniques_webgl'] = {};
  35. // gltf.extensions['KHR_techniques_webgl'].programs = gltf.programs;
  36. // gltf.extensions['KHR_techniques_webgl'].shaders = gltf.shaders;
  37. // gltf.extensions['KHR_techniques_webgl'].techniques = gltf.techniques;
  38. // var techniques = gltf.extensions['KHR_techniques_webgl'].techniques;
  39. // gltf.materials.forEach(function (mat, index) {
  40. // gltf.materials[index].extensions || (gltf.materials[index].extensions = { KHR_technique_webgl: {} });
  41. // gltf.materials[index].extensions['KHR_technique_webgl'].values = gltf.materials[index].values;
  42. // gltf.materials[index].extensions['KHR_techniques_webgl'] = gltf.materials[index].extensions['KHR_technique_webgl'];
  43. // var myMaterialExtension = gltf.materials[index].extensions['KHR_techniques_webgl'];
  44. // myMaterialExtension.technique || (myMaterialExtension.technique = gltf.materials[index].technique);
  45. // for (var value in myMaterialExtension.values) {
  46. // var us = techniques[myMaterialExtension.technique].uniforms;
  47. // for (var key in us) {
  48. // if (us[key] === value) {
  49. // myMaterialExtension.values[key] = myMaterialExtension.values[value];
  50. // delete myMaterialExtension.values[value];
  51. // break;
  52. // }
  53. // }
  54. // };
  55. // });
  56. // techniques.forEach(function (t) {
  57. // for (var attribute in t.attributes) {
  58. // var name = t.attributes[attribute];
  59. // t.attributes[attribute] = t.parameters[name];
  60. // };
  61. // for (var uniform in t.uniforms) {
  62. // var name = t.uniforms[uniform];
  63. // t.uniforms[uniform] = t.parameters[name];
  64. // };
  65. // });
  66. // }
  67. // Object.defineProperties(Cesium.Model.prototype, {
  68. // _cachedGltf: {
  69. // set: function (value) {
  70. // this._my_cachedGltf = value;
  71. // if (this._my_cachedGltf && this._my_cachedGltf._gltf) {
  72. // fixGltf(this._my_cachedGltf._gltf);
  73. // }
  74. // },
  75. // get: function () {
  76. // return this._my_cachedGltf;
  77. // }
  78. // }
  79. // });
  80. } catch (e) {
  81. console.log(e);
  82. }