wheel updates
parent
5075d50d6d
commit
5b3e5afd0c
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
* Raycast Vehicles :)
|
||||||
* @param engine GamLib.D3.Engine
|
* @param engine GameLib.D3.Engine
|
||||||
* @param chassisBody GamLib.D3.RigidBody
|
* @param chassisBody GameLib.D3.RigidBody
|
||||||
* @param wheels GameLib.D3.RaycastWheel[]
|
* @param wheels GameLib.D3.RaycastWheel[]
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -42,4 +42,13 @@ GameLib.D3.RaycastVehicle.prototype.addWheel = function (
|
||||||
) {
|
) {
|
||||||
this.wheels.push(wheel);
|
this.wheels.push(wheel);
|
||||||
this.instance.addWheel(wheel.instance);
|
this.instance.addWheel(wheel.instance);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns updated wheel info
|
||||||
|
* @returns {*}
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() {
|
||||||
|
return this.instance.wheelInfos;
|
||||||
};
|
};
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Physics Rigid Body Vehicle Superset
|
* Physics Rigid Body Vehicle Superset
|
||||||
* @param engine
|
* @param engine GameLib.D3.Engine
|
||||||
* @param chassisBody
|
* @param chassisBody GameLib.D3.RigidBody
|
||||||
* @param wheels
|
* @param wheels GameLib.D3.RigidWheel[]
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.RigidBodyVehicle = function(
|
GameLib.D3.RigidBodyVehicle = function(
|
||||||
|
@ -23,6 +23,14 @@ GameLib.D3.RigidBodyVehicle = function(
|
||||||
this.instance = this.createInstance();
|
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}
|
* @returns {GameLib.D3.RigidVehicle}
|
||||||
|
@ -35,14 +43,29 @@ GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a wheel to this rigid body vehicle
|
* Adds a wheel to this rigid body vehicle
|
||||||
|
* @param wheel GameLib.D3.RigidWheel
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param wheel
|
|
||||||
*/
|
*/
|
||||||
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
|
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
|
||||||
|
|
||||||
this.wheels.push(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
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -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(
|
GameLib.D3.RigidWheel = function(
|
||||||
engine,
|
body,
|
||||||
position,
|
position,
|
||||||
axis,
|
axis,
|
||||||
direction
|
direction
|
||||||
) {
|
) {
|
||||||
this.engine = engine;
|
this.body = body;
|
||||||
|
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.axis = axis;
|
this.axis = axis;
|
||||||
this.direction = direction;
|
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
|
|
||||||
// )
|
|
||||||
);
|
|
Loading…
Reference in New Issue