question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Soft Body broken when source model is glTF

See original GitHub issue

When using glTF files as soft bodies they end up having very strange behavior. More specifically, despite how the soft body properties are set, they crumple like paper and their collision detection breaks and they fall through other objects. Multiple soft bodies inserted into the scene this way also don’t interact with each-other in any logical fashion.

Repro Because this bug requires an external glTF model, I’m not able to easily reproduce it in the sandbox. Instead, allow me to provide sample files and code here:

import * as BABYLON from 'babylonjs'
import 'babylonjs-loaders'

function init() {
  var canvas = document.getElementById('renderCanvas')
  var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true })
  var scene = new BABYLON.Scene(engine)
  scene.enablePhysics(new BABYLON.Vector3(0,-9.81, 0), new BABYLON.AmmoJSPlugin())
  scene.debugLayer.show()
  var camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 2, Math.PI / 2.5, 15, BABYLON.Vector3.Zero(), scene);
  camera.setTarget(BABYLON.Vector3.Zero())
  camera.attachControl(canvas, false)
  var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0, 1, 0), scene)

  var options = {
    mass: 1,
    friction: 0.1,
    restitution: 0.3,
    pressure: 2000,
    velocityIterations: 40,
    positionIterations: 40,
    stiffness: 0.9,
    damping: 0.01
  }

  var ground = BABYLON.MeshBuilder.CreateBox('ground', {width: 5, height:0.2, depth: 5}, scene)
  ground.physicsImpostor = new BABYLON.PhysicsImpostor(ground, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, friction: 0.5, restitution: 0 }, scene)

  BABYLON.SceneLoader.ImportMeshAsync('', 'assets/glb/box.glb', '', scene).then(model => {
    var targetMesh = model.meshes[1]
    targetMesh.parent = null
    targetMesh.forceSharedVertices()
    targetMesh.physicsImpostor = new BABYLON.PhysicsImpostor(targetMesh, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 10 }, scene)
  })

  BABYLON.SceneLoader.ImportMeshAsync('', 'assets/glb/soft.glb', '', scene).then(model => {
    var targetMesh = model.meshes[1]
    targetMesh.parent = null
    targetMesh.forceSharedVertices()
    targetMesh.position.y = 3
    targetMesh.physicsImpostor = new BABYLON.PhysicsImpostor(targetMesh, BABYLON.PhysicsImpostor.SoftbodyImpostor, options, scene)
  })

  window.addEventListener('resize', () => {
    engine.resize()
  })

  engine.runRenderLoop(() => {
    scene.render()
  })
}

init()

soft-body-glb-samples.zip

Screenshots image

Desktop (please complete the following information):

  • OS: Tested on both OSX and Linux
  • Browser Tested on both Chrome and FireFox

Additional context I’m not the developer who discovered this bug, I just translated the information, so my description may not be accurate. If you are unable to replicate the issue or find my description to be inaccurate or lacking please let me know and I will try to get a better description or have the developer make a sample that can be viewed easily in the sandbox.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
deltakoshcommented, Jul 12, 2020

" so if just copying the above and pasting it on the forum would be sufficient I’ll do so" That would be perfect!

0reactions
Kagetsukicommented, Jul 15, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Soft body issues when importing a glTF model - Bugs
Making a model/mesh into a soft body when that model was imported from glTF yields some strange results. Essentially the model can't stay ......
Read more >
Part 2: glTF: Modeling pieces that can move - YouTube
In this follow-up modeling session, movable solar panels are attachedto the Cubesat.
Read more >
Using SoftBody - Godot Docs
Soft bodies (or soft-body dynamics) simulate movement, changing shape and other physical properties ... A SoftBody node is used for soft body simulations....
Read more >
TransformControls with GLTF Animations - Three.js Tutorials
In this example, you can transform the animated models position, rotation and ... the file name in the source code to match your...
Read more >
glTF render node - SideFX
glb: Export as a single binary file with .glb format. Texture Source. Controls the origin of textures that are included in the exported...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found