From e34154dc4508f1598d0bf83e84fa8ec9f81d9884 Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Wed, 13 Nov 2024 13:38:09 +0000 Subject: [PATCH] catch correctly --- src/framework/parsers/ply.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/framework/parsers/ply.js b/src/framework/parsers/ply.js index 50bcc81528e..2171a56ccbf 100644 --- a/src/framework/parsers/ply.js +++ b/src/framework/parsers/ply.js @@ -552,14 +552,15 @@ class PlyParser { * @param {Asset} asset - Container asset. */ async load(url, callback, asset) { - const response = await fetch(url.load); - if (!response || !response.body) { - callback('Error loading resource', null); - } else { - readPly(response.body.getReader(), asset.data.elementFilter ?? defaultElementFilter) - .then((gsplatData) => { + try { + const response = await fetch(url.load); + if (!response || !response.body) { + callback('Error loading resource', null); + } else { + const gsplatData = await readPly(response.body.getReader(), asset.data.elementFilter ?? defaultElementFilter); + + // reorder data if (!gsplatData.isCompressed) { - // reorder data if (asset.data.reorder ?? true) { gsplatData.reorderData(); } @@ -572,10 +573,9 @@ class PlyParser { ); callback(null, resource); - }) - .catch((err) => { - callback(err, null); - }); + } + } catch (err) { + callback(err, null); } }