UNPKG

convex-pixel

Version:

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

71 lines 3.04 kB
import { __extends } from "tslib"; import * as PIXI from "pixi.js"; import { P3DCameraProcessor } from "../../core/camera-processor"; import * as DisplayUtils from "../../utils/display"; import * as SonarUtils from "../../utils/sonar"; import { BaseContainer } from "./base-container"; var BaseRoom = /** @class */ (function (_super) { __extends(BaseRoom, _super); function BaseRoom(appContext, options) { var _this = _super.call(this, appContext) || this; _this._roomBound = new PIXI.Rectangle(); _this._resizeSonarHandler = function () { _this.resetScaleFactor(); }; _this._autosize = options.autosize || DisplayUtils.RatioFitTypes.NONE; // Create a camera _this._camera = new options.camera.class(_this, options.camera.viewport, options.camera.config); for (var _i = 0, _a = options.camera.controllers; _i < _a.length; _i++) { var controller = _a[_i]; if (!_this._camera.controllers) { continue; } _this._camera.controllers.add(new controller(appContext)); } _this._cameraProcessor = new P3DCameraProcessor(_this); _this._sonarResize = new SonarUtils.SonarDebounce(); _this._sonarResize.addListener(SonarUtils.SonarEventTypes.CHANGE, _this._resizeSonarHandler); return _this; // this._dispatcher.addEventListener("resize", this._resizeHandler); // this._dispatcher.addEventListener("recalculate-pov", this._recalculatePOVHandler); } Object.defineProperty(BaseRoom.prototype, "camera", { get: function () { return this._camera; }, enumerable: true, configurable: true }); Object.defineProperty(BaseRoom.prototype, "roomBound", { get: function () { return this._roomBound; }, enumerable: true, configurable: true }); BaseRoom.prototype.recalculateCameraPOV = function () { this._cameraProcessor.updatePOV(this); }; BaseRoom.prototype.setViewport = function (width, height) { this._camera.viewport.width = width; this._camera.viewport.height = height; this.resetScaleFactor(); }; BaseRoom.prototype.setSize = function (width, height) { this._roomBound.width = width; this._roomBound.height = height; this.resetScaleFactor(); }; BaseRoom.prototype.destroy = function () { this._sonarResize.destroy(); this._cameraProcessor.destroy(); this._camera.destroy(); _super.prototype.destroy.call(this); }; BaseRoom.prototype.resetScaleFactor = function () { this._camera.maxZoom = DisplayUtils.getRatio(this._roomBound.width, this._roomBound.height, this._camera.viewport.width, this._camera.viewport.height, this._autosize); }; return BaseRoom; }(BaseContainer)); export { BaseRoom }; //# sourceMappingURL=base-room.js.map