wheel updates

beta.r3js.org
Theunis J. Botha 2016-10-28 13:31:21 +02:00
parent 5075d50d6d
commit 5b3e5afd0c
3 changed files with 55 additions and 38 deletions

View File

@ -1,7 +1,7 @@
/**
*
* @param engine GamLib.D3.Engine
* @param chassisBody GamLib.D3.RigidBody
* Raycast Vehicles :)
* @param engine GameLib.D3.Engine
* @param chassisBody GameLib.D3.RigidBody
* @param wheels GameLib.D3.RaycastWheel[]
* @constructor
*/
@ -42,4 +42,13 @@ GameLib.D3.RaycastVehicle.prototype.addWheel = function (
) {
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
};
/**
* Returns updated wheel info
* @returns {*}
* @constructor
*/
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelInfos;
};

View File

@ -1,8 +1,8 @@
/**
* Physics Rigid Body Vehicle Superset
* @param engine
* @param chassisBody
* @param wheels
* @param engine GameLib.D3.Engine
* @param chassisBody GameLib.D3.RigidBody
* @param wheels GameLib.D3.RigidWheel[]
* @constructor
*/
GameLib.D3.RigidBodyVehicle = function(
@ -23,6 +23,14 @@ GameLib.D3.RigidBodyVehicle = function(
this.instance = this.createInstance();
};
/**
* Returns physics wheelbody info (for updates)
* @returns {Array}
*/
GameLib.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelBodies;
};
/**
*
* @returns {GameLib.D3.RigidVehicle}
@ -35,14 +43,29 @@ GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
/**
* Adds a wheel to this rigid body vehicle
* @constructor
*/
/**
*
* @param wheel
* @param wheel GameLib.D3.RigidWheel
*/
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
this.instance.addWheel({
body: wheel.body.instance,
position: new this.engine.instance.Vec3(
wheel.position.x,
wheel.position.y,
wheel.position.z
),
axis: new this.engine.instance.Vec3(
wheel.axis.x,
wheel.axis.y,
wheel.axis.z
),
direction: new this.engine.instance.Vec3(
wheel.direction.x,
wheel.direction.y,
wheel.direction.z
)
});
};

View File

@ -1,34 +1,19 @@
/**
* Rigid Wheel superset
* @param body GameLib.D3.RigidBody
* @param position GameLib.D3.Vector3
* @param axis GameLib.D3.Vector3
* @param direction GameLib.D3.Vector3
* @constructor
*/
GameLib.D3.RigidWheel = function(
engine,
body,
position,
axis,
direction
) {
this.engine = engine;
this.body = body;
this.position = position;
this.axis = axis;
this.direction = direction;
this.instance = this.createInstance();
};
GameLib.D3.RigidWheel.prototype.createInstance = function(
//
// body: rigidBody.instance,
// position: new this.engine.instance.Vec3(
// position.x,
// position.y,
// position.z
// ),
// axis: new this.engine.instance.Vec3(
// axis.x,
// axis.y,
// axis.z
// ),
// direction: new this.engine.instance.Vec3(
// direction.x,
// direction.y,
// direction.z
// )
);