• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript frontend.VertexChunkData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap