UNPKG

convex-pixel

Version:

The library for creating pseudo 3d interactive scenes based on webgl

73 lines 2.65 kB
import * as PIXI from "pixi.js"; import { sonar as SonarUtils } from "../utils/package"; import { DomSynchronizer } from "./dom-synchronizer"; var App = /** @class */ (function () { function App(config) { var _this = this; this.tick = function () { _this.update(); }; SonarUtils.Sonar.create().run(); this._viewDomElement = config.view; this.pixi = new PIXI.Application({ antialias: config.antialias, transparent: config.transparent, sharedLoader: config.sharedLoader, sharedTicker: config.sharedTicker, preserveDrawingBuffer: config.preserveDrawingBuffer, resolution: config.resolution, forceCanvas: config.forceCanvas, backgroundColor: config.backgroundColor, clearBeforeRender: config.clearBeforeRender, forceFXAA: config.forceFXAA, autoDensity: config.autoDensity, powerPreference: config.powerPreference, resizeTo: config.resizeTo, width: config.width, height: config.height, }); this._domSynchronizer = new DomSynchronizer(this); this._viewDomElement.appendChild(this.pixi.view); this.pixi.ticker.add(this.tick, 9999); } Object.defineProperty(App.prototype, "room", { get: function () { return this._room; }, enumerable: true, configurable: true }); Object.defineProperty(App.prototype, "domSynchronizer", { get: function () { return this._domSynchronizer; }, enumerable: true, configurable: true }); App.prototype.setRoom = function (room) { this._room = room; }; App.prototype.destroy = function () { SonarUtils.Sonar.instance.destroy(); this.pixi.destroy(); }; App.prototype.update = function () { var needResize = false; if (this.pixi.view.width !== this._viewDomElement.offsetWidth) { this.pixi.view.width = this._viewDomElement.offsetWidth; needResize = true; } if (this.pixi.view.height !== this._viewDomElement.offsetHeight) { this.pixi.view.height = this._viewDomElement.offsetHeight; needResize = true; } if (needResize) this.resize(this.pixi.view.width, this.pixi.view.height); }; App.prototype.resize = function (width, height) { // etc }; return App; }()); export { App }; //# sourceMappingURL=app.js.map