r3-legacy/src/r3-d3-api-spline.js

57 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-04-09 09:35:04 +02:00
/**
* API Spline
* @param id String
* @param name String
* @param vertices R3.API.Vector3[]
* @param parentEntity
* @constructor
*/
R3.D3.API.Spline = function(
id,
name,
vertices,
parentEntity
) {
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,
parentEntity
);
};
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(
function (objectVertex) {
return R3.API.Vector3.FromObject(objectVertex);
}
),
objectComponent.parentEntity
);
};