Browse Source

PLYLoader: Fix for linesplitting on universal newlines (#24264)

Co-authored-by: George Ash <[email protected]>
05gash 3 years ago
parent
commit
23046e42af
2 changed files with 6 additions and 6 deletions
  1. 3 3
      examples/js/loaders/PLYLoader.js
  2. 3 3
      examples/jsm/loaders/PLYLoader.js

+ 3 - 3
examples/js/loaders/PLYLoader.js

@@ -81,7 +81,7 @@
 
 			function parseHeader( data ) {
 
-				const patternHeader = /^ply([\s\S]*)end_header\r?\n/;
+				const patternHeader = /^ply([\s\S]*)end_header(\r\n|\r|\n)/;
 				let headerText = '';
 				let headerLength = 0;
 				const result = patternHeader.exec( data );
@@ -99,7 +99,7 @@
 					headerLength: headerLength,
 					objInfo: ''
 				};
-				const lines = headerText.split( '\n' );
+				const lines = headerText.split( /\r\n|\r|\n/ );
 				let currentElement;
 
 				function make_ply_element_property( propertValues, propertyNameMapping ) {
@@ -269,7 +269,7 @@
 
 				}
 
-				const lines = body.split( '\n' );
+				const lines = body.split( /\r\n|\r|\n/ );
 				let currentElement = 0;
 				let currentElementCount = 0;
 

+ 3 - 3
examples/jsm/loaders/PLYLoader.js

@@ -90,7 +90,7 @@ class PLYLoader extends Loader {
 
 		function parseHeader( data ) {
 
-			const patternHeader = /^ply([\s\S]*)end_header\r?\n/;
+			const patternHeader = /^ply([\s\S]*)end_header(\r\n|\r|\n)/;
 			let headerText = '';
 			let headerLength = 0;
 			const result = patternHeader.exec( data );
@@ -109,7 +109,7 @@ class PLYLoader extends Loader {
 				objInfo: ''
 			};
 
-			const lines = headerText.split( '\n' );
+			const lines = headerText.split( /\r\n|\r|\n/ );
 			let currentElement;
 
 			function make_ply_element_property( propertValues, propertyNameMapping ) {
@@ -283,7 +283,7 @@ class PLYLoader extends Loader {
 
 			}
 
-			const lines = body.split( '\n' );
+			const lines = body.split( /\r\n|\r|\n/ );
 			let currentElement = 0;
 			let currentElementCount = 0;