Skip to content

Commit aedcfa9

Browse files
committed
poc test
1 parent 1133902 commit aedcfa9

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

packages/engine/Source/DataSources/LabelVisualizer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ LabelVisualizer.prototype.update = function (time) {
9494

9595
const items = this._items.values;
9696
const cluster = this._cluster;
97-
97+
let ready = true;
9898
for (let i = 0, len = items.length; i < len; i++) {
9999
const item = items[i];
100100
const entity = item.entity;
@@ -250,7 +250,12 @@ LabelVisualizer.prototype.update = function (time) {
250250
if (updateClamping) {
251251
label._updateClamping();
252252
}
253+
// console.log(label._labelCollection?._backgroundBillboardCollection);
254+
if (label._labelCollection) {
255+
ready = label._labelCollection.ready && ready;
256+
}
253257
}
258+
// console.log(ready);
254259
return true;
255260
};
256261

packages/engine/Source/Renderer/TextureAtlas.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ function AddImageRequest({ index, image, resolve, reject }) {
512512
* @param {TexturePacker.PackableObject} image An object, such as an <code>Image</code> with <code>width</code> and <code>height</code> properties in pixels
513513
* @returns {Promise<number>} Promise which resolves to the image index once the image has been added, or rejects if there was an error. The promise resolves to <code>-1</code> if the texture atlas is destoyed in the interim.
514514
*/
515-
TextureAtlas.prototype._addImage = function (index, image) {
515+
TextureAtlas.prototype._addImage = function (index, image, onImageLoad) {
516516
//>>includeStart('debug', pragmas.debug);
517517
Check.typeOf.number.greaterThanOrEquals("index", index, 0);
518518
Check.defined("image", image);
@@ -527,6 +527,7 @@ TextureAtlas.prototype._addImage = function (index, image) {
527527
reject,
528528
}),
529529
);
530+
onImageLoad?.();
530531

531532
this._imagesToAddQueue.sort(
532533
({ image: imageA }, { image: imageB }) =>
@@ -644,14 +645,13 @@ async function resolveImage(image, id) {
644645
* @param {string} id An identifier to detect whether the image already exists in the atlas.
645646
* @param {HTMLImageElement|HTMLCanvasElement|string|Resource|Promise|TextureAtlas.CreateImageCallback} image An image or canvas to add to the texture atlas,
646647
* or a URL to an Image, or a Promise for an image, or a function that creates an image.
647-
* @returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resouces are in the process of being destroyed.
648+
* @returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resources are in the process of being destroyed.
648649
*/
649-
TextureAtlas.prototype.addImage = function (id, image) {
650+
TextureAtlas.prototype.addImage = function (id, image, onImageLoad) {
650651
//>>includeStart('debug', pragmas.debug);
651652
Check.typeOf.string("id", id);
652653
Check.defined("image", image);
653654
//>>includeEnd('debug');
654-
655655
let promise = this._indexPromiseById.get(id);
656656
if (defined(promise)) {
657657
// This image has already been added
@@ -671,7 +671,7 @@ TextureAtlas.prototype.addImage = function (id, image) {
671671
return -1;
672672
}
673673

674-
return this._addImage(index, image);
674+
return this._addImage(index, image, onImageLoad);
675675
};
676676

677677
promise = resolveAndAddImage();

packages/engine/Source/Scene/BillboardTexture.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ BillboardTexture.prototype.loadImage = async function (id, image) {
192192
let index;
193193
const atlas = this._billboardCollection.textureAtlas;
194194
try {
195-
index = await atlas.addImage(id, image);
195+
index = await atlas.addImage(id, image, () => console.log("id render now")); //this._billboardCollection._scene?.requestRender());
196+
console.log("fuck me");
196197
} catch (error) {
197198
// There was an error loading the image
198199
billboardTexture._loadState = BillboardLoadState.ERROR;

0 commit comments

Comments
 (0)