Skip to content

Documentation / @ripl/3d / sampleTexture

Function: sampleTexture() ​

sampleTexture(texture, coordU, coordV): ColorRGBA | undefined

Defined in: 3d/src/core/texture.ts:359

Samples a texture on the CPU, honouring its wrap modes, filter, flip and transform.

Used by the Canvas painter's texture mapping and by raycast queries. The pixel data is read back once per texture version and cached, because reading it per sample would be ruinous.

Parameters ​

ParameterTypeDescription
textureTextureThe texture to sample.
coordUnumberThe horizontal surface coordinate.
coordVnumberThe vertical surface coordinate.

Returns ​

ColorRGBA | undefined

The sampled colour in 0–255 channels, or undefined when the image has no pixels.