From a00c0aab1eb5a7a55bef8ca08115bdd722ab5699 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 16 May 2021 19:50:15 -0400 Subject: Moved the frontend directory up so that it no longer exists --- frontend/_shared/math/line2.js | 63 ------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 frontend/_shared/math/line2.js (limited to 'frontend/_shared/math/line2.js') diff --git a/frontend/_shared/math/line2.js b/frontend/_shared/math/line2.js deleted file mode 100644 index 8b30c1c..0000000 --- a/frontend/_shared/math/line2.js +++ /dev/null @@ -1,63 +0,0 @@ -/// -/// - -/** - * Creates a new line object - * @param {vec2} pStart - * @param {vec2} pEnd - * @param {WebGLRenderingContext} pGl - */ -function line2(pStart, pEnd, pGl, pColor, pMass) { - const lDiffVector = subVec2(pEnd, pStart); - - const lBuffer = pGl.createBuffer(); - pGl.bindBuffer(pGl.ARRAY_BUFFER, lBuffer); - - var lBufferedData = [ - pStart.x, pStart.y, pColor.x, pColor.y, pColor.z, pColor.w, - pEnd.x, pEnd.y, pColor.x, pColor.y, pColor.z, pColor.w - ]; - - pGl.bufferData(pGl.ARRAY_BUFFER, new Float32Array(lBufferedData), pGl.STATIC_DRAW) - pGl.bindBuffer(pGl.ARRAY_BUFFER, undefined); - - var lSlope = (pEnd.y - pStart.y) / (pEnd.x - pStart.x); - - return { - buffer: lBuffer, - start: pStart, - end: pEnd, - slope: lSlope, - normal: normalize2(getPerp2(lDiffVector)), - length: length2(lDiffVector), - mass: pMass, - direction: normalize2(lDiffVector), - velocity: vec2(0, 0), - position: vec2() - }; -} - -function getLine2MomentOfInertia(pLine) { - return (1.0 / 12.0) * pLine.mass * Math.pow(pLine.length, 2); -} - -function getLine2MidPoint(pLine) { - return { - x: (pLine.end.x + pLine.start.x) / 2.0, - y: (pLine.end.y + pLine.start.y) / 2.0 - } -} - -function renderLine2(pGl, pProgramInfo, pLine) { - pGl.uniformMatrix4fv(pProgramInfo.uniformLocations.model, false, mat4()); // Model on a line is always default matrix - pGl.bindBuffer(pGl.ARRAY_BUFFER, pLine.buffer); - { - pGl.enableVertexAttribArray(pProgramInfo.attributeLocations.position); - pGl.vertexAttribPointer(pProgramInfo.attributeLocations.position, 2, pGl.FLOAT, false, BYTES_PER_FLOAT * 6, 0); - - pGl.enableVertexAttribArray(pProgramInfo.attributeLocations.color); - pGl.vertexAttribPointer(pProgramInfo.attributeLocations.color, 4, pGl.FLOAT, false, BYTES_PER_FLOAT * 6, BYTES_PER_FLOAT * 2); - } - - pGl.drawArrays(pGl.LINES, 0, 2); -} \ No newline at end of file -- cgit v1.2.1