Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

How can you change restitution when using aframe physics system with ammo.js #186

Open
Jantu82 opened this issue Jan 15, 2021 · 1 comment

Comments

@Jantu82
Copy link

Jantu82 commented Jan 15, 2021

Is it possible to change the restitution (bounciness) somehow when using ammo.js with aframe physics system?

@mackbjon
Copy link

mackbjon commented Mar 5, 2021

Restitution with ammo.js is zero by default which requires every object in collision to be given explicit value.

Example below uses a ball and floor:

AFRAME.registerComponent("do-something", {
        init: function () {
          var sceneEl = this.el;
          var floorEl = sceneEl.querySelector("#floor");
          var ballEl = sceneEl.querySelector("#ball");
          floorEl.body.setRestitution(0.9);
          ballEl.body.setRestitution(0.8);
        },
      });

<a-scene do-something>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants