UNPKG

@kitware/vtk.js

Version:

Visualization Toolkit for the Web

4 lines (2 loc) 2.65 kB
var vtkStickMapperVS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkStickMapperVS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// this shader implements imposters in OpenGL for Sticks\n\nattribute vec4 vertexMC;\nattribute vec3 orientMC;\nattribute vec4 offsetMC;\nattribute float radiusMC;\n\n// optional normal declaration\n//VTK::Normal::Dec\n\n//VTK::Picking::Dec\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\nuniform mat3 normalMatrix; // transform model coordinate directions to view coordinates\n\n// material property values\n//VTK::Color::Dec\n\n// clipping plane vars\n//VTK::Clip::Dec\n\n// camera and actor matrix values\n//VTK::Camera::Dec\n\nvarying vec4 vertexVCVSOutput;\nvarying float radiusVCVSOutput;\nvarying float lengthVCVSOutput;\nvarying vec3 centerVCVSOutput;\nvarying vec3 orientVCVSOutput;\n\nuniform int cameraParallel;\n\nvoid main()\n{\n //VTK::Picking::Impl\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Clip::Impl\n\n vertexVCVSOutput = MCVCMatrix * vertexMC;\n centerVCVSOutput = vertexVCVSOutput.xyz;\n radiusVCVSOutput = radiusMC;\n lengthVCVSOutput = length(orientMC);\n orientVCVSOutput = normalMatrix * normalize(orientMC);\n\n // make sure it is pointing out of the screen\n if (orientVCVSOutput.z < 0.0)\n {\n orientVCVSOutput = -orientVCVSOutput;\n }\n\n // make the basis\n vec3 xbase;\n vec3 ybase;\n vec3 dir = vec3(0.0,0.0,1.0);\n if (cameraParallel == 0)\n {\n dir = normalize(-vertexVCVSOutput.xyz);\n }\n if (abs(dot(dir,orientVCVSOutput)) == 1.0)\n {\n xbase = normalize(cross(vec3(0.0,1.0,0.0),orientVCVSOutput));\n ybase = cross(xbase,orientVCVSOutput);\n }\n else\n {\n xbase = normalize(cross(orientVCVSOutput,dir));\n ybase = cross(orientVCVSOutput,xbase);\n }\n\n vec3 offsets = offsetMC.xyz*2.0-1.0;\n vertexVCVSOutput.xyz = vertexVCVSOutput.xyz +\n radiusVCVSOutput*offsets.x*xbase +\n radiusVCVSOutput*offsets.y*ybase +\n 0.5*lengthVCVSOutput*offsets.z*orientVCVSOutput;\n\n gl_Position = VCPCMatrix * vertexVCVSOutput;\n}\n"; export { vtkStickMapperVS as v };