r3-legacy/src/game-lib-d3-api-input-drive.js

110 lines
2.7 KiB
JavaScript
Raw Normal View History

2017-01-02 17:05:40 +01:00
/**
* This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param id String
* @param name String
* @param domElementId
* @param pathFollowingComponent GameLib.D3.Mesh
* @param parentEntity
2017-01-04 16:12:30 +01:00
* @param wheelFL
* @param wheelFR
* @param wheelRL
* @param wheelRR
* @param heightOffset
* @param distance
* @param distanceGrain
2017-01-02 17:05:40 +01:00
* @constructor
*/
GameLib.D3.API.Input.Drive = function (
id,
name,
domElementId,
pathFollowingComponent,
2017-01-04 16:12:30 +01:00
parentEntity,
wheelFL,
wheelFR,
wheelRL,
wheelRR,
heightOffset,
distance,
distanceGrain,
rotationFactor
2017-01-02 17:05:40 +01:00
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_INPUT_DRIVE,
{
2017-01-04 16:12:30 +01:00
'pathFollowingComponent' : GameLib.D3.PathFollowing,
'wheelFL' : GameLib.D3.Mesh,
'wheelFR' : GameLib.D3.Mesh,
'wheelRL' : GameLib.D3.Mesh,
'wheelRR' : GameLib.D3.Mesh
2017-01-02 17:05:40 +01:00
},
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = this.constructor.name;
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
domElementId = "divCanvas";
}
this.domElementId = domElementId;
if (GameLib.Utils.UndefinedOrNull(pathFollowingComponent)) {
pathFollowingComponent = null;
}
this.pathFollowingComponent = pathFollowingComponent;
2017-01-04 16:12:30 +01:00
if (GameLib.Utils.UndefinedOrNull(wheelFL)) {
wheelFL = null;
}
this.wheelFL = wheelFL;
if (GameLib.Utils.UndefinedOrNull(wheelFR)) {
wheelFR = null;
}
this.wheelFR = wheelFR;
if (GameLib.Utils.UndefinedOrNull(wheelRL)) {
wheelRL = null;
}
this.wheelRL = wheelRL;
if (GameLib.Utils.UndefinedOrNull(wheelRR)) {
wheelRR = null;
}
this.wheelRR = wheelRR;
if (GameLib.Utils.UndefinedOrNull(heightOffset)) {
heightOffset = 0;
}
this.heightOffset = heightOffset;
if (GameLib.Utils.UndefinedOrNull(distance)) {
distance = 0;
}
this.distance = distance;
if (GameLib.Utils.UndefinedOrNull(distanceGrain)) {
distanceGrain = 0.1;
}
this.distanceGrain = distanceGrain;
if (GameLib.Utils.UndefinedOrNull(rotationFactor)) {
rotationFactor = 0.1;
}
this.rotationFactor = rotationFactor;
2017-01-02 17:05:40 +01:00
};
GameLib.D3.API.Input.Drive.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Input.Drive.prototype.constructor = GameLib.D3.API.Input.Drive;