|
@@ -103,13 +103,6 @@ THREE.Loader.prototype = {
|
|
|
|
|
|
var _this = this;
|
|
|
|
|
|
- function is_pow2( n ) {
|
|
|
-
|
|
|
- var l = Math.log( n ) / Math.LN2;
|
|
|
- return Math.floor( l ) == l;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
function nearest_pow2( n ) {
|
|
|
|
|
|
var l = Math.log( n ) / Math.LN2;
|
|
@@ -117,36 +110,6 @@ THREE.Loader.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function load_image( where, url ) {
|
|
|
-
|
|
|
- var image = new Image();
|
|
|
-
|
|
|
- image.onload = function () {
|
|
|
-
|
|
|
- if ( !is_pow2( this.width ) || !is_pow2( this.height ) ) {
|
|
|
-
|
|
|
- var width = nearest_pow2( this.width );
|
|
|
- var height = nearest_pow2( this.height );
|
|
|
-
|
|
|
- where.image.width = width;
|
|
|
- where.image.height = height;
|
|
|
- where.image.getContext( '2d' ).drawImage( this, 0, 0, width, height );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- where.image = this;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- where.needsUpdate = true;
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- if ( _this.crossOrigin !== undefined ) image.crossOrigin = _this.crossOrigin;
|
|
|
- image.src = url;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
|
|
|
|
|
|
var isCompressed = /\.dds$/i.test( sourceFile );
|
|
@@ -204,7 +167,31 @@ THREE.Loader.prototype = {
|
|
|
|
|
|
if ( ! isCompressed ) {
|
|
|
|
|
|
- load_image( where[ name ], fullPath );
|
|
|
+ var texture = where[ name ];
|
|
|
+
|
|
|
+ var loader = new THREE.ImageLoader();
|
|
|
+ loader.crossOrigin = _this.crossOrigin;
|
|
|
+ loader.load( fullPath, function ( image ) {
|
|
|
+
|
|
|
+ if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
|
|
|
+ THREE.Math.isPowerOfTwo( image.height ) === false ) {
|
|
|
+
|
|
|
+ var width = nearest_pow2( image.width );
|
|
|
+ var height = nearest_pow2( image.height );
|
|
|
+
|
|
|
+ texture.image.width = width;
|
|
|
+ texture.image.height = height;
|
|
|
+ texture.image.getContext( '2d' ).drawImage( image, 0, 0, width, height );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ texture.image = image;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ texture.needsUpdate = true;
|
|
|
+
|
|
|
+ } );
|
|
|
|
|
|
}
|
|
|
|