A helper class for creating realistic simulation of vehicles and suspensions.
VehicleHelper | A helper class for creating realistic simulation of vehicles and suspensions. |
Constructor | |
Preference Dialog | None. |
Comments | Here is a sample use of the VehicleHelper. |
Functions | |
addWheel | |
setCoordinateSystem | |
setSteering | |
setBrake | |
applyEngineForce | |
delete |
VehicleHelper( molecule, tuning )
molecule | (object) the mesh molecule of the chasis. |
tuning | (object) properties of vehicle’s suspensions: |
Here is a sample use of the VehicleHelper.
this.car = new VehicleHelper(this.r8, { suspension_stiffness: 10.88, suspension_compression: 1.83, suspension_damping: 0.28, max_suspension_travel: 500, friction_slip: 10.5, max_suspension_force: 6000});
// determine the connection point of each wheel var dir = this.car.worldPosition.sub(ws[0].worldPosition); var offsetfz = Math.abs(dir.z); var offsetx = Math.abs(dir.x); dir = this.r8.worldPosition.sub(ws[3].worldPosition); var offsetrz = -Math.abs(dir.z); var offsety = -dir.y;
var radius = ws[0].size.y * 0.42; for (var i=0; i<4; i++) { this.car.addWheel( ws[i], newVector3( i%2===0? offsetx : -offsetx, offsety, i<2? offsetfz : offsetrz), newVector3( 0, -1, 0), newVector3( -1, 0, 0), 0.5, radius, i<2?true: false); }
addWheel(molecule, connection_point, wheel_direction, wheel_axle, suspension_rest_length, wheel_radius, is_front_wheel, tuning );
Destroy this joint.
molecule | (object) the mesh molecule of the wheel. |
connection_point | (vector3) point where wheel is connected to the chasis in the chasis’s coordinate space. |
wheel_direction | (vector3) the direction where wheels are pointing away from the chasis. Normally (0, -1, 0). |
wheel_axle | (vector3) the direction of wheels’ rotational axis. For z-forward vehicle, this is (-1, 0, 0). |
suspension_rest_length | (float) the length of suspension during rest. |
wheel_radis | (float) the radius of wheel. |
is_front_wheel | (bool) the wheel to be added is in front. |
tuning | (object) suspension tuning for individual wheel. default to the vehicle’s setting. |
N/A
setCoordinateSystem( rightIndex, upIndex, forwardIndex );
Determine the vehicle’s orientation. For z-forward, y-up vehicle, this is (0, 1, 2).
rightIndex | (int) axis index. (0 for x-axis, 1 for y-axis, 2 for z-axis). |
upIndex | (int) axis index. |
forwardIndex | (int) axis index. |
N/A