How to initialize a vtkDataArray with NaN values


I’m trying to initialize a vtkDataArray with NaN values, but I can’t figure out how. The created array always is filled with default 0 values…
I need to do this because I want to rely on NaN colors in the LookupTable of my mapper.

Thanks for your help

Here is a code sample :

const array_values = new Uint8Array(gcns_nb_stars);
array_values.fill(null); // tryied Nan also
console.log(“created array”, array_values);
const scalars = vtkDataArray.newInstance({
name: array_name,
values: array_values,
numberOfComponents: 1

You might be better off using a regular array and passing that as the values.

As I’m coming from the VTK C++ world, I didn’t realize this was an option.

Wonderful ! it’s working.