r3-legacy/src/game-lib-raycast-wheel.js

205 lines
5.5 KiB
JavaScript
Raw Normal View History

2016-10-28 11:47:50 +02:00
GameLib.D3.RaycastWheel = function(
engine,
chassisConnectionPointLocal,
chassisConnectionPointWorld,
directionLocal,
directionWorld,
axleLocal,
axleWorld,
suspensionRestLength,
suspensionMaxLength,
radius,
suspensionStiffness,
dampingCompression,
dampingRelaxation,
frictionSlip,
steering,
rotation,
deltaRotation,
rollInfluence,
maxSuspensionForce,
isFrontWheel,
clippedInvContactDotSuspension,
suspensionRelativeVelocity,
suspensionForce,
skidInfo,
suspensionLength,
maxSuspensionTravel,
useCustomSlidingRotationalSpeed,
customSlidingRotationalSpeed
) {
this.engine = engine;
this.engine.isNotCannonThrow();
if(typeof chassisConnectionPointLocal == 'undefined') {
chassisConnectionPointLocal = new this.engine.instance.Vec3();
}
this.chassisConnectionPointLocal = chassisConnectionPointLocal;
if(typeof chassisConnectionPointWorld == 'undefined') {
chassisConnectionPointWorld = new this.engine.instance.Vec3();
}
this.chassisConnectionPointWorld = chassisConnectionPointWorld;
if(typeof directionLocal == 'undefined') {
directionLocal = new this.engine.instance.Vec3();
}
this.directionLocal = directionLocal;
if(typeof directionWorld == 'undefined') {
directionWorld = new this.engine.instance.Vec3();
}
this.directionWorld = directionWorld;
if(typeof axleLocal == 'undefined') {
axleLocal = new this.engine.instance.Vec3();
}
this.axleLocal = axleLocal;
if(typeof axleWorld == 'undefined') {
axleWorld = new this.engine.instance.Vec3();
}
this.axleWorld = axleWorld;
if(typeof suspensionRestLength == 'undefined') {
suspensionRestLength = 1;
}
this.suspensionRestLength = suspensionRestLength;
if(typeof suspensionMaxLength == 'undefined') {
suspensionMaxLength = 2;
}
this.suspensionMaxLength = suspensionMaxLength;
if(typeof radius == 'undefined') {
radius = 1;
}
this.radius = radius;
if(typeof suspensionStiffness == 'undefined') {
suspensionStiffness = 100;
}
this.suspensionStiffness = suspensionStiffness;
if(typeof dampingCompression == 'undefined') {
dampingCompression = 10;
}
this.dampingCompression = dampingCompression;
if(typeof dampingRelaxation == 'undefined') {
dampingRelaxation = 10;
}
this.dampingRelaxation = dampingRelaxation;
if(typeof frictionSlip == 'undefined') {
frictionSlip = 10000;
}
this.frictionSlip = frictionSlip;
if(typeof steering == 'undefined') {
steering = 0;
}
this.steering = steering;
if(typeof rotation == 'undefined') {
rotation = 0;
}
this.rotation = rotation;
if(typeof deltaRotation == 'undefined') {
deltaRotation = 0;
}
this.deltaRotation = deltaRotation;
if(typeof rollInfluence == 'undefined') {
rollInfluence = 0.01;
}
this.rollInfluence = rollInfluence;
if(typeof maxSuspensionForce == 'undefined') {
maxSuspensionForce = Number.MAX_VALUE;
}
this.maxSuspensionForce = maxSuspensionForce;
if(typeof isFrontWheel == 'undefined') {
isFrontWheel = true;
}
this.isFrontWheel = isFrontWheel;
if(typeof clippedInvContactDotSuspension == 'undefined') {
clippedInvContactDotSuspension = 1;
}
this.clippedInvContactDotSuspension = clippedInvContactDotSuspension;
if(typeof suspensionRelativeVelocity == 'undefined') {
suspensionRelativeVelocity = 0;
}
this.suspensionRelativeVelocity = suspensionRelativeVelocity;
if(typeof suspensionForce == 'undefined') {
suspensionForce = 0;
}
this.suspensionForce = suspensionForce;
if(typeof skidInfo == 'undefined') {
skidInfo = 0;
}
this.skidInfo = skidInfo;
if(typeof suspensionLength == 'undefined') {
suspensionLength = 0;
}
this.suspensionLength = suspensionLength;
if(typeof maxSuspensionTravel == 'undefined') {
maxSuspensionTravel = 1;
}
this.maxSuspensionTravel = maxSuspensionTravel;
if(typeof useCustomSlidingRotationalSpeed == 'undefined') {
useCustomSlidingRotationalSpeed = false;
}
this.useCustomSlidingRotationalSpeed = useCustomSlidingRotationalSpeed;
if(typeof customSlidingRotationalSpeed == 'undefined') {
customSlidingRotationalSpeed = -0.1;
}
this.customSlidingRotationalSpeed = customSlidingRotationalSpeed;
this.instance = this.createInstance();
};
GameLib.D3.RaycastWheel.prototype.createInstance = function() {
return new this.engine.instance.WheelInfo({
chassisConnectionPointLocal : this.chassisConnectionPointLocal,
chassisConnectionPointWorld : this.chassisConnectionPointWorld,
directionLocal : this.directionLocal,
directionWorld : this.directionWorld,
axleLocal : this.axleLocal,
axleWorld : this.axleWorld,
suspensionRestLength : this.suspensionRestLength,
suspensionMaxLength : this.suspensionMaxLength,
radius : this.radius,
suspensionStiffness : this.suspensionStiffness,
dampingCompression : this.dampingCompression,
dampingRelaxation : this.dampingRelaxation,
frictionSlip : this.frictionSlip,
steering : this.steering,
rotation : this.rotation,
deltaRotation : this.deltaRotation,
rollInfluence : this.rollInfluence,
maxSuspensionForce : this.maxSuspensionForce,
isFrontWheel : this.isFrontWheel,
clippedInvContactDotSuspension : this.clippedInvContactDotSuspension,
suspensionRelativeVelocity : this.suspensionRelativeVelocity,
suspensionForce : this.suspensionForce,
skidInfo : this.skidInfo,
suspensionLength : this.suspensionLength,
maxSuspensionTravel : this.maxSuspensionTravel,
useCustomSlidingRotationalSpeed : this.useCustomSlidingRotationalSpeed,
customSlidingRotationalSpeed : this.customSlidingRotationalSpeed
});
2016-10-28 11:47:50 +02:00
};