2020-10-02 12:48:33 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2022-02-28 14:29:51 +00:00
|
|
|
* @copyright 2022 Photon Storm Ltd.
|
2020-10-02 12:48:33 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
var CullBounds = require('./HexagonalCullBounds');
|
|
|
|
var RunCull = require('./RunCull');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the tiles in the given layer that are within the cameras viewport. This is used internally.
|
|
|
|
*
|
|
|
|
* @function Phaser.Tilemaps.Components.HexagonalCullTiles
|
|
|
|
* @since 3.50.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
|
|
|
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to run the cull check against.
|
|
|
|
* @param {array} [outputArray] - An optional array to store the Tile objects within.
|
2020-11-23 10:22:13 +00:00
|
|
|
* @param {number} [renderOrder=0] - The rendering order constant.
|
2020-10-02 12:48:33 +00:00
|
|
|
*
|
|
|
|
* @return {Phaser.Tilemaps.Tile[]} An array of Tile objects.
|
|
|
|
*/
|
|
|
|
var HexagonalCullTiles = function (layer, camera, outputArray, renderOrder)
|
|
|
|
{
|
|
|
|
if (outputArray === undefined) { outputArray = []; }
|
|
|
|
if (renderOrder === undefined) { renderOrder = 0; }
|
|
|
|
|
|
|
|
outputArray.length = 0;
|
|
|
|
|
|
|
|
var tilemapLayer = layer.tilemapLayer;
|
|
|
|
|
|
|
|
if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
|
|
|
|
{
|
|
|
|
// Camera world view bounds, snapped for scaled tile size
|
|
|
|
// Cull Padding values are given in tiles, not pixels
|
|
|
|
|
|
|
|
var bounds = CullBounds(layer, camera);
|
|
|
|
|
|
|
|
RunCull(layer, bounds, renderOrder, outputArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
return outputArray;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = HexagonalCullTiles;
|