Texture

Introduction

vtkTexture is an image algorithm that handles loading and binding of texture maps.
It obtains its data from an input image data dataset type.
Thus you can create visualization pipelines to read, process, and construct textures.
Note that textures will only work if texture coordinates are also defined, and if the rendering system supports texture.

Methods

extend

Method use to decorate a given object (publicAPI+model) with vtkTexture characteristics.

Argument Type Required Description
publicAPI Yes object on which methods will be bounds (public)
model Yes object on which data structure will be bounds (protected)
initialValues ITextureInitialValues No (default: {})

getEdgeClamp

getImage

getImageLoaded

getInterpolate

getRepeat

newInstance

Method use to create a new instance of vtkTexture.

Argument Type Required Description
initialValues ITextureInitialValues No for pre-setting some of its content

setEdgeClamp

Argument Type Required Description
edgeClamp Yes

setImage

Argument Type Required Description
image Yes

setInterpolate

Argument Type Required Description
interpolate Yes

setRepeat

Argument Type Required Description
repeat Yes

Source

index.d.ts
import { vtkAlgorithm } from "../../../interfaces";

export interface ITextureInitialValues {
repeat?: boolean;
interpolate?: boolean;
edgeClamp?: boolean;
imageLoaded?: boolean;
}

export interface vtkTexture extends vtkAlgorithm {

/**
*
*/
getRepeat(): boolean;

/**
*
*/
getEdgeClamp(): boolean;

/**
*
*/
getInterpolate(): boolean;

/**
*
*/
getImage(): any;

/**
*
*/
getImageLoaded(): boolean;

/**
*
* @param repeat
* @default false
*/
setRepeat(repeat: boolean): boolean;

/**
*
* @param edgeClamp
* @default false
*/
setEdgeClamp(edgeClamp: boolean): boolean;

/**
*
* @param interpolate
* @default false
*/
setInterpolate(interpolate: boolean): boolean;


/**
*
* @param image
* @default null
*/
setImage(image: any): void;
}

/**
* Method use to decorate a given object (publicAPI+model) with vtkTexture characteristics.
*
* @param publicAPI object on which methods will be bounds (public)
* @param model object on which data structure will be bounds (protected)
* @param {ITextureInitialValues} [initialValues] (default: {})
*/
export function extend(publicAPI: object, model: object, initialValues?: ITextureInitialValues): void;

/**
* Method use to create a new instance of vtkTexture.
* @param {ITextureInitialValues} [initialValues] for pre-setting some of its content
*/
export function newInstance(initialValues?: ITextureInitialValues): vtkTexture;

/**
* vtkTexture is an image algorithm that handles loading and binding of texture maps.
* It obtains its data from an input image data dataset type.
* Thus you can create visualization pipelines to read, process, and construct textures.
* Note that textures will only work if texture coordinates are also defined, and if the rendering system supports texture.
*/
export declare const vtkTexture: {
newInstance: typeof newInstance,
extend: typeof extend,
};
export default vtkTexture;
index.js
import macro from 'vtk.js/Sources/macros';

// ----------------------------------------------------------------------------
// vtkTexture methods
// ----------------------------------------------------------------------------

function vtkTexture(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkTexture');

publicAPI.imageLoaded = () => {
model.image.removeEventListener('load', publicAPI.imageLoaded);
model.imageLoaded = true;
publicAPI.modified();
};

publicAPI.setImage = (image) => {
if (model.image === image) {
return;
}

if (image !== null) {
publicAPI.setInputData(null);
publicAPI.setInputConnection(null);
}

model.image = image;
model.imageLoaded = false;

if (image.complete) {
publicAPI.imageLoaded();
} else {
image.addEventListener('load', publicAPI.imageLoaded);
}

publicAPI.modified();
};
}

// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------

const DEFAULT_VALUES = {
repeat: false,
interpolate: false,
edgeClamp: false,
image: null,
imageLoaded: false,
};

// ----------------------------------------------------------------------------

export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);

// Build VTK API
macro.obj(publicAPI, model);
macro.algo(publicAPI, model, 6, 0);

macro.get(publicAPI, model, ['imageLoaded']);

macro.setGet(publicAPI, model, [
'repeat',
'edgeClamp',
'interpolate',
'image',
]);

vtkTexture(publicAPI, model);
}

// ----------------------------------------------------------------------------

export const newInstance = macro.newInstance(extend, 'vtkTexture');

// ----------------------------------------------------------------------------

export default { newInstance, extend };