UNPKG

awv3

Version:
60 lines (49 loc) 1.85 kB
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import * as THREE from 'three'; import { getArcAngles } from '../geomutils'; import BaseGraphics from './base'; import RingGeometry from '../../../three/ringgeometry'; import { setMaterialMeta } from './index'; var material = new THREE.MeshBasicMaterial({ color: 0x6d67bd, side: THREE.DoubleSide, polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -10 }); var segments = 32; var Arc = /*#__PURE__*/ function (_BaseGraphics) { _inheritsLoose(Arc, _BaseGraphics); function Arc() { var _this; _this = _BaseGraphics.call(this) || this; var materialClone = material.clone(); _this.localMesh = new THREE.Mesh(new RingGeometry(segments), materialClone); _this.localMesh.type = 'SketcherMesh'; _this.localMesh.material.meta = {}; _this.localMesh.material.meta.material = setMaterialMeta(material); _this.add(_this.localMesh); return _this; } var _proto = Arc.prototype; _proto.updateWithAngles = function updateWithAngles(center, radius, startAngle, endAngle, scale) { this.localMesh.geometry.updateParameters({ innerRadius: radius - scale * 0.5, outerRadius: radius + scale * 0.5, thetaStart: startAngle, thetaLength: endAngle - startAngle }); this.localMesh.position.copy(center); }; _proto.updateFromGeomParams = function updateFromGeomParams(geomParams) { _BaseGraphics.prototype.updateFromGeomParams.call(this, geomParams); var angleParams = getArcAngles(geomParams); var radius = geomParams.radius === undefined ? angleParams.radius : geomParams.radius; this.updateWithAngles(geomParams.center, radius, angleParams.start, angleParams.end, geomParams.scale); this.updateMetaBox(); }; return Arc; }(BaseGraphics); export { Arc as default };