Skip to main content

Function: importTexture()

importTexture(image, options?): ImportedTexture

Defined in: rendering/utilities/import-texture.ts:66

Runs a texture through Forge's texture import pipeline, converting its pixel dimensions into a world-unit size via pixelsPerUnit, the way an art pipeline's per-texture import settings would. Hand the result's worldWidth/worldHeight to createSprite/addSpriteComponent instead of authoring a sprite's world size by hand from pixel dimensions.

Parameters​

image​

HTMLImageElement

The source image to import.

options?​

Partial<ImportTextureOptions> = {}

Options for configuring the import. width/height default to the image's own pixel dimensions; pixelsPerUnit defaults to 100.

Returns​

ImportedTexture

The resulting imported texture.

Throws​

An error if pixelsPerUnit, width, or height is not positive.