feat: API for three.js bridge

This commit is contained in:
cha0s 2019-04-19 00:49:46 -05:00
parent 8e22e43f95
commit 77af345889

View File

@ -13,6 +13,16 @@ export class Image extends Resource {
this.texture.destroy();
}
static fromHtmlCanvas(htmlCanvas) {
const baseTexture = PIXI.BaseTexture.fromCanvas(
htmlCanvas,
PIXI.SCALE_MODES.NEAREST
);
const image = new Image();
image.texture = new PIXI.Texture(baseTexture);
return image;
}
static load(uri) {
return this.loadBaseTexture(uri).then((baseTexture) => {
const image = new Image();
@ -63,6 +73,12 @@ export class Image extends Resource {
return subimage;
}
updateBaseTexture() {
if (this.texture && this.texture.baseTexture) {
this.texture.baseTexture.update();
}
}
get width() {
if (!this.texture) {
return 0;