diff --git a/src/game-lib-raycast-vehicle.js b/src/game-lib-raycast-vehicle.js index e748786..ae4c5e7 100644 --- a/src/game-lib-raycast-vehicle.js +++ b/src/game-lib-raycast-vehicle.js @@ -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; }; \ No newline at end of file diff --git a/src/game-lib-rigid-body-vehicle.js b/src/game-lib-rigid-body-vehicle.js index c077408..3eb0ae2 100644 --- a/src/game-lib-rigid-body-vehicle.js +++ b/src/game-lib-rigid-body-vehicle.js @@ -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 + ) + }); + }; diff --git a/src/game-lib-rigid-wheel.js b/src/game-lib-rigid-wheel.js index 423bd7d..068df7f 100644 --- a/src/game-lib-rigid-wheel.js +++ b/src/game-lib-rigid-wheel.js @@ -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 - // ) -); \ No newline at end of file