feat: API for three.js bridge
This commit is contained in:
parent
8e22e43f95
commit
77af345889
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user