Browse Source

VTKLoader: Support Int32 DataArray, and allow tabs in XML

Trevor Blackwell 7 years ago
parent
commit
2ca4891a66
1 changed files with 6 additions and 2 deletions
  1. 6 2
      examples/js/loaders/VTKLoader.js

+ 6 - 2
examples/js/loaders/VTKLoader.js

@@ -851,7 +851,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 						if ( ele[ '#text' ] ) {
 
-							var content = ele[ '#text' ].replace( /\n/g, ' ' ).split( ' ' ).filter( function ( el ) {
+							var content = ele[ '#text' ].split( /s+/ ).filter( function ( el ) {
 
 								if ( el !== '' ) return el;
 
@@ -872,6 +872,10 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 						var txt = new Float32Array( content );
 
+          } else if ( ele.attributes.type == 'Int32' ) {
+
+            var txt = new Int32Array( content );
+
 					} else if ( ele.attributes.type === 'Int64' ) {
 
 						var txt = new Int32Array( content );
@@ -959,7 +963,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
 
 					// If it has a DataArray in it
 
-					if ( section.DataArray ) {
+					if ( section && section.DataArray ) {
 
 						// Depending on the number of DataArrays