提交 5a0323ac 编写于 作者: M Mr.doob

Replaced startsWidth and endsWidth with regexp. See #3003.

上级 e1b70079
......@@ -401,7 +401,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
THREE.MTLLoader.loadTexture = function ( url, mapping, onLoad, onError ) {
var isCompressed = url.toLowerCase().endsWith( ".dds" );
var isCompressed = /\.dds$/i.test( url );
if ( isCompressed ) {
......
......@@ -382,7 +382,7 @@ THREE.OBJLoader.prototype = {
}
} else if ( line.startsWith( "o " ) ) {
} else if ( /^o /.test( line ) ) {
// object
......@@ -390,23 +390,23 @@ THREE.OBJLoader.prototype = {
object.name = line.substring( 2 ).trim();
group.add( object );
} else if ( line.startsWith( "g " ) ) {
} else if ( /^g /.test( line ) ) {
// group
meshN( line.substring( 2 ).trim(), undefined );
} else if ( line.startsWith( "usemtl " ) ) {
} else if ( /^usemtl /.test( line ) ) {
// material
meshN( undefined, line.substring( 7 ).trim() );
} else if ( line.startsWith( "mtllib ") ) {
} else if ( /^mtllib /.test( line ) ) {
// mtl file
} else if ( line.startsWith( "s ") ) {
} else if ( /^s /.test( line ) ) {
// smooth shading
......
......@@ -518,7 +518,7 @@ THREE.OBJMTLLoader.prototype = {
}
} else if ( line.startsWith( "o " ) ) {
} else if ( /^o /.test( line ) ) {
// object
......@@ -526,19 +526,19 @@ THREE.OBJMTLLoader.prototype = {
object.name = line.substring( 2 ).trim();
group.add( object );
} else if ( line.startsWith( "g " ) ) {
} else if ( /^g /.test( line ) ) {
// group
meshN( line.substring( 2 ).trim(), undefined );
} else if ( line.startsWith( "usemtl " ) ) {
} else if ( /^usemtl /.test( line ) ) {
// material
meshN( undefined, line.substring( 7 ).trim() );
} else if ( line.startsWith( "mtllib ") ) {
} else if ( /^mtllib /.test( line ) ) {
// mtl file
......@@ -550,7 +550,7 @@ THREE.OBJMTLLoader.prototype = {
}
} else if ( line.startsWith( "s ") ) {
} else if ( /^s /.test( line ) ) {
// Smooth shading
......
......@@ -18,27 +18,6 @@ self.console = self.console || {
self.Int32Array = self.Int32Array || Array;
self.Float32Array = self.Float32Array || Array;
// Shims for "startsWith", "endsWith", and "trim" for browsers where this is not yet implemented
// not sure we should have this, or at least not have it here
// http://stackoverflow.com/questions/646628/javascript-startswith
// http://stackoverflow.com/questions/498970/how-do-i-trim-a-string-in-javascript
// http://wiki.ecmascript.org/doku.php?id=harmony%3astring_extras
String.prototype.startsWith = String.prototype.startsWith || function ( str ) {
return this.slice( 0, str.length ) === str;
};
String.prototype.endsWith = String.prototype.endsWith || function ( str ) {
var t = String( str );
var index = this.lastIndexOf( t );
return ( -1 < index && index ) === (this.length - t.length);
};
String.prototype.trim = String.prototype.trim || function () {
return this.replace( /^\s+|\s+$/g, '' );
......
......@@ -145,7 +145,7 @@ THREE.Loader.prototype = {
function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
var isCompressed = sourceFile.toLowerCase().endsWith( ".dds" );
var isCompressed = /\.dds$/i.test( sourceFile );
var fullPath = texturePath + "/" + sourceFile;
if ( isCompressed ) {
......
......@@ -903,7 +903,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
var isCompressed = url_array[ 0 ].endsWith( ".dds" );
var isCompressed = /\.dds$/i.test( url_array[ 0 ] );
if ( isCompressed ) {
......@@ -917,7 +917,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
} else {
var isCompressed = textureJSON.url.toLowerCase().endsWith( ".dds" );
var isCompressed = /\.dds$/i.test( textureJSON.url );
var fullUrl = get_url( textureJSON.url, data.urlBaseType );
var textureCallback = generateTextureCallback( 1 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册