src/primitives.js
function deindexVertices(vertices) {
  const indices = vertices.indices;
  const newVertices = {};
  const numElements = indices.length;

  function expandToUnindexed(channel) {
    const srcBuffer = vertices[channel];
    const numComponents = srcBuffer.numComponents;
    const dstBuffer = createAugmentedTypedArray(numComponents, numElements, srcBuffer.constructor);
    for (let ii = 0; ii < numElements; ++ii) {
      const ndx = indices[ii];
      const offset = ndx * numComponents;
      for (let jj = 0; jj < numComponents; ++jj) {
        dstBuffer.push(srcBuffer[offset + jj]);
      }
    }
    newVertices[channel] = dstBuffer;
  }

  Object.keys(vertices).filter(allButIndices).forEach(expandToUnindexed);

  return newVertices;
}
function deindexVertices(vertices) {
  const indices = vertices.indices;
  const newVertices = {};
  const numElements = indices.length;

  function expandToUnindexed(channel) {
    const srcBuffer = vertices[channel];
    const numComponents = srcBuffer.numComponents;
    const dstBuffer = createAugmentedTypedArray(numComponents, numElements, srcBuffer.constructor);
    for (let ii = 0; ii < numElements; ++ii) {
      const ndx = indices[ii];
      const offset = ndx * numComponents;
      for (let jj = 0; jj < numComponents; ++jj) {
        dstBuffer.push(srcBuffer[offset + jj]);
      }
    }
    newVertices[channel] = dstBuffer;
  }

  Object.keys(vertices).filter(allButIndices).forEach(expandToUnindexed);

  return newVertices;
}
function deindexVertices ( vertices ) { const indices = vertices . indices ; const newVertices = { } ; const numElements = indices . length ; function expandToUnindexed ( channel ) { const srcBuffer = vertices [ channel ] ; const numComponents = srcBuffer . numComponents ; const dstBuffer = createAugmentedTypedArray ( numComponents , numElements , srcBuffer . constructor ) ; for ( let ii = 0 ; ii < numElements ; ++ ii ) { const ndx = indices [ ii ] ; const offset = ndx * numComponents ; for ( let jj = 0 ; jj < numComponents ; ++ jj ) { dstBuffer . push ( srcBuffer [ offset + jj ] ) ; } } newVertices [ channel ] = dstBuffer ; } Object . keys ( vertices ) . filter ( allButIndices ) . forEach ( expandToUnindexed ) ; return newVertices ; }
Given indexed vertices creates a new set of vertices unindexed by expanding the indexed vertices.
@param {Object.<string, TypedArray>} vertices The indexed vertices to deindex
@return {Object.<string, TypedArray>} The deindexed vertices
@memberOf module:twgl/primitives
Given indexed vertices creates a new set of vertices unindexed by expanding the indexed vertices .