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

VTKLoader: Handle invalid DATASET types.

Mugen87 6 жил өмнө
parent
commit
1dd2601bea

+ 15 - 3
examples/js/loaders/VTKLoader.js

@@ -99,7 +99,13 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 
 				var line = lines[ i ];
 				var line = lines[ i ];
 
 
-				if ( inPointsSection ) {
+				if ( line.indexOf( 'DATASET' ) === 0 ) {
+
+					var dataset = line.split( ' ' )[ 1 ];
+
+					if ( dataset !== 'POLYDATA' ) throw new Error( 'Unsupported DATASET type: ' + dataset );
+
+				} else if ( inPointsSection ) {
 
 
 					// get the vertices
 					// get the vertices
 					while ( ( result = pat3Floats.exec( line ) ) !== null ) {
 					while ( ( result = pat3Floats.exec( line ) ) !== null ) {
@@ -354,7 +360,13 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 				state = findString( buffer, index );
 				state = findString( buffer, index );
 				line = state.parsedString;
 				line = state.parsedString;
 
 
-				if ( line.indexOf( 'POINTS' ) === 0 ) {
+				if ( line.indexOf( 'DATASET' ) === 0 ) {
+
+					var dataset = line.split( ' ' )[ 1 ];
+
+					if ( dataset !== 'POLYDATA' ) throw new Error( 'Unsupported DATASET type: ' + dataset );
+
+				} else if ( line.indexOf( 'POINTS' ) === 0 ) {
 
 
 					vtk.push( line );
 					vtk.push( line );
 					// Add the points
 					// Add the points
@@ -1117,7 +1129,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 
 			} else {
 			} else {
 
 
-				// TODO for vtu,vti,and other xml formats
+				throw new Error( 'Unsupported DATASET type' );
 
 
 			}
 			}