五年以上倾斜摄影osgb模型转3dtiles如何在mars3d加载

方案一:

复制代码
// 兼容1.50 (2018-10-01)版本更改了名称,造成部分3dtiles可能会出现加载不上导致渲染停止的错误。
// 错误说明为:RuntimeError: Unsupported glTF Extension: KHR_technique_webgl
// 原因:KHR_technique_webgl扩展新版Cesium已经不支持的缘故,需要升级一下gltf数据,使用KHR_techniques_webgl扩展即可(注意多了一个s)。
try {
  var fixGltf = function (gltf) {
      if (!gltf.extensionsUsed || !gltf.extensionsUsed.indexOf || !gltf.extensionsRequired) {
          return;
      }
      var v = gltf.extensionsUsed.indexOf('KHR_technique_webgl');
      if (v == -1) return;
      // 中招了。。
      var t = gltf.extensionsRequired.indexOf('KHR_technique_webgl');
      gltf.extensionsRequired.splice(t, 1, 'KHR_techniques_webgl');
      gltf.extensionsUsed.splice(v, 1, 'KHR_techniques_webgl');
      gltf.extensions = gltf.extensions || {};
      gltf.extensions['KHR_techniques_webgl'] = {};
      gltf.extensions['KHR_techniques_webgl'].programs = gltf.programs;
      gltf.extensions['KHR_techniques_webgl'].shaders = gltf.shaders;
      gltf.extensions['KHR_techniques_webgl'].techniques = gltf.techniques;
      var techniques = gltf.extensions['KHR_techniques_webgl'].techniques;
      gltf.materials.forEach(function (mat, index) {
          gltf.materials[index].extensions || (gltf.materials[index].extensions = { KHR_technique_webgl: {} });
          gltf.materials[index].extensions['KHR_technique_webgl'].values = gltf.materials[index].values;
          gltf.materials[index].extensions['KHR_techniques_webgl'] = gltf.materials[index].extensions['KHR_technique_webgl'];
          var myMaterialExtension = gltf.materials[index].extensions['KHR_techniques_webgl'];
          myMaterialExtension.technique || (myMaterialExtension.technique = gltf.materials[index].technique);
          for (var value in myMaterialExtension.values) {
              var us = techniques[myMaterialExtension.technique].uniforms;
              for (var key in us) {
                  if (us[key] === value) {
                      myMaterialExtension.values[key] = myMaterialExtension.values[value];
                      delete myMaterialExtension.values[value];
                      break;
                  }
              }
          };
      });
      techniques.forEach(function (t) {
          for (var attribute in t.attributes) {
              var name = t.attributes[attribute];
              t.attributes[attribute] = t.parameters[name];
          };
          for (var uniform in t.uniforms) {
              var name = t.uniforms[uniform];
              t.uniforms[uniform] = t.parameters[name];
          };
      });
  }
  Object.defineProperties(Cesium.Model.prototype, {
      _cachedGltf: {
          set: function (value) {
              this._my_cachedGltf = value;
              if (this._my_cachedGltf && this._my_cachedGltf._gltf) {
                  fixGltf(this._my_cachedGltf._gltf);
              }
          },
          get: function () {
              return this._my_cachedGltf;
          }
      }
  });
} catch (e) {
  console.log(e)
}

方案二:

需要安装KHR_techniques_webgl包,也可能是ktx1不支持造成的


方案三:

可以用原生cesium来试试哪个版本兼容,可以1.79和1.8X加载看看。切换版本试试

如果有原始的osgb数据,重新跑一次数据处理肯定可以

相关推荐
Kagol10 小时前
TinyVue 支持 Skills 啦!现在你可以让 AI 使用 TinyVue 组件搭建项目
前端·agent·ai编程
柳杉10 小时前
从零打造 AI 全球趋势监测大屏
前端·javascript·aigc
simple_lau10 小时前
Cursor配置MasterGo MCP:一键读取设计稿生成高还原度前端代码
前端·javascript·vue.js
睡不着先生10 小时前
如何设计一个真正可扩展的表单生成器?
前端·javascript·vue.js
天蓝色的鱼鱼11 小时前
模块化与组件化:90%的前端开发者都没搞懂的本质区别
前端·架构·代码规范
明君8799711 小时前
Flutter 如何给图片添加多行文字水印
前端·flutter
进击的尘埃11 小时前
AI 代码审查工具链搭建:用 AST 解析 + LLM 实现自动化 Code Review 的前端工程方案
javascript
juejin_cn11 小时前
[转][译] 从零开始构建 OpenClaw — 第五部分(对话压缩)
javascript
leolee1811 小时前
Redux Toolkit 实战使用指南
前端·react.js·redux
bluceli11 小时前
React Hooks最佳实践:写出优雅高效的组件代码
前端·react.js