TexturesModule Overview
TexturesModule Overview
TexturesModule Overview

TexturesModule

The TexturesModule class enables images, animation sequences, videos, colors, and other visual artifacts to be combined to form materials.

Example

//==============================================================================
// The following example demonstrates how to access a texture in the Assets and
// assign it to a material.
//
// Project setup:
// - Insert a plane
// - Create a material
// - Import an image to use as a texture (renaming it texture0)
// - Assign the material to the plane
//==============================================================================

// Load in the required modules
const Materials = require('Materials');
const Textures = require('Textures');

// Enable async/await in JS [part 1]
(async function() {
  // Locate the material and texture in the Assets
  const [material, texture] = await Promise.all([
    Materials.findFirst('defaultMaterial0'),
    Textures.findFirst('texture0')
  ]);

  // Assign the texture to the material
  material.diffuse = texture;
// Enable async/await in JS [part 2]
})();

Properties

This module exposes no properties.

Methods

MethodDescription
clone
clone(texture: string | TextureBase, initialState?: {[key: string]: any}): Promise<TextureBase>


Clone a texture asynchronously.
When creating the textures, keep the following in mind:
- Cloning a texture with an identifier that doesn't exist fails the Promise.
- New textures always get assigned a globally unique name and identifier.
- initialState is optional, but encouraged to be used.
- All properties that are using Signal types get assigned a ConstSignal with last value. Use initialState to override it.

Note: This API requires "Scripting Dynamic Instantiation" capability to be enabled.
create
create(className: string, initialState?: {[key: string]: any}): Promise<TextureBase>


Create a texture asynchronously.
When creating the textures, keep the following in mind:
- All textures must have an existing class.
- New textures always get assigned a globally unique name and identifier.
- initialState is optional, but encouraged to be used.

Note: This API requires "Scripting Dynamic Instantiation" capability to be enabled.
destroy
destroy(texture: string | TextureBase): Promise<void>


Destroy a texture asynchronously.
When destroying the textures, keep the following in mind:
- All bound properties will be automatically unbound on destruction.
- Destroying a texture that doesn't exist fails the Future.
- Destroying a set of textures that was created in Studio fails the Future.

Note: This API requires "Scripting Dynamic Instantiation" capability to be enabled.
findFirst
findFirst(textureName: string): Promise<TextureBase | null>


Returns a promise that is resolved with the texture of a requested name or null if none was found.
See Also: Textures.findUsingPattern, Textures.getAll.
findUsingPattern
findUsingPattern(namePattern: string, config?: {limit: number}): Promise<Array<TextureBase>>


Returns a promise that is resolved with the all of the textures matching the name pattern or empty array if none was found.
Pattern format:
* matches any characters sequence.
\ can be used to include in pattern any of the control characters (including '\' itself)

Examples:
findUsingPattern("*") will retrive all of the textures.
findUsingPattern("*A") will retrieve all of the textures suffixed with 'A'.
findUsingPattern("A*") will retrieve all of the textures prefixed with 'A'.
findUsingPattern("*A*", {limit: 10}) will retrieve at most 10 of the textures containing 'A',

limit parameter describes if findUsingPattern should finish the search if it finds specified number of results (default is no limit). Non-positive values for limit are treated as unlimited.

See Also: Textures.getAll, Textures.findFirst.
getAll
getAll(): Promise<Array<TextureBase>>


Returns a promise that is resolved with all of the textures.
See Also: Textures.findUsingPattern, Textures.findFirst.

Classes

ClassDescription
CameraTextureThe CameraTexture class represents a texture type that contains image data coming in from system camera, or captured photo/video in case of using the effect with "Media Library".
CanvasTextureThe CanvasTexture class enables painting with a brush to a texture.
ColorTextureThe ColorTexture class encapsulates a texture that has a color (including alpha channel).
DeepLinkTextureThe DeepLinkTexture class represents an image texture passed in via the sharing SDK.
GalleryTextureThe GalleryTexture class encapsulates a texture that was picked from the gallery.
GalleryTextureMediaBaseGalleryTextureMediaBase is a base class for different types of media that can be selected from gallery and used in a gallery texture.
GalleryTextureMediaImageGalleryTextureMediaImage represents image media that was picked from the gallery that is being used by a given GalleryTexture.
GalleryTextureMediaVideoGalleryTextureMediaVideo represents "video" media that was picked from the gallery that is being used by a given GalleryTexture.
It exposes a set of APIs that are specifically tailored for controlling video playback.
ImageTextureThe ImageTexture class encapsulates an image that may be used to form materials for rendering in the scene.
SceneDepthTextureDescribes a texture which provides the current scene's estimated depth information. Depth is calculated as the relative distance to the camera.
You can follow the steps in this article to add a camera depth texture asset to your project.
SegmentationTextureThe SegmentationTexture class encapsulates a texture that will be used for image segmentation.
SequenceTextureThe SequenceTexture class is a collection of still images that form an animation.
SourceImageRegionTextureThe SourceImageRegionTexture class represents a texture type that contains extracted texture image from a certain region of an object or a set of objects in the scene.
E.g. Face extracted texture that contains a region of a camera image with a face as extracted using a face tracker.
SubTextureThe SubTexture class exposes details of a texture in UV coordinates.
TextureBaseThe TextureBase class describes a texture.

Enums

EnumDescription
TextureColorEncodingTextureColorEncoding describes different color encoding formats used for data in a texture.
TextureFilteringModeTextureFilteringMode describes different modes for how a texture
should address size mismatch between the actual image data, and it's footprint when rendered.
TextureWrapModeTextureWrapMode describes different ways a given texture should be sampled
when a coordinate falls outside of the 0->1 range.

Was this article helpful?