fix: image buffers into native

This commit is contained in:
cha0s 2021-01-16 11:51:15 -06:00
parent fbf9d954e3
commit 15f05d065d

View File

@ -24,13 +24,16 @@ export class Image extends Resource {
load(buffer) {
if (buffer) {
const {height, width} = imageSize(Buffer.from(buffer));
const realBuffer = Buffer.from(buffer);
if ('client' === process.env.SIDE) {
// eslint-disable-next-line global-require
const {Texture} = require('@pixi/core');
this.texture = Texture.fromBuffer(buffer, width, height);
const native = window.document.createElement('img');
native.src = `data:;base64,${realBuffer.toString('base64')}`;
this.texture = Texture.from(native);
}
else {
const {height, width} = imageSize(realBuffer);
this.texture = {
height,
isFake: true,