TextureCreator

TextureCreator

Takes away the pain of creating textures of various sorts.

Constructor

new TextureCreator()

Methods

clear()

Releases any references to cached objects

loadTexture2D(imageUrl, settings) → {Promise}

Creates a texture and loads an image into it.

Parameters:
Name Type Description
imageUrl string
settings Object

passed to the {Texture} constructor

Example
new TextureCreator().loadTexture2D('sumerian.jpg').then(function (texture) {
    material.setTexture('DIFFUSE_MAP', texture);
}, function () {
    console.error('Error loading image.');
});

loadTexture3D(imageDataArray, settings) → {Promise}

Loads an array of n images into a 3D Texture.

Parameters:
Name Type Description
imageDataArray Array

Array containing images, image elements or image urls

settings Object

Settings object to pass to the Texture constructor

loadTextureArray(imageDataArray, settings) → {Promise}

Loads an array of n images into a Texture as a single texture 2d array.

Parameters:
Name Type Description
imageDataArray Array

Array containing images, image elements or image urls

settings Object

Settings object to pass to the Texture constructor

loadTextureCube(imageDataArray, settings) → {Promise}

Loads an array of six images into a Texture.

Parameters:
Name Type Description
imageDataArray Array

Array containing images, image elements or image urls. [left, right, bottom, top, back, front]

settings Object

Settings object to pass to the Texture constructor

loadTextures2D(imageUrls, settings) → {Promise}

Loads an array of textures.

Parameters:
Name Type Description
imageUrls Array.<string>
settings Array.<Object>

loadTextureVideo(videoURL, optionsopt) → {Promise}

Creates a texture and loads a video into it

Parameters:
Name Type Attributes Description
videoURL string
options Object <optional>
Properties
Name Type Attributes Default Description
loop boolean <optional>
true
autoPlay boolean <optional>
true
wrapS boolean <optional>
'EdgeClamp'
wrapT boolean <optional>
'EdgeClamp'
Example
new TextureCreator().loadTexture2D('sumerian.mp4').then(function (texture) {
    material.setTexture('DIFFUSE_MAP', texture);
}, function () {
    console.error('Error loading video texture.');
});

loadTextureWebCam() → {Promise}

Creates a video texture streamed from the webcam.

Example
new TextureCreator().loadTextureWebCam().then(function (data) {
    material.setTexture('DIFFUSE_MAP', data.texture);
}, function () {
    console.error('Error loading webcam texture.');
});