Browse Source

Don't reload dynamic texture when `update` is false (#1135).

pull/1140/head
Matthew Petroff 1 year ago
parent
commit
6c639ae033
2 changed files with 10 additions and 9 deletions
  1. +8
    -7
      src/js/libpannellum.js
  2. +2
    -2
      src/js/pannellum.js

+ 8
- 7
src/js/libpannellum.js View File

@@ -45,7 +45,7 @@ function Renderer(container, context) {
var world; var world;
var vtmps; var vtmps;
var pose; var pose;
var image, imageType, dynamic;
var image, imageType;
var texCoordBuffer, cubeVertBuf, cubeVertTexCoordBuf, cubeVertIndBuf; var texCoordBuffer, cubeVertBuf, cubeVertTexCoordBuf, cubeVertIndBuf;
var globalParams; var globalParams;
var sides = ['f', 'b', 'u', 'd', 'l', 'r']; var sides = ['f', 'b', 'u', 'd', 'l', 'r'];
@@ -65,14 +65,13 @@ function Renderer(container, context) {
* configuration object. * configuration object.
* @param {string} imageType - The type of the image: `equirectangular`, * @param {string} imageType - The type of the image: `equirectangular`,
* `cubemap`, or `multires`. * `cubemap`, or `multires`.
* @param {boolean} dynamic - Whether or not the image is dynamic (e.g., video).
* @param {number} haov - Initial horizontal angle of view. * @param {number} haov - Initial horizontal angle of view.
* @param {number} vaov - Initial vertical angle of view. * @param {number} vaov - Initial vertical angle of view.
* @param {number} voffset - Initial vertical offset angle. * @param {number} voffset - Initial vertical offset angle.
* @param {function} callback - Load callback function. * @param {function} callback - Load callback function.
* @param {Object} [params] - Other configuration parameters (`horizonPitch`, `horizonRoll`, `backgroundColor`). * @param {Object} [params] - Other configuration parameters (`horizonPitch`, `horizonRoll`, `backgroundColor`).
*/ */
this.init = function(_image, _imageType, _dynamic, haov, vaov, voffset, callback, params) {
this.init = function(_image, _imageType, haov, vaov, voffset, callback, params) {
// Default argument for image type // Default argument for image type
if (_imageType === undefined) if (_imageType === undefined)
_imageType = 'equirectangular'; _imageType = 'equirectangular';
@@ -85,7 +84,6 @@ function Renderer(container, context) {


imageType = _imageType; imageType = _imageType;
image = _image; image = _image;
dynamic = _dynamic;
globalParams = params || {}; globalParams = params || {};


// Clear old data // Clear old data
@@ -498,7 +496,7 @@ function Renderer(container, context) {
} }


// Set parameters for rendering any size // Set parameters for rendering any size
if (imageType != "cubemap" && image.width <= maxWidth &&
if (imageType != "cubemap" && image.width && image.width <= maxWidth &&
haov == 2 * Math.PI && (image.width & (image.width - 1)) == 0) haov == 2 * Math.PI && (image.width & (image.width - 1)) == 0)
gl.texParameteri(glBindType, gl.TEXTURE_WRAP_S, gl.REPEAT); // Only supported for power-of-two images in WebGL 1 gl.texParameteri(glBindType, gl.TEXTURE_WRAP_S, gl.REPEAT); // Only supported for power-of-two images in WebGL 1
else else
@@ -748,6 +746,7 @@ function Renderer(container, context) {
* @param {number} [params.roll] - Camera roll (in radians). * @param {number} [params.roll] - Camera roll (in radians).
* @param {string} [params.returnImage] - Return rendered image? If specified, should be 'ImageBitmap', 'image/jpeg', or 'image/png'. * @param {string} [params.returnImage] - Return rendered image? If specified, should be 'ImageBitmap', 'image/jpeg', or 'image/png'.
* @param {function} [params.hook] - Hook for executing arbitrary function in this environment. * @param {function} [params.hook] - Hook for executing arbitrary function in this environment.
* @param {boolean} [params.dynamic] - Whether or not the image is dynamic (e.g., video) and should be updated.
*/ */
this.render = function(pitch, yaw, hfov, params) { this.render = function(pitch, yaw, hfov, params) {
var focal, i, s, roll = 0; var focal, i, s, roll = 0;
@@ -755,6 +754,8 @@ function Renderer(container, context) {
params = {}; params = {};
if (params.roll) if (params.roll)
roll = params.roll; roll = params.roll;
if (params.dynamic)
var dynamic = params.dynamic;


// Apply pitch and roll transformation if applicable // Apply pitch and roll transformation if applicable
if (pose !== undefined) { if (pose !== undefined) {
@@ -1952,8 +1953,8 @@ var fragMulti = [
].join(''); ].join('');


return { return {
renderer: function(container, image, imagetype, dynamic) {
return new Renderer(container, image, imagetype, dynamic);
renderer: function(container, image, imagetype) {
return new Renderer(container, image, imagetype);
} }
}; };




+ 2
- 2
src/js/pannellum.js View File

@@ -1650,7 +1650,7 @@ function render() {
maxPitch = 90; maxPitch = 90;
config.pitch = Math.max(minPitch, Math.min(maxPitch, config.pitch)); config.pitch = Math.max(minPitch, Math.min(maxPitch, config.pitch));
renderer.render(config.pitch * Math.PI / 180, config.yaw * Math.PI / 180, config.hfov * Math.PI / 180, {roll: config.roll * Math.PI / 180});
renderer.render(config.pitch * Math.PI / 180, config.yaw * Math.PI / 180, config.hfov * Math.PI / 180, {roll: config.roll * Math.PI / 180, dynamic: update});
renderHotSpots(); renderHotSpots();
@@ -1783,7 +1783,7 @@ function renderInit() {
params.horizonRoll = config.horizonRoll * Math.PI / 180; params.horizonRoll = config.horizonRoll * Math.PI / 180;
if (config.backgroundColor !== undefined) if (config.backgroundColor !== undefined)
params.backgroundColor = config.backgroundColor; params.backgroundColor = config.backgroundColor;
renderer.init(panoImage, config.type, config.dynamic, config.haov * Math.PI / 180, config.vaov * Math.PI / 180, config.vOffset * Math.PI / 180, renderInitCallback, params);
renderer.init(panoImage, config.type, config.haov * Math.PI / 180, config.vaov * Math.PI / 180, config.vOffset * Math.PI / 180, renderInitCallback, params);
if (config.dynamic !== true) { if (config.dynamic !== true) {
// Allow image to be garbage collected // Allow image to be garbage collected
panoImage = undefined; panoImage = undefined;


Loading…
Cancel
Save