當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript frontend.VertexChunkData類代碼示例

本文整理匯總了TypeScript中neuroglancer/single_mesh/frontend.VertexChunkData的典型用法代碼示例。如果您正苦於以下問題:TypeScript VertexChunkData類的具體用法?TypeScript VertexChunkData怎麽用?TypeScript VertexChunkData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了VertexChunkData類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('attributes', () => {
    const attributeNames = ['attrA', 'attrB', 'attrC'];
    const attributeInfo: VertexAttributeInfo[] = [];

    let numVertices = 146423;

    const vertexData = new VertexChunkData();
    vertexData.vertexPositions = new Float32Array(numVertices * 3);
    vertexData.vertexNormals = new Float32Array(numVertices * 3);
    for (let i = 0; i < numVertices * 3; ++i) {
      vertexData.vertexPositions[i] = i;
      vertexData.vertexNormals[i] = i + 0.5;
    }

    vertexData.vertexAttributes = [];

    fragmentShaderTest(6, tester => {
      let shaderManager =
          new SingleMeshShaderManager(attributeNames, attributeInfo, /*fragmentMain=*/'');
      const attributeFormats = getAttributeTextureFormats(attributeInfo);

      let {gl, builder} = tester;
      builder.addUniform('highp float', 'vertexIndex');
      builder.addVarying('highp vec3', 'vVertexPosition');
      builder.addVarying('highp vec3', 'vVertexNormal');
      shaderManager.defineAttributeAccess(builder, 'vertexIndex');
      builder.addVertexMain(`
  vVertexPosition = vertexPosition;
  vVertexNormal = vertexNormal;
`);
      builder.setFragmentMain(`
  gl_FragData[0] = packFloatIntoVec4(vVertexPosition.x);
  gl_FragData[1] = packFloatIntoVec4(vVertexPosition.y);
  gl_FragData[2] = packFloatIntoVec4(vVertexPosition.z);
  gl_FragData[3] = packFloatIntoVec4(vVertexNormal.x);
  gl_FragData[4] = packFloatIntoVec4(vVertexNormal.y);
  gl_FragData[5] = packFloatIntoVec4(vVertexNormal.z);
`);
      vertexData.copyToGPU(gl, attributeFormats);
      tester.build();
      let {shader} = tester;
      shader.bind();

      for (let index of [0, 1, 2, 32104, 100201, 143212]) {
        shaderManager.bindVertexData(gl, shader, vertexData);
        gl.uniform1f(shader.uniform('vertexIndex'), index);
        tester.execute();
        let values = new Float32Array(6);
        for (let i = 0; i < 6; ++i) {
          values[i] = tester.readFloat(i);
        }
        for (let i = 0; i < 3; ++i) {
          expect(values[i]).toEqual(
              vertexData.vertexPositions[index * 3 + i], `vertexPositions: index=${index}, i=${i}`);
          expect(values[i + 3])
              .toEqual(
                  vertexData.vertexNormals[index * 3 + i], `vertexNormals: index=${index}, i=${i}`);
        }
      }
    });
  });
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:61,代碼來源:frontend.spec.ts

示例2: it

  it('attributes', () => {
    const attributeNames = ['attrA', 'attrB', 'attrC'];
    const attributeInfo: VertexAttributeInfo[] = [];

    let numVertices = 146423;

    const vertexData = new VertexChunkData();
    vertexData.vertexPositions = new Float32Array(numVertices * 3);
    vertexData.vertexNormals = new Float32Array(numVertices * 3);
    for (let i = 0; i < numVertices * 3; ++i) {
      vertexData.vertexPositions[i] = i;
      vertexData.vertexNormals[i] = i + 0.5;
    }

    vertexData.vertexAttributes = [];

    fragmentShaderTest(
        {
          posX: 'float',
          posY: 'float',
          posZ: 'float',
          normX: 'float',
          normY: 'float',
          normZ: 'float',
        },
        tester => {
          let shaderManager =
              new SingleMeshShaderManager(attributeNames, attributeInfo, /*fragmentMain=*/ '');
          const attributeFormats = getAttributeTextureFormats(attributeInfo);

          let {gl, builder} = tester;
          builder.addUniform('highp uint', 'vertexIndex');
          builder.addVarying('highp vec3', 'vVertexPosition');
          builder.addVarying('highp vec3', 'vVertexNormal');
          shaderManager.defineAttributeAccess(builder, 'vertexIndex');
          builder.addVertexMain(`
  vVertexPosition = vertexPosition;
  vVertexNormal = vertexNormal;
`);
          builder.setFragmentMain(`
  posX = vVertexPosition.x;
  posY = vVertexPosition.y;
  posZ = vVertexPosition.z;
  normX = vVertexNormal.x;
  normY = vVertexNormal.y;
  normZ = vVertexNormal.z;
`);
          vertexData.copyToGPU(gl, attributeFormats);
          tester.build();
          let {shader} = tester;
          shader.bind();

          for (let index of [0, 1, 2, 32104, 100201, 143212]) {
            shaderManager.bindVertexData(gl, shader, vertexData);
            gl.uniform1ui(shader.uniform('vertexIndex'), index);
            tester.execute();
            const {values} = tester;
            const pos = [values.posX, values.posY, values.posZ];
            const norm = [values.normX, values.normY, values.normZ];
            for (let i = 0; i < 3; ++i) {
              expect(pos[i]).toEqual(
                  vertexData.vertexPositions[index * 3 + i],
                  `vertexPositions: index=${index}, i=${i}`);
              expect(norm[i]).toEqual(
                  vertexData.vertexNormals[index * 3 + i], `vertexNormals: index=${index}, i=${i}`);
            }
          }
        });
  });
