jQuery Ready Callback

The jQuery ready callback does not let you access the THREE object without bringing it into the execution context of your ready method.

 

Uncaight ReferenceError: THREE is not defined
$.ready(function () {
 
	new THREE.Scene();
 
});

The solutions below may not be accurate. This has not been tested.

 

To solve this problem we need to help jQuery's ready method know where to look for THREE.

 

$.ready(function () {
	
	var THREE = window.THREE;
 
}); 
$.ready(function (THREE) {
	return function () {
		
		new THREE.Scene();
 
	}
}(window.THREE));