2018-05-28 09:49:45 +08:00
|
|
|
"use strict";
|
2018-06-06 17:23:22 +08:00
|
|
|
var __extends = (this && this.__extends) || (function () {
|
|
|
|
var 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 function (d, b) {
|
|
|
|
extendStatics(d, b);
|
|
|
|
function __() { this.constructor = d; }
|
|
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
|
};
|
|
|
|
})();
|
2018-05-28 09:49:45 +08:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2018-06-06 17:23:22 +08:00
|
|
|
var three_1 = require("three");
|
|
|
|
var ColorPalette_1 = require("./ColorPalette");
|
|
|
|
var Text_1 = require("./Text");
|
|
|
|
var GeUtils_1 = require("./GeUtils");
|
2018-05-28 09:49:45 +08:00
|
|
|
/**
|
|
|
|
* 标注实体
|
|
|
|
*
|
|
|
|
* @export
|
|
|
|
* @class Dimension
|
|
|
|
* @extends {Group}
|
|
|
|
*/
|
2018-06-06 17:23:22 +08:00
|
|
|
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;
|
2018-05-28 09:49:45 +08:00
|
|
|
if (mirrorFoot) {
|
|
|
|
footLength = -footLength;
|
|
|
|
}
|
|
|
|
//针脚几何体
|
2018-06-06 17:23:22 +08:00
|
|
|
var lineGeo = new three_1.Geometry();
|
2018-05-28 09:49:45 +08:00
|
|
|
lineGeo.vertices.push(new three_1.Vector3(), new three_1.Vector3(0, footLength, 0));
|
|
|
|
//托盘几何体
|
2018-06-06 17:23:22 +08:00
|
|
|
var lineGeo2 = new three_1.Geometry();
|
2018-05-28 09:49:45 +08:00
|
|
|
lineGeo2.vertices.push(new three_1.Vector3(0, footLength), new three_1.Vector3(length, footLength, 0));
|
2018-06-06 17:23:22 +08:00
|
|
|
var material = ColorPalette_1.ColorMaterial.GetLineMaterial(5);
|
|
|
|
var line1 = new three_1.Line(lineGeo, material);
|
|
|
|
var line2 = new three_1.Line(lineGeo, material);
|
2018-05-28 09:49:45 +08:00
|
|
|
line2.position.x = length;
|
2018-06-06 17:23:22 +08:00
|
|
|
var line3 = new three_1.Line(lineGeo2, material);
|
|
|
|
var text = new Text_1.DbText(parseFloat(length.toFixed(2)).toString(), textHeight);
|
2018-05-28 09:49:45 +08:00
|
|
|
if (mirror) {
|
2018-06-06 17:23:22 +08:00
|
|
|
var roMat = new three_1.Matrix4().makeRotationZ(Math.PI);
|
2018-05-28 09:49:45 +08:00
|
|
|
text.applyMatrix(roMat);
|
|
|
|
text.applyMatrix(GeUtils_1.MoveMatrix(new three_1.Vector3(length * 0.5, footLength - textHeight * 0.1)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
text.applyMatrix(GeUtils_1.MoveMatrix(new three_1.Vector3(length * 0.5, footLength * 1.1)));
|
|
|
|
}
|
2018-06-06 17:23:22 +08:00
|
|
|
_this.add(text);
|
|
|
|
_this.add(line1, line2, line3);
|
|
|
|
return _this;
|
2018-05-28 09:49:45 +08:00
|
|
|
}
|
2018-06-06 17:23:22 +08:00
|
|
|
return Dimension;
|
|
|
|
}(three_1.Group));
|
2018-05-28 09:49:45 +08:00
|
|
|
exports.Dimension = Dimension;
|
|
|
|
//# sourceMappingURL=Dimension.js.map
|