我尝试使用promise和Threejs
加载程序以及方法promise.all([...]).then(...)
加载两个PLY文件,但是.then()
中的代码从不打印几何图形或原因,我不知道为什么...
这是我的代码:
var loader = new THREE.PLYLoader();
function loadAsset(path) {
return new Promise((resolve) => {
loader.load(path, (resolve) => {
console.log('Success');
});
});
}
Promise.all([
loadAsset("ply/ply1.ply"),
loadAsset("ply/ply2.ply")
])
.then(geometries => {
console.log(geometries);
}, reason => {
console.log(reason);
});
答案 0 :(得分:0)
正如所提到的评论,您的诺言永远无法解决
var loader = new THREE.PLYLoader();
function loadAsset(path) {
return new Promise((resolve) => {
loader.load(path, (result) => {
console.log('Success');
resolve(result) //<-------------------
});
});
}