Pure THREE.JS template

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/three.js/r83/three.min.js"></script>
<script type="text/javascript">
/**
 * @author qiao / https://github.com/qiao
 * @author mrdoob / http://mrdoob.com
 * @author alteredq / http://alteredqualia.com/
 * @author WestLangley / http://github.com/WestLangley
 * @author erich666 / http://erichaines.com
 */

// This set of controls performs orbiting, dollying (zooming), and panning.
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
//
//    Orbit - left mouse / touch: one finger move
//    Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
//    Pan - right mouse, or arrow keys / touch: three finger swipe

THREE.OrbitControls = function ( object, domElement ) {

	this.object = object;

	this.domElement = ( domElement !== undefined ) ? domElement : document;

	// Set to false to disable this control
	this.enabled = true;

	// "target" sets the location of focus, where the object orbits around
	this.target = new THREE.Vector3();

	// How far you can dolly in and out ( PerspectiveCamera only )
	this.minDistance = 0;
	this.maxDistance = Infinity;

	// How far you can zoom in and out ( OrthographicCamera only )
	this.minZoom = 0;
	this.maxZoom = Infinity;

	// How far you can orbit vertically, upper and lower limits.
	// Range is 0 to Math.PI radians.
	this.minPolarAngle = 0; // radians
	this.maxPolarAngle = Math.PI; // radians

	// How far you can orbit horizontally, upper and lower limits.
	// If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
	this.minAzimuthAngle = - Infinity; // radians
	this.maxAzimuthAngle = Infinity; // radians

	// Set to true to enable damping (inertia)
	// If damping is enabled, you must call controls.update() in your animation loop
	this.enableDamping = false;
	this.dampingFactor = 0.25;

	// This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
	// Set to false to disable...

JavaScript

var scene, renderer, camera;
var cube;
var controls;
var tgeometry;
var pointCloud;
var nbPoints = 500;
var INTERVAL_DURATION = 10;
var MAX_POINTS = 100000;
var currentPointsIndex = 0;
var currentPoints = 0;
var interval;

var startTime = Date.now();

init();

animate();

interval = setInterval(function() {
  setPoints();
}, INTERVAL_DURATION)

function setPoints() {

    var positions = pointCloud.geometry.attributes.position.array;

		var x, y, z, index;
    
    var l  = currentPoints + nbPoints;
    if(l >= MAX_POINTS) {
    	clearInterval(interval);
      console.log('Milliseconds to render ' + MAX_POINTS +' points: ');
      console.log( Date.now() - startTime);    
      console.log('Expected milliseconds: ' + (INTERVAL_DURATION * MAX_POINTS / nbPoints));
    }

		for ( var i = currentPoints; i < l; i ++ ) {
        x = ( Math.random() - 0.5 ) * 300;
        y = ( Math.random() - 0.5 ) * 300;
        z = ( Math.random() - 0.5 ) * 300;
        positions[ currentPointsIndex ++ ] = x;
        positions[ currentPointsIndex ++ ] = y;
        positions[ currentPointsIndex ++ ] = z;
  	}
    currentPoints = l;
    pointCloud.geometry.attributes.position.needsUpdate = true;	
    pointCloud.geometry.setDrawRange( 0, currentPoints );  
   	update();
 
}

function update() {

  controls.update();
  renderer.render(scene, camera);
}

function init() {
	  renderer = new THREE.WebGLRenderer( {antialias:true} );
    var width = window.innerWidth;
    var height = window.innerHeight;
    renderer.setSize (width, height);
    document.body.appendChild (renderer.domElement);

    scene = new THREE.Scene();

    camera = new THREE.PerspectiveCamera (45, width/height, 1, 10000);
    camera.position.y = 160;
    camera.position.z = 800;
    camera.lookAt (new THREE.Vector3(0,0,0));

		console.log(THREE);
    controls = new THREE.OrbitControls (camera, renderer.domElement);

    var tmaterial = new THREE.PointsMaterial({
      color: 0xff0000,
      size: 2,
      opacity: 1
  ...