126 lines
3.0 KiB
JavaScript
126 lines
3.0 KiB
JavaScript
/**
|
|
* This component makes the parentEntity (ex. car) follow the path provided by the spline
|
|
* @param id String
|
|
* @param name String
|
|
* @param domElementId
|
|
* @param pathFollowingComponent R3.D3.Mesh
|
|
* @param parentEntity
|
|
* @param wheelFL
|
|
* @param wheelFR
|
|
* @param wheelRL
|
|
* @param wheelRR
|
|
* @param heightOffset
|
|
* @param distance
|
|
* @param distanceGrain
|
|
* @param rotationFactor
|
|
* @constructor
|
|
*/
|
|
R3.D3.API.Input.Drive = function (
|
|
id,
|
|
name,
|
|
domElementId,
|
|
pathFollowingComponent,
|
|
parentEntity,
|
|
wheelFL,
|
|
wheelFR,
|
|
wheelRL,
|
|
wheelRR,
|
|
heightOffset,
|
|
distance,
|
|
distanceGrain,
|
|
rotationFactor
|
|
) {
|
|
if (R3.Utils.UndefinedOrNull(id)) {
|
|
id = R3.Utils.RandomId();
|
|
}
|
|
this.id = id;
|
|
|
|
if (R3.Utils.UndefinedOrNull(name)) {
|
|
name = 'Input.Drive (' + this.id + ')';
|
|
}
|
|
this.name = name;
|
|
|
|
if (R3.Utils.UndefinedOrNull(domElementId)) {
|
|
domElementId = "divCanvas";
|
|
}
|
|
this.domElementId = domElementId;
|
|
|
|
if (R3.Utils.UndefinedOrNull(pathFollowingComponent)) {
|
|
pathFollowingComponent = null;
|
|
}
|
|
this.pathFollowingComponent = pathFollowingComponent;
|
|
|
|
if (R3.Utils.UndefinedOrNull(parentEntity)) {
|
|
parentEntity = null;
|
|
}
|
|
this.parentEntity = parentEntity;
|
|
|
|
if (R3.Utils.UndefinedOrNull(wheelFL)) {
|
|
wheelFL = null;
|
|
}
|
|
this.wheelFL = wheelFL;
|
|
|
|
if (R3.Utils.UndefinedOrNull(wheelFR)) {
|
|
wheelFR = null;
|
|
}
|
|
this.wheelFR = wheelFR;
|
|
|
|
if (R3.Utils.UndefinedOrNull(wheelRL)) {
|
|
wheelRL = null;
|
|
}
|
|
this.wheelRL = wheelRL;
|
|
|
|
if (R3.Utils.UndefinedOrNull(wheelRR)) {
|
|
wheelRR = null;
|
|
}
|
|
this.wheelRR = wheelRR;
|
|
|
|
if (R3.Utils.UndefinedOrNull(heightOffset)) {
|
|
heightOffset = 0;
|
|
}
|
|
this.heightOffset = heightOffset;
|
|
|
|
if (R3.Utils.UndefinedOrNull(distance)) {
|
|
distance = 0;
|
|
}
|
|
this.distance = distance;
|
|
|
|
if (R3.Utils.UndefinedOrNull(distanceGrain)) {
|
|
distanceGrain = 0.1;
|
|
}
|
|
this.distanceGrain = distanceGrain;
|
|
|
|
if (R3.Utils.UndefinedOrNull(rotationFactor)) {
|
|
rotationFactor = 0.1;
|
|
}
|
|
this.rotationFactor = rotationFactor;
|
|
|
|
};
|
|
|
|
R3.D3.API.Input.Drive.prototype = Object.create(R3.Component.prototype);
|
|
R3.D3.API.Input.Drive.prototype.constructor = R3.D3.API.Input.Drive;
|
|
|
|
/**
|
|
* Object to R3.D3.API.Input.Drive
|
|
* @param objectComponent
|
|
* @returns {R3.D3.API.Input.Drive}
|
|
* @constructor
|
|
*/
|
|
R3.D3.API.Input.Drive.FromObject = function(objectComponent) {
|
|
return new R3.D3.API.Input.Drive(
|
|
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
|
|
);
|
|
};
|