# Cannon.js collision - preservation of energy

**URL:** https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785
**Category:** Questions
**Tags:** cannonjs
**Created:** [March 24, 2020, 8:17pm UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785 "2020-03-24T20:17:08Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ac70](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ac70/32/8339_2.png) [@ac70](https://discourse.threejs.org/u/ac70)
#### Post date: [March 24, 2020, 8:17pm UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/1 "2020-03-24T20:17:08Z")

</div>

I’m using cannon.js to handle collisions and it’s working fine except for one case: I need the collision between a sphere and a box doesn’t make them lose energy so they can preserve their velocity.

Is it possible?

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [March 24, 2020, 8:39pm UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/2 "2020-03-24T20:39:06Z")

</div>

Consider to ask pure `cannon.js` related questions at the respective repository:

> **[schteppe/cannon.js](https://github.com/schteppe/cannon.js)**
>
> A lightweight 3D physics engine written in JavaScript. - schteppe/cannon.js

---

<div class="post-metadata">

### Author: ![ac70](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ac70/32/8339_2.png) [@ac70](https://discourse.threejs.org/u/ac70)
#### Post date: [March 26, 2020, 11:56pm UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/3 "2020-03-26T23:56:55Z")

</div>

Nobody is going to answer in that website. The real problem is that Physijs and Cannonjs are not a maintained anymore. With the last releases of Threejs they give some errors and now I don’t know what to use as physics engine anymore. I have been using Threejs for few years and now it looks like there is no choice but migrate to another platform.

---

<div class="post-metadata">

### Author: ![yannick](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/yannick/32/8539_2.png) [@yannick](https://discourse.threejs.org/u/yannick)
#### Post date: [March 27, 2020, 12:33am UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/4 "2020-03-27T00:33:23Z")

</div>

I made a physics library on top of ammo.js (just like physijs) which might help you. It’s [enable3d.io](https://enable3d.io/).

---

<div class="post-metadata">

### Author: ![ac70](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ac70/32/8339_2.png) [@ac70](https://discourse.threejs.org/u/ac70)
#### Post date: [March 27, 2020, 7:48am UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/5 "2020-03-27T07:48:15Z")

</div>

Thanks yannick, this could be useful. At the moment I’ve been using Physijs and I was trying to replace it with Cannonjs. I could try replacing it with your library instead. I’m gonna come back to you when I finished and let you know if it worked. Anyway, I must say that Threejs users’ should not rely on good heart people library’s but Threejs should provide with its own physics engine.

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [March 27, 2020, 9:51am UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/6 "2020-03-27T09:51:51Z")

</div>

> [@ac70](#):
>
> The real problem is that Physijs and Cannonjs are not a maintained anymore. With the last releases of Threejs they give some errors and now I don’t know what to use as physics engine anymore.

This official cannon.js/three.js demo seems to work fine without issues:

[https://threejs.org/examples/physics\_cannon\_instancing](https://threejs.org/examples/physics_cannon_instancing)

Besides, there are multiple official example with ammo.js:

[https://threejs.org/examples/?q=ammo](https://threejs.org/examples/?q=ammo)

---

<div class="post-metadata">

### Author: ![ac70](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ac70/32/8339_2.png) [@ac70](https://discourse.threejs.org/u/ac70)
#### Post date: [March 27, 2020, 10:39am UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/7 "2020-03-27T10:39:46Z")

</div>

Hi Mugen87, maybe I got the wrong [Cannonjs’s repository](https://github.com/schteppe/cannon.js), but it looks like the last commit was 5 years ago. Also, it’s a good thing when you have a forum like this one where you can [ask questions](https://github.com/schteppe/cannon.js/issues/441) and compare your experiences but not too many people are still using Physyjs and CannonJs and when you have some problems that you can’t figure out by your self, you get in trouble. (I don’t want to use another tool which is going to disappear like Physijs) I have never thought of using Ammojs and I’m going to evaluate also this one before to take a decision. Thanks

---

<div class="post-metadata">

### Author: ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)
#### Post date: [March 29, 2020, 12:15am UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/8 "2020-03-29T00:15:41Z")

</div>

we picked up cannon, you can ask here [https://github.com/react-spring/cannon-es](https://github.com/react-spring/cannon-es) it’s constantly being updated now. most pr’s that were left hanging are in there already, lots of bugfixes and some new features from us. i just help out a little, couldn’t answer your question but the others for sure can.

---

<div class="post-metadata">

### Author: ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)
#### Post date: [March 29, 2020, 1:45pm UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/9 "2020-03-29T13:45:12Z")

</div>

![Screenshot 2020-03-29 at 15.44.13](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/a/a1410396921e5a1a6f1430ee08e4a375ed28dad5.png)

---

<div class="post-metadata">

### Author: ![ac70](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ac70/32/8339_2.png) [@ac70](https://discourse.threejs.org/u/ac70)
#### Post date: [March 29, 2020, 3:57pm UTC](https://discourse.threejs.org/t/cannon-js-collision-preservation-of-energy/13785/10 "2020-03-29T15:57:56Z")

</div>

It works perfectly!! thanks
