@visactor/vrender-core
Version:
## Description
59 lines (53 loc) • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.createRect3d = exports.Rect3d = void 0;
const vutils_1 = require("@visactor/vutils"), rect_1 = require("./rect"), constants_1 = require("./constants"), graphic_1 = require("./graphic"), CUBE_VERTICES = [ [ 0, 0, 0 ], [ 1, 0, 0 ], [ 1, 1, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ], [ 1, 0, 1 ], [ 1, 1, 1 ], [ 0, 1, 1 ] ];
class Rect3d extends rect_1.Rect {
constructor(params) {
super(params), this.type = "rect3d", this.numberType = constants_1.RECT3D_NUMBER_TYPE;
}
findFace() {
const faces = {
polygons: [],
vertices: [],
edges: []
}, rectTheme = this.getGraphicTheme(), {x1: x1, y1: y1, x: x, y: y, length: length = (0,
vutils_1.min)(rectTheme.width, rectTheme.height)} = this.attribute;
let {width: width, height: height} = this.attribute;
width = null != width ? width : x1 - x, height = null != height ? height : y1 - y;
for (let i = 0; i < CUBE_VERTICES.length; i++) {
const v = CUBE_VERTICES[i];
faces.vertices.push([ v[0] * width, v[1] * height, v[2] * length ]);
}
return faces.polygons.push({
polygon: [ 0, 1, 5, 4 ],
normal: [ 0, -1, 0 ]
}), faces.polygons.push({
polygon: [ 2, 3, 7, 6 ],
normal: [ 0, 1, 0 ]
}), faces.polygons.push({
polygon: [ 4, 7, 3, 0 ],
normal: [ -1, 0, 0 ]
}), faces.polygons.push({
polygon: [ 1, 2, 6, 5 ],
normal: [ 1, 0, 0 ]
}), faces.polygons.push({
polygon: [ 0, 1, 2, 3 ],
normal: [ 0, 0, -1 ]
}), faces.polygons.push({
polygon: [ 4, 5, 6, 7 ],
normal: [ 0, 0, 1 ]
}), faces.edges = [ [ 0, 1 ], [ 1, 2 ], [ 2, 3 ], [ 3, 0 ], [ 4, 5 ], [ 5, 6 ], [ 6, 7 ], [ 7, 4 ], [ 0, 4 ], [ 3, 7 ], [ 1, 5 ], [ 2, 6 ] ],
faces;
}
getNoWorkAnimateAttr() {
return Rect3d.NOWORK_ANIMATE_ATTR;
}
}
function createRect3d(attributes) {
return new Rect3d(attributes);
}
exports.Rect3d = Rect3d, Rect3d.NOWORK_ANIMATE_ATTR = graphic_1.NOWORK_ANIMATE_ATTR,
exports.createRect3d = createRect3d;
//# sourceMappingURL=rect3d.js.map