promise.all().then() not working
Clash Royale CLAN TAG#URR8PPP
promise.all().then() not working
I tried to load two PLY files using promise and Threejs
Loaders, and the method promise.all([...]).then(...)
but the code inside .then()
never prints the geometries or reason and I don't have idea why...
Threejs
promise.all([...]).then(...)
.then()
here is my code:
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);
);
You are not calling
resolve
, even shadow the outer parameter with an inner one, but don't even use that.– ASDFGerte
Aug 11 at 21:41
resolve
Can you show a example?
– mihael
Aug 11 at 21:46
1 Answer
1
As the comments mentioned, your promises never resolve
var loader = new THREE.PLYLoader();
function loadAsset(path)
return new Promise((resolve) =>
loader.load(path, (result) =>
console.log('Success');
resolve(result) //<-------------------
);
);
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You never seem to resolve any of the promises.
– jonrsharpe
Aug 11 at 21:41