import { mat4 } from 'gl-matrix';
import * as macro from 'vtk.js/Sources/macros'; import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode';
import { registerOverride } from 'vtk.js/Sources/Rendering/OpenGL/ViewNodeFactory';
function vtkOpenGLImageSlice(publicAPI, model) { model.classHierarchy.push('vtkOpenGLImageSlice');
publicAPI.buildPass = (prepass) => { if (!model.renderable || !model.renderable.getVisibility()) { return; } if (prepass) { if (!model.renderable) { return; } model._openGLRenderWindow = publicAPI.getLastAncestorOfType( 'vtkOpenGLRenderWindow' ); model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); model.context = model._openGLRenderWindow.getContext(); publicAPI.prepareNodes(); publicAPI.addMissingNode(model.renderable.getMapper()); publicAPI.removeUnusedNodes(); } };
publicAPI.traverseZBufferPass = (renderPass) => { if ( !model.renderable || !model.renderable.getNestedVisibility() || (model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) ) { return; }
publicAPI.apply(renderPass, true); model.children.forEach((child) => { child.traverse(renderPass); }); publicAPI.apply(renderPass, false); };
publicAPI.traverseOpaqueZBufferPass = (renderPass) => publicAPI.traverseOpaquePass(renderPass);
publicAPI.traverseOpaquePass = (renderPass) => { if ( !model.renderable || !model.renderable.getNestedVisibility() || !model.renderable.getIsOpaque() || (model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) ) { return; }
publicAPI.apply(renderPass, true); model.children.forEach((child) => { child.traverse(renderPass); }); publicAPI.apply(renderPass, false); };
publicAPI.traverseTranslucentPass = (renderPass) => { if ( !model.renderable || !model.renderable.getNestedVisibility() || model.renderable.getIsOpaque() || (model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) ) { return; }
publicAPI.apply(renderPass, true); model.children.forEach((child) => { child.traverse(renderPass); }); publicAPI.apply(renderPass, false); };
publicAPI.queryPass = (prepass, renderPass) => { if (prepass) { if (!model.renderable || !model.renderable.getVisibility()) { return; } if (model.renderable.getIsOpaque()) { renderPass.incrementOpaqueActorCount(); } else { renderPass.incrementTranslucentActorCount(); } } };
publicAPI.zBufferPass = (prepass, renderPass) => publicAPI.opaquePass(prepass, renderPass);
publicAPI.opaqueZBufferPass = (prepass, renderPass) => publicAPI.opaquePass(prepass, renderPass);
publicAPI.opaquePass = (prepass, renderPass) => { if (prepass) { model.context.depthMask(true); } };
publicAPI.translucentPass = (prepass, renderPass) => { model.context.depthMask(!prepass); };
publicAPI.getKeyMatrices = () => { if (model.renderable.getMTime() > model.keyMatrixTime.getMTime()) { mat4.copy(model.keyMatrices.mcwc, model.renderable.getMatrix()); mat4.transpose(model.keyMatrices.mcwc, model.keyMatrices.mcwc); model.keyMatrixTime.modified(); }
return model.keyMatrices; }; }
const DEFAULT_VALUES = { context: null, keyMatrixTime: null, keyMatrices: null, };
export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues);
vtkViewNode.extend(publicAPI, model, initialValues);
model.keyMatrixTime = {}; macro.obj(model.keyMatrixTime, { mtime: 0 }); model.keyMatrices = { mcwc: mat4.identity(new Float64Array(16)), };
macro.setGet(publicAPI, model, ['context']);
vtkOpenGLImageSlice(publicAPI, model); }
export const newInstance = macro.newInstance(extend, 'vtkOpenGLImageSlice');
export default { newInstance, extend };
registerOverride('vtkImageSlice', newInstance);
|