Use class Data3Texture in R3F

I would like to convert the following scripts to R3F and got stuck with using Data3Texture since R3F doesn’t have the class.

volumeTexture = {
  const texture = new THREE.Data3DTexture(
    dataValues, // The data values stored in the pixels of the texture.
    dataDescription.xExtent, // Width of texture.
    dataDescription.yExtent, // Height of texture.
    dataDescription.zExtent // Depth of texture.
  );
  
  texture.format = THREE.RedFormat; // Our texture has only one channel (red).
  texture.type = THREE.UnsignedByteType; // The data type is 8 bit unsighed integer.
  texture.minFilter = THREE.LinearFilter; // Linear filter for minification.
  texture.magFilter = THREE.LinearFilter; // Linear filter for maximization.

   // Repeat edge values when sampling outside of texture boundaries.
  texture.wrapS = THREE.ClampToEdgeWrapping;
  texture.wrapT = THREE.ClampToEdgeWrapping;
  texture.wrapR = THREE.ClampToEdgeWrapping;

  // Mark texture for update so that the changes take effect.
  texture.needsUpdate = true;

  // Free texture memory when a notebook cell is invalidated.
  invalidation.then(() => texture.dispose());
  
  return texture;
}

From

Any idea? Thanks

1 Like