90 lines
2.1 KiB
JavaScript
90 lines
2.1 KiB
JavaScript
/**
|
|
* R3.API.Curve
|
|
* @param id
|
|
* @param name
|
|
* @param curveType
|
|
* @param parentEntity
|
|
* @param arcLenghDivisions
|
|
* @constructor
|
|
*/
|
|
R3.API.Curve = function (
|
|
id,
|
|
name,
|
|
curveType,
|
|
parentEntity,
|
|
arcLenghDivisions
|
|
) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(id)) {
|
|
id = R3.Utils.RandomId();
|
|
}
|
|
this.id = id;
|
|
|
|
if (R3.Utils.UndefinedOrNull(curveType)) {
|
|
curveType = R3.API.Curve.CURVE_TYPE_NONE;
|
|
}
|
|
this.curveType = curveType;
|
|
|
|
if (R3.Utils.UndefinedOrNull(name)) {
|
|
|
|
switch (this.curveType) {
|
|
case R3.API.Curve.CURVE_TYPE_NONE :
|
|
name = 'Curve';
|
|
break;
|
|
case R3.API.Curve.CURVE_TYPE_PATH :
|
|
name = 'Curve Path';
|
|
break;
|
|
default:
|
|
console.log('no nice name for curve');
|
|
}
|
|
|
|
name += ' (' + this.id + ')';
|
|
}
|
|
this.name = name;
|
|
|
|
if (R3.Utils.UndefinedOrNull(arcLenghDivisions)) {
|
|
arcLenghDivisions = 200;
|
|
}
|
|
this.arcLenghDivisions = arcLenghDivisions;
|
|
|
|
R3.API.Component.call(
|
|
this,
|
|
R3.API.Curve.GetComponentType(this.curveType),
|
|
parentEntity
|
|
);
|
|
};
|
|
|
|
R3.API.Curve.prototype = Object.create(R3.API.Curve.prototype);
|
|
R3.API.Curve.prototype.constructor = R3.API.Curve;
|
|
|
|
R3.API.Curve.GetComponentType = function(curveType) {
|
|
|
|
var componentType = null;
|
|
|
|
switch (curveType) {
|
|
case R3.API.Curve.CURVE_TYPE_NONE :
|
|
componentType = R3.Component.CURVE;
|
|
break;
|
|
case R3.API.Curve.CURVE_TYPE_PATH :
|
|
componentType = R3.Component.CURVE_PATH;
|
|
break;
|
|
case R3.API.Curve.CURVE_TYPE_PATH_2D :
|
|
componentType = R3.Component.CURVE_PATH_D2;
|
|
break;
|
|
case R3.API.Curve.CURVE_TYPE_PATH_2D_SHAPE :
|
|
componentType = R3.Component.CURVE_PATH_D2_SHAPE;
|
|
break;
|
|
default :
|
|
throw new Error('unhandled curve type');
|
|
}
|
|
|
|
return componentType;
|
|
};
|
|
|
|
R3.API.Curve.CURVE_TYPE_NONE = 0x0;
|
|
R3.API.Curve.CURVE_TYPE_PATH = 0x1;
|
|
R3.API.Curve.CURVE_TYPE_PATH_2D = 0x2;
|
|
R3.API.Curve.CURVE_TYPE_PATH_2D_SHAPE = 0x3;
|
|
|
|
|