let gltfExporter = new GLTFExporter();
// 单个模型数据 obj
gltfExporter.parse(obj, function (result) {
console.log(result);
let link = document.createElement('a');
link.style.display = 'none';
document.body.appendChild(link);
link.href = URL.createObjectURL(new Blob([JSON.stringify(result)], { type: 'text/plain' }));
link.download = unescape(_this.ChildrenData[i].modelType) + '.gltf';
link.click();
document.body.removeChild(link);
});
const loader = new GLTFLoader();
loader.load(‘文件路径’ (res) => {
this.scene.add(res.scene.children[0]);
}, function (xhr) {
if ((xhr.loaded / xhr.total * 100) === 100) {
console.log((xhr.loaded / xhr.total * 100) + '% loaded');
}
}, function (error) {
console.log('load error!'+ error.getWebGLErrorMessage());
});