Преглед изворни кода

Fix point cloud system after async readPixels change

Popov72 пре 4 година
родитељ
комит
8465415f1b
1 измењених фајлова са 17 додато и 6 уклоњено
  1. 17 6
      src/Particles/pointsCloudSystem.ts

+ 17 - 6
src/Particles/pointsCloudSystem.ts

@@ -479,12 +479,23 @@ export class PointsCloudSystem implements IDisposable {
                 if (n > textureList.length - 1) {
                     n =  textureList.length - 1;
                 }
-                pointsGroup._groupImageData = textureList[n].readPixels();
-                pointsGroup._groupImgWidth = textureList[n].getSize().width;
-                pointsGroup._groupImgHeight = textureList[n].getSize().height;
-                this._setPointsColorOrUV(clone, pointsGroup, isVolume, true, true);
-                clone.dispose();
-                return resolve();
+                const finalize = () => {
+                    pointsGroup._groupImgWidth = textureList[n].getSize().width;
+                    pointsGroup._groupImgHeight = textureList[n].getSize().height;
+                    this._setPointsColorOrUV(clone, pointsGroup, isVolume, true, true);
+                    clone.dispose();
+                    resolve();
+                };
+                pointsGroup._groupImageData = null;
+                const dataPromise = textureList[n].readPixels();
+                if (!dataPromise) {
+                    finalize();
+                } else {
+                    dataPromise.then((data) => {
+                        pointsGroup._groupImageData = data;
+                        finalize();
+                    });
+                }
             });
         }));
     }