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 vtkOpenGLActor2D(publicAPI, model) { model.classHierarchy.push('vtkOpenGLActor2D');
publicAPI.buildPass = (prepass) => { if (prepass) { if (!model.renderable) { return; } model._openGLRenderWindow = publicAPI.getLastAncestorOfType( 'vtkOpenGLRenderWindow' ); model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); model.context = model._openGLRenderWindow.getContext(); publicAPI.prepareNodes(); publicAPI.addMissingNodes(model.renderable.getTextures()); publicAPI.addMissingNode(model.renderable.getMapper()); publicAPI.removeUnusedNodes();
model.ogltextures = null; model.activeTextures = null; for (let index = 0; index < model.children.length; index++) { const child = model.children[index]; if (child.isA('vtkOpenGLTexture')) { if (!model.ogltextures) { model.ogltextures = []; } model.ogltextures.push(child); } else { model.oglmapper = child; } } } };
publicAPI.queryPass = (prepass, renderPass) => { if (prepass) { if (!model.renderable || !model.renderable.getVisibility()) { return; } renderPass.incrementOverlayActorCount(); } };
publicAPI.traverseOpaquePass = (renderPass) => { if ( !model.oglmapper || !model.renderable || !model.renderable.getNestedVisibility() || !model.renderable.getIsOpaque() || (model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) ) { return; }
publicAPI.apply(renderPass, true); model.oglmapper.traverse(renderPass);
publicAPI.apply(renderPass, false); };
publicAPI.traverseTranslucentPass = (renderPass) => { if ( !model.oglmapper || !model.renderable || !model.renderable.getNestedVisibility() || model.renderable.getIsOpaque() || (model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) ) { return; }
publicAPI.apply(renderPass, true); model.oglmapper.traverse(renderPass);
publicAPI.apply(renderPass, false); };
publicAPI.traverseOverlayPass = (renderPass) => { if ( !model.oglmapper || !model.renderable || !model.renderable.getNestedVisibility() || (model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable) ) { return; } publicAPI.apply(renderPass, true); model.oglmapper.traverse(renderPass);
publicAPI.apply(renderPass, false); };
publicAPI.activateTextures = () => { if (!model.ogltextures) { return; }
model.activeTextures = []; for (let index = 0; index < model.ogltextures.length; index++) { const child = model.ogltextures[index]; child.render(); if (child.getHandle()) { model.activeTextures.push(child); } } };
publicAPI.opaquePass = (prepass, renderPass) => { if (prepass) { model.context.depthMask(true); publicAPI.activateTextures(); } else if (model.activeTextures) { for (let index = 0; index < model.activeTextures.length; index++) { model.activeTextures[index].deactivate(); } } };
publicAPI.translucentPass = (prepass, renderPass) => { if (prepass) { model.context.depthMask(false); publicAPI.activateTextures(); } else if (model.activeTextures) { for (let index = 0; index < model.activeTextures.length; index++) { model.activeTextures[index].deactivate(); } } };
publicAPI.overlayPass = (prepass, renderPass) => { if (prepass) { model.context.depthMask(true); publicAPI.activateTextures(); } else if (model.activeTextures) { for (let index = 0; index < model.activeTextures.length; index++) { model.activeTextures[index].deactivate(); } } }; }
const DEFAULT_VALUES = { context: null, activeTextures: null, };
export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues);
vtkViewNode.extend(publicAPI, model, initialValues);
macro.setGet(publicAPI, model, ['context']);
macro.get(publicAPI, model, ['activeTextures']);
vtkOpenGLActor2D(publicAPI, model); }
export const newInstance = macro.newInstance(extend);
export default { newInstance, extend };
registerOverride('vtkActor2D', newInstance);
|