UNPKG

@deck.gl/experimental-layers

Version:

Experimental layers for deck.gl

72 lines (53 loc) 3.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _luma = require("luma.gl"); function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Arrow2DGeometry = /*#__PURE__*/ function (_Geometry) { _inherits(Arrow2DGeometry, _Geometry); function Arrow2DGeometry() { var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, Arrow2DGeometry); return _possibleConstructorReturn(this, _getPrototypeOf(Arrow2DGeometry).call(this, Object.assign({}, opts, { attributes: getArrowAttributes(opts) }))); } return Arrow2DGeometry; }(_luma.Geometry); exports.default = Arrow2DGeometry; function getArrowAttributes(_ref) { var _ref$length = _ref.length, length = _ref$length === void 0 ? 1 : _ref$length, _ref$headSize = _ref.headSize, headSize = _ref$headSize === void 0 ? 0.2 : _ref$headSize, _ref$tailWidth = _ref.tailWidth, tailWidth = _ref$tailWidth === void 0 ? 0.05 : _ref$tailWidth, _ref$tailStart = _ref.tailStart, tailStart = _ref$tailStart === void 0 ? 0.05 : _ref$tailStart; var texCoords = [// HEAD 0.5, 1.0, 0, 0.5 - headSize / 2, 1.0 - headSize, 0, 0.5 + headSize / 2, 1.0 - headSize, 0, 0.5 - tailWidth / 2, tailStart, 0, 0.5 + tailWidth / 2, 1.0 - headSize, 0, 0.5 + tailWidth / 2, tailStart, 0, 0.5 - tailWidth / 2, tailStart, 0, 0.5 - tailWidth / 2, 1.0 - headSize, 0, 0.5 + tailWidth / 2, 1.0 - headSize, 0]; var normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]; // Center and scale var positions = new Array(texCoords.length); for (var i = 0; i < texCoords.length / 3; i++) { var i3 = i * 3; positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length; positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length; positions[i3 + 2] = 0; } return { positions: new Float32Array(positions), normals: new Float32Array(normals), texCoords: new Float32Array(texCoords) }; } //# sourceMappingURL=arrow-2d-geometry.js.map