Merge branch 'next' into feature-triMesh

beta.r3js.org
Theunis J. Botha 2016-10-28 13:12:11 +02:00
commit 5075d50d6d
6 changed files with 187 additions and 166 deletions

File diff suppressed because one or more lines are too long

View File

@ -2426,17 +2426,24 @@ GameLib.D3.PolyVertex.prototype.clone = function() {
*
* @param engine GamLib.D3.Engine
* @param chassisBody GamLib.D3.RigidBody
* @param wheels GameLib.D3.RaycastWheel[]
* @constructor
*/
GameLib.D3.RaycastVehicle = function(
engine,
chassisBody
chassisBody,
wheels
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.chassisBody = chassisBody;
if (typeof wheels == 'undefined') {
wheels = [];
}
this.wheels = wheels;
this.instance = this.createInstance();
};
@ -2445,13 +2452,9 @@ GameLib.D3.RaycastVehicle = function(
* @returns {GameLib.D3.RaycastVehicle|GameLib.D3.Physics.RaycastVehicle|*}
*/
GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
var instance = new this.engine.instance.RaycastVehicle({
return new this.engine.instance.RaycastVehicle({
chassisBody: this.chassisBody.instance
});
this.instance = instance;
return instance;
};
/**
@ -2461,31 +2464,9 @@ GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
GameLib.D3.RaycastVehicle.prototype.addWheel = function (
wheel
) {
var options = {};
for (var property in wheel) {
if (wheel.hasOwnProperty(property)){
if (property == 'engine') {
continue;
}
options[property] = wheel[property];
}
}
this.instance.addWheel(options);
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
};
/**
* Eventually we can wrap wheels
* @returns {*}
* @constructor
*/
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelInfos;
};
GameLib.D3.RaycastWheel = function(
engine,
chassisConnectionPointLocal,
@ -2653,81 +2634,91 @@ GameLib.D3.RaycastWheel = function(
customSlidingRotationalSpeed = -0.1;
}
this.customSlidingRotationalSpeed = customSlidingRotationalSpeed;
this.instance = this.createInstance();
};
GameLib.D3.RaycastWheel.prototype.createInstance = function() {
return new this.engine.instance.WheelInfo({
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,
isFrontWheel : this.isFrontWheel,
clippedInvContactDotSuspension : this.clippedInvContactDotSuspension,
suspensionRelativeVelocity : this.suspensionRelativeVelocity,
suspensionForce : this.suspensionForce,
skidInfo : this.skidInfo,
suspensionLength : this.suspensionLength,
maxSuspensionTravel : this.maxSuspensionTravel,
useCustomSlidingRotationalSpeed : this.useCustomSlidingRotationalSpeed,
customSlidingRotationalSpeed : this.customSlidingRotationalSpeed
});
};
/**
* Physics Rigid Body Vehicle Superset
* TODO: body + wheels[]
* @param engine
* @param chassisBody
* @param wheels
* @constructor
*/
GameLib.D3.RigidBodyVehicle = function(
engine
engine,
chassisBody,
wheels
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.instance = null;
this.chassisBody = chassisBody;
if (typeof wheels == 'undefined') {
wheels = [];
}
this.wheels = wheels;
this.instance = this.createInstance();
};
/**
*
* @returns {*}
* @returns {GameLib.D3.RigidVehicle}
*/
GameLib.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelBodies;
};
/**
*
* @param chassisBody
* @returns {GameLib.D3.RigidVehicle|GameLib.D3.Physics.RigidVehicle}
*/
GameLib.D3.RigidBodyVehicle.prototype.createInstance = function(
chassisBody // Physics.RigidBody
) {
var vehicle = new this.engine.instance.RigidVehicle({
chassisBody: chassisBody.bodyObject
GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
return new this.engine.instance.RigidVehicle({
chassisBody: this.chassisBody.instance
});
this.instance = vehicle;
return vehicle;
};
/**
* Adds a wheel to this rigid body vehicle
* @param rigidBody GameLib.D3.RigidBody
* @param position
* @param axis
* @param direction
* @constructor
*/
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(
rigidBody,
position,
axis,
direction
) {
this.instance.addWheel({
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
)
});
/**
*
* @param wheel
*/
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
};
/**
@ -2877,6 +2868,10 @@ GameLib.D3.RigidBody.prototype.addShape = function(
/**
* Created by tj on 28.10.16.
*/
/**
* Scenes are objects putting meshes into 'world space'
* @param id

View File

@ -2,17 +2,24 @@
*
* @param engine GamLib.D3.Engine
* @param chassisBody GamLib.D3.RigidBody
* @param wheels GameLib.D3.RaycastWheel[]
* @constructor
*/
GameLib.D3.RaycastVehicle = function(
engine,
chassisBody
chassisBody,
wheels
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.chassisBody = chassisBody;
if (typeof wheels == 'undefined') {
wheels = [];
}
this.wheels = wheels;
this.instance = this.createInstance();
};
@ -21,13 +28,9 @@ GameLib.D3.RaycastVehicle = function(
* @returns {GameLib.D3.RaycastVehicle|GameLib.D3.Physics.RaycastVehicle|*}
*/
GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
var instance = new this.engine.instance.RaycastVehicle({
return new this.engine.instance.RaycastVehicle({
chassisBody: this.chassisBody.instance
});
this.instance = instance;
return instance;
};
/**
@ -37,27 +40,6 @@ GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
GameLib.D3.RaycastVehicle.prototype.addWheel = function (
wheel
) {
var options = {};
for (var property in wheel) {
if (wheel.hasOwnProperty(property)){
if (property == 'engine') {
continue;
}
options[property] = wheel[property];
}
}
this.instance.addWheel(options);
};
/**
* Eventually we can wrap wheels
* @returns {*}
* @constructor
*/
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelInfos;
};
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
};

View File

@ -165,4 +165,40 @@ GameLib.D3.RaycastWheel = function(
customSlidingRotationalSpeed = -0.1;
}
this.customSlidingRotationalSpeed = customSlidingRotationalSpeed;
this.instance = this.createInstance();
};
GameLib.D3.RaycastWheel.prototype.createInstance = function() {
return new this.engine.instance.WheelInfo({
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,
isFrontWheel : this.isFrontWheel,
clippedInvContactDotSuspension : this.clippedInvContactDotSuspension,
suspensionRelativeVelocity : this.suspensionRelativeVelocity,
suspensionForce : this.suspensionForce,
skidInfo : this.skidInfo,
suspensionLength : this.suspensionLength,
maxSuspensionTravel : this.maxSuspensionTravel,
useCustomSlidingRotationalSpeed : this.useCustomSlidingRotationalSpeed,
customSlidingRotationalSpeed : this.customSlidingRotationalSpeed
});
};

View File

@ -1,74 +1,48 @@
/**
* Physics Rigid Body Vehicle Superset
* TODO: body + wheels[]
* @param engine
* @param chassisBody
* @param wheels
* @constructor
*/
GameLib.D3.RigidBodyVehicle = function(
engine
engine,
chassisBody,
wheels
) {
this.engine = engine;
this.engine.isNotCannonThrow();
this.instance = null;
this.chassisBody = chassisBody;
if (typeof wheels == 'undefined') {
wheels = [];
}
this.wheels = wheels;
this.instance = this.createInstance();
};
/**
*
* @returns {*}
* @returns {GameLib.D3.RigidVehicle}
*/
GameLib.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelBodies;
};
/**
*
* @param chassisBody
* @returns {GameLib.D3.RigidVehicle|GameLib.D3.Physics.RigidVehicle}
*/
GameLib.D3.RigidBodyVehicle.prototype.createInstance = function(
chassisBody // Physics.RigidBody
) {
var vehicle = new this.engine.instance.RigidVehicle({
chassisBody: chassisBody.bodyObject
GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
return new this.engine.instance.RigidVehicle({
chassisBody: this.chassisBody.instance
});
this.instance = vehicle;
return vehicle;
};
/**
* Adds a wheel to this rigid body vehicle
* @param rigidBody GameLib.D3.RigidBody
* @param position
* @param axis
* @param direction
* @constructor
*/
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(
rigidBody,
position,
axis,
direction
) {
this.instance.addWheel({
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
)
});
/**
*
* @param wheel
*/
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
};

View File

@ -0,0 +1,34 @@
GameLib.D3.RigidWheel = function(
engine,
position,
axis,
direction
) {
this.engine = engine;
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
// )
);