UNPKG

awv3

Version:
57 lines (44 loc) 1.98 kB
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import * as THREE from 'three'; import BaseGraphics from './base'; var Linear = /*#__PURE__*/ function (_BaseGraphics) { _inheritsLoose(Linear, _BaseGraphics); function Linear() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _BaseGraphics.call.apply(_BaseGraphics, [this].concat(args, [4, 0, 2])) || this; } var _proto = Linear.prototype; _proto.updateFromState = function updateFromState(info) { var _BaseGraphics$prototy; var _map = ['startPt', 'endPt', 'dimPt'].map(function (x) { return new THREE.Vector3().fromArray(info.dimension.members[x].value); }), start = _map[0], end = _map[1], dim = _map[2]; var dir = new THREE.Vector3(Math.cos(info.dimension.members.angle.value), Math.sin(info.dimension.members.angle.value), 0); var _map2 = [start, end].map(function (x) { return x.clone().sub(dim).projectOnVector(dir).add(dim); }), startFoot = _map2[0], endFoot = _map2[1]; if (endFoot.clone().sub(startFoot).dot(dir) < 0) dir.negate(); var outside = dim.clone().sub(startFoot).dot(dim.clone().sub(endFoot)) > 0; this.updateLine(0, start, startFoot); this.updateLine(1, startFoot, dim); this.updateLine(2, dim, endFoot); this.updateLine(3, endFoot, end); this.updateArrow(0, startFoot, dir.clone().multiplyScalar(outside ? 1 : -1)); this.updateArrow(1, endFoot, dir.clone().multiplyScalar(outside ? -1 : 1)); for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } (_BaseGraphics$prototy = _BaseGraphics.prototype.updateFromState).call.apply(_BaseGraphics$prototy, [this, info].concat(args)); }; return Linear; }(BaseGraphics); export { Linear as default };