for (var i = 0; i < 6; ++i) {
const renderPassDescriptor = {
colorAttachments: [
{
view: renderView,
clearValue: { r: 0, g: 0, b: 0, a: 1.0 },
loadOp: "clear",
storeOp: "store",
},
],
depthStencilAttachment: {
view: depthView,
depthClearValue: 1.0,
depthLoadOp: "clear",
depthStoreOp: "store",
},
};
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setPipeline(pipeline);
passEncoder.setVertexBuffer(0, positionBuffer);
passEncoder.setIndexBuffer(indicesBuffer, "uint32");
passEncoder.setBindGroup(0, vertexBindGroup);
passEncoder.setBindGroup(1, fragmentBindGroup);
passEncoder.drawIndexed(indices.length, 1, 0, 0);
passEncoder.end();
commandEncoder.copyTextureToTexture(
{
texture: renderTexture,
},
{
texture: cubeMap,
origin: [0, 0, i],
},
[1024, 1024]
);
}