awv3
Version:
⚡ AWV3 embedded CAD
51 lines (41 loc) • 1.75 kB
JavaScript
import * as ConstraintType from '../constraint/type';
import Point from './point';
import Line from './line';
import Arc from './arc';
import Circle from './circle';
import Sketch from './sketch';
import Constraint from './constraint';
import BaseGraphics from './base';
export function Graphics(name) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
switch (name) {
case 'CC_Point':
return new (Function.prototype.bind.apply(Point, [null].concat(args)))();
case 'CC_Line':
return new (Function.prototype.bind.apply(Line, [null].concat(args)))();
case 'CC_Arc':
return new (Function.prototype.bind.apply(Arc, [null].concat(args)))();
case 'CC_Circle':
return new (Function.prototype.bind.apply(Circle, [null].concat(args)))();
case 'CC_Sketch':
return new (Function.prototype.bind.apply(Sketch, [null].concat(args)))();
case 'CC_Container':
return new (Function.prototype.bind.apply(BaseGraphics, [null].concat(args)))();
}
if (name.endsWith('Constraint')) if (!Object.values(ConstraintType).find(function (ct) {
return ct.type === name;
}).isParametric) return new Constraint();
}
export function setMaterialMeta(material) {
//TODO: take from session.globals.selection["SketcherMesh"] ?
var selectProps = ["color", "opacity", "polygonOffsetFactor", "polygonOffsetUnits"];
var res = {};
for (var _i = 0; _i < selectProps.length; _i++) {
var prop = selectProps[_i];
res[prop] = material[prop];
}
return res;
} // Support hot reloading
if (module.hot) module.hot.accept(['./point', './line', './arc', './circle', './sketch', './constraint']);