@daign/tile-space
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

daign-tile-space

NPM package

Data structure for a recursive tile raster.

Installation

npm install @daign/tile-space --save

Usage example

import { expect } from 'chai';
import { Vector2 } from '@daign/math';
import { Tile, TileSpace } from '@daign/tile-space';

// The number of partitions in a tile along one axis.
const partitionCount = 2;

// Create the tile space document.
const tileSpace = new TileSpace( partitionCount );

// Create the first tile.
const min = new Vector2( 0, 0 );
const max = new Vector2( 8, 8 );
const rootTile = new Tile( min, max, partitionCount );
tileSpace.root = rootTile;

// Split the tile.
rootTile.split();

// Find the tile at a given point.
const point = new Vector2( 7, 3 );
const tile = rootTile.findTile( point );

// The found tile goes from (4, 0) to (8, 4).
expect( tile ).to.not.be.null;
expect( tile!.min.x ).to.equal( 4 );
expect( tile!.min.y ).to.equal( 0 );
expect( tile!.max.x ).to.equal( 8 );
expect( tile!.max.y ).to.equal( 4 );

Scripts

Build

npm run build

Run lint analysis

npm run lint

Run unit tests with code coverage

npm run test

Package Sidebar

Install

npm i @daign/tile-space

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

9.09 kB

Total Files

9

Last publish

Collaborators

  • daign