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


TypeScript geom.vec4類代碼示例

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


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

示例1: describe

 describe(`random values out of ${numPossibleValues} possible`, () => {
   const dataType = DataType.UINT64;
   for (let volumeSize of [vec4.fromValues(64, 64, 64, 1), vec4.fromValues(36, 36, 36, 1), ]) {
     const numElements = prod4(volumeSize);
     let rawData = makeRandomUint64Array(numElements, numPossibleValues);
     runTest(dataType, volumeSize, rawData, vec888);
   }
 });
開發者ID:funkey,項目名稱:neuroglancer,代碼行數:8,代碼來源:chunk_format.spec.ts

示例2: testPair

 function testPair(a: number, b: number) {
   let result = (a + b) >>> 0;
   gl.uniform4fv(shader.uniform('uValue1'), setVec4FromUint32(vec4.create(), a));
   gl.uniform4fv(shader.uniform('uValue2'), setVec4FromUint32(vec4.create(), b));
   tester.execute();
   let value = tester.readUint32();
   expect(value).toEqual(result, `${a} + ${b}`);
 }
開發者ID:stephenplaza,項目名稱:neuroglancer,代碼行數:8,代碼來源:shader_lib.spec.ts

示例3: fragmentShaderTest

 fragmentShaderTest(1, tester => {
   let {gl, builder} = tester;
   builder.addUniform('vec4', 'inputValue');
   builder.setFragmentMain(`gl_FragData[0] = inputValue;`);
   tester.build();
   let {shader} = tester;
   let inputValue = vec4.fromValues(0, 64 / 255, 128 / 255, 192 / 255);
   shader.bind();
   gl.uniform4fv(shader.uniform('inputValue'), inputValue);
   tester.execute();
   let outputValue = tester.readVec4();
   expect(outputValue).toEqual(inputValue);
 });
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:13,代碼來源:shader_testing.spec.ts

