Browse Source

VTKLoader: Fix parsing of VTP data with multiple components. (#23684)

* Fix parsing of VTP data with multiple components

Fix parsing of VTP, currently failing when a data item contains multiple
components.
In that case, ele['#text'] is not the compressed data but
an array of 1 element (this data). This makes the parsing fail as Base64toByteArray expects a string.
Use the array's content for parsing.

* Update VTKLoader.js

* Update VTKLoader.js

* Update VTKLoader.js

* Update VTKLoader.js

Co-authored-by: Michael Herzog <[email protected]>
Co-authored-by: mrdoob <[email protected]>
Eino Gourdin 3 năm trước cách đây
mục cha
commit
e30e515f3d

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

@@ -688,8 +688,9 @@
 						// The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
 						// The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
 						// computed by summing the compressed block sizes from preceding blocks according to the header.
 						// computed by summing the compressed block sizes from preceding blocks according to the header.
 
 
+						const textNode = ele[ '#text' ];
+						const rawData = Array.isArray( textNode ) ? textNode[ 0 ] : textNode;
 
 
-						const rawData = ele[ '#text' ];
 						const byteData = Base64toByteArray( rawData );
 						const byteData = Base64toByteArray( rawData );
 						let blocks = byteData[ 0 ];
 						let blocks = byteData[ 0 ];
 
 

+ 2 - 1
examples/jsm/loaders/VTKLoader.js

@@ -736,7 +736,8 @@ class VTKLoader extends Loader {
 					// The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
 					// The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
 					// computed by summing the compressed block sizes from preceding blocks according to the header.
 					// computed by summing the compressed block sizes from preceding blocks according to the header.
 
 
-					const rawData = ele[ '#text' ];
+					const textNode = ele[ '#text' ];
+					const rawData = Array.isArray( textNode ) ? textNode[ 0 ] : textNode;
 
 
 					const byteData = Base64toByteArray( rawData );
 					const byteData = Base64toByteArray( rawData );