@bloopjs/toodle / textures/Bundles / Bundles
Class: Bundles
Defined in: textures/Bundles.ts:45
Bundles manages texture bundle registration and atlas coordinate lookups.
This is a pure TypeScript class with no WebGPU dependencies, suitable for use with custom renderers (e.g., WebGL fallbacks).
Constructors
Constructor
new Bundles(
options):Bundles
Defined in: textures/Bundles.ts:50
Parameters
options
BundlesOptions = {}
Returns
Bundles
Accessors
atlasSize
Get Signature
get atlasSize():
number
Defined in: textures/Bundles.ts:465
The atlas size used for coordinate calculations.
Returns
number
textureIds
Get Signature
get textureIds():
string[]
Defined in: textures/Bundles.ts:284
A read-only array of all currently loaded texture ids.
Returns
string[]
textures
Get Signature
get textures():
ReadonlyMap<string,AtlasCoords[]>
Defined in: textures/Bundles.ts:277
A read-only map of all currently loaded textures.
Returns
ReadonlyMap<string, AtlasCoords[]>
Methods
addTextureEntry()
addTextureEntry(
id,coords):void
Defined in: textures/Bundles.ts:329
Add atlas coordinates for a texture entry. Used by AssetManager.loadAtlas for textures loaded outside of bundles.
Parameters
id
string
The texture ID
coords
The atlas coordinates to add
Returns
void
getAtlasCoords()
getAtlasCoords(
id):AtlasCoords[]
Defined in: textures/Bundles.ts:294
Get the atlas coordinates for a texture.
Parameters
id
string
The texture ID
Returns
Array of atlas coordinates (may have multiple if texture exists in multiple atlases)
getBundleAtlases()
getBundleAtlases(
bundleId):CpuTextureAtlas[]
Defined in: textures/Bundles.ts:454
Get the CPU-side atlas data for a bundle. Useful for custom renderers that need access to the raw atlas data.
Parameters
bundleId
string
The bundle ID
Returns
Array of CPU texture atlases
getBundleAtlasIndices()
getBundleAtlasIndices(
bundleId):number[]
Defined in: textures/Bundles.ts:171
Get the atlas indices for a loaded bundle.
Parameters
bundleId
string
The bundle ID
Returns
number[]
Array of atlas indices, or empty array if not loaded
getCroppedSize()
getCroppedSize(
id):Size
Defined in: textures/Bundles.ts:409
Get the cropped size of a texture.
Parameters
id
string
The texture ID
Returns
The cropped size in pixels
getLoadedBundleIds()
getLoadedBundleIds():
string[]
Defined in: textures/Bundles.ts:441
Get all loaded bundle IDs.
Returns
string[]
getRegisteredBundleIds()
getRegisteredBundleIds():
string[]
Defined in: textures/Bundles.ts:434
Get all registered bundle IDs.
Returns
string[]
getSize()
getSize(
id):Size
Defined in: textures/Bundles.ts:394
Get the original (uncropped) size of a texture.
Parameters
id
string
The texture ID
Returns
The original size in pixels
getTextureOffset()
getTextureOffset(
id):Vec2
Defined in: textures/Bundles.ts:378
Get the crop offset for a texture.
Parameters
id
string
The texture ID
Returns
The crop offset vector
getTextureRegion()
getTextureRegion(
id):undefined|TextureRegion
Defined in: textures/Bundles.ts:364
Get the texture region (without atlas index) for a texture.
Parameters
id
string
The texture ID
Returns
undefined | TextureRegion
The texture region, or undefined if not found
hasBundle()
hasBundle(
bundleId):boolean
Defined in: textures/Bundles.ts:151
Check if a bundle is registered.
Parameters
bundleId
string
The bundle ID to check
Returns
boolean
hasTexture()
hasTexture(
id):boolean
Defined in: textures/Bundles.ts:427
Check if a texture exists.
Parameters
id
string
The texture ID
Returns
boolean
True if the texture is registered
isBundleLoaded()
isBundleLoaded(
bundleId):boolean
Defined in: textures/Bundles.ts:160
Check if a bundle is loaded.
Parameters
bundleId
string
The bundle ID to check
Returns
boolean
markBundleLoaded()
markBundleLoaded(
bundleId,atlasIndices?):void
Defined in: textures/Bundles.ts:199
Mark a bundle as loaded and populate texture lookups. For standalone usage (without AssetManager).
Parameters
bundleId
string
The bundle to mark as loaded
atlasIndices?
number[]
Array of atlas indices, one per atlas. If not provided, indices are auto-assigned sequentially.
Returns
void
registerAtlasBundle()
registerAtlasBundle(
bundleId,opts):Promise<string>
Defined in: textures/Bundles.ts:61
Register a bundle of pre-baked texture atlases.
Parameters
bundleId
string
Unique identifier for this bundle
opts
Atlas bundle options containing atlas definitions
Returns
Promise<string>
The bundle ID
registerDynamicBundle()
registerDynamicBundle(
bundleId,atlases):void
Defined in: textures/Bundles.ts:138
Register a bundle with pre-built CPU texture atlases. Used internally by AssetManager for texture bundles that require GPU packing.
Parameters
bundleId
string
Unique identifier for this bundle
atlases
Pre-built CPU texture atlases
Returns
void
removeTextureEntriesForAtlas()
removeTextureEntriesForAtlas(
atlasIndex):void
Defined in: textures/Bundles.ts:344
Remove texture entries for a specific atlas index. Used by AssetManager.unloadAtlas.
Parameters
atlasIndex
number
The atlas index to remove entries for
Returns
void
setAtlasCoords()
setAtlasCoords(
id,coords):void
Defined in: textures/Bundles.ts:311
Set the atlas coordinates for a texture. This allows for UV precision adjustments.
Parameters
id
string
The texture ID
coords
The atlas coordinates to set
Returns
void
setBundleLoaded()
setBundleLoaded(
bundleId,atlasIndices):void
Defined in: textures/Bundles.ts:183
Mark a bundle as loaded without populating texture lookups. Used when texture lookups are already populated via loadAtlas.
Parameters
bundleId
string
The bundle to mark as loaded
atlasIndices
number[]
Array of atlas indices, one per atlas
Returns
void
unloadBundle()
unloadBundle(
bundleId):void
Defined in: textures/Bundles.ts:244
Unmark a bundle as loaded and remove texture lookups.
Parameters
bundleId
string
The bundle to unload
Returns
void