schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.67k stars 709 forks source link

CCD #366

Open bllem opened 6 years ago

bllem commented 6 years ago

Hello. Did a real shooting from the weapons in the shooter, and fought with the lack of ccd in cannon, but it is present in p1. Moves ccd into the cannon, and it works great. I removed the rotation, because I did for the bullets. Perhaps someone will need

https://github.com/bllem/cannon.js/commits/master

dirkk0 commented 6 years ago

do you have a demo somewehere?

bllem commented 6 years ago

I have a video. By default, the CCD is turned on at a speed of 10+. In this video, the balls are not bullets, but only a display of hits. A bullet with a diameter of 0.1 and it is represented by a physical object with a start velocity about 360 https://youtu.be/5WsRRIVgk3I

dirkk0 commented 6 years ago

Wow, impressive! All of this is done with ThreeJS and CannonJS?

flerokoo commented 6 years ago

Cool and just in time! Although I've encountered a problem. Take a look at those gifs: usual cannon.js — https://gfycat.com/ContentSleepyBedlingtonterrier cannon.js with CCD — https://gfycat.com/ContentShallowKingfisher

I control the ball by applying force (directed to the left or right).

With CCD, angularVelocity builds up too quickly, and then the ball gets thrown hard (look like in opposite direction of applied force, or maybe direction depends on angularVelocity, i don't know for sure). Without CCD it's stable, no unexpected speed ups.

bllem commented 6 years ago

I did not add a correction for angular acceleration and rotation, if it is necessary - I can add

ubernaut commented 6 years ago

that is a really cool looking demo!

flerokoo commented 6 years ago

@bllem It would be great to have full-blown CCD in cannon.js, so if you have the time... :)

sinper0079 commented 6 years ago

I have used your new build of cannonjs but still not working , is that something need to set up?

bllem commented 6 years ago

in body options you can setup ccdSpeedThreshold - speed s at witch CCD starts to work and - ccdIterations collision accuracy.