awv3
Version:
AWV client CAD framework
1 lines • 5.72 kB
JavaScript
;function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _getOwnPropertyNames=require("babel-runtime/core-js/object/get-own-property-names"),_getOwnPropertyNames2=_interopRequireDefault(_getOwnPropertyNames),_freeze=require("babel-runtime/core-js/object/freeze"),_freeze2=_interopRequireDefault(_freeze),_map=require("babel-runtime/core-js/map"),_map2=_interopRequireDefault(_map),_promise=require("babel-runtime/core-js/promise"),_promise2=_interopRequireDefault(_promise),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_ccobjects=require("sketcher/ccobjects"),_sketcher=require("sketcher/sketcher"),_sketcher2=_interopRequireDefault(_sketcher),_cchelpers=require("sketcher/cchelpers"),_view=require("core/view"),_view2=_interopRequireDefault(_view),_three=require("three"),_three2=_interopRequireDefault(_three),Constraint=function(e){function t(r,n,i){(0,_classCallCheck3["default"])(this,t);var s=(0,_possibleConstructorReturn3["default"])(this,e.call(this));return _sketcher2["default"].mixinPixelSizedGeometry.call(s,s.thickness),s.points=[],r=r||[],s.typename=r[0],s.type=r[1],s.args=n||[],i=i||{},s.expression=i.expression,s.value=i.value,s.fixed=i.fixed,s.mesh=s.interact=new _three2["default"].Mesh(new _three2["default"].PlaneGeometry(1,1),new _three2["default"].MeshBasicMaterial),s.add(s.mesh),s.hide(),s}return(0,_inherits3["default"])(t,e),t.prototype.getData=function(){var e=[this.typename,this.type],t=this.args,r={expression:this.expression,value:this.value,fixed:this.fixed};return[e,t,r]},t.prototype.addMember=function(e){switch(_ccobjects.ClassCadObject.prototype.addMember.apply(this,arguments),e.userData.memberInfo.name){case"value":this.value=e.valueOf(),this.expression=e.userData.memberInfo.expression,this.fixed=e.userData.memberInfo.fixed;break;case"entities":this.args=e}},t.prototype.finishedUpdating=function(){this.typename=t.TypeFromCctype.get(this.type),this.loadTexture()},t.prototype.updateMatrixFromMatrixWorld=function(){},t.prototype.loadTexture=function(){var e=this,r=t.TextParameters;return new _promise2["default"](function(t,n){var i=r.imgPath(e),s=new _three2["default"].TextureLoader;i?s.load(i,t,void 0,n):n()}).then(function(t){e.mesh.material=new _three2["default"].MeshBasicMaterial({map:t,polygonOffset:!0,polygonOffsetFactor:-3,polygonOffsetUnits:-15})})["catch"](function(){var t=new _three2["default"].TextGeometry(e.typename,r);e.mesh=e.interact=new _three2["default"].Mesh(t,new _three2["default"].MeshBasicMaterial({color:r.color}))})},t.prototype.updateGeometry=function(){},t.prototype.show=function(){this.visible=!0},t.prototype.hide=function(){this.visible=!1},t.prototype.hover=function(){this.args.forEach(function(e){e.interact&&e.interact.hover&&e.interact.hover()})},t.prototype.unhover=function(){this.args.forEach(function(e){e.interact&&e.interact.unhover&&e.interact.unhover()})},t.prototype.setGeomSizes=function(e){var t=e[0];this.mesh.scale.set(t,t,t)},t.prototype.getState=function(){var e=this,t=new _map2["default"];return["expression","value","fixed"].forEach(function(r){return t.set(r,e[r])}),t},t.prototype.applyStateDiff=function(e){var t=this;["expression","value","fixed"].forEach(function(r){e.has(r)&&(t[r]=e.get(r))})},t.prototype.prepareAddOnServer=function(e){return _cchelpers.Interop.AddConstraint(e,this.typename,this.type,this.args,this.expression,this.value,this.fixed).parseToObject(this,this.args.map(function(t){return e.getAncestorOnSketch(t)}))},t.prototype.prepareUpdateToServer=function(e){return _cchelpers.Interop.UpdateConstraint(e,this,this.args,this.expression,this.value,this.fixed).parseToObject(this,this.args.map(function(t){return e.getAncestorOnSketch(t)}))},t.prototype.prepareRemoveOnServer=function(e){return _cchelpers.Interop.RemoveConstraint(e,this)},t}(_ccobjects.ClassCadObject);exports["default"]=Constraint,Constraint.TextParameters={color:48896,size:1,height:1,font:"droid sans",weight:"normal",style:"normal",imgPath:function(e){}},Constraint.Type=(0,_freeze2["default"])({FIXATION:["FIXATION","CC_2DFixationConstraint"],INCIDENCE:["INCIDENCE","CC_2DCoincidentConstraint"],DISTANCE:["DISTANCE","CC_2DOffsetConstraint"],ANGLE:["ANGLE","CC_2DAngleConstraint"],ANGLEOX:["ANGLEOX","CC_2DAngleOXConstraint"],TANGENCY:["TANGENCY","CC_2DTangentSketchConstraint"],HORIZONTALITY:["HORIZONTALITY","CC_2DHorizontalConstraint"],VERTICALITY:["VERTICALITY","CC_2DVerticalConstraint"],PERPENDICULARITY:["PERPENDICULARITY","CC_2DPerpendicularConstraint"],PARALLELITY:["PARALLELITY","CC_2DParallelConstraint"],CONCENTRIC:["CONCENTRIC","CC_2DConcentricConstraint"],MIDPOINT:["MIDPOINT","CC_2DMidpointConstraint"],SYMMETRIC:["SYMMETRIC","CC_2DSymmetryConstraint"],COLINEAR:["COLINEAR","CC_2DColinearConstraint"],EQUAL_DISTANCE:["EQUAL_DISTANCE","CC_2DEqualLengthConstraint"],RADIUS:["RADIUS","CC_2DRadiusConstraint"],EQUAL_RADIUS:["EQUAL_RADIUS","CC_2DEqualRadiusConstraint"],HORIZONTAL_DISTANCE:["HORIZONTAL_DISTANCE","CC_2DHorizontalDistanceConstraint"],VERTICAL_DISTANCE:["VERTICAL_DISTANCE","CC_2DVerticalDistanceConstraint"]}),Constraint.TypeFromCctype=new _map2["default"],(0,_getOwnPropertyNames2["default"])(Constraint.Type).forEach(function(e){var t=Constraint.Type[e][1];void 0!==t&&(Constraint.TypeFromCctype.set(t,e),_ccobjects.ClassCadObject.classMapping[t]=Constraint)}),Constraint.prototype.thickness=16;