@turbox3d/graphic-component-pixi
Version:
Graphic component library based on pixi
43 lines • 2.36 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(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; })(); }
import { Mesh2D } from '@turbox3d/renderer-pixi';
import { GridHelper } from './grid-helper';
var Grid2d = /*#__PURE__*/function (_Mesh2D) {
function Grid2d() {
_classCallCheck(this, Grid2d);
return _callSuper(this, Grid2d, arguments);
}
_inherits(Grid2d, _Mesh2D);
return _createClass(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(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;
}
}]);
}(Mesh2D);
export { Grid2d as default };