Ver código fonte

Added progress callback to ColladaLoader.

Erik Kitson 13 anos atrás
pai
commit
298afecf80
1 arquivos alterados com 17 adições e 1 exclusões
  1. 17 1
      src/extras/loaders/ColladaLoader.js

+ 17 - 1
src/extras/loaders/ColladaLoader.js

@@ -49,7 +49,9 @@ THREE.ColladaLoader = function () {
 
 	var TO_RADIANS = Math.PI / 180;
 
-	function load ( url, readyCallback ) {
+	function load ( url, readyCallback, progressCallback ) {
+
+		var length = 0;
 
 		if ( document.implementation && document.implementation.createDocument ) {
 
@@ -83,6 +85,20 @@ THREE.ColladaLoader = function () {
 
 					}
 
+				} else if ( req.readyState == 3 ) {
+
+					if ( progressCallback ) {
+
+						if ( length == 0 ) {
+
+							length = req.getResponseHeader( "Content-Length" );
+
+						}
+
+						progressCallback( { total: length, loaded: req.responseText.length } );
+
+					}
+
 				}
 
 			}