From 8a40ae1b4244b0f974f463f9928ffbfc293a929a Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 26 Mar 2022 14:57:21 -0400 Subject: [PATCH] Add ability to provide a hook to execute just prior to rendering. This allows interoperability with other WebGL code. --- src/js/libpannellum.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/js/libpannellum.js b/src/js/libpannellum.js index eaa94ff..efb26e8 100644 --- a/src/js/libpannellum.js +++ b/src/js/libpannellum.js @@ -747,6 +747,7 @@ function Renderer(container, context) { * @param {Object} [params] - Extra configuration parameters. * @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 {function} [params.hook] - Hook for executing arbitrary function in this environment. */ this.render = function(pitch, yaw, hfov, params) { var focal, i, s, roll = 0; @@ -789,6 +790,20 @@ function Renderer(container, context) { roll += roll_adj; } + // Execute function hook + if (params.hook) { + params.hook({ + gl: gl, + program: program, + previewProgram: previewProgram, + imageType: imageType, + texCoordBuffer: texCoordBuffer, + cubeVertBuf: cubeVertBuf, + cubeVertTexCoordBuf: cubeVertTexCoordBuf, + cubeVertIndBuf: cubeVertIndBuf + }); + } + // If no WebGL if (!gl && (imageType == 'multires' || imageType == 'cubemap')) { // Determine face transforms