2
0
Эх сурвалжийг харах

VRMLLoader: Improve version check.

Mugen87 5 жил өмнө
parent
commit
a037a0dbc3

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

@@ -3129,18 +3129,18 @@ THREE.VRMLLoader = ( function () {
 			var textureLoader = new THREE.TextureLoader( this.manager );
 			textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
 
-			// create JSON representing the tree structure of the VRML asset
-
-			var tree = generateVRMLTree( data );
-
 			// check version (only 2.0 is supported)
 
-			if ( tree.version.indexOf( 'V2.0' ) === - 1 ) {
+			if ( data.indexOf( '#VRML V2.0' ) === - 1 ) {
 
 				throw Error( 'THREE.VRMLLexer: Version of VRML asset not supported.' );
 
 			}
 
+			// create JSON representing the tree structure of the VRML asset
+
+			var tree = generateVRMLTree( data );
+
 			// parse the tree structure to a three.js scene
 
 			var scene = parseTree( tree );

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

@@ -3167,18 +3167,18 @@ var VRMLLoader = ( function () {
 			var textureLoader = new TextureLoader( this.manager );
 			textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
 
-			// create JSON representing the tree structure of the VRML asset
-
-			var tree = generateVRMLTree( data );
-
 			// check version (only 2.0 is supported)
 
-			if ( tree.version.indexOf( 'V2.0' ) === - 1 ) {
+			if ( data.indexOf( '#VRML V2.0' ) === - 1 ) {
 
 				throw Error( 'THREE.VRMLLexer: Version of VRML asset not supported.' );
 
 			}
 
+			// create JSON representing the tree structure of the VRML asset
+
+			var tree = generateVRMLTree( data );
+
 			// parse the tree structure to a three.js scene
 
 			var scene = parseTree( tree );