開發者ID:google,項目名稱:neuroglancer,代碼行數:69,代碼來源:frontend.spec.ts

示例3: SingleMeshShaderManager

    fragmentShaderTest(6, tester => {
      let shaderManager =
          new SingleMeshShaderManager(attributeNames, attributeInfo, /*fragmentMain=*/'');
      const attributeFormats = getAttributeTextureFormats(attributeInfo);

      let {gl, builder} = tester;
      builder.addUniform('highp float', 'vertexIndex');
      builder.addVarying('highp vec3', 'vVertexPosition');
      builder.addVarying('highp vec3', 'vVertexNormal');
      shaderManager.defineAttributeAccess(builder, 'vertexIndex');
      builder.addVertexMain(`
  vVertexPosition = vertexPosition;
  vVertexNormal = vertexNormal;
`);
      builder.addOutputBuffer('vec4', 'v4f_fragData0', 0);
      builder.addOutputBuffer('vec4', 'v4f_fragData1', 1);
      builder.addOutputBuffer('vec4', 'v4f_fragData2', 2);
      builder.addOutputBuffer('vec4', 'v4f_fragData3', 3);
      builder.addOutputBuffer('vec4', 'v4f_fragData4', 4);
      builder.addOutputBuffer('vec4', 'v4f_fragData5', 5);
      builder.setFragmentMain(`
  v4f_fragData0 = packFloatIntoVec4(vVertexPosition.x);
  v4f_fragData1 = packFloatIntoVec4(vVertexPosition.y);
  v4f_fragData2 = packFloatIntoVec4(vVertexPosition.z);
  v4f_fragData3 = packFloatIntoVec4(vVertexNormal.x);
  v4f_fragData4 = packFloatIntoVec4(vVertexNormal.y);
  v4f_fragData5 = packFloatIntoVec4(vVertexNormal.z);
`);
      vertexData.copyToGPU(gl, attributeFormats);
      tester.build();
      //debugger;
      let {shader} = tester;
      shader.bind();

      for (let index of [0, 1, 2, 32104, 100201, 143212]) {
        shaderManager.bindVertexData(gl, shader, vertexData);
        gl.uniform1f(shader.uniform('vertexIndex'), index);
        tester.execute();
        let values = new Float32Array(6);
        for (let i = 0; i < 6; ++i) {
          values[i] = tester.readFloat(i);
        }
        for (let i = 0; i < 3; ++i) {
          expect(values[i]).toEqual(
              vertexData.vertexPositions[index * 3 + i], `vertexPositions: index=${index}, i=${i}`);
          expect(values[i + 3])
              .toEqual(
                  vertexData.vertexNormals[index * 3 + i], `vertexNormals: index=${index}, i=${i}`);
        }
      }
    });
開發者ID:stephenplaza,項目名稱:neuroglancer,代碼行數:51,代碼來源:frontend.spec.ts

示例4: SingleMeshShaderManager

        tester => {
          let shaderManager =
              new SingleMeshShaderManager(attributeNames, attributeInfo, /*fragmentMain=*/ '');
          const attributeFormats = getAttributeTextureFormats(attributeInfo);

          let {gl, builder} = tester;
          builder.addUniform('highp uint', 'vertexIndex');
          builder.addVarying('highp vec3', 'vVertexPosition');
          builder.addVarying('highp vec3', 'vVertexNormal');
          shaderManager.defineAttributeAccess(builder, 'vertexIndex');
          builder.addVertexMain(`
  vVertexPosition = vertexPosition;
  vVertexNormal = vertexNormal;
`);
          builder.setFragmentMain(`
  posX = vVertexPosition.x;
  posY = vVertexPosition.y;
  posZ = vVertexPosition.z;
  normX = vVertexNormal.x;
  normY = vVertexNormal.y;
  normZ = vVertexNormal.z;
`);
          vertexData.copyToGPU(gl, attributeFormats);
          tester.build();
          let {shader} = tester;
          shader.bind();

          for (let index of [0, 1, 2, 32104, 100201, 143212]) {
            shaderManager.bindVertexData(gl, shader, vertexData);
            gl.uniform1ui(shader.uniform('vertexIndex'), index);
            tester.execute();
            const {values} = tester;
            const pos = [values.posX, values.posY, values.posZ];
            const norm = [values.normX, values.normY, values.normZ];
            for (let i = 0; i < 3; ++i) {
              expect(pos[i]).toEqual(
                  vertexData.vertexPositions[index * 3 + i],
                  `vertexPositions: index=${index}, i=${i}`);
              expect(norm[i]).toEqual(
                  vertexData.vertexNormals[index * 3 + i], `vertexNormals: index=${index}, i=${i}`);
            }
          }
        });
開發者ID:google,項目名稱:neuroglancer,代碼行數:43,代碼來源:frontend.spec.ts


注:本文中的neuroglancer/single_mesh/frontend.VertexChunkData類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。