@turbox3d/graphic-component-pixi
Version:
Graphic component library based on pixi
58 lines • 2.24 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 * as PIXI from 'pixi.js';
import DrawUtils from '../draw-utils/index';
/** 坐标轴 2d 控件 */
var Axis2d = /*#__PURE__*/function (_Mesh2D) {
function Axis2d() {
var _this;
_classCallCheck(this, Axis2d);
_this = _callSuper(this, Axis2d, arguments);
_this.view = new PIXI.Graphics();
return _this;
}
_inherits(Axis2d, _Mesh2D);
return _createClass(Axis2d, [{
key: "draw",
value: function draw() {
this.view.clear();
this.view.zIndex = Number.MAX_SAFE_INTEGER;
var red = 0xff0000; // x轴
var green = 0x09ff00; // y轴
var blue = 0x005cfc; // z轴
var lineColors = [red, green];
if (this.props.type === 'front') {
lineColors = [red, green];
} else if (this.props.type === 'top') {
lineColors = [red, blue];
} else if (this.props.type === 'left') {
lineColors = [blue, green];
}
DrawUtils.drawLine(this.view, {
x0: 0,
y0: 0,
x1: Number.MAX_SAFE_INTEGER,
y1: 0,
lineWidth: 5,
lineColor: lineColors[0],
alignment: 0.5
});
DrawUtils.drawLine(this.view, {
x0: 0,
y0: 0,
x1: 0,
y1: Number.MAX_SAFE_INTEGER,
lineWidth: 5,
lineColor: lineColors[1],
alignment: 0.5
});
}
}]);
}(Mesh2D);
export { Axis2d as default };