n5ro / aframe-physics-system

Physics system for A-Frame VR, built on CANNON.js.

Home Page:https://n5ro.github.io/aframe-physics-system/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Jantu82 opened this issue · comments

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

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>