Giter Site home page Giter Site logo

gravitation's Introduction

gravitation

Build Status

Introduction

Simple 3d simulation of Newton's law of universal gravitation with sample Three.js project.

## Usage ##

Consists of two main classes: Univers and Body in app/ and a sample project with Three.js in app/sampleProject.

require( ['gravitation/Univers'], function( Univers ){
    
    var univers = new Univers() // see app/Univers.js#+options for different options
    univers.buildBody({ // see app/Univers.js#buildRandomBody as an example
        position: [ 0, 0, 0],
        velocity: [ 1, 2, 3 ],
        rotation: [ 3, 4, 5 ]
    })

    univers.bodies // your bodies instances are here

    var update = function( ){
        univers.step()
        requestAnimationFrame(update)
    }

    update()

})

or just read app/sampleProject/SampleGravitationProject.js

Demo

See cagosta.github.io/gravitation

## Install ##

gravitation is coded as AMD module but can be installed with npm, bower or old-fashioned src=".min.js".

With bower:

bower install gravitation

Point gravitation to [bower_components_path]/gravitation/app/gravitation.js into your requirejs path config and load it with requirejs:

require(['gravitation/gravitation'], function( gravitation ){

})

With src=" .min.js"

Inside the dist folder, download latest standalone minified version or development version and include it in your html page:

<script src="[path_to_source]/gravitation-latest-standalone-min.js%>"></script>

The module is available via the scope

window.gravitation

To do

## Documentation ##

See jsdoc-generated documentation in /documentation

Folder Structure

app         ->  development files
|- bower_components          ->  [bower](https://github.com/bower/bower) front-end packages
|- main.js                   ->  main file for browser and node.js, handle AMD config
|- gravitation   -> main AMD module
test        ->  unit tests
|
tasks       -> [Grunt](http://gruntjs.com/) tasks, see [generator-mangrove-module](https://github.com/cagosta/generator-mangrove-module)
|
dist        ->  distribution & build files
|
node_modules -> node packages
|
documentation  -> [jsdoc](http://usejsdoc.org/about-jsdoc3.html) generated documentation 

Run unit tests

On the browser

Run grunt test:browser and open test/ on your browser.

#### On a headless browser ####

grunt test:headless will run your tests in a headless browser, with phantomjs and mocha

On node

grunt test:node will run your tests with node and mocha.

Because of requirejs, the mocha command does not work.

On saucelabs

Beta: run your tests with saucelabs and sauce connect:

  • add your saucelabs credentials into .credentials.json
{
 
    "saucelabs": {
        "username": "",
        "key": ""
    }   

}
  • configure the browser your want your tests to run on in config.json
  • and run your tests with:
grunt test:sauce

Build your own

This project uses Node.js, Grunt and Require.js for the build process. If for some reason you need to build a custom version install Node.js, npm install and run:

grunt build

## Yeoman Mangrove module Generator ##

This module is based on a Yeoman generator: Generator-mangrove-module
Check it for task-related references such as build, deploy etc ..

Authors

License

MIT License

gravitation's People

Contributors

cagosta avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.