Skip to content

VTP parsing fails for DataArray with multiple components #23683

@eino

Description

@eino

Describe the bug

Using VTKLoader to parse a VTP file containing DataArrays with multiple components
fails with a parsing error

To Reproduce

Steps to reproduce the behavior:

  1. Save face.vtp that it attached to the bug face.zip
  2. Try to load it with VTKLoader

Code

import { VTKLoader} from 'three/examples/jsm/loaders/VTKLoader.js';
// ...
var loader1 = new VTKLoader();
    loader1.load( 'face.vtp',
    function ( geometry ) {
});

Loading fails with the following error

VTKLoader.js?e3d9:42 Error: Invalid string. Length must be a multiple of 4
    at Base64toByteArray (VTKLoader.js?e3d9:661:1)
    at parseDataArray (VTKLoader.js?e3d9:741:1)
    at parseXML (VTKLoader.js?e3d9:928:1)
    at VTKLoader.parse (VTKLoader.js?e3d9:1135:1)
    at Object.eval [as onLoad] (VTKLoader.js?e3d9:32:1)
    at eval (three.module.js?5a89:39645:1)

Expected behavior

VTP file is loaded

Platform:

  • Device: Desktop
  • OS: Linux
  • Browser: Chrome, Firefox
  • Three.js version: r138

PR

The issue is that in parseDataArray, rather than the usual/expected string, the data is in form of an array, containing 1 element (the compressed string). If using this first element as string, parsing works as expected.
I hope you don't mind, I started a PR to fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions