2018-04-09 09:35:04 +02:00
|
|
|
/**
|
|
|
|
* API Spline
|
|
|
|
* @param id String
|
|
|
|
* @param name String
|
|
|
|
* @param vertices R3.API.Vector3[]
|
2019-07-24 08:08:02 +02:00
|
|
|
* @param parent
|
2018-04-09 09:35:04 +02:00
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
R3.D3.API.Spline = function(
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
vertices,
|
2019-07-24 08:08:02 +02:00
|
|
|
parent
|
2018-04-09 09:35:04 +02:00
|
|
|
) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = R3.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (R3.Utils.UndefinedOrNull(name)) {
|
|
|
|
name = 'Spline (' + this.id + ')';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
|
|
|
if (R3.Utils.UndefinedOrNull(vertices)) {
|
|
|
|
vertices = [];
|
|
|
|
}
|
|
|
|
this.vertices = vertices;
|
|
|
|
|
|
|
|
R3.API.Component.call(
|
|
|
|
this,
|
|
|
|
R3.Component.SPLINE,
|
2019-07-24 08:08:02 +02:00
|
|
|
parent
|
2018-04-09 09:35:04 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
R3.D3.API.Spline.prototype = Object.create(R3.API.Component.prototype);
|
|
|
|
R3.D3.API.Spline.prototype.constructor = R3.D3.API.Spline;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to R3.D3.API.Spline
|
|
|
|
* @param objectComponent
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
R3.D3.API.Spline.FromObject = function(objectComponent) {
|
|
|
|
return new R3.D3.API.Spline(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
|
|
|
objectComponent.vertices.map(
|
2019-07-24 08:08:02 +02:00
|
|
|
function(objectVertex) {
|
2018-04-09 09:35:04 +02:00
|
|
|
return R3.API.Vector3.FromObject(objectVertex);
|
|
|
|
}
|
|
|
|
),
|
2019-07-24 08:08:02 +02:00
|
|
|
objectComponent.parent
|
2018-04-09 09:35:04 +02:00
|
|
|
);
|
|
|
|
};
|