Texture constructor
renderer object or GPUCurtains class object used to create this Texture.
parameters used to create this Texture.
The GPUExternalTexture used if any.
The MediaTexture sources to use if any.
Options used to create this MediaTexture.
Array of requestVideoFrameCallback returned ids if used.
Vec2 offset to apply to the Texture if useTransform parameter has been set to true
.
Vec2 scale to apply to the Texture if useTransform parameter has been set to true
.
Vec2 transformation origin to use when applying the transformations to the Texture if useTransform parameter has been set to true
. A value of (0.5, 0.5) corresponds to the center of the texture. Default is (0, 0), the upper left.
Mat3 transformation matrix to apply to the Texture if useTransform parameter has been set to true
.
Optional
transformBufferBinding to send the transformation matrix to the shaders if useTransform parameter has been set to true
.
The type of the Texture.
Readonly
uuidThe universal unique id of this Texture.
The GPUTexture used.
Array of bindings that will actually only hold one texture binding.
Get the actual rotation value.
Set the actual rotation value and update the modelMatrix.
new rotation value to use.
Get our texture binding.
function assigned to the onSourceLoaded callback
function assigned to the onAllSourcesLoaded callback
function assigned to the onSourceUploaded callback
function assigned to the onAllSourcesUploaded callback
Update the modelMatrix using the offset, rotation, scale and transformOrigin and tell the transformBinding to update, only if useTransform parameter has been set to true
.
Set our bindings.
Texture to copy.
Create the texture (or copy it from source) and update the binding resource.
Import a GPUExternalTexture from the Renderer, update the textureBinding and its bind group
Load an HTMLImageElement from a URL and create an ImageBitmap to use as a source.
URL of the image to load.
Load and create an ImageBitmap from a URL or HTMLImageElement, use it as a source and create the GPUTexture.
the image URL or HTMLImageElement to load.
Use an already loaded ImageBitmap as a sources.
ImageBitmap to use.
Index at which to insert the source in the sources array in case of cube map.
Load and create images using loadImage from an array of images sources as strings or HTMLImageElement. Useful for cube maps.
Array of images sources as strings or HTMLImageElement to load.
Set our source shouldUpdate flag to true at each new video frame.
Callback to run when a HTMLVideoElement has loaded (when it has enough data to play). Set the HTMLVideoElement as a MediaTextureSource.source and create the GPUTexture or GPUExternalTexture.
the newly loaded HTMLVideoElement.
Index of the HTMLVideoElement in the sources array.
Get whether the provided source is a video.
TextureSource to check.
Get whether the provided video source is ready to be played.
TextureSource to check.
Get whether the provided video source is ready to be uploaded.
TextureSource to check.
Load a video from a URL or HTMLVideoElement and register onVideoLoaded callback.
the video URL or HTMLVideoElement to load.
Load and create videos using loadVideo from an array of videos sources as strings or HTMLVideoElement. Useful for cube maps.
Array of images sources as strings or HTMLVideoElement to load.
Load a HTMLCanvasElement and use it as one of our sources.
the HTMLCanvasElement to use.
Load an array of HTMLCanvasElement using loadCanvas . Useful for cube maps.
Array of HTMLCanvasElement to load.
Set the sourceUploaded flag to true for the source at a given index in our sources array. If all sources have been uploaded, set our sourcesUploaded flag to true.
Callback to run when one of the source has been loaded.
callback to run when one of the source has been loaded.
Callback to run when all of the source have been loaded.
callback to run when all of the sources have been loaded.
Callback to run when one of the MediaTextureSource.source has been uploaded to the GPU.
callback to run when one of the source has been uploaded to the GPU.
Callback to run when all of the source have been uploaded to the GPU.
callback to run when all of the sources been uploaded to the GPU.
Update a MediaTexture by uploading the texture if needed.
Destroy the MediaTexture.
New Renderer or GPUCurtains instance to use.
Copy a GPUTexture directly into this Texture. Mainly used for depth textures.
GPUTexture to copy.
Upload a source to the GPU and use it for our texture.
parameters used to upload the source.
source to use for our texture.
Optional
width?: numbersource width.
Optional
height?: numbersource height.
Optional
depth?: numbersource depth.
Optional
origin?: GPUOrigin3D().destination.origin | GPUOrigin3D of the source copy.
Optional
colorSpace?: PredefinedColorSpaceUse data as the texture source and upload it to the GPU.
parameters used to upload the source.
Optional
width?: numberdata source width.
Optional
height?: numberdata source height.
Optional
depth?: numberdata source depth.
Optional
origin?: GPUOrigin3D().destination.origin | GPUOrigin3D of the data source copy.
Optional
data?: Float32ArrayFloat32Array data to use as source.
Resize our Texture, which means recreate it/copy it again and tell the texture bind group to update.
the optional new size to set.
This class extends the Texture class specifically to handle external sources such as images, videos or canvases. It can be used with ComputePass and/or any kind of Mesh.
Can also handle texture transformations using a Mat3 if the useTransform parameter has been set to
true
upon creation.If you use transformations, the modelMatrix will be available in the shaders using
texturesMatrices.${texture.options.name}.matrix
.The library provide a convenient helpers in the shaders to help you compute the transformed UV:
Example