CompositeCameraManipulator

Methods

computeDisplayCenter

Computes the display center.

Argument Type Required Description
observer Yes
renderer Yes

getCenter

Gets the center.

getDisplayCenter

Gets the display center.

getRotationFactor

Gets the rotation factor.

setCenter

Sets the center.

Argument Type Required Description
center Yes

setDisplayCenter

Sets the display center.

Argument Type Required Description
center Yes

setRotationFactor

Sets the rotation factor.

Argument Type Required Description
factor Yes

Source

index.d.ts
import vtkInteractorObserver from '../../../Rendering/Core/InteractorObserver';
import vtkRenderer from '../../../Rendering/Core/Renderer';
import { Vector2, Vector3 } from '../../../types';

export interface vtkCompositeCameraManipulator {
/**
* Computes the display center.
* @param observer
* @param renderer
*/
computeDisplayCenter(
observer: vtkInteractorObserver,
renderer: vtkRenderer
): void;

/**
* Sets the rotation factor.
* @param factor
*/
setRotationFactor(factor: number): boolean;

/**
* Gets the rotation factor.
*/
getRotationFactor(): number;

/**
* Sets the display center.
* @param center
*/
setDisplayCenter(center: Vector2): boolean;
setDisplayCenter(x: number, y: number): boolean;

/**
* Gets the display center.
*/
getDisplayCenter(): Vector2;

/**
* Sets the center.
* @param center
*/
setCenter(center: Vector3): boolean;
setCenter(x: number, y: number, z: number): boolean;

/**
* Gets the center.
*/
getCenter(): Vector3;
}

export interface ICompositeCameraManipulatorInitialValues {
center?: Vector3;
rotationFactor?: number;
displayCenter?: Vector2;
}

export function extend(
publicAPI: object,
model: object,
initialValues?: ICompositeCameraManipulatorInitialValues
): void;

export const vtkCompositeCameraManipulator: {
extend: typeof extend;
};

export default vtkCompositeCameraManipulator;
index.js
import macro from 'vtk.js/Sources/macros';

// ----------------------------------------------------------------------------
// vtkCompositeCameraManipulator methods
// ----------------------------------------------------------------------------

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

//-------------------------------------------------------------------------
publicAPI.computeDisplayCenter = (iObserver, renderer) => {
const pt = iObserver.computeWorldToDisplay(
renderer,
model.center[0],
model.center[1],
model.center[2]
);
model.displayCenter[0] = pt[0];
model.displayCenter[1] = pt[1];
};
}

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

const DEFAULT_VALUES = {
center: [0, 0, 0],
rotationFactor: 1,
displayCenter: [0, 0],
};

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

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

// Create get-set macros
macro.setGet(publicAPI, model, ['rotationFactor']);
macro.setGetArray(publicAPI, model, ['displayCenter'], 2);
macro.setGetArray(publicAPI, model, ['center'], 3);

// Object specific methods
vtkCompositeCameraManipulator(publicAPI, model);
}

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

export default { extend };