Jump to content

Why happend rotationQuaternion undefined?


ian
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...