subprotocol / verlet-js Goto Github PK
View Code? Open in Web Editor NEWA simple Verlet physics engine written in javascript
License: Other
A simple Verlet physics engine written in javascript
License: Other
Currently, the bounds are handled by forcing any particles outside of the bounds to be inside the bounds. However, since we're using verlet integration, this will result in an effective tangential acceleration (green vector) being applied to the body.
https://github.com/cwgreene/verlet-js/blob/master/images/error_type1.png?raw=true
This is visible by dragging the tire object in the demo to the left of the screen. Since the acceleration is applied downwards on the left hand side, the body rotates counter clockwise. When moved to the right hand side the acceleration will be applied upwards on the right hand side, again resulting in counter clockwise rotation.
I believe that by computing the intersection point (the origin of the green vector), and moving the particle there instead of the nearest bounding point (what is currently done), this issue will be resolved.
When you play with the mouse, you select the canvas.
Only tested on Canary 28 on Windows 7.
-webkit-user-select:none;
-moz-user-select:-moz-none;
-o-user-select:none;
-ms-user-select:none;
-khtml-user-select:none;
user-select:none;
Can someone give me a documentation about this library?
I don't know how dead this project is but I believe it has a lot of potential.
A lot is still broken. But I'm hoping that I could get some help and/or merge at some point.
Amoungst my problems are
Alot of my math is done on pen and paper and then applied to the engine. I can show as much as need be if you'd like to help. Some of it I've written inline for others to double check if need be.
Again: At some point I want to merge back to the main repository but of course that is only if you are willing. I've made many changes, some of which are breaking changes and to be honest more will be coming in the future.
Right now the breaking changes are
.clone()
if they don't want them to be. This was done because of a delaunay algorithm I was initially using. Though I'm no longer using it, I wouldn't doubt I may do it again if it helps my blob.Some other changes I may play with in the future
for( a in array)
to while(length--)
and eventually .foreach() once chrome gets its act togethor- http://jsperf.com/for-vs-foreach/268Is there a way to stop a composite from getting mashed-up when you slam it against a wall with a lot of force? For example the particles can collapse on themselves and either seemingly vanish (from a visual point of view) or are combining on-top of themselves.
I've tried the new bounds check in the Pull Request but it happens for that also. I've tried setting stiffness to 1 but it doesn't seem to prevent it. Am I missing something obvious?
Also any pointers on how to handle collision between two composite objects?
It would be great to submit this to bower.
Then it would be easer to integrate it in your own projects.
If not, do you know of a comparable 3D physics library?
@subprotocol would you accept a PR that makes this thing easier to run out-of-the-box? When I npm install
and build things locally I get some errors and the examples are all non-functional.
Happy to simplify things and get the default state running again if you're open to that.
Before I go gallivanting off to search for a CSS touch intercept parameter, is there already a common method of allowing verlet to work with mobile? Currently touches seem to scroll the entire page instead of manipulating the canvas.
Sometime we need to redraw whole composite not just drawConstraints nor drawParticles.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.