render mesh offsets (position & quaternion)
parent
1b53eb912e
commit
e57d470c8c
35
game-lib.js
35
game-lib.js
|
@ -2827,8 +2827,10 @@ GameLib.D3.Physics.World.prototype.Step = function(
|
||||||
) {
|
) {
|
||||||
if(this.engineType == GameLib.D3.Physics.Engine.TYPE_CANNON) {
|
if(this.engineType == GameLib.D3.Physics.Engine.TYPE_CANNON) {
|
||||||
|
|
||||||
var now = performance.now() / 1000;
|
this.worldObject.internalStep(timeStep);
|
||||||
|
return;
|
||||||
|
|
||||||
|
var now = performance.now() / 1000;
|
||||||
if(!this.lastCallTime){
|
if(!this.lastCallTime){
|
||||||
// last call time not saved, cant guess elapsed time. Take a simple step.
|
// last call time not saved, cant guess elapsed time. Take a simple step.
|
||||||
this.worldObject.step(timeStep);
|
this.worldObject.step(timeStep);
|
||||||
|
@ -3125,8 +3127,35 @@ GameLib.D3.Game.prototype.ProcessPhysics = function (
|
||||||
|
|
||||||
if(mesh) {
|
if(mesh) {
|
||||||
if(physicsWorld.engineType === GameLib.D3.Physics.Engine.TYPE_CANNON) {
|
if(physicsWorld.engineType === GameLib.D3.Physics.Engine.TYPE_CANNON) {
|
||||||
mesh.position.copy(body.bodyObject.position);
|
|
||||||
mesh.quaternion.copy(body.bodyObject.quaternion);
|
var quaternion = new THREE.Quaternion();
|
||||||
|
quaternion.copy(body.bodyObject.quaternion);
|
||||||
|
|
||||||
|
var quaternionCopy = quaternion.clone();
|
||||||
|
|
||||||
|
var position = new THREE.Vector3();
|
||||||
|
position.copy(body.bodyObject.position);
|
||||||
|
|
||||||
|
if(mesh.permutate) {
|
||||||
|
|
||||||
|
if(mesh.permutate.offset) {
|
||||||
|
if(mesh.permutate.offset.quaternion) {
|
||||||
|
var offsetQuaternion = new THREE.Quaternion();
|
||||||
|
offsetQuaternion.copy(mesh.permutate.offset.quaternion);
|
||||||
|
quaternion = quaternion.multiply(offsetQuaternion).normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mesh.permutate.offset.position) {
|
||||||
|
var offsetPosition = new THREE.Vector3();
|
||||||
|
offsetPosition.copy(mesh.permutate.offset.position);
|
||||||
|
//position = position.add(offsetPosition);
|
||||||
|
position = position.add(offsetPosition.applyQuaternion(quaternionCopy));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.position.copy(position);
|
||||||
|
mesh.quaternion.copy(quaternion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue