|
@@ -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); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|