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

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-11-29 12:54:25 +01:00
/**
* API Spline
* @param id String
* @param name String
2016-12-23 16:07:10 +01:00
* @param vertices GameLib.API.Vector3[]
2017-01-02 17:05:40 +01:00
* @param parentEntity
2016-11-29 12:54:25 +01:00
* @constructor
*/
GameLib.D3.API.Spline = function(
id,
name,
2017-01-02 17:05:40 +01:00
vertices,
parentEntity
2016-11-29 12:54:25 +01:00
) {
2016-12-22 17:22:19 +01:00
GameLib.Component.call(
this,
2017-01-02 17:05:40 +01:00
GameLib.Component.COMPONENT_SPLINE,
null,
parentEntity
2016-12-22 17:22:19 +01:00
);
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
2016-11-29 12:54:25 +01:00
}
this.id = id;
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Spline (unknown)';
2016-11-29 12:54:25 +01:00
}
this.name = name;
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(vertices)) {
2016-11-29 12:54:25 +01:00
vertices = [];
}
this.vertices = vertices;
2016-12-22 17:22:19 +01:00
};
GameLib.D3.API.Spline.prototype = Object.create(GameLib.Component.prototype);
2017-01-06 16:53:53 +01:00
GameLib.D3.API.Spline.prototype.constructor = GameLib.D3.API.Spline;
/**
* Object to GameLib.D3.API.Spline
* @param objectComponent
* @constructor
*/
GameLib.D3.API.Spline.FromObjectComponent = function(objectComponent) {
return new GameLib.D3.API.Spline(
objectComponent.id,
objectComponent.name,
objectComponent.vertices.map(
function (objectVertex) {
return GameLib.API.Vector3.FromObjectVector(objectVertex);
}
),
objectComponent.parentEntity
);
};