2 Star 0 Fork 3

Cesium/blender-3d-tiler

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
texture-updater.js 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
const fs = require('fs');
const path = require('path');
const argv = require('yargs').argv;
if (!argv.input || !fs.existsSync(argv.input)) {
console.log('input file not found');
process.exit(1);
}
let absoluteGltfPath = path.resolve(argv.input);
let absoluteMapPath = path.join( path.dirname(absoluteGltfPath) , "refined_texture_map.json");
if (!fs.existsSync(absoluteMapPath)) {
console.log("MAP file is missing");
process.exit(1);
}
let map = JSON.parse(fs.readFileSync(absoluteMapPath, 'utf8'));
let gltf = JSON.parse(fs.readFileSync(absoluteGltfPath, 'utf8'));
map.forEach((m) => {
// looking for old texture image name in gltf
for (let i = 0; i < gltf.images.length; i++) {
if (path.basename(gltf.images[i].uri) == m.old) {
gltf.images[i].name = m.new;
gltf.images[i].mimeType = 'image/jpeg';
gltf.images[i].uri = path.dirname(gltf.images[i].uri) + '/' + m.new;
}
}
});
let absoluteOutputPath = path.join( path.dirname(absoluteGltfPath), "refined_" + path.basename(absoluteGltfPath));
fs.writeFileSync(absoluteOutputPath, JSON.stringify(gltf, null, 2));
process.exit(0);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cesium_processing/blender-3d-tiler.git
git@gitee.com:cesium_processing/blender-3d-tiler.git
cesium_processing
blender-3d-tiler
blender-3d-tiler
master

搜索帮助