Module: textures

API methods to control textures.

Summary

Methods

Type Definitions

Detailed Description

Methods

change_image(obj, text_name, image_path, callbackopt)

Change texture image. Changing video textures is forbidden.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
text_name string Texture name specified in Blender
image_path string Path to image (relative to the main html file)
callback TexChangingFinishCallback <optional>
Callback to be executed after changing
Deprecated since 17.08:
Source:
Example
var m_scenes  = require("scenes");
var m_tex = require("textures");

var cube = m_scenes.get_object_by_name("Cube");
m_tex.change_image(cube, "Texture", "./test.png");

get_canvas_ctx(obj, text_name) → {CanvasRenderingContext2D}

Returns canvas texture context.
Parameters:
Name Type Description
obj Object3D Object 3D
text_name string Texture name specified in Blender
Returns:
Canvas texture context
Type
CanvasRenderingContext2D
Source:
See:
Example
var m_scenes = require("scenes");
var m_tex = require("textures");

var cube = m_scenes.get_object_by_name("Cube");
var ctx = m_tex.get_canvas_ctx(cube, "Texture");

get_texture_names(obj) → {Array}

Get texture names.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Texture names array
Type
Array
Source:

pause_video(texture_name, data_idopt)

Pause video.
Parameters:
Name Type Attributes Default Description
texture_name string Texture name
data_id number <optional>
0 ID of loaded data
Source:

play_video(texture_name, data_idopt)

Play video.
Parameters:
Name Type Attributes Default Description
texture_name string Texture name
data_id number <optional>
0 ID of loaded data
Source:
See:

replace_image(obj, text_name, image, callbackopt)

Change texture image. Changing video textures is forbidden.
Parameters:
Name Type Attributes Description
obj Object3D Object 3D
text_name string Texture name specified in Blender
image HTMLElement HTML element Image.
callback TexChangingFinishCallback <optional>
Callback to be executed after changing
Source:
Example
var m_scenes  = require("scenes");
var m_tex = require("textures");

var cube = m_scenes.get_object_by_name("Cube");
var image = new Image();
image.onload = function() {
    m_tex.replace_image(cube, "Texture", image);
}
image.src = "./test.png";

reset_video(texture_name, data_idopt)

Reset video (considering frame_offset value from Blender).
Parameters:
Name Type Attributes Default Description
texture_name string Texture name
data_id number <optional>
0 ID of loaded data
Source:

update_canvas_ctx(obj, text_name)

Update canvas texture context.
Parameters:
Name Type Description
obj Object3D Object 3D
text_name string Texture name specified in Blender
Source:
See:
Example
var m_scenes = require("scenes");
var m_tex = require("textures");

var cube = m_scenes.get_object_by_name("Cube");
m_tex.update_canvas_ctx(cube, "Texture");

Type Definitions

TexChangingFinishCallback(success)

Texture changing finish callback.
Parameters:
Name Type Description
success boolean Operation result
Source: