Bläddra i källkod

start supporting backgroundColor for Cube and Mulitres panoramas

pull/565/head
David von Oheimb 6 år sedan
committed by Matthew Petroff
förälder
incheckning
2491c2b4dc
1 ändrade filer med 19 tillägg och 10 borttagningar
  1. +19
    -10
      src/js/libpannellum.js

+ 19
- 10
src/js/libpannellum.js Visa fil

@@ -325,6 +325,11 @@ function Renderer(container) {
program.texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
gl.enableVertexAttribArray(program.texCoordLocation);

// Set background color
program.backgroundColor = gl.getUniformLocation(program, 'u_backgroundColor');
var color = params.backgroundColor ? params.backgroundColor : [0, 0, 0];
gl.uniform4fv(program.backgroundColor, color.concat([1]));

if (imageType != 'multires') {
// Provide texture coordinates for rectangle
if (!texCoordBuffer)
@@ -351,13 +356,6 @@ function Renderer(container) {
gl.uniform1f(program.v, vaov / Math.PI);
gl.uniform1f(program.vo, voffset / Math.PI * 2);

// Set background color
if (imageType == 'equirectangular') {
program.backgroundColor = gl.getUniformLocation(program, 'u_backgroundColor');
var color = params.backgroundColor ? params.backgroundColor : [0, 0, 0];
gl.uniform4fv(program.backgroundColor, color.concat([1]));
}

// Create texture
program.texture = gl.createTexture();
gl.bindTexture(glBindType, program.texture);
@@ -1287,7 +1285,10 @@ var fragEquiCubeBase = [
var fragCube = fragEquiCubeBase + [
// Look up color from texture
'float cosphi = cos(phi);',
'gl_FragColor = textureCube(u_imageCube, vec3(cosphi*sin(lambda), sin(phi), cosphi*cos(lambda)));',
'if(false)', // TODO: calculate if outside image
'gl_FragColor = u_backgroundColor;',
'else',
'gl_FragColor = textureCube(u_imageCube, vec3(cosphi*sin(lambda), sin(phi), cosphi*cos(lambda)));',
'}'
].join('\n');

@@ -1310,16 +1311,24 @@ var fragEquirectangular = fragEquiCubeBase + [

// Fragment shader
var fragMulti = [
'precision mediump float;',

'varying mediump vec2 v_texCoord;',
'uniform sampler2D u_sampler;',
//'uniform mediump vec4 u_color;',

// Background color (display for partial panoramas)
'uniform vec4 u_backgroundColor;',

'void main(void) {',
// Look up color from texture
'gl_FragColor = texture2D(u_sampler, v_texCoord);',
'if(false)', // TODO: calculate if outside image
'gl_FragColor = u_backgroundColor;',
'else',
'gl_FragColor = texture2D(u_sampler, v_texCoord);',
// 'gl_FragColor = u_color;',
'}'
].join('');
].join('\n');

return {
renderer: function(container, image, imagetype, dynamic) {


Laddar…
Avbryt
Spara