Example of fetching data to a vtkDataArray

Hello,

is there an example to use the “Scalar array reference” explained here https://kitware.github.io/vtk-js/docs/structures_DataArray.html
I couldn’t figure how you can use ref data to ask an url for an array for example.

Thanks in advance for you help

Here is (untested) code that outlines how you can fetch JSON data containing your array values and store them in a vtkDataArray.

const resp = await fetch(URL)
const data = await resp.json()
const dataArray = vtkDataArray.newInstance({
  values: Float32Array.from(data.arrayOfValues),
  numberOfComponents: 1 // or however many components exist per datum
})

Thanks Forrest, that helped a lot !