I am importing the rotations into a JavaScript. It is imported from blender and working correctly in the JS alone. But I see an issue when swapped YZ and ammo.js is added. Right now, I am using only 3 cylinders (and have to add more in the future). Use of green cylinder is created by using initcylinder() function. Also, two other cylinders are loaded from blender scene using Object loader instance.
Physics is incorporate by using lmkrPhy() and creatingPhy() functions only. These files are simple just a little addition to three.js file. Here are those two physics functions:
function lmkrPhy() {
hit = new Ammo.btDefaultCollisionConfiguration();
hitandrun = new Ammo.btCollisionDispatcher(hit);
perfectp = new Ammo.btDbvtBroadphase();
solution = new Ammo.btSequentialImpulseConstraintSolver();
patchW = new Ammo.btDiscreteDynamicsWorld(hitandrun, perfectp,
solution, hit);
patchW.setGravity(new Ammo.btVector3(9, -9, 18));
initBlender();
initCylinder();
initFloor();
}
function creatingPhy(delta) {
var index, length, orb, inner, instance, getO, getR, ddelta;
ddelta = new Ammo.btTransform();
phWorld.stepSimulation(delta, 10);
length = dynamicObjects.length;
for(index = 0; index < length; index++) {
orb = dynamicObjects[index];
body = orb.userData.physicsBody;
instance = inner.getMotionState();
if(st) {
instance.getWorldTransform(ddelta);
getO = ddelta.getOrigin();
getR = ddelta.getRotation();
inner.position.set(getO.x(), getO.y(), getO.z());
inner.quaternion.set(getR.x(), getR.y(), getR.z(), getR.w());
}
}
}
Updating the cylinders (in creatingPhy()) to match updated position and doing the circular shift with entities present in ammo.js. Relative position is important in this case as the blue is 90d to the green. The other blue cylinder is a clone to the blue and it is rotated to match ammo.js. The orientations have default settings compared with blender from three.js file and before ammo.js.
How to handle this issue? Means, how to get the object from blender to three.js, keeping in mind that ammo.js is still had to be imported? Ammo.js does not have the documentation for imported meshes. The meshes created by fly event are correctly expected. Blender to three.js is shady here but the ammo script is working fine. This tells that something is missing in 1 or 2 steps.
After the copying quaternion from the engine and performing the simple translation (e.g in official jsfiddle file implementation for cylinders). This file does not have good kludge, due to the extra transformations required at each up gradation. Clarity about the side-effects is vague. As there are cases of complex geometries, compare to my case. And ammo.js is only used to handle the bounding box.
At the end, my job is to create a 3D model of the http://militarybases.co/directory/camp-price-support-center-army-base-in-granite-city-il/ and provide to Union High School Granite city school Illinois. This project is initiated by municipal authority of the city and will be shown to 7th Grade students as a sample project of 3D designing. Only two days are left in deadline, and this issue is messing with my head.