fix: image buffers into native
This commit is contained in:
parent
fbf9d954e3
commit
15f05d065d
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user