1.0.1 • Published 3 years ago

simple-physic v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

simplePhysic

HTML elements affected by laws of physic

SimplePhysic is a library that manipulates dom object to obtain physic simulation of HTML elements. You can find sample usage on simplePhysic-sample. If you are interested how impulse collision is calculated visit wiki collision response.

Installation

npm i simple-physic

Usage

First import module into project

import simplePhysic from 'simple-physic'

Then markdown scene and rectangles.

        <div id="simplePhysic-scene">
            <div className="simplePhysic-rectangle"></div>
            <div className="simplePhysic-rectangle"></div>
        </div>

Then pass document object into it and start simulation

  useEffect(() => {
    simplePhysic.parseDOM(document)
    simplePhysic.start()
  })

Development

Things to add & change:

  • add friction impulse
  • add easy interface for controllig physic's aspects
  • replace rectangle collision detect algorithm for more effective
  • test prediction collision algorithm instead remove one
  • add drag&drop sensitive to speed of cursor
  • remove absolute position requirement for html elements
  • add one constrained behaviour