getBoundingBoxAt method

dynamic getBoundingBoxAt(
  1. dynamic id,
  2. dynamic target
)

Implementation

getBoundingBoxAt( id, target ) {
	final active = _active;
	if ( active[ id ] == false ) {
		return null;
	}

	// compute bounding box
	final bound = _bounds[ id ];
	final box = bound.box;
	final geometry = this.geometry;
	if ( bound.boxInitialized == false ) {

		box.empty();

		final index = geometry?.index;
		final position = geometry?.attributes['position'];
		final drawRange = _drawRanges[ id ];
		for (int i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
			int iv = i;
			if ( index != null) {
				iv = index.getX( iv )!.toInt();
			}

			box.expandByPoint( _vector.fromBuffer( position, iv ) );
		}

		bound.boxInitialized = true;
	}

	target.copy( box );
	return target;
}