Skip to content

Instantly share code, notes, and snippets.

View faridiot's full-sized avatar

@faridiot faridiot

View GitHub Profile

React is a small library that does one thing well. Here's a list of tools we've found that work really well with React when building applications.

If you want your project on this list, or think one of these projects should be removed, feel free to edit this page.

Debugging

Related: [[Best Practices]], [[Anti-Patterns]]

Editors: put 2 spaces at the end of a question to create a <br>

  1. Why does it think the jQuery plugin is missing?
    Remember: load jQuery before AngularJS if you are using jQuery plugins!

  2. How do I access the DOM from a controller?
    DO NOT perform DOM selection/traversal from the controller. The HTML hasn't rendered yet. Look up 'directives'.

  3. Why does angular say my controllers/directives/etc are missing?

Visit https://www.madewithangular.com for the latest additions!

Launched sites:

Download the minified library and include it in your html. Alternatively see how to build the library yourself.

<script src="js/three.min.js"></script>

This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a WebGL renderer for the scene and camera, and it adds that viewport to the document.body element. Finally it animates the cube within the scene for the camera.

The MIT License

Copyright © 2010-2016 three.js authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

We can easily set up three.js scenes. These scenes require only a few lines of code to initialize. To construct a scene, we use three different types of objects: cameras, lights, and meshes.

To render a three.js scene, first create a WebGL renderer object. The following code creates a new WebGLRenderer object, sets the size of the HTML output canvas of that object to 800 x 640 pixels, adds the object to the document's body, and initializes a three.js scene.

	var renderer = new THREE.WebGLRenderer();
	renderer.setSize( 800, 640 );
	document.body.appendChild( renderer.domElement );
	
	var scene = new THREE.Scene();

Three.js includes the following features:

  • Renderers: WebGL, <canvas>, <svg>, CSS3D, DOM, Software; effects: anaglyph, crosseyed, stereo and more
  • Scenes: add and remove objects at run-time; fog
  • Cameras: perspective and orthographic; controllers: trackball, FPS, path and more
  • Animation: morph and keyframe
  • Lights: ambient, direction, point, spot and hemisphere lights; shadows: cast and receive
  • Materials: Lambert, Phong and more - all with textures, smooth-shading and more
  • Shaders: access to full WebGL capabilities; lens flare, depth pass and extensive post-processing library
  • Objects: meshes, particles, sprites, lines, ribbons, bones and more - all with level of detail

The problem

Not all browsers support WebGL, in fact only chrome and firefox work with three.js WebGLRenderer currently. iOS works with the canvas renderer and although IE9 supports canvas, it doesn't support workers so currently isn't supported.

A solution

In order to detect webgl compatibility and gracefully inform the user you can add https://github.com/mrdoob/three.js/blob/master/examples/js/Detector.js to your javascript and use this example to avoid even attempting to render anything:

if (Detector.webgl) {
	init();
	animate();
} else {