Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | 1x 16x 16x 182x 182x 182x 182x 182x 182x 182x 182x 16x 196x 98x 1x 16x 16x 16x 1x 1x | // import { mat4, vec3 } 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'; const { vtkDebugMacro } = macro; // ---------------------------------------------------------------------------- // vtkOpenGLPixelSpaceCallbackMapper methods // ---------------------------------------------------------------------------- function vtkOpenGLPixelSpaceCallbackMapper(publicAPI, model) { model.classHierarchy.push('vtkOpenGLPixelSpaceCallbackMapper'); publicAPI.opaquePass = (prepass, renderPass) => { model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); model._openGLRenderWindow = model._openGLRenderer.getLastAncestorOfType( 'vtkOpenGLRenderWindow' ); const aspectRatio = model._openGLRenderer.getAspectRatio(); const camera = model._openGLRenderer ? model._openGLRenderer.getRenderable().getActiveCamera() : null; const tsize = model._openGLRenderer.getTiledSizeAndOrigin(); let texels = null; Iif (model.renderable.getUseZValues()) { const zbt = renderPass.getZBufferTexture(); const width = Math.floor(zbt.getWidth()); const height = Math.floor(zbt.getHeight()); const gl = model._openGLRenderWindow.getContext(); zbt.bind(); // Here we need to use vtkFramebuffer to save current settings (bindings/buffers) const fb = renderPass.getFramebuffer(); if (!fb) { vtkDebugMacro('No framebuffer to save/restore'); } else { // save framebuffer settings fb.saveCurrentBindingsAndBuffers(); } const framebuffer = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, zbt.getHandle(), 0 ); if ( gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE ) { texels = new Uint8Array(width * height * 4); gl.viewport(0, 0, width, height); gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, texels); } // Now we need to restore framebuffer bindings/buffers if (fb) { fb.restorePreviousBindingsAndBuffers(); } gl.deleteFramebuffer(framebuffer); } model.renderable.invokeCallback( model.renderable.getInputData(), camera, aspectRatio, tsize, texels ); }; publicAPI.queryPass = (prepass, renderPass) => { if (prepass) { Iif (model.renderable.getUseZValues()) { renderPass.requestDepth(); } } }; } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance vtkViewNode.extend(publicAPI, model, initialValues); // Object methods vtkOpenGLPixelSpaceCallbackMapper(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance( extend, 'vtkOpenGLPixelSpaceCallbackMapper' ); // ---------------------------------------------------------------------------- export default { newInstance, extend }; // Register ourself to OpenGL backend if imported registerOverride('vtkPixelSpaceCallbackMapper', newInstance); |