Jump to content

BabylonJS and Native Cannon.js API


ian
 Share

Recommended Posts

Hi Ian.  CheckCollisions property is not used with physics engines (afaik).  That is for BJS built-in collision system, not 3rd party physics engines.

Now, native api...
Go here...  http://www.babylonjs-playground.com/#1ND6TH#9

Look at lines 124-129... nativeParams:

That is one way set native parameters during construction of physics things.

Now for another way... for after-construction fun...

See line 100... it logs wheelBody object to console.  Open your browser f12 dev tools, and click on that object in the console.  View it in object inspector.  Notice that it is the same object as...

http://schteppe.github.io/cannon.js/docs/classes/Body.html

So, you may work-with a Cannon Body Class... by working with wheelBody.  Makes sense, right?  WheelBody ==  CannonBody.  Many properties and methods on wheelBody... all native to Cannon.  You can call/set them all... from within scene.

Also, http://doc.babylonjs.com/classes/2.4/PhysicsEngine

That is a way to interface with the physics engine, too.  There is no scene.currentPhysicsEngineObject, becasue physics engines do not use that method of "integrating" with BJS.

This should help.  Experiment, experiment, experiment.  :)

Link to comment
Share on other sites

Thanks Wingnut! :) A perfect answer.

Just wanted to add - each and every impostor has a public variable called physicsBody , which is the physics engine body. Every joint has physicsJoint (I will let you guess what this is), and the physics engine class itself has the world (of the physics engine) as a public variable as well.

You have all tools to use the native functions of the physics engine, just don't forget that Babylon is always taking care of the basics for you - position and rotation update every frame. 

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...