UNPKG

htmol

Version:

NEXT-GENERATION MOLECULAR DYNAMICS WEB VISUALIZATION

1,045 lines (855 loc) 81.8 kB
/* This file is part of HTMoL: Copyright (C) 2014 Dr. Mauricio Carrillo-Tripp http://tripplab.com Developers: v1.0 Leonardo Alvarez-Rivera, Francisco Javier Becerra-Toledo, Adan Vega-Ramirez v2.0 Javier Garcia-Vieyra v3.0 Omar Israel Lara-Ramirez, Eduardo González-Zavala, Emmanuel Quijas-Valades, Julio Cesar González-Vázquez v3.5 Leonardo Alvarez-Rivera */ var AtomArray=[]; function cleanMemory() { LstBSphe=[]; NBSphe=0; //Limpieza de las esferas vertexPositionData = [[]]; ColorTotal = [[]]; indexData = [[]]; normalDataN = [[]]; ChainIndex=[[]]; indiceOffset=0; //////////////////////// //limpieza de los enlaces verticesLineas = []; colores=[]; colorBndDif =[]; linesNormals=[]; ChainIndexBnd=[]; //limpieza de los enlaces Skeleton verLineSkele = []; coloresSkele=[]; colorSkeleBndDif =[]; lineSkeleNor=[]; ChainSkeleIndexBnd=[]; //-------------------Julio //limpieza de los enlaces Spline verLineSpl = []; coloresSpl = []; colorSplBndDif = []; lineSplNor = []; ChainSplIndexBnd = []; //------Julio //////////////// parte de las mediciones diPosition = []; diColor = []; diNormal = []; diIndex = []; chaIndex = []; diColorDif = []; DistanceBool=false; AngleBool=false; indxOffset=0; } function initBuffersSpheresSB() { var atmX= null; var atmY= null; var atmZ= null; var NoAtomos = molecule.LstAtoms.length; NoBloques = Math.ceil(NoAtomos/NoPaso); var Restantes = NoAtomos - ((NoBloques-1) * NoPaso); var ultimo=0; var apuntador = 0; if (NoBloques==1) { LstBSphe[0]=new Array(); for(var i=0; i<NoAtomos; i++) { //----------------------------------------------------------------------------------------- molecule.LstAtoms[apuntador].BloqueSolid=1; molecule.LstAtoms[apuntador].PositionBSolid=i+1; LstBSphe[0].push(molecule.LstAtoms[apuntador]); //----------------------------------------------------------------------------------------- if (DinamicaActiva) //////////*********** checar instrucción { var s=molecule.LstAtoms.length*pos+apuntador; //entonces toman las posiciones x y z del frame en el que se encuentra if(bndbuffer==0) { atmX=coordsX[s]; atmY=coordsY[s]; atmZ=coordsZ[s]; } else { atmX=coordsX1[s]; atmY=coordsY1[s]; atmZ=coordsZ1[s]; } } else { atmX=molecule.LstAtoms[apuntador].X; atmY=molecule.LstAtoms[apuntador].Y; atmZ=molecule.LstAtoms[apuntador].Z; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// molecule.LstAtoms[apuntador].Representation="SB"; for (var z=0; z<verArray.length;) { vertexPositionData[0].push(verArray[z] + atmX -Cx); vertexPositionData[0].push(verArray[z+1] + atmY -Cy); vertexPositionData[0].push(verArray[z+2] + atmZ -Cz); normalDataN[0].push(normalData[z]); normalDataN[0].push(normalData[z+1]); normalDataN[0].push(normalData[z+2]); z=z+3; ColorTotal[0].push(molecule.LstAtoms[apuntador].ColorRGB[0]); ColorTotal[0].push(molecule.LstAtoms[apuntador].ColorRGB[1]); ColorTotal[0].push(molecule.LstAtoms[apuntador].ColorRGB[2]); ColorTotal[0].push(1); ColorTotalDiffuse[0].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[0]); ColorTotalDiffuse[0].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[1]); ColorTotalDiffuse[0].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[2]); ColorTotalDiffuse[0].push(1); ChainIndex[0].push(molecule.LstAtoms[apuntador].idChain); ChainIndex[0].push(molecule.LstAtoms[apuntador].idChain); } for(var t=0; t<indx.length; t++) { indexData[0].push( indx[t] + indiceOffset); } indiceOffset= indiceOffset + indexOff; apuntador=apuntador+1; //----------------------------------------------------------------------------------------------------- } ///////////////////////////////////////// COLORES REALES /////////////////////////////////////////////// sphereVertexPositionBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexPositionBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData[0]), gl.DYNAMIC_DRAW); sphereVertexPositionBuffer[0].itemSize = 3; sphereVertexPositionBuffer[0].numItems = vertexPositionData[0].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("vertices: "+ vertexPositionData[0].length); sphereVertexColorBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotal[0]), gl.DYNAMIC_DRAW); sphereVertexColorBuffer[0].itemSize = 4; sphereVertexColorBuffer[0].numItems = ColorTotal[0].length/4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorTotal: "+ ColorTotal[0].length); ChainBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, ChainBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ChainIndex[0]), gl.DYNAMIC_DRAW); ChainBuffer[0].itemSize = 2; ChainBuffer[0].numItems = ChainIndex[0].length/2; gl.bindBuffer(gl.ARRAY_BUFFER, null); sphereVertexIndexBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sphereVertexIndexBuffer[0]); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData[0]), gl.DYNAMIC_DRAW); sphereVertexIndexBuffer[0].itemSize = 1; sphereVertexIndexBuffer[0].numItems = indexData[0].length; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); //alert("indices: "+indexData[0].length); sphereVertexNormalBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexNormalBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normalDataN[0]), gl.DYNAMIC_DRAW); sphereVertexNormalBuffer[0].itemSize = 3; sphereVertexNormalBuffer[0].numItems = normalDataN[0].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); ////////////////////////////////////////// COLORES DIFFUSOS /////////////////////////////////////////////// sphereVertexColorBufferDiffuse[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBufferDiffuse[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotalDiffuse[0]), gl.DYNAMIC_DRAW); sphereVertexColorBufferDiffuse[0].itemSize = 4; sphereVertexColorBufferDiffuse[0].numItems = ColorTotalDiffuse[0].length/4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorDiffuse: "+ColorTotalDiffuse[0].length); ////////////////////////////////////////////////////////////////////////////////////////////////// } else { for(var i=0; i<NoBloques; i++) { ultimo=0; vertexPositionData[i]=new Array(); normalDataN[i]=new Array(); ColorTotal[i]=new Array(); indexData[i]=new Array(); ColorTotalDiffuse[i]=new Array(); LstBSphe[i]=new Array(); ChainIndex[i]=new Array(); indiceOffset=0; if (i==NoBloques-1) //esto es que llegó al último { for(var j=0; j<Restantes; j++) { molecule.LstAtoms[apuntador].BloqueSolid=i+1; molecule.LstAtoms[apuntador].PositionBSolid=j+1; molecule.LstAtoms[apuntador].Representation="SB"; LstBSphe[i].push(molecule.LstAtoms[apuntador]); //----------------------------------------------------------------------------------------- if (DinamicaActiva) //////////*********** checar instrucción { var s=molecule.LstAtoms.length*pos+apuntador; //entonces toman las posiciones x y z del frame en el que se encuentra if(bndbuffer==0) { atmX=coordsX[s]; atmY=coordsY[s]; atmZ=coordsZ[s]; } else { atmX=coordsX1[s]; atmY=coordsY1[s]; atmZ=coordsZ1[s]; } } else { atmX=molecule.LstAtoms[apuntador].X; atmY=molecule.LstAtoms[apuntador].Y; atmZ=molecule.LstAtoms[apuntador].Z; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for (var z=0; z<verArray.length;) { vertexPositionData[i].push(verArray[z] + atmX -Cx); vertexPositionData[i].push(verArray[z+1] + atmY -Cy); vertexPositionData[i].push(verArray[z+2] + atmZ -Cz); normalDataN[i].push(normalData[z]); normalDataN[i].push(normalData[z+1]); normalDataN[i].push(normalData[z+2]); z=z+3; ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[0]); ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[1]); ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[2]); ColorTotal[i].push(1); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[0]); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[1]); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[2]); ColorTotalDiffuse[i].push(1); ChainIndex[i].push(molecule.LstAtoms[apuntador].idChain); ChainIndex[i].push(molecule.LstAtoms[apuntador].idChain); //ColorDiffuse=ColorDiffuse.concat(molecule.LstAtoms[apuntador].ColorRGBDiffuse); } for(var t=0; t<indx.length; t++) { indexData[i].push( indx[t] + indiceOffset); } indiceOffset= indiceOffset + indexOff; apuntador=apuntador+1; //--------------------------------------------------------------------------------------------------------- } sphereVertexPositionBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexPositionBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData[i]), gl.DYNAMIC_DRAW); sphereVertexPositionBuffer[i].itemSize = 3; sphereVertexPositionBuffer[i].numItems = vertexPositionData[i].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); sphereVertexColorBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotal[i]), gl.DYNAMIC_DRAW); sphereVertexColorBuffer[i].itemSize = 4; sphereVertexColorBuffer[i].numItems = ColorTotal[i].length/4; gl.bindBuffer(gl.ARRAY_BUFFER, null); ChainBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, ChainBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ChainIndex[i]), gl.DYNAMIC_DRAW); ChainBuffer[i].itemSize = 2; ChainBuffer[i].numItems = ChainIndex[i].length/2; gl.bindBuffer(gl.ARRAY_BUFFER, null); sphereVertexIndexBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sphereVertexIndexBuffer[i]); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData[i]), gl.DYNAMIC_DRAW); sphereVertexIndexBuffer[i].itemSize = 1; sphereVertexIndexBuffer[i].numItems = indexData[i].length; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); sphereVertexNormalBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexNormalBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normalDataN[i]), gl.DYNAMIC_DRAW); sphereVertexNormalBuffer[i].itemSize = 3; sphereVertexNormalBuffer[i].numItems = normalDataN[i].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); ///////////////////////////////////////// COLORES DIFFUSOS /////////////////////////////////////////////// sphereVertexColorBufferDiffuse[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBufferDiffuse[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotalDiffuse[i]), gl.DYNAMIC_DRAW); sphereVertexColorBufferDiffuse[i].itemSize = 4; sphereVertexColorBufferDiffuse[i].numItems = ColorTotalDiffuse[i].length/4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorDiffuse: "+ColorTotalDiffuse[0].length); //limpieza normalDataN[i]=[]; indexData[i]=[]; ColorTotalDiffuse[i]=[]; ChainIndex[i]=[]; } else { for (var j=0; j <NoPaso; j++) { //----------------------------------------------------------------------------------------------------------- molecule.LstAtoms[apuntador].BloqueSolid=i+1; molecule.LstAtoms[apuntador].PositionBSolid=j+1; molecule.LstAtoms[apuntador].Representation="SB"; LstBSphe[i].push(molecule.LstAtoms[apuntador]); //----------------------------------------------------------------------------------------- if (DinamicaActiva) //////////*********** checar instrucción { var s=molecule.LstAtoms.length*pos+apuntador; //entonces toman las posiciones x y z del frame en el que se encuentra if(bndbuffer==0) { atmX=coordsX[s]; atmY=coordsY[s]; atmZ=coordsZ[s]; } else { atmX=coordsX1[s]; atmY=coordsY1[s]; atmZ=coordsZ1[s]; } } else { atmX=molecule.LstAtoms[apuntador].X; atmY=molecule.LstAtoms[apuntador].Y; atmZ=molecule.LstAtoms[apuntador].Z; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for (var z=0; z<verArray.length;) { vertexPositionData[i].push(verArray[z] + atmX -Cx); vertexPositionData[i].push(verArray[z+1] + atmY -Cy); vertexPositionData[i].push(verArray[z+2] + atmZ -Cz); normalDataN[i].push(normalData[z]); normalDataN[i].push(normalData[z+1]); normalDataN[i].push(normalData[z+2]); z=z+3; ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[0]); ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[1]); ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[2]); ColorTotal[i].push(1); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[0]); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[1]); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[2]); ColorTotalDiffuse[i].push(1); ChainIndex[i].push(molecule.LstAtoms[apuntador].idChain); ChainIndex[i].push(molecule.LstAtoms[apuntador].idChain); //ColorDiffuse=ColorDiffuse.concat(molecule.LstAtoms[apuntador].ColorRGBDiffuse); } //ColorTotalDiffuse[i]=ColorTotalDiffuse[i].concat(molecule.LstAtoms[apuntador].ColorRGBDiffuse); //estas son las líneas que se congelan //ColorTotal[i]=ColorTotal[i].concat(molecule.LstAtoms[apuntador].ColorRGB); //estas son las líneas que se congelan for(var t=0; t<indx.length; t++) { indexData[i].push( indx[t] + indiceOffset); } indiceOffset= indiceOffset + indexOff; apuntador=apuntador+1; //--------------------------------------------------------------------------------------------------- } sphereVertexPositionBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexPositionBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData[i]), gl.DYNAMIC_DRAW); sphereVertexPositionBuffer[i].itemSize = 3; sphereVertexPositionBuffer[i].numItems = vertexPositionData[i].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); sphereVertexColorBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotal[i]), gl.DYNAMIC_DRAW); sphereVertexColorBuffer[i].itemSize = 4; sphereVertexColorBuffer[i].numItems = ColorTotal[i].length/4; gl.bindBuffer(gl.ARRAY_BUFFER, null); ChainBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, ChainBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ChainIndex[i]), gl.DYNAMIC_DRAW); ChainBuffer[i].itemSize = 2; ChainBuffer[i].numItems = ChainIndex[i].length/2; gl.bindBuffer(gl.ARRAY_BUFFER, null); sphereVertexIndexBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sphereVertexIndexBuffer[i]); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData[i]), gl.DYNAMIC_DRAW); sphereVertexIndexBuffer[i].itemSize = 1; sphereVertexIndexBuffer[i].numItems = indexData[i].length; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); sphereVertexNormalBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexNormalBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normalDataN[i]), gl.DYNAMIC_DRAW); sphereVertexNormalBuffer[i].itemSize = 3; sphereVertexNormalBuffer[i].numItems = normalDataN[i].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); ///////////////////////////////////////// COLORES DIFFUSOS /////////////////////////////////////////////// sphereVertexColorBufferDiffuse[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBufferDiffuse[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotalDiffuse[i]), gl.DYNAMIC_DRAW); sphereVertexColorBufferDiffuse[i].itemSize = 4; sphereVertexColorBufferDiffuse[i].numItems = ColorTotalDiffuse[i].length/4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorDiffuse: "+ColorTotalDiffuse[0].length); ////////////////////////////////////////////////////////////////////////////////////////////////// //limpieza normalDataN[i]=[]; indexData[i]=[]; ColorTotalDiffuse[i]=[]; ChainIndex[i]=[]; } } } NBSphe=NoBloques; } function initBuffersSpheresVDW() { var atmX= null; var atmY= null; var atmZ= null; var NoAtomos = molecule.LstAtoms.length; NoBloques = Math.ceil(NoAtomos / NoPaso); var Restantes = NoAtomos - ((NoBloques - 1) * NoPaso); var ultimo = 0; var apuntador = 0; if (NoBloques == 1) { LstBSphe[0] = new Array(); for (var i = 0; i < NoAtomos; i++) { //----------------------------------------------------------------------------------------- molecule.LstAtoms[apuntador].BloqueSolid = 1; molecule.LstAtoms[apuntador].PositionBSolid = i + 1; molecule.LstAtoms[apuntador].Representation = "VDW"; LstBSphe[0].push(molecule.LstAtoms[apuntador]); //----------------------------------------------------------------------------------------- if (DinamicaActiva) //////////*********** checar instrucción { var s=molecule.LstAtoms.length*pos+apuntador; //entonces toman las posiciones x y z del frame en el que se encuentra if(bndbuffer==0) { atmX=coordsX[s]; atmY=coordsY[s]; atmZ=coordsZ[s]; } else { atmX=coordsX1[s]; atmY=coordsY1[s]; atmZ=coordsZ1[s]; } } else { atmX=molecule.LstAtoms[apuntador].X; atmY=molecule.LstAtoms[apuntador].Y; atmZ=molecule.LstAtoms[apuntador].Z; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (molecule.LstAtoms[apuntador].Element == 'H') { // NameAtom for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayH[z] + atmX - Cx); vertexPositionData[0].push(verArrayH[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayH[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'C') { for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayC_PB_TI_CA[z] + atmX - Cx); vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); z = z + 3; } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'PB') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[0].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'TI') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[0].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'CA') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[0].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[0].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } } else if (molecule.LstAtoms[apuntador].Element == 'N') { for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayN[z] + atmX - Cx); vertexPositionData[0].push(verArrayN[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayN[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'O') { for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayO[z] + atmX - Cx); vertexPositionData[0].push(verArrayO[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayO[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'S') { for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayS[z] + atmX - Cx); vertexPositionData[0].push(verArrayS[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayS[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'P') { for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayP[z] + atmX - Cx); vertexPositionData[0].push(verArrayP[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayP[z + 2] + atmZ - Cz); z = z + 3; } } else { for (var z = 0; z < verArray.length;) { vertexPositionData[0].push(verArrayDefault[z] + atmX - Cx); vertexPositionData[0].push(verArrayDefault[z + 1] + atmY - Cy); vertexPositionData[0].push(verArrayDefault[z + 2] + atmZ - Cz); z = z + 3; } } for (var z = 0; z < verArray.length;) { normalDataN[0].push(normalData[z]); normalDataN[0].push(normalData[z + 1]); normalDataN[0].push(normalData[z + 2]); //////////////////////////////////////////////////////////////////////////////////// z = z + 3; ColorTotal[0].push(molecule.LstAtoms[apuntador].ColorRGB[0]); ColorTotal[0].push(molecule.LstAtoms[apuntador].ColorRGB[1]); ColorTotal[0].push(molecule.LstAtoms[apuntador].ColorRGB[2]); ColorTotal[0].push(1); ChainIndex[0].push(molecule.LstAtoms[apuntador].idChain); ChainIndex[0].push(molecule.LstAtoms[apuntador].idChain); } for(var t=0; t<indx.length; t++) { indexData[0].push( indx[t] + indiceOffset); } indiceOffset= indiceOffset + indexOff; apuntador = apuntador + 1; //----------------------------------------------------------------------------------------------------- } ///////////////////////////////////////// COLORES REALES /////////////////////////////////////////////// sphereVertexPositionBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexPositionBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData[0]), gl.DYNAMIC_DRAW); sphereVertexPositionBuffer[0].itemSize = 3; sphereVertexPositionBuffer[0].numItems = vertexPositionData[0].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("vertices: "+ vertexPositionData[0].length); sphereVertexColorBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotal[0]), gl.DYNAMIC_DRAW); sphereVertexColorBuffer[0].itemSize = 4; sphereVertexColorBuffer[0].numItems = ColorTotal[0].length / 4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorTotal: "+ ColorTotal[0].length); ChainBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, ChainBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ChainIndex[0]), gl.DYNAMIC_DRAW); ChainBuffer[0].itemSize = 2; ChainBuffer[0].numItems = ChainIndex[0].length / 2; gl.bindBuffer(gl.ARRAY_BUFFER, null); sphereVertexIndexBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sphereVertexIndexBuffer[0]); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData[0]), gl.DYNAMIC_DRAW); sphereVertexIndexBuffer[0].itemSize = 1; sphereVertexIndexBuffer[0].numItems = indexData[0].length; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("indices: "+indexData[0].length); sphereVertexNormalBuffer[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexNormalBuffer[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normalDataN[0]), gl.DYNAMIC_DRAW); sphereVertexNormalBuffer[0].itemSize = 3; sphereVertexNormalBuffer[0].numItems = normalDataN[0].length / 3; gl.bindBuffer(gl.ARRAY_BUFFER, null); ////////////////////////////////////////// COLORES DIFFUSOS /////////////////////////////////////////////// sphereVertexColorBufferDiffuse[0] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBufferDiffuse[0]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotalDiffuse[0]), gl.DYNAMIC_DRAW); sphereVertexColorBufferDiffuse[0].itemSize = 4; sphereVertexColorBufferDiffuse[0].numItems = ColorTotalDiffuse[0].length / 4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorDiffuse: "+ColorTotalDiffuse[0].length); ////////////////////////////////////////////////////////////////////////////////////////////////// } else { for (var i = 0; i < NoBloques; i++) { ultimo = 0; vertexPositionData[i] = new Array(); normalDataN[i] = new Array(); ColorTotal[i] = new Array(); indexData[i] = new Array(); ColorTotalDiffuse[i] = new Array(); LstBSphe[i] = new Array(); ChainIndex[i] = new Array(); indiceOffset=0; if (i == NoBloques - 1) //esto es que llegó al último { for (var j = 0; j < Restantes; j++) { //------------------------------------------------------------------------------------------------- molecule.LstAtoms[apuntador].BloqueSolid = i + 1; molecule.LstAtoms[apuntador].PositionBSolid = j + 1; molecule.LstAtoms[apuntador].Representation = "VDW"; LstBSphe[i].push(molecule.LstAtoms[apuntador]); //----------------------------------------------------------------------------------------- if (pos>0) //////////*********** checar instrucción { var s=molecule.LstAtoms.length*pos+apuntador; //entonces toman las posiciones x y z del frame en el que se encuentra if(bndbuffer==0) { atmX=coordsX[s]; atmY=coordsY[s]; atmZ=coordsZ[s]; } else { atmX=coordsX1[s]; atmY=coordsY1[s]; atmZ=coordsZ1[s]; } } else { atmX=molecule.LstAtoms[apuntador].X; atmY=molecule.LstAtoms[apuntador].Y; atmZ=molecule.LstAtoms[apuntador].Z; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //en esta parte se asigna el color al átom AsignaColor(molecule.LstAtoms[apuntador]); if (molecule.LstAtoms[apuntador].Element == 'H') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayH[z] + atmX - Cx); vertexPositionData[i].push(verArrayH[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayH[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'C') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); z = z + 3; } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'PB') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'TI') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'CA') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } } else if (molecule.LstAtoms[apuntador].Element == 'N') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayN[z] + atmX - Cx); vertexPositionData[i].push(verArrayN[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayN[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'O') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayO[z] + atmX - Cx); vertexPositionData[i].push(verArrayO[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayO[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'S') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayS[z] + atmX - Cx); vertexPositionData[i].push(verArrayS[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayS[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'P') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayP[z] + atmX - Cx); vertexPositionData[i].push(verArrayP[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayP[z + 2] + atmZ - Cz); z = z + 3; } } else { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayDefault[z] + atmX - Cx); vertexPositionData[i].push(verArrayDefault[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayDefault[z + 2] + atmZ - Cz); z = z + 3; } } for (var z = 0; z < verArray.length;) { normalDataN[i].push(normalData[z]); normalDataN[i].push(normalData[z + 1]); normalDataN[i].push(normalData[z + 2]); //////////////////////////////////////////////////////////////////////////////////// z = z + 3; ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[0]); ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[1]); ColorTotal[i].push(molecule.LstAtoms[apuntador].ColorRGB[2]); ColorTotal[i].push(1); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[0]); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[1]); ColorTotalDiffuse[i].push(molecule.LstAtoms[apuntador].ColorRGBDiffuse[2]); ColorTotalDiffuse[i].push(1); ChainIndex[i].push(molecule.LstAtoms[apuntador].idChain); ChainIndex[i].push(molecule.LstAtoms[apuntador].idChain); } for(var t=0; t<indx.length; t++) { indexData[i].push( indx[t] + indiceOffset); } indiceOffset= indiceOffset + indexOff; apuntador = apuntador + 1; //--------------------------------------------------------------------------------------------------------- } sphereVertexPositionBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexPositionBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData[i]), gl.DYNAMIC_DRAW); sphereVertexPositionBuffer[i].itemSize = 3; sphereVertexPositionBuffer[i].numItems = (vertexPositionData[i].length / 3) * 1; sphereVertexColorBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotal[i]), gl.DYNAMIC_DRAW); sphereVertexColorBuffer[i].itemSize = 4; sphereVertexColorBuffer[i].numItems = ColorTotal[i].length / 4; ChainBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, ChainBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ChainIndex[i]), gl.DYNAMIC_DRAW); ChainBuffer[i].itemSize = 2; ChainBuffer[i].numItems = ChainIndex[i].length / 2; sphereVertexIndexBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sphereVertexIndexBuffer[i]); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData[i]), gl.DYNAMIC_DRAW); sphereVertexIndexBuffer[i].itemSize = 1; sphereVertexIndexBuffer[i].numItems = indexData[i].length; sphereVertexNormalBuffer[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexNormalBuffer[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normalDataN[i]), gl.DYNAMIC_DRAW); sphereVertexNormalBuffer[i].itemSize = 3; sphereVertexNormalBuffer[i].numItems = (normalDataN[i].length / 3) * 1; ///////////////////////////////////////// COLORES DIFFUSOS /////////////////////////////////////////////// sphereVertexColorBufferDiffuse[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, sphereVertexColorBufferDiffuse[i]); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(ColorTotalDiffuse[i]), gl.DYNAMIC_DRAW); sphereVertexColorBufferDiffuse[i].itemSize = 4; sphereVertexColorBufferDiffuse[i].numItems = ColorTotalDiffuse[i].length / 4; gl.bindBuffer(gl.ARRAY_BUFFER, null); //alert("ColorDiffuse: "+ColorTotalDiffuse[0].length); ////////////////////////////////////////////////////////////////////////////////////////////////// } else { for (var j = 0; j < NoPaso; j++) { //----------------------------------------------------------------------------------------------------------- molecule.LstAtoms[apuntador].BloqueSolid = i + 1; molecule.LstAtoms[apuntador].PositionBSolid = j + 1; molecule.LstAtoms[apuntador].Representation = "VDW"; LstBSphe[i].push(molecule.LstAtoms[apuntador]); //----------------------------------------------------------------------------------------- if (DinamicaActiva) //////////*********** checar instrucción { var s=molecule.LstAtoms.length*pos+apuntador; //entonces toman las posiciones x y z del frame en el que se encuentra if(bndbuffer==0) { atmX=coordsX[s]; atmY=coordsY[s]; atmZ=coordsZ[s]; } else { atmX=coordsX1[s]; atmY=coordsY1[s]; atmZ=coordsZ1[s]; } } else { atmX=molecule.LstAtoms[apuntador].X; atmY=molecule.LstAtoms[apuntador].Y; atmZ=molecule.LstAtoms[apuntador].Z; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (molecule.LstAtoms[apuntador].Element == 'H') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayH[z] + atmX - Cx); vertexPositionData[i].push(verArrayH[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayH[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'C') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); z = z + 3; } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'PB') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // z = z + 3; // } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'TI') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } // } else if (molecule.LstAtoms[apuntador].NameAtom == 'CA') { // for (var z = 0; z < verArray.length;) { // vertexPositionData[i].push(verArrayC_PB_TI_CA[z] + atmX - Cx); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 1] + atmY - Cy); // vertexPositionData[i].push(verArrayC_PB_TI_CA[z + 2] + atmZ - Cz); // // z = z + 3; // } } else if (molecule.LstAtoms[apuntador].Element == 'N') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayN[z] + atmX - Cx); vertexPositionData[i].push(verArrayN[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayN[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'O') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayO[z] + atmX - Cx); vertexPositionData[i].push(verArrayO[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayO[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecule.LstAtoms[apuntador].Element == 'S') { for (var z = 0; z < verArray.length;) { vertexPositionData[i].push(verArrayS[z] + atmX - Cx); vertexPositionData[i].push(verArrayS[z + 1] + atmY - Cy); vertexPositionData[i].push(verArrayS[z + 2] + atmZ - Cz); z = z + 3; } } else if (molecu