valaxy-addon-live2d
Version:
<a href="https://www.npmjs.com/package/valaxy-addon-live2d" rel="nofollow"><img src="https://img.shields.io/npm/v/valaxy-addon-live2d?color=0078E7" alt="NPM version"></a>
31 lines (30 loc) • 1.04 kB
JavaScript
import { Application } from '@pixi/app';
import { BatchRenderer, extensions } from '@pixi/core';
import { Extract } from '@pixi/extract';
import { TickerPlugin } from '@pixi/ticker';
extensions.add(TickerPlugin, Extract, BatchRenderer);
export class PixiApp extends Application {
constructor(stats) {
const view = document.getElementById('live2d-canvas');
if (!view)
console.warn('The view element with id "live2d" was not found in the document.');
else if (!(view instanceof HTMLCanvasElement))
console.warn('The view element must be an instance of HTMLCanvasElement.');
super({
view,
antialias: true,
resolution: 2,
autoStart: true,
autoDensity: true,
backgroundAlpha: 0,
width: 0,
height: 0,
});
this.ticker.remove(this.render, this);
this.ticker.add(() => {
stats?.begin();
this.render();
stats?.end();
});
}
}