r3-legacy/bak/r3-d3-api-input-drive.js

126 lines
3.0 KiB
JavaScript
Raw Permalink 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
2018-04-09 10:05:13 +02:00
* @param pathFollowingComponent R3.D3.Mesh
2017-01-02 17:05:40 +01:00
* @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-06 16:53:53 +01:00
* @param rotationFactor
2017-01-02 17:05:40 +01:00
* @constructor
*/
2018-04-09 10:05:13 +02:00
R3.D3.API.Input.Drive = function (
2017-01-02 17:05:40 +01:00
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
) {
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
2017-01-02 17:05:40 +01:00
}
this.id = id;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(name)) {
2017-01-12 17:40:17 +01:00
name = 'Input.Drive (' + this.id + ')';
2017-01-02 17:05:40 +01:00
}
this.name = name;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(domElementId)) {
2017-01-02 17:05:40 +01:00
domElementId = "divCanvas";
}
this.domElementId = domElementId;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(pathFollowingComponent)) {
2017-01-02 17:05:40 +01:00
pathFollowingComponent = null;
}
this.pathFollowingComponent = pathFollowingComponent;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(parentEntity)) {
2017-06-16 15:49:53 +02:00
parentEntity = null;
}
this.parentEntity = parentEntity;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(wheelFL)) {
2017-01-04 16:12:30 +01:00
wheelFL = null;
}
this.wheelFL = wheelFL;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(wheelFR)) {
2017-01-04 16:12:30 +01:00
wheelFR = null;
}
this.wheelFR = wheelFR;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(wheelRL)) {
2017-01-04 16:12:30 +01:00
wheelRL = null;
}
this.wheelRL = wheelRL;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(wheelRR)) {
2017-01-04 16:12:30 +01:00
wheelRR = null;
}
this.wheelRR = wheelRR;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(heightOffset)) {
2017-01-04 16:12:30 +01:00
heightOffset = 0;
}
this.heightOffset = heightOffset;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(distance)) {
2017-01-04 16:12:30 +01:00
distance = 0;
}
this.distance = distance;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(distanceGrain)) {
2017-01-04 16:12:30 +01:00
distanceGrain = 0.1;
}
this.distanceGrain = distanceGrain;
2018-04-09 10:05:13 +02:00
if (R3.Utils.UndefinedOrNull(rotationFactor)) {
2017-01-04 16:12:30 +01:00
rotationFactor = 0.1;
}
this.rotationFactor = rotationFactor;
2017-01-02 17:05:40 +01:00
};
2018-04-09 10:05:13 +02:00
R3.D3.API.Input.Drive.prototype = Object.create(R3.Component.prototype);
R3.D3.API.Input.Drive.prototype.constructor = R3.D3.API.Input.Drive;
2017-01-06 16:53:53 +01:00
/**
2018-04-09 10:05:13 +02:00
* Object to R3.D3.API.Input.Drive
2017-01-06 16:53:53 +01:00
* @param objectComponent
2018-04-09 10:05:13 +02:00
* @returns {R3.D3.API.Input.Drive}
2017-01-06 16:53:53 +01:00
* @constructor
*/
2018-04-09 10:05:13 +02:00
R3.D3.API.Input.Drive.FromObject = function(objectComponent) {
return new R3.D3.API.Input.Drive(
2017-01-06 16:53:53 +01:00
objectComponent.id,
objectComponent.name,
objectComponent.domElementId,
objectComponent.pathFollowingComponent,
objectComponent.parentEntity,
objectComponent.wheelFL,
objectComponent.wheelFR,
objectComponent.wheelRL,
objectComponent.wheelRR,
objectComponent.heightOffset,
objectComponent.distance,
objectComponent.distanceGrain,
objectComponent.rotationFactor
);
};