浏览代码

VRMLLoader: Handle multiple points defined in a single line. Fixes #5391.

Mr.doob 10 年之前
父节点
当前提交
a5c18b2ae6
共有 1 个文件被更改,包括 3 次插入8 次删除
  1. 3 8
      examples/js/loaders/VRMLLoader.js

+ 3 - 8
examples/js/loaders/VRMLLoader.js

@@ -65,7 +65,7 @@ THREE.VRMLLoader.prototype = {
 		var parseV2 = function ( lines, scene ) {
 			var defines = {};
 			var float_pattern = /(\b|\-|\+)([\d\.e]+)/;
-			var float3_pattern = /([\d\.\+\-e]+),?\s+([\d\.\+\-e]+),?\s+([\d\.\+\-e]+)/;
+			var float3_pattern = /([\d\.\+\-e]+)\s+([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g;
 
 			/**
 			* Interpolates colors a and b following their relative distance
@@ -279,10 +279,7 @@ THREE.VRMLLoader.prototype = {
 
 				} else if (this.isRecordingPoints) {
 
-					parts = float3_pattern.exec(line);
-
-					// parts may be empty on first and last line
-					if (null != parts) {
+					while ( null !== ( parts = float3_pattern.exec(line) ) ) {
 						point = {
 							x: parseFloat(parts[1]),
 							y: parseFloat(parts[2]),
@@ -322,10 +319,8 @@ THREE.VRMLLoader.prototype = {
 					}
 
 				} else if (this.isRecordingColors) {
-					// this is the float3 regex with the g modifier added, you could also explode the line by comma first (faster probably)
-					var float3_repeatable = /([\d\.\+\-e]+),?\s+([\d\.\+\-e]+),?\s+([\d\.\+\-e]+)/g;
 
-					while( null !== (parts = float3_repeatable.exec(line) ) ) {
+					while( null !== ( parts = float3_pattern.exec(line) ) ) {
 
 						color = {
 							r: parseFloat(parts[1]),