浏览代码

Normalize all line endings in an OBJ file (#9633)

`String.prototype.replace` only targets and replaces the first occurrence of a string. By using a regex with the global flag, all instances of a pattern are replaced.
Daniel Hritzkiv 9 年之前
父节点
当前提交
89b3d0babe
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      examples/js/loaders/OBJLoader.js

+ 1 - 1
examples/js/loaders/OBJLoader.js

@@ -412,7 +412,7 @@ THREE.OBJLoader.prototype = {
 		if ( text.indexOf( '\r\n' ) !== - 1 ) {
 		if ( text.indexOf( '\r\n' ) !== - 1 ) {
 
 
 			// This is faster than String.split with regex that splits on both
 			// This is faster than String.split with regex that splits on both
-			text = text.replace( '\r\n', '\n' );
+			text = text.replace( /\r\n/g, '\n' );
 
 
 		}
 		}