Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Nightre/Rapid.js/llms.txt
Use this file to discover all available pages before exploring further.
TextureManager is the central hub for all texture operations in Rapid.js. It is accessed through rapid.texture and takes care of loading images from the network, creating textures from in-memory sources, and tracking every GPU resource through reference counting so nothing leaks and nothing is destroyed too early.
URLs loaded via
.load() are cached by URL string. Calling .load() again
with the same URL skips the network request and returns a new Texture view
that shares the same underlying BaseTexture — no duplicate GPU uploads.Methods
load(url, options?)
Asynchronously fetches an image from a URL, uploads it to the GPU, caches the result, and returns a Texture wrapping the full image.
The URL of the image to load. Used as the cache key.
Optional texture configuration. See ITextureOptions below.
Promise<Texture>
create(source, options?)
Synchronously creates a Texture from an existing browser media element or bitmap. Useful when you already have an image decoded in memory — for example a procedurally drawn HTMLCanvasElement or a decoded ImageBitmap.
The pixel source. Accepted types:
HTMLImageElement, HTMLCanvasElement,
HTMLVideoElement, ImageBitmap, OffscreenCanvas.Optional texture configuration. If
options.key is provided and a cached
texture with that key already exists, the existing BaseTexture is reused.Texture
createRenderTexture(options)
Creates a RenderTexture — a texture backed by a WebGL framebuffer that you can draw into. See the RenderTexture reference for full details on drawing and pixel readback.
Configuration for the offscreen framebuffer. See the
RenderTexture page for all fields.RenderTexture
createTextTexture(options?)
Creates a TextTexture — a texture that renders styled text via an internal HTML5 canvas and uploads the result to the GPU. See the TextTexture reference for styling and live-update details.
Optional text content and style configuration. See the
TextTexture page for all fields.TextTexture
destroy(textureOrUrl, force?)
Destroys a texture and, if the underlying BaseTexture reference count drops to zero (or force is true), removes the WebGL texture from the GPU and evicts it from the cache.
The resource to destroy. Accepts a
Texture instance, a BaseTexture
instance, or the URL string that was used to load the texture.When
true, the underlying BaseTexture is destroyed immediately regardless
of its current refCount. Use with caution — other Texture views sharing
the same BaseTexture will be left with dangling GPU references.void
destroyAll()
Destroys every cached BaseTexture and clears the internal cache. Reference counts are ignored. Call this during a full scene teardown or when shutting down the renderer.
void
ITextureOptions
Options accepted byload(), create(), and the RenderTexture/TextTexture factory methods.
Controls how the texture is sampled when scaled.
| Value | Description |
|---|---|
TextureFilterMode.NEAREST | Pixel-perfect, no blending. Default. |
TextureFilterMode.LINEAR | Bilinear interpolation — smoother at scale. |
Controls how UV coordinates outside the
[0, 1] range are handled.| Value | Description |
|---|---|
TextureWrapMode.CLAMP | Clamps to the edge pixel. |
TextureWrapMode.REPEAT | Tiles the texture. |
TextureWrapMode.MIRRORED_REPEAT | Tiles with alternating mirror flips. |
Whether the texture data uses premultiplied alpha. When set, the WebGL
UNPACK_PREMULTIPLY_ALPHA_WEBGL pixel store flag is toggled accordingly.An explicit cache key. If provided, the resulting
BaseTexture is stored in
the cache under this key and reused on subsequent create() calls with the
same key. Has no effect on load() (which always uses the URL as key).