@turbox3d/graphic-component-pixi
Version:
Graphic component library based on pixi
49 lines (48 loc) • 2.8 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _rendererPixi = require("@turbox3d/renderer-pixi");
var _gridHelper = require("./grid-helper");
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var Grid2d = exports["default"] = /*#__PURE__*/function (_Mesh2D) {
function Grid2d() {
(0, _classCallCheck2["default"])(this, Grid2d);
return _callSuper(this, Grid2d, arguments);
}
(0, _inherits2["default"])(Grid2d, _Mesh2D);
return (0, _createClass2["default"])(Grid2d, [{
key: "draw",
value: function draw() {
var _this$props = this.props,
_this$props$lineWidth = _this$props.lineWidth,
lineWidth = _this$props$lineWidth === void 0 ? 2 : _this$props$lineWidth,
_this$props$lineColor = _this$props.lineColor,
lineColor = _this$props$lineColor === void 0 ? 0xffffff : _this$props$lineColor,
_this$props$drawBound = _this$props.drawBoundaries,
drawBoundaries = _this$props$drawBound === void 0 ? true : _this$props$drawBound,
gridWidth = _this$props.gridWidth,
_this$props$cellSize = _this$props.cellSize,
cellSize = _this$props$cellSize === void 0 ? 0 : _this$props$cellSize,
_this$props$zIndex = _this$props.zIndex,
zIndex = _this$props$zIndex === void 0 ? 0 : _this$props$zIndex;
this.view = new _gridHelper.GridHelper(gridWidth, cellSize);
this.view.lineStyle({
width: lineWidth,
color: lineColor
});
this.view.drawBoundaries = drawBoundaries;
this.view.drawGrid();
this.view.position.set(-gridWidth / 2 + window.innerWidth / 2, -gridWidth / 2 + window.innerHeight / 2);
this.view.zIndex = zIndex;
}
}]);
}(_rendererPixi.Mesh2D);