Jump to content

joint issue in babylon js

shakeel ahmed

Recommended Posts

Hello guys, 
I have made two custom meshes properly using xhtml code, one is garment(T-Shirt) and another is Model(Human Body).But i am trying to simulate Garment with Model means i have added physics engine and collision. I am unable to add imposter and joints. Beacuse of this, the simulation task between Garment(Cloth) and Model(Human Body) is done .I am too much stuck and waiting your reply.
I am writing whole code for both custom meshed



var position_vertices_data = garment.getVerticesData(BABYLON.VertexBuffer.PositionKind);
var spheres = [];
for (var i = 0; i < position_vertices_data.length; i = i + 3) {
  var v = BABYLON.Vector3.FromArray(position_vertices_data, i);
  var s = BABYLON.MeshBuilder.CreateSphere("s" + i, { diameter: 0.5 }, scene);
  s.position.y = 60;

function createJoint(imp1, imp2) {
  var joint = new BABYLON.DistanceJoint({
    maxDistance: 1
  imp1.addJoint(imp2, joint);

spheres.forEach(function (point, idx) {
  var mass = 1;
  point.physicsImpostor = new BABYLON.PhysicsImpostor(point, BABYLON.PhysicsImpostor.ParticleImpostor, { mass: mass, restitution: 0.9 }, scene);
  if (idx >= subdivisions) {
    createJoint(point.physicsImpostor, spheres[idx - subdivisions].physicsImpostor);
    if (idx % subdivisions) {
      createJoint(point.physicsImpostor, spheres[idx - 1].physicsImpostor);


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.

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.


  • Recently Browsing   0 members

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