r3-legacy/bak/r3-d3-raycast-wheel.js

202 lines
6.2 KiB
JavaScript

R3.D3.RaycastWheel = function(
engine,
chassisConnectionPointLocal,
chassisConnectionPointWorld,
directionLocal,
directionWorld,
axleLocal,
axleWorld,
suspensionRestLength,
suspensionMaxLength,
radius,
suspensionStiffness,
dampingCompression,
dampingRelaxation,
frictionSlip,
steering,
rotation,
deltaRotation,
rollInfluence,
maxSuspensionForce,
clippedInvContactDotSuspension,
suspensionRelativeVelocity,
suspensionForce,
skidInfo,
suspensionLength,
maxSuspensionTravel,
useCustomSlidingRotationalSpeed,
customSlidingRotationalSpeed
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.id = R3.Utils.RandomId();
if(typeof chassisConnectionPointLocal == 'undefined' || chassisConnectionPointLocal == null) {
chassisConnectionPointLocal = new this.engine.instance.Vec3();
}
this.chassisConnectionPointLocal = chassisConnectionPointLocal;
if(typeof chassisConnectionPointWorld == 'undefined' || chassisConnectionPointWorld == null) {
chassisConnectionPointWorld = new this.engine.instance.Vec3();
}
this.chassisConnectionPointWorld = chassisConnectionPointWorld;
if(typeof directionLocal == 'undefined' || directionLocal == null) {
directionLocal = new this.engine.instance.Vec3();
}
this.directionLocal = directionLocal;
if(typeof directionWorld == 'undefined' || directionWorld == null) {
directionWorld = new this.engine.instance.Vec3();
}
this.directionWorld = directionWorld;
if(typeof axleLocal == 'undefined' || axleLocal == null) {
axleLocal = new this.engine.instance.Vec3();
}
this.axleLocal = axleLocal;
if(typeof axleWorld == 'undefined' || axleWorld == null) {
axleWorld = new this.engine.instance.Vec3();
}
this.axleWorld = axleWorld;
if(typeof suspensionRestLength == 'undefined' || suspensionRestLength == null) {
suspensionRestLength = 1;
}
this.suspensionRestLength = suspensionRestLength;
if(typeof suspensionMaxLength == 'undefined' || suspensionMaxLength == null) {
suspensionMaxLength = 2;
}
this.suspensionMaxLength = suspensionMaxLength;
if(typeof radius == 'undefined' || radius == null) {
radius = 1;
}
this.radius = radius;
if(typeof suspensionStiffness == 'undefined' || suspensionStiffness == null) {
suspensionStiffness = 100;
}
this.suspensionStiffness = suspensionStiffness;
if(typeof dampingCompression == 'undefined' || dampingCompression == null) {
dampingCompression = 10;
}
this.dampingCompression = dampingCompression;
if(typeof dampingRelaxation == 'undefined' || dampingRelaxation == null) {
dampingRelaxation = 10;
}
this.dampingRelaxation = dampingRelaxation;
if(typeof frictionSlip == 'undefined' || frictionSlip == null) {
frictionSlip = 10000;
}
this.frictionSlip = frictionSlip;
if(typeof steering == 'undefined' || steering == null) {
steering = 0;
}
this.steering = steering;
if(typeof rotation == 'undefined' || rotation == null) {
rotation = 0;
}
this.rotation = rotation;
if(typeof deltaRotation == 'undefined' || deltaRotation == null) {
deltaRotation = 0;
}
this.deltaRotation = deltaRotation;
if(typeof rollInfluence == 'undefined' || rollInfluence == null) {
rollInfluence = 0.01;
}
this.rollInfluence = rollInfluence;
if(typeof maxSuspensionForce == 'undefined' || maxSuspensionForce == null) {
maxSuspensionForce = Number.MAX_VALUE;
}
this.maxSuspensionForce = maxSuspensionForce;
if(typeof clippedInvContactDotSuspension == 'undefined' || clippedInvContactDotSuspension == null) {
clippedInvContactDotSuspension = 1;
}
this.clippedInvContactDotSuspension = clippedInvContactDotSuspension;
if(typeof suspensionRelativeVelocity == 'undefined' || suspensionRelativeVelocity == null) {
suspensionRelativeVelocity = 0;
}
this.suspensionRelativeVelocity = suspensionRelativeVelocity;
if(typeof suspensionForce == 'undefined' || suspensionForce == null) {
suspensionForce = 0;
}
this.suspensionForce = suspensionForce;
if(typeof skidInfo == 'undefined' || skidInfo == null) {
skidInfo = 0;
}
this.skidInfo = skidInfo;
if(typeof suspensionLength == 'undefined' || suspensionLength == null) {
suspensionLength = 0;
}
this.suspensionLength = suspensionLength;
if(typeof maxSuspensionTravel == 'undefined' || maxSuspensionTravel == null) {
maxSuspensionTravel = 1;
}
this.maxSuspensionTravel = maxSuspensionTravel;
if(typeof useCustomSlidingRotationalSpeed == 'undefined' || useCustomSlidingRotationalSpeed == null) {
useCustomSlidingRotationalSpeed = false;
}
this.useCustomSlidingRotationalSpeed = useCustomSlidingRotationalSpeed;
if(typeof customSlidingRotationalSpeed == 'undefined' || customSlidingRotationalSpeed == null) {
customSlidingRotationalSpeed = -0.1;
}
this.customSlidingRotationalSpeed = customSlidingRotationalSpeed;
this.instance = this.createInstance();
// this gets assigned at runtime, when the wheel gets added to a vehicle
this.wheelIndex = -1;
};
R3.D3.RaycastWheel.prototype.createInstance = function() {
return {
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,
clippedInvContactDotSuspension : this.clippedInvContactDotSuspension,
suspensionRelativeVelocity : this.suspensionRelativeVelocity,
suspensionForce : this.suspensionForce,
skidInfo : this.skidInfo,
suspensionLength : this.suspensionLength,
maxSuspensionTravel : this.maxSuspensionTravel,
useCustomSlidingRotationalSpeed : this.useCustomSlidingRotationalSpeed,
customSlidingRotationalSpeed : this.customSlidingRotationalSpeed
};
};