/** * @class * @implements Geometry * @classdesc A @{geometry} implementation suitable for tiled cube images with * multiple resolution levels. * * The following restrictions apply: * - All tiles in a level must be square and form a rectangular grid; * - The size of a level must be a multiple of the tile size; * - The size of a level must be a multiple of the parent level size; * - The number of tiles in a level must be a multiple of the number of tiles * in the parent level. * * @param {Object[]} levelPropertiesList Level description * @param {number} levelPropertiesList[].size Cube face size in pixels * @param {number} levelPropertiesList[].tileSize Tile size in pixels */ function CubeGeometry(levelPropertiesList) { if (type(levelPropertiesList) !== 'array') { throw new Error('Level list must be an array'); } this.levelList = makeLevelList(levelPropertiesList, CubeLevel); this.selectableLevelList = makeSelectableLevelList(this.levelList); for (var i = 1; i < this.levelList.length; i++) { this.levelList[i]._validateWithParentLevel(this.levelList[i-1]); } this._graphFinder = new GraphFinder(CubeTile.equals, CubeTile.hash); this._neighborsCache = new LruMap(CubeTile.equals, CubeTile.hash, 64); this._vec = vec3.create(); this._viewSize = {}; this._viewParams = {}; this._tileVertices = [ vec3.create(), vec3.create(), vec3.create(), vec3.create() ]; }
constructor (duration, easing) { super(); this.duration = duration; this.easing = easing || Easing.Linear; this.elapsed = 0; this.running = false; this.starting = false; this.start = vec3.create(); this.position = vec3.create(); }
function WebGlBaseRenderer(gl) { this.gl = gl; // vtMatrix is the matrix which has the view and tile transforms // Seams are visible at large zoom levels when the projection and tile // matrices are multiplied in the vertex shader. Therefore they are // multiplied in Javascript. this.vtMatrix = mat4.create(); // vccMatrix is the matrix to compensate for viewport clamping // see the setViewport() function for more details this.vccMatrix = mat4.create(); this.translateVector = vec3.create(); this.scaleVector = vec3.create(); this.constantBuffers = createConstantBuffers(this.gl, vertexIndices, vertexPositions, textureCoords); this.shaderProgram = createShaderProgram(this.gl, vertexSrc, fragmentSrc, attribList, uniformList); }
// on the vertex shader by offsetting and scaling the vertexes. // Offsets larger than the total size and sizes which cause the viewport to // be larger than the canvas do not seem to cause any rendering problems. // However, this may still have a performance impact. Therefore, the maximum // values are also clamped. rectToViewport(rect, viewportParameters, viewportMatrix); gl.viewport(ratio * viewportParameters.offsetX, ratio * viewportParameters.offsetY, ratio * viewportParameters.width, ratio * viewportParameters.height); } // Temporary vectors for rectToViewport var translateVector = vec3.create(); var scaleVector = vec3.create(); function rectToViewport(rect, resultParameters, resultViewportMatrix) { // Horizontal axis. var offsetX = rect.left; var totalWidth = rect.totalWidth; var clampedOffsetX = clamp(offsetX, 0, totalWidth); var widthWithoutDiscarded = rect.width - (clampedOffsetX - offsetX); var maxWidth = totalWidth - clampedOffsetX; var clampedWidth = clamp(widthWithoutDiscarded, 0, maxWidth); resultParameters.offsetX = clampedOffsetX; resultParameters.width = clampedWidth;