Giter Site home page Giter Site logo

three-cannon's Introduction

#3D Physics: three-cannon

A plugin built to have three.js and cannon.js working together.

Demo - Demo in context

DEMO

##Usage

###Initiation

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>3D Physics</title>
	<style>
		body { margin: 0; overflow: hidden; }
		canvas { width: 100%; height: 100%; }
	</style>
</head>
<body>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/cannon.js/0.6.2/cannon.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r74/three.min.js"></script>
	<script src="vendor/OrbitControls.js"></script>
	<script src="three-cannon.js"></script>
	<script>
		var world, timestep = 1/60;
		var scene, camera, renderer, control, raycaster, mouse, lights=[];
		var objAry = [];

		initWorld();
		initScene();
		render();
	</script>
</body>
</html>

###Building

var material = new THREE.MeshPhongMaterial({
	color: 0x156289,
	emissive: 0x072534,
	side: THREE.DoubleSide,
	shading: THREE.FlatShading
});

var box = new Box({
	parent: scene, // Optional, default is scene.
	mass: 0, // Optional, default is 0.
	position: {x:0, y:0, z:0}, // Optional, default is {x:0, y:0, z:0}.
	material: material, // Optional, default is new THREE.MeshNormalMaterial({side:THREE.DoubleSide}).
	size: {x:2, y:2, z:2} // Required, specific to the Box class.
});

##Contributing

Welcome to submit an issues, fork and create a pull request.

three-cannon's People

Contributors

alice24 avatar neo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.