本文整理汇总了TypeScript中neuroglancer/single_mesh/frontend.VertexChunkData.copyToGPU方法的典型用法代码示例。如果您正苦于以下问题:TypeScript VertexChunkData.copyToGPU方法的具体用法?TypeScript VertexChunkData.copyToGPU怎么用?TypeScript VertexChunkData.copyToGPU使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neuroglancer/single_mesh/frontend.VertexChunkData
的用法示例。
在下文中一共展示了VertexChunkData.copyToGPU方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fragmentShaderTest
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}`);
}
}
});
示例2: 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}`);
}
}
});