UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

49 lines (36 loc) 1.35 kB
import { m_getNumFaces } from "./m_getNumFaces.js"; import { MakeIndex } from "./MakeIndex.js"; import { assert } from "../../../../core/assert.js"; /** * * @param {STriInfo[]} pTriInfos * @param {number[]|Int32Array} piTriList_out * @param {SMikkTSpaceContext } pContext * @param {number} iNrTrianglesIn * @return {number} */ export function GenerateInitialVerticesIndexList(pTriInfos, piTriList_out, pContext, iNrTrianglesIn) { let iTSpacesOffs = 0; let iDstTriIndex = 0; const face_count = m_getNumFaces(pContext); for (let f = 0; f < face_count; f++) { const tri_info = pTriInfos[iDstTriIndex]; tri_info.iOrgFaceNumber = f; tri_info.iTSpacesOffs = iTSpacesOffs; const pVerts = tri_info.vert_num; pVerts[0] = 0; pVerts[1] = 1; pVerts[2] = 2; piTriList_out[iDstTriIndex * 3 ] = MakeIndex(f, 0); piTriList_out[iDstTriIndex * 3 + 1] = MakeIndex(f, 1); piTriList_out[iDstTriIndex * 3 + 2] = MakeIndex(f, 2); ++iDstTriIndex; // next iTSpacesOffs += 3; assert.lessThanOrEqual(iDstTriIndex, iNrTrianglesIn); } for (let t = 0; t < iNrTrianglesIn; t++) { pTriInfos[t].iFlag = 0; } // return total amount of tspaces return iTSpacesOffs; }