示例4: fragmentShaderTest

       fragmentShaderTest(outputChannelsPerChannel * numChannels, tester => {
         let {gl, builder} = tester;
         let [chunkFormat, textureLayout] = getChunkFormatAndTextureLayout(gl);
         builder.addUniform('vec3', 'vChunkPosition');
         builder.addUniform('vec3', 'uChunkDataSize');
         builder.addFragmentCode(glsl_getPositionWithinChunk);
         chunkFormat.defineShader(builder);
         {
           let fragmentMain = '';
           let outputChannel = 0;
           for (let channel = 0; channel < numChannels; ++channel) {
             switch (dataType) {
               case DataType.UINT64:
                 builder.addOutputBuffer('vec4', `v4f_fragData${outputChannel}`, outputChannel);
                 builder.addOutputBuffer('vec4', `v4f_fragData${outputChannel + 1}`, outputChannel + 1);
                 fragmentMain += `
{
  uint64_t value = getDataValue(${channel});
  v4f_fragData${outputChannel++} = value.low;
  v4f_fragData${outputChannel++} = value.high;
}
`;
                 break;
               case DataType.UINT8:
                 builder.addOutputBuffer('vec4', `v4f_fragData${outputChannel}`, outputChannel);
                 fragmentMain += `
v4f_fragData${outputChannel++} = vec4(getDataValue(${channel}).value, 0, 0, 0);
`;
                 break;
               case DataType.FLOAT32:
                 builder.addOutputBuffer('vec4', `v4f_fragData${outputChannel}`, outputChannel);
                 fragmentMain += `
v4f_fragData${outputChannel++} = packFloatIntoVec4(getDataValue(${channel}));
`;
                 break;
               case DataType.UINT16:
                 builder.addOutputBuffer('vec4', `v4f_fragData${outputChannel}`, outputChannel);
                 fragmentMain += `
v4f_fragData${outputChannel++} = vec4(getDataValue(${channel}).value, 0, 0);
`;
                 break;
               case DataType.UINT32:
                 builder.addOutputBuffer('vec4', `v4f_fragData${outputChannel}`, outputChannel);
                 fragmentMain += `
v4f_fragData${outputChannel++} = getDataValue(${channel}).value;
`;
                 break;
             }
           }
           builder.setFragmentMain(fragmentMain);
         }
         tester.build();
         let {shader} = tester;
         shader.bind();
         gl.uniform3fv(shader.uniform('uChunkDataSize'), volumeSize.subarray(0, 3));

         let texture = gl.createTexture();
         tester.registerDisposer(() => {
           gl.deleteTexture(texture);
         });

         chunkFormat.beginDrawing(gl, shader);
         gl.bindTexture(gl.TEXTURE_2D, texture);
         chunkFormat.setTextureData(gl, textureLayout, encodedData);
         chunkFormat.setupTextureLayout(gl, shader, textureLayout);


         // Position within chunk in floating point range [0, chunkDataSize].
         function checkPosition(positionInChunk: vec3) {
           gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
           chunkFormat.beginDrawing(gl, shader);
           chunkFormat.beginSource(gl, shader);
           chunkFormat.setupTextureLayout(gl, shader, textureLayout);
           gl.bindTexture(gl.TEXTURE_2D, texture);
           tester.execute();
           chunkFormat.endDrawing(gl, shader);
           let offset = 0;
           for (let i = 0; i < 3; ++i) {
             offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
                 strides[i];
           }
           let outputChannel = 0;
           for (let channel = 0; channel < numChannels; ++channel) {
             const curOffset = offset + channel * strides[3];
             const msg = `volumeSize = ${vec3Key(volumeSize)}, ` +
                 `positionInChunk = ${vec3Key(positionInChunk)}, ` +
                 `channel = ${channel}, offset = ${curOffset}`;
             switch (dataType) {
               case DataType.UINT64: {
                 let low = tester.readUint32(outputChannel++);
                 let high = tester.readUint32(outputChannel++);
                 expect(low).toBe(rawData[curOffset * 2], `${msg} (low)`);
                 expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
                 break;
               }
               case DataType.FLOAT32: {
                 let result = tester.readFloat(outputChannel++);
                 expect(result).toBe(rawData[curOffset], msg);
                 break;
               }
//.........這裏部分代碼省略.........
開發者ID:stephenplaza,項目名稱:neuroglancer,代碼行數:101,代碼來源:chunk_format_testing.ts

示例5: it

 it('serializeColor works', () => {
   expect(serializeColor(vec3.fromValues(0x12 / 255, 0x34 / 255, 0x56 / 255))).toEqual('#123456');
   expect(serializeColor(vec4.fromValues(101 / 255, 102 / 255, 103 / 255, 0.45)))
       .toEqual('rgba(101, 102, 103, 0.45)');
 });
開發者ID:google,項目名稱:neuroglancer,代碼行數:5,代碼來源:color.spec.ts

示例6: checkPosition

       fragmentShaderTest(outputs, tester => {
         let {gl, builder} = tester;
         let [chunkFormat, textureLayout] = getChunkFormatAndTextureLayout(gl);
         builder.addUniform('highp vec3', 'vChunkPosition');
         builder.addUniform('vec3', 'uChunkDataSize');
         builder.addFragmentCode(glsl_getPositionWithinChunk);
         chunkFormat.defineShader(builder);
         {
           let fragmentMain = '';
           for (let channel = 0; channel < numChannels; ++channel) {
             switch (dataType) {
               case DataType.UINT64:
                 fragmentMain += `
{
  uint64_t value = getDataValue(${channel});
  output${channel}Low = value.value[0];
  output${channel}High = value.value[1];
}
`;
                 break;
               case DataType.FLOAT32:
                 fragmentMain += `
output${channel} = getDataValue(${channel});
`;
                 break;
               default:
                 fragmentMain += `
output${channel} = getDataValue(${channel}).value;
`;
                 break;
             }
           }
           builder.setFragmentMain(fragmentMain);
         }
         tester.build();
         let {shader} = tester;
         shader.bind();
         gl.uniform3fv(shader.uniform('uChunkDataSize'), volumeSize.subarray(0, 3));

         let texture = gl.createTexture();
         tester.registerDisposer(() => {
           gl.deleteTexture(texture);
         });
         const textureTarget = textureTargetForSamplerType[chunkFormat.shaderSamplerType];
         chunkFormat.beginDrawing(gl, shader);
         gl.bindTexture(textureTarget, texture);
         chunkFormat.setTextureData(gl, textureLayout, encodedData);
         chunkFormat.setupTextureLayout(gl, shader, textureLayout);


         // Position within chunk in floating point range [0, chunkDataSize].
         function checkPosition(positionInChunk: vec3) {
           gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
           chunkFormat.beginDrawing(gl, shader);
           chunkFormat.beginSource(gl, shader);
           chunkFormat.setupTextureLayout(gl, shader, textureLayout);
           gl.bindTexture(textureTarget, texture);
           tester.execute();
           chunkFormat.endDrawing(gl, shader);
           let offset = 0;
           for (let i = 0; i < 3; ++i) {
             offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
                 strides[i];
           }
           const values = tester.values;
           for (let channel = 0; channel < numChannels; ++channel) {
             const curOffset = offset + channel * strides[3];
             const msg = `volumeSize = ${vec3Key(volumeSize)}, ` +
                 `positionInChunk = ${vec3Key(positionInChunk)}, ` +
                 `channel = ${channel}, offset = ${curOffset}`;
             switch (dataType) {
               case DataType.UINT64: {
                 let low = values[`output${channel}Low`];
                 let high = values[`output${channel}High`];
                 expect(low).toBe(rawData[curOffset * 2], `${msg} (low)`);
                 expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
                 break;
               }
               default: {
                 let result = values[`output${channel}`];
                 expect(result).toBe(rawData[curOffset], msg);
                 break;
               }
             }
           }
         }
         checkPosition(vec3.fromValues(0, 0, 0));
         checkPosition(vec3.fromValues(0, 0, 1));
         checkPosition(vec3.fromValues(0, 1, 0));
         checkPosition(vec3.fromValues(0, volumeSize[1], 0));
         checkPosition(vec3.fromValues(0, volumeSize[1], volumeSize[2]));
         checkPosition(vec3.fromValues(volumeSize[0], volumeSize[1], volumeSize[2]));
         checkPosition(vec3.fromValues(volumeSize[0] - 1, 1, 1));

         const COUNT = 100;
         for (let iter = 0; iter < COUNT; ++iter) {
           let vChunkPosition = vec3.create();
           for (let i = 0; i < 3; ++i) {
             vChunkPosition[i] = Math.random() * volumeSize[i];
           }
//.........這裏部分代碼省略.........
開發者ID:google,項目名稱:neuroglancer,代碼行數:101,代碼來源:chunk_format_testing.ts


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