Skip to content

Documentation / @ripl/3d / resolveTexturePattern

Function: resolveTexturePattern() ​

resolveTexturePattern(ctx, texture): TexturePattern

Defined in: 3d/src/core/texture-pattern.ts:167

Builds the repeating CanvasPattern that maps a texture across a surface, caching it per context and texture version.

A pattern tiles infinitely, which is what makes a repeat above 1 cover the whole surface — a single drawImage paints one tile and leaves the rest bare. It is also one fill per triangle rather than one image draw, and it is where a texture's wrap modes finally reach the Canvas backend. Release it with releaseTexturePatternCache when the context is torn down.

Parameters ​

ParameterTypeDescription
ctxCanvasRenderingContext2DThe native context the pattern will paint into.
textureTextureThe texture to tile.

Returns ​

TexturePattern

The pattern and the tile scale the UV transform must account for.