CADViewComponent/dist/Dimension.js

64 lines
2.6 KiB
JavaScript
Raw Normal View History

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var three_1 = require("three");
var ColorPalette_1 = require("./ColorPalette");
var Text_1 = require("./Text");
var GeUtils_1 = require("./GeUtils");
/**
* 标注实体
* @export
* @class Dimension
* @extends {Group}
*/
var Dimension = /** @class */ (function (_super) {
__extends(Dimension, _super);
function Dimension(length, textHeight, mirror, mirrorFoot) {
if (textHeight === void 0) { textHeight = 25; }
if (mirror === void 0) { mirror = false; }
if (mirrorFoot === void 0) { mirrorFoot = false; }
var _this = _super.call(this) || this;
var footLength = 60;
if (mirrorFoot) {
footLength = -footLength;
}
//针脚几何体
var lineGeo = new three_1.Geometry();
lineGeo.vertices.push(new three_1.Vector3(), new three_1.Vector3(0, footLength, 0));
//托盘几何体
var lineGeo2 = new three_1.Geometry();
lineGeo2.vertices.push(new three_1.Vector3(0, footLength), new three_1.Vector3(length, footLength, 0));
var material = ColorPalette_1.ColorMaterial.GetLineMaterial(5);
var line1 = new three_1.Line(lineGeo, material);
var line2 = new three_1.Line(lineGeo, material);
line2.position.x = length;
var line3 = new three_1.Line(lineGeo2, material);
var text = new Text_1.DbText(parseFloat(length.toFixed(2)).toString(), textHeight);
if (mirror) {
var roMat = new three_1.Matrix4().makeRotationZ(Math.PI);
text.applyMatrix4(roMat);
text.applyMatrix4(GeUtils_1.MoveMatrix(new three_1.Vector3(length * 0.5, footLength - textHeight * 0.1)));
}
else {
text.applyMatrix4(GeUtils_1.MoveMatrix(new three_1.Vector3(length * 0.5, footLength * 1.1)));
}
_this.add(text);
_this.add(line1, line2, line3);
return _this;
}
return Dimension;
}(three_1.Group));
exports.Dimension = Dimension;
//# sourceMappingURL=Dimension.js.map