ian Posted August 25, 2016 Share Posted August 25, 2016 Maybe realy stupid question. So each object have Can anybody explanin why happend transform.position = (0,0,0) transform.rotationQuaternion = undefined Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 25, 2016 Share Posted August 25, 2016 Hi @ian... not a stupid question at all. .rotationQuaternion is created only when needed... automatically. But you can add one yourself, too. mesh.rotationQuaternion = BABYLON.Quaternion.Identity() is one way. Quote Link to comment Share on other sites More sharing options...
ian Posted August 25, 2016 Author Share Posted August 25, 2016 ok this is code (which I don't understand). Is there any simpler mybe more realible babylon api for this code Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 25, 2016 Share Posted August 25, 2016 Ahh, physics. .updatePhysicsBody() is deprecated, and/or no longer necessary. umm... I would say STEP #1... learn about the difference between a physics engine's Quaternion class, and a Babylon.js Quaternion class. When a physics engine is doing it's stuff, it is using a Quaternion-class that IT made... from IT'S api.... such as OIMO.Math.Quaternion. Babylon.js Quaternions are not the same... but real close. Build a converter between the two types... or make sure they are compatible. Perhaps... the physics body Quaternion IS being copied into the mesh.rotationQuaternion constantly. But... setting the mesh.rotationQuaternion might not instantly copy to the physics body Quaterion. Not sure if it is a 2-way connection/update. Use the rotate method... http://www.babylonjs-playground.com/#15BK6Z#2 (line 34). Also look at the BJS Quaternion class, especially at the yaw-pitch-roll stuff... that could make your life easier. Again, that's the BJS Quaternion class, not the Oimo or Cannon Quaternion class. You'll need to look at the API for those objects... at their websites. A Cannon.js quat, and an oimo.js quat, and a bjs quat... are not always compatible, and might need "adjusting". For example, I don't think you will find a 'w' factor on an Oimo quat. It is 's' for Oimo (I think). MAYBE... @RaananW removed these issues when he re-factored our physics plugins. Not sure, though. Maybe he'll visit. He knows Quaternions quite well. Meanwhile, you can do some SMALL testings... perhaps in a playground. Perhaps two physics objects (boxes are best, to easier-see them rotate than a sphere). Get refs/vars to the physics body/imposter... and see what happens when you do rotate()'s or yaw-pitch-roll activity. ApplyImpulse or set linearVelocities or angularVelocities... slam the box against a wall... see what happens. Start small. Quote Link to comment Share on other sites More sharing options...
ian Posted August 25, 2016 Author Share Posted August 25, 2016 I thought it was see somewhere that updatPhysicsBody() is deprecated. I remove it and it works fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.