Преглед изворни кода

Fixed regular expression so that they match better and more efficiently (without leading whitespace). None of my old VRML models could be loaded using the previous versions of the regexes.

Bart McLeod пре 12 година
родитељ
комит
9cd8eedf2a
1 измењених фајлова са 5 додато и 5 уклоњено
  1. 5 5
      examples/js/loaders/VRMLLoader.js

+ 5 - 5
examples/js/loaders/VRMLLoader.js

@@ -91,9 +91,9 @@ THREE.VRMLLoader.prototype = {
 			}
 
 			var defines = {};
-			var float_pattern = /( +[\d|\.|\+|\-|e]+)/;
-			var float3_pattern = /( +[\d|\.|\+|\-|e]+),?( +[\d|\.|\+|\-|e]+),?( +[\d|\.|\+|\-|e]+)/;
-			var float4_pattern = /( +[\d|\.|\+|\-|e]+),?( +[\d|\.|\+|\-|e]+),?( +[\d|\.|\+|\-|e]+),?( +[\d|\.|\+|\-|e]+)/;
+			var float_pattern = /\s+([\d|\.|\+|\-|e]+)/;
+			var float3_pattern = /\s+([\d|\.|\+|\-|e]+),?\s+([\d|\.|\+|\-|e]+),?\s+([\d|\.|\+|\-|e]+)/;
+			var float4_pattern = /\s+([\d|\.|\+|\-|e]+),?\s+([\d|\.|\+|\-|e]+),?\s+([\d|\.|\+|\-|e]+),?\s+([\d|\.|\+|\-|e]+)/;
 
 			var parseNode = function ( data, parent ) {
 
@@ -257,7 +257,7 @@ THREE.VRMLLoader.prototype = {
 
 					} else if ( /Sphere/.exec( data.string ) ) {
 
-						var result = /radius( +[\d|\.|\+|\-|e]+)/.exec( data.children[ 0 ] );
+						var result = /radius\s+([\d|\.|\+|\-|e]+)/.exec( data.children[ 0 ] );
 
 						parent.geometry = new THREE.SphereGeometry( parseFloat( result[ 1 ] ) );
 
@@ -311,7 +311,7 @@ THREE.VRMLLoader.prototype = {
 
 								} else if ( /transparency/.exec( parameter ) ) {
 
-									var result = /( +[\d|\.|\+|\-|e]+)/.exec( parameter );
+									var result = /\s+([\d|\.|\+|\-|e]+)/.exec( parameter );
 
 									material.opacity = parseFloat( result[ 1 ] );
 									material.transparent = true;

粤ICP备19079148号