@archvisioninc/canvas 2.6.5 → 2.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -418,25 +418,36 @@ export const getImageFileFromBuffer = args => {
|
|
|
418
418
|
});
|
|
419
419
|
const url = URL.createObjectURL(blob);
|
|
420
420
|
if (asBase64Data) {
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
return new Promise((resolve, reject) => {
|
|
422
|
+
const reader = new FileReader();
|
|
423
|
+
reader.onloadend = () => {
|
|
424
|
+
resolve(reader.result);
|
|
425
|
+
};
|
|
426
|
+
reader.onerror = error => {
|
|
427
|
+
console.error('Error reading buffer: ', error);
|
|
428
|
+
reject(error);
|
|
429
|
+
};
|
|
430
|
+
reader.readAsDataURL(blob);
|
|
431
|
+
});
|
|
423
432
|
}
|
|
424
|
-
return url;
|
|
433
|
+
return Promise.resolve(url);
|
|
425
434
|
} catch (error) {
|
|
426
435
|
console.error('Unable to get image from buffer: ', error);
|
|
436
|
+
return Promise.reject(error);
|
|
427
437
|
}
|
|
428
438
|
};
|
|
429
|
-
export const getTextureUrl = args => {
|
|
439
|
+
export const getTextureUrl = async args => {
|
|
430
440
|
const {
|
|
431
441
|
texture,
|
|
432
442
|
asBase64Data
|
|
433
443
|
} = args || {};
|
|
434
444
|
const buffer = texture?._buffer;
|
|
435
445
|
if (_.isEmpty(buffer)) return texture?.url || '';
|
|
436
|
-
|
|
446
|
+
const url = await getImageFileFromBuffer({
|
|
437
447
|
buffer,
|
|
438
448
|
asBase64Data
|
|
439
449
|
});
|
|
450
|
+
return url;
|
|
440
451
|
};
|
|
441
452
|
export const materialData = material => {
|
|
442
453
|
const meshesWithMaterial = getUserMeshes().map(mesh => {
|
package/package.json
CHANGED
|
@@ -476,22 +476,36 @@ export const getImageFileFromBuffer = args => {
|
|
|
476
476
|
const url = URL.createObjectURL(blob);
|
|
477
477
|
|
|
478
478
|
if (asBase64Data) {
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
return new Promise((resolve, reject) => {
|
|
480
|
+
const reader = new FileReader();
|
|
481
|
+
|
|
482
|
+
reader.onloadend = () => {
|
|
483
|
+
resolve(reader.result);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
reader.onerror = error => {
|
|
487
|
+
console.error('Error reading buffer: ', error);
|
|
488
|
+
reject(error);
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
reader.readAsDataURL(blob);
|
|
492
|
+
});
|
|
481
493
|
}
|
|
482
494
|
|
|
483
|
-
return url;
|
|
495
|
+
return Promise.resolve(url);
|
|
484
496
|
} catch (error) {
|
|
485
497
|
console.error('Unable to get image from buffer: ', error);
|
|
498
|
+
return Promise.reject(error);
|
|
486
499
|
}
|
|
487
500
|
};
|
|
488
501
|
|
|
489
|
-
export const getTextureUrl = args => {
|
|
502
|
+
export const getTextureUrl = async args => {
|
|
490
503
|
const { texture, asBase64Data } = args || {};
|
|
491
504
|
const buffer = texture?._buffer;
|
|
492
505
|
|
|
493
506
|
if (_.isEmpty(buffer)) return texture?.url || '';
|
|
494
|
-
|
|
507
|
+
const url = await getImageFileFromBuffer({ buffer, asBase64Data });
|
|
508
|
+
return url;
|
|
495
509
|
};
|
|
496
510
|
|
|
497
511
|
export const materialData = material => {
|