소스 검색

Reduce nodes to render for multiresrec.

pull/880/head
Nico Höllerich 4 년 전
부모
커밋
ca02dcfbe2
1개의 변경된 파일66개의 추가작업 그리고 31개의 파일을 삭제
  1. +66
    -31
      src/js/libpannellum.js

+ 66
- 31
src/js/libpannellum.js 파일 보기

@@ -1036,48 +1036,83 @@ function Renderer(container) {
* @private
*/
function multiresrecDraw() {
if (!program.drawInProgress) {
program.drawInProgress = true;
gl.clear(gl.COLOR_BUFFER_BIT);

var draw = (node) => {
//transform input parameters from [-1,1]² to [0,1]² in screen coordinates (i.e. y-axis pointing downwards)
let v = node.vertices;
if (program.drawInProgress || !program.currentNodes.length)
return;

// Upload extents of tile relative to full panorama
gl.uniform1f(program.bb, (-v[0][1] + 1) / 2);
gl.uniform1f(program.br, (v[1][0] + 1) / 2);
gl.uniform1f(program.bt, (-v[2][1] + 1) / 2);
gl.uniform1f(program.bl, (v[3][0] + 1) / 2);

// Prep for texture
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
gl.vertexAttribPointer(program.texCoordLocation, 2, gl.FLOAT, false, 0, 0);
program.drawInProgress = true;
gl.clear(gl.COLOR_BUFFER_BIT);

// Bind texture and draw tile
gl.bindTexture(gl.TEXTURE_2D, node.texture); // Bind node.texture to TEXTURE0
gl.drawArrays(gl.TRIANGLES, 0, 6);
}
var parentNodes = [];
var nodesToRender = [];
var nodes = program.currentNodes;
var currentMaxLevel = nodes[nodes.length - 1].level;

gl.uniform1f(program.tilePaddingX, 0);
gl.uniform1f(program.tilePaddingY, 0);
for (var node of program.currentNodes) {
for (var i = nodes.length - 1; i >= 0; i--) {
var node = nodes[i];
if (node.level == currentMaxLevel) {
if (node.textureLoaded > 1)
draw(node);
nodesToRender.unshift(node);
else parentNodes.push({
x: Math.floor(node.x / 2),
y: Math.floor(node.y / 2),
level: node.level - 1
});
} else if (!parentNodes.length) {
break;
} else {
for (var parent of parentNodes) {
if (parent.x == node.x && parent.y == node.y && parent.level == node.level) {
if (node.textureLoaded > 1)
nodesToRender.unshift(node);
else parentNodes.push({
x: Math.floor(node.x / 2),
y: Math.floor(node.y / 2),
level: node.level - 1
});
break;
}
}
}
}

if (globalParams.interpolateBetweenTiles) {
gl.uniform1f(program.tilePaddingX, texelWidth / 4);
gl.uniform1f(program.tilePaddingY, texelHeight / 4);
var draw = (node) => {
//transform input parameters from [-1,1]² to [0,1]² in screen coordinates (i.e. y-axis pointing downwards)
let v = node.vertices;

// Upload extents of tile relative to full panorama
gl.uniform1f(program.bb, (-v[0][1] + 1) / 2);
gl.uniform1f(program.br, (v[1][0] + 1) / 2);
gl.uniform1f(program.bt, (-v[2][1] + 1) / 2);
gl.uniform1f(program.bl, (v[3][0] + 1) / 2);

for (var node of program.currentGapNodes.values())
if(!node.missing)
draw(node);
}
// Prep for texture
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
gl.vertexAttribPointer(program.texCoordLocation, 2, gl.FLOAT, false, 0, 0);

program.drawInProgress = false;
// Bind texture and draw tile
gl.bindTexture(gl.TEXTURE_2D, node.texture); // Bind node.texture to TEXTURE0
gl.drawArrays(gl.TRIANGLES, 0, 6);
}

gl.uniform1f(program.tilePaddingX, 0);
gl.uniform1f(program.tilePaddingY, 0);
for (var node of nodesToRender) {
draw(node);
}

if (globalParams.interpolateBetweenTiles) {
gl.uniform1f(program.tilePaddingX, texelWidth / 4);
gl.uniform1f(program.tilePaddingY, texelHeight / 4);


for (var node of program.currentGapNodes.values())
if (!node.missing)
draw(node);
}

program.drawInProgress = false;

}

/**


불러오는 중...
취소
저장