MeshTexture
require(["esri/geometry/support/MeshTexture"], function(MeshTexture) { /* code goes here */ });
esri/geometry/support/MeshTexture
MeshTexture represents image data to be used for a esri/geometry/support/MeshMaterial. It is mapped to the mesh by its uv vertex attributes. MeshTexture instances can be used with the MeshComponent.material property and they can be set either as a MeshMaterial.colorTexture or as MeshMaterial.normalTexture. Images can be referred to either by url or directly by data ( HTMLImageElement, HTMLCanvasElement or ImageData).
const meshColorByUrl = new MeshTexture({
url: "./image.png"
});
const mesh = Mesh.createBox(location, {
material: {
colorTexture: meshColorByUrl
}
});
const meshColorByCanvas = new MeshTexture({
data: canvasElement
});
const meshWithCanvasMaterial = Mesh.createBox(location, {
material: {
colorTexture: meshColorByCanvas
}
});
// Support for autocasting within a mesh material constructor
const meshWithAutocastMaterial = Mesh.createSphere(location, {
material: {
colorTexture: {
url: "./image.png"
}
}
});
// Mesh materials also support additional advanced autocasting types
// such as a Canvas element. In this case the canvas element will be
// available in the MeshTexture.element property.
const meshWithCanvasAutocastMaterial = Mesh.createSphere(location, {
material: {
colorTexture: canvasElement
}
});
// Here meshWithCanvasAutocastMaterial.material.colorTexture is a MeshTexture
// instance with its data property set canvasElement
- See also:
Constructors
- new MeshTexture(properties)
- Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
HTMLImageElement|HTMLCanvasElement|ImageData | A direct reference to the image data. more details | more details | MeshTexture | |
String | The name of the class. more details | more details | Accessor | |
Boolean | Indicates whether the image data should be interpreted as being semi-transparent. more details | more details | MeshTexture | |
String | The url to the image resource. more details | more details | MeshTexture | |
String|SeparableWrapModes | Specifies how uv coordinates outside the [0, 1] range are handled. more details | more details | MeshTexture |
Property Details
A direct reference to the image data. The image data can be an image element, canvas element or ImageData.
The data property is mutually exclusive with the url property, setting the data will clear the url (if there is one).
The name of the class. The declared class name is formatted as
esri.folder.className
.
- transparent Boolean
Indicates whether the image data should be interpreted as being semi-transparent. The default value is automatically derived when the data property contains a canvas element or an ImageData object. If instead a url to a .png file was provided, it is assumed that transparency is present. In all other cases it defaults to
false
.- Default Value:undefined
- url String
The url to the image resource. This can either be a remote url (absolute or relative) or a data url.
The url property is mutually exclusive with the data property, setting the url will clear the data (if there is one).
Specifies how uv coordinates outside the [0, 1] range are handled. One of "repeat", "clamp" or "mirror". Can also be specified separately for the two texture axes using an object:
{ vertical: "clamp", horizontal: "repeat" }
Possible Values:"clamp"|"repeat"|"mirror"
- Default Value:"repeat"
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
MeshTexture | Creates a deep clone. more details | more details | MeshTexture |
Method Details
- clone(){MeshTexture}
Creates a deep clone.
Returns:Type Description MeshTexture A deep clone of the object that invoked this method.