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

56 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-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;
2017-06-16 15:49:53 +02:00
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
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
*/
2017-06-14 14:21:57 +02:00
GameLib.D3.API.Spline.FromObject = function(objectComponent) {
2017-01-06 16:53:53 +01:00
return new GameLib.D3.API.Spline(
objectComponent.id,
objectComponent.name,
objectComponent.vertices.map(
function (objectVertex) {
2017-06-14 14:21:57 +02:00
return GameLib.API.Vector3.FromObject(objectVertex);
2017-01-06 16:53:53 +01:00
}
),
objectComponent.parentEntity
);
};