ViewNodeFactory

factory that chooses vtkViewNodes to create specific to WebGL

Registers functions to create WebGL ViewNodes for vtk

registerOverride(apiName, createFunc)

Give a function pointer to a class that will manufacture a
vtkViewNode when given a class name string.

createNode(apiName)

Creates and returns a vtkViewNode for the provided renderable.

Source

index.js
import macro from 'vtk.js/Sources/macro';
import vtkViewNodeFactory from 'vtk.js/Sources/Rendering/SceneGraph/ViewNodeFactory';

const CLASS_MAPPING = Object.create(null);

export function registerOverride(className, fn) {
CLASS_MAPPING[className] = fn;
}

// ----------------------------------------------------------------------------
// vtkOpenGLViewNodeFactory methods
// ----------------------------------------------------------------------------

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

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

const DEFAULT_VALUES = {};

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

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

// Static class mapping shared across instances
model.overrides = CLASS_MAPPING;

// Inheritance
vtkViewNodeFactory.extend(publicAPI, model, initialValues);

// Object methods
vtkOpenGLViewNodeFactory(publicAPI, model);
}

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

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

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

export default { newInstance, extend };