Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TileCameraGenerator

Support Class that wraps the calculation of camera tiling and iteration with various algorithms by giving access to an adjusted camera which NDC-Coordinates match the current tile index. Iteration can be done manually (variant: 1) or automatically (variant: 2). It is intended to be used like: The enum that is used to select one of the different algorithm.

tileCameraGenerator = new TileCameraGenerator(); tileCameraGenerator.sourceCamera = camera; tileCameraGenerator.sourceViewport = canvasSize; tileCameraGenerator.tileSize = [128, 128]; tileCameraGenerator.algorithm = TileCameraGenerator.Algorithm.ScanLine; let offset: [number, number];

iteration variant 1: for (let i = 0; i < tileCameraGenerator.numberOfTiles(); ++i){ tileCameraGenerator.tile = i; // property tileCameraGenerator.update(); offset = tileCameraGenerator.offset; "render camera" }

iteration variant 2: while(tileCameraGenerator.nextTile()){ offset = tileCameraGenerator.offset; "render" } // reset generator tileCameraGenerator.reset();

NOTE: Use sourceCameraChanged if the source camera is altered.

Hierarchy

  • TileCameraGenerator

Index

Properties

Protected _algorithm

_algorithm: Algorithm = TileCameraGenerator.Algorithm.ScanLine
see

algorithm

Protected _camera

_camera: Camera | undefined
see

{@link eye}

Protected _indices

_indices: Uint16Array

Protected _offset

_offset: GLsizei2 = [0, 0]

Protected _padding

_padding: vec4 = vec4.fromValues(0, 0, 0, 0)
see

padding

Protected _sourceCamera

_sourceCamera: Camera | undefined

Protected _sourceViewport

_sourceViewport: GLsizei2 | undefined

Protected _tile

_tile: number = -1
see

tile

Protected _tileSize

_tileSize: GLsizei2 = [0, 0]
see

tileSize

Protected _valid

_valid: boolean

Accessors

algorithm

  • Returns the selected IterationAlgorithm which determines the sequence in which the tiles are rendered.

    Returns Algorithm

  • Sets the selected IterationAlgorithm which determines the order in which the tiles are rendered. The default is ScanLine. If needed, it automatically adjusts the tileSize to match the new algorithm.

    Parameters

    Returns void

camera

  • get camera(): Camera | undefined
  • Read-only access to the tiled camera that has the viewport of the current tile of the input/source camera.

    Returns Camera | undefined

    • The reference to the tile viewing camera.

numTiles

  • get numTiles(): number
  • Returns the total number of tiles based on the how many of tileSize fit inside the sourceViewport.

    Returns number

    • The total number of tiles.

numXTiles

  • get numXTiles(): number
  • Returns the number of tiles along the x-axis based on the number of tiles that fit inside the horizontal extent of the source camera's viewport.

    Returns number

    • The number of tiles along the x-axis.

numYTiles

  • get numYTiles(): number
  • Returns the number of tiles along the y-axis based on the number of tiles that fit inside the vertical extent of the source camera's viewport.

    Returns number

    • The number of tiles along the y-axis.

offset

padding

  • get padding(): vec4
  • set padding(padding: vec4): void
  • Returns the padding per tile in CSS order: top, right, bottom, left. The standard is (0, 0, 0, 0).

    Returns vec4

  • Stets the padding per tile in CSS order: top, right, bottom, left. The standard is (0, 0, 0, 0).

    Parameters

    • padding: vec4

    Returns void

sourceCamera

  • get sourceCamera(): Camera | undefined
  • set sourceCamera(camera: Camera | undefined): void
  • Returns the sourceCamera which viewport should be divided in tiles. If the sourceCamera has not been set, it returns a default camera.

    Returns Camera | undefined

    • The sourceCamera which viewport should be divided in tiles.
  • Assigns the input camera whose viewport will be divided in tiles. Additionally it creates a deep copy of the input camera which is used as the tiled camera camera.

    Parameters

    • camera: Camera | undefined

      The input camera whose viewport will be divided in tiles.

    Returns void

    • The sourceCamera which viewport should be divided in tiles.

sourceViewport

  • get sourceViewport(): GLsizei2 | undefined
  • set sourceViewport(viewport: GLsizei2 | undefined): void
  • Returns the size of the original viewport which should be divided in tiles based on the tile size. If the viewport has not been set, it returns [-1, -1].

    Returns GLsizei2 | undefined

    • Size of the Viewport.
  • Sets the size of the viewport from the sourceCamera. It checks if the sourceViewport is compatible with the selected algorithm and eventually adjusts the tileSize to match the conditions of the algorithm.

    Parameters

    Returns void

    • Size of the Viewport.

tile

  • get tile(): number
  • set tile(index: GLsizei): void

tileSize

valid

  • get valid(): boolean

viewport

  • Creates a 4-tuple with x0, y0, and width and height of the viewport for the current tile and camera.

    Returns GLsizei4

    • 4-tuple with [x0, y0, width, height] based on the current tile.

Methods

Protected ensureValidIterationIndices

  • ensureValidIterationIndices(): void

Protected getPaddedTileSize

  • getPaddedTileSize(): [number, number]

hasNextTile

  • hasNextTile(): boolean

Protected invalidate

  • invalidate(clearIndices: boolean): void

nextTile

  • nextTile(): boolean
  • Used for Iterator behavior. It sets the tile to 0 (first tile) if the value of tile is negative and therefore initiates the iteration. Otherwise it increments the tile and calls update to directly change the camera. If the tile index would get out of range it returns false to indicate, that all tiles were rendered.

    Returns boolean

    • If the camera has been set to a next tile.

reset

  • reset(): void
  • Resets the tile index to prepare the generator for the next rendering. Should be called after iteration with nextTile().

    Returns void

sourceCameraChanged

  • sourceCameraChanged(): void

Protected tableIndices

update

  • Updates the camera view frustum to current tile based on the sourceViewport, tileSize and the padding. If the tile is less than zero, the camera is set to the first tile. If the tile is too high, the camera is not updated and remains in the last valid state.

    Returns GLsizei2

    • the offset of the new camera tile.

Static generateHilbertIndices

  • generateHilbertIndices(indices: Uint16Array, numX: number, numY: number): void
  • Fills the iterationAlgorithmIndices with the table indices from the HilbertCurve-Iteration-Algorithm.

    Parameters

    • indices: Uint16Array
    • numX: number
    • numY: number

    Returns void

Static generateScanLineIndices

  • generateScanLineIndices(indices: Uint16Array, numX: number, numY: number): void
  • Generates interleaved table indices using the ZCurve-Iteration-Algorithm.

    Parameters

    • indices: Uint16Array
    • numX: number
    • numY: number

    Returns void

Static generateZCurveIndices

  • generateZCurveIndices(indices: Uint16Array, numX: number, numY: number): void
  • Fills the sequence/array of indices with the table indices from the ZCurve-Iteration-Algorithm.

    Parameters

    • indices: Uint16Array
    • numX: number
    • numY: number

    Returns void

Static Protected hilbertIndices

  • hilbertIndices(indices: Uint16Array, numX: number, numY: number, x: number, y: number, xi: number, xj: number, yi: number, yj: number, depth: number, hilbertIndex: number): number
  • Recursively fills the interleaved indices using the Hilbert Curve. This method is not intended to be used directly. Use generateHilbertIndices generateHilbertIndices instead.

    Parameters

    • indices: Uint16Array
    • numX: number
    • numY: number
    • x: number
    • y: number
    • xi: number
    • xj: number
    • yi: number
    • yj: number
    • depth: number
    • hilbertIndex: number

    Returns number