1 line
1005 B
JavaScript
1 line
1005 B
JavaScript
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbShape from"../MxDbShape";class MxDbRegularPolygonShape extends MxDbShape{constructor(){super(),this.center=new THREE.Vector3,this.sidesNumber=6,this.radius=70,this._propertyDbKeys=[...this._propertyDbKeys,"center","sidesNumber","radius"]}getTypeName(){return"MxDbRegularPolygonShape"}worldDraw(e){this._drawPolygonShape(e)}_drawPolygonShape(e){const t=this._getPoints(),r=new THREE.Path;r.moveTo(t[0].x,t[0].y);for(let e=0;e<t.length;e++)r.lineTo(t[e].x,t[e].y);r.closePath();const s=this.createPaths(r),o=this.getShapePoints(s);this._draw(e,o),this._drawStoreLine(e,o)}_getPoints(){const{sidesNumber:e,radius:t}=this,{x:r,y:s}=this.center,o=[];for(let i=0;i<e;i++)o.push({x:t*Math.sin(2*i*Math.PI/e)+r,y:-1*t*Math.cos(2*i*Math.PI/e)+s});return o}getGripPoints(){return[this.center]}moveGripPointsAt(e,t){return 0===e&&this.center.add(t),!0}}addRegisterMxDbEntity(MxDbRegularPolygonShape);export default MxDbRegularPolygonShape; |