@aidinabedi/playcanvas
Version:
PlayCanvas WebGL game engine
705 lines (665 loc) • 48.1 kB
HTML
<html lang="en">
<head>
<title>pc.Texture | PlayCanvas API Reference</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/playcanvas-favicon.png">
<link href="styles/styles.css" rel="stylesheet">
<link href="styles/playcanvas-theme.css" rel="stylesheet">
<script src="scripts/interface.js"></script>
<script src="scripts/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<header>
<nav class="header-width">
<a href="/" class="header-title"><img src="images/playcanvas-manual.png"></a>
<ul class="header-menu">
<li class="user-manual"><a href="https://developer.playcanvas.com/en/user-manual/">User Manual</a></li>
<li class="tutorials"><a href="https://developer.playcanvas.com/en/tutorials">Tutorials</a></li>
<li class="forum"><a href="https://forum.playcanvas.com/" target="_blank">Forum</a></li>
<li class="api active"><a href="/api/">API Reference</a></li>
</ul>
</nav>
<div class="header-content header-page header-width">
<h1><span class="font-icon"></span>API Reference</h1>
<input id="search" class="search" type="text" placeholder="Search"></input>
</div>
</header>
<div class="container content-width">
<nav class="sidebar">
<div class="sidebarFilter">
<input id="filter-input" type="text" placeholder="Filter">
</div>
<ul>
<li id="nav-pc"><a href="pc.html">pc</a></li>
<li id="nav-pc.callbacks"><a href="pc.callbacks.html">pc.callbacks</a></li>
<li id="nav-pc.guid"><a href="pc.guid.html">pc.guid</a></li>
<li id="nav-pc.math"><a href="pc.math.html">pc.math</a></li>
<li id="nav-pc.path"><a href="pc.path.html">pc.path</a></li>
<li id="nav-pc.platform"><a href="pc.platform.html">pc.platform</a></li>
<li id="nav-pc.script"><a href="pc.script.html">pc.script</a></li>
<li id="nav-pc.string"><a href="pc.string.html">pc.string</a></li>
<li id="nav-pc.Animation"><a href="pc.Animation.html">Animation</a></li>
<li id="nav-pc.AnimationComponent"><a href="pc.AnimationComponent.html">AnimationComponent</a></li>
<li id="nav-pc.AnimationComponentSystem"><a href="pc.AnimationComponentSystem.html">AnimationComponentSystem</a></li>
<li id="nav-pc.AnimationHandler"><a href="pc.AnimationHandler.html">AnimationHandler</a></li>
<li id="nav-pc.AnimCache"><a href="pc.AnimCache.html">AnimCache</a></li>
<li id="nav-pc.AnimClip"><a href="pc.AnimClip.html">AnimClip</a></li>
<li id="nav-pc.AnimController"><a href="pc.AnimController.html">AnimController</a></li>
<li id="nav-pc.AnimCurve"><a href="pc.AnimCurve.html">AnimCurve</a></li>
<li id="nav-pc.AnimData"><a href="pc.AnimData.html">AnimData</a></li>
<li id="nav-pc.AnimSnapshot"><a href="pc.AnimSnapshot.html">AnimSnapshot</a></li>
<li id="nav-pc.AnimTarget"><a href="pc.AnimTarget.html">AnimTarget</a></li>
<li id="nav-pc.AnimTrack"><a href="pc.AnimTrack.html">AnimTrack</a></li>
<li id="nav-pc.Application"><a href="pc.Application.html">Application</a></li>
<li id="nav-pc.Asset"><a href="pc.Asset.html">Asset</a></li>
<li id="nav-pc.AssetReference"><a href="pc.AssetReference.html">AssetReference</a></li>
<li id="nav-pc.AssetRegistry"><a href="pc.AssetRegistry.html">AssetRegistry</a></li>
<li id="nav-pc.AudioHandler"><a href="pc.AudioHandler.html">AudioHandler</a></li>
<li id="nav-pc.AudioListenerComponent"><a href="pc.AudioListenerComponent.html">AudioListenerComponent</a></li>
<li id="nav-pc.AudioListenerComponentSystem"><a href="pc.AudioListenerComponentSystem.html">AudioListenerComponentSystem</a></li>
<li id="nav-pc.BasicMaterial"><a href="pc.BasicMaterial.html">BasicMaterial</a></li>
<li id="nav-pc.Batch"><a href="pc.Batch.html">Batch</a></li>
<li id="nav-pc.BatchGroup"><a href="pc.BatchGroup.html">BatchGroup</a></li>
<li id="nav-pc.BatchManager"><a href="pc.BatchManager.html">BatchManager</a></li>
<li id="nav-pc.BoundingBox"><a href="pc.BoundingBox.html">BoundingBox</a></li>
<li id="nav-pc.BoundingSphere"><a href="pc.BoundingSphere.html">BoundingSphere</a></li>
<li id="nav-pc.ButtonComponent"><a href="pc.ButtonComponent.html">ButtonComponent</a></li>
<li id="nav-pc.ButtonComponentSystem"><a href="pc.ButtonComponentSystem.html">ButtonComponentSystem</a></li>
<li id="nav-pc.CameraComponent"><a href="pc.CameraComponent.html">CameraComponent</a></li>
<li id="nav-pc.CameraComponentSystem"><a href="pc.CameraComponentSystem.html">CameraComponentSystem</a></li>
<li id="nav-pc.CollisionComponent"><a href="pc.CollisionComponent.html">CollisionComponent</a></li>
<li id="nav-pc.CollisionComponentSystem"><a href="pc.CollisionComponentSystem.html">CollisionComponentSystem</a></li>
<li id="nav-pc.Color"><a href="pc.Color.html">Color</a></li>
<li id="nav-pc.Component"><a href="pc.Component.html">Component</a></li>
<li id="nav-pc.ComponentSystem"><a href="pc.ComponentSystem.html">ComponentSystem</a></li>
<li id="nav-pc.ComponentSystemRegistry"><a href="pc.ComponentSystemRegistry.html">ComponentSystemRegistry</a></li>
<li id="nav-pc.ContactPoint"><a href="pc.ContactPoint.html">ContactPoint</a></li>
<li id="nav-pc.ContactResult"><a href="pc.ContactResult.html">ContactResult</a></li>
<li id="nav-pc.ContainerHandler"><a href="pc.ContainerHandler.html">ContainerHandler</a></li>
<li id="nav-pc.ContainerResource"><a href="pc.ContainerResource.html">ContainerResource</a></li>
<li id="nav-pc.Controller"><a href="pc.Controller.html">Controller</a></li>
<li id="nav-pc.CubemapHandler"><a href="pc.CubemapHandler.html">CubemapHandler</a></li>
<li id="nav-pc.Curve"><a href="pc.Curve.html">Curve</a></li>
<li id="nav-pc.CurveSet"><a href="pc.CurveSet.html">CurveSet</a></li>
<li id="nav-pc.ElementComponent"><a href="pc.ElementComponent.html">ElementComponent</a></li>
<li id="nav-pc.ElementComponentSystem"><a href="pc.ElementComponentSystem.html">ElementComponentSystem</a></li>
<li id="nav-pc.ElementDragHelper"><a href="pc.ElementDragHelper.html">ElementDragHelper</a></li>
<li id="nav-pc.ElementInput"><a href="pc.ElementInput.html">ElementInput</a></li>
<li id="nav-pc.ElementInputEvent"><a href="pc.ElementInputEvent.html">ElementInputEvent</a></li>
<li id="nav-pc.ElementMouseEvent"><a href="pc.ElementMouseEvent.html">ElementMouseEvent</a></li>
<li id="nav-pc.ElementTouchEvent"><a href="pc.ElementTouchEvent.html">ElementTouchEvent</a></li>
<li id="nav-pc.Entity"><a href="pc.Entity.html">Entity</a></li>
<li id="nav-pc.EventHandler"><a href="pc.EventHandler.html">EventHandler</a></li>
<li id="nav-pc.Font"><a href="pc.Font.html">Font</a></li>
<li id="nav-pc.FontHandler"><a href="pc.FontHandler.html">FontHandler</a></li>
<li id="nav-pc.ForwardRenderer"><a href="pc.ForwardRenderer.html">ForwardRenderer</a></li>
<li id="nav-pc.Frustum"><a href="pc.Frustum.html">Frustum</a></li>
<li id="nav-pc.GamePads"><a href="pc.GamePads.html">GamePads</a></li>
<li id="nav-pc.GraphicsDevice"><a href="pc.GraphicsDevice.html">GraphicsDevice</a></li>
<li id="nav-pc.GraphNode"><a href="pc.GraphNode.html">GraphNode</a></li>
<li id="nav-pc.Http"><a href="pc.Http.html">Http</a></li>
<li id="nav-pc.I18n"><a href="pc.I18n.html">I18n</a></li>
<li id="nav-pc.IndexBuffer"><a href="pc.IndexBuffer.html">IndexBuffer</a></li>
<li id="nav-pc.Keyboard"><a href="pc.Keyboard.html">Keyboard</a></li>
<li id="nav-pc.KeyboardEvent"><a href="pc.KeyboardEvent.html">KeyboardEvent</a></li>
<li id="nav-pc.Layer"><a href="pc.Layer.html">Layer</a></li>
<li id="nav-pc.LayerComposition"><a href="pc.LayerComposition.html">LayerComposition</a></li>
<li id="nav-pc.LayoutChildComponent"><a href="pc.LayoutChildComponent.html">LayoutChildComponent</a></li>
<li id="nav-pc.LayoutChildComponentSystem"><a href="pc.LayoutChildComponentSystem.html">LayoutChildComponentSystem</a></li>
<li id="nav-pc.LayoutGroupComponent"><a href="pc.LayoutGroupComponent.html">LayoutGroupComponent</a></li>
<li id="nav-pc.LayoutGroupComponentSystem"><a href="pc.LayoutGroupComponentSystem.html">LayoutGroupComponentSystem</a></li>
<li id="nav-pc.LightComponent"><a href="pc.LightComponent.html">LightComponent</a></li>
<li id="nav-pc.LightComponentSystem"><a href="pc.LightComponentSystem.html">LightComponentSystem</a></li>
<li id="nav-pc.Lightmapper"><a href="pc.Lightmapper.html">Lightmapper</a></li>
<li id="nav-pc.Mat3"><a href="pc.Mat3.html">Mat3</a></li>
<li id="nav-pc.Mat4"><a href="pc.Mat4.html">Mat4</a></li>
<li id="nav-pc.Material"><a href="pc.Material.html">Material</a></li>
<li id="nav-pc.MaterialHandler"><a href="pc.MaterialHandler.html">MaterialHandler</a></li>
<li id="nav-pc.Mesh"><a href="pc.Mesh.html">Mesh</a></li>
<li id="nav-pc.MeshInstance"><a href="pc.MeshInstance.html">MeshInstance</a></li>
<li id="nav-pc.Model"><a href="pc.Model.html">Model</a></li>
<li id="nav-pc.ModelComponent"><a href="pc.ModelComponent.html">ModelComponent</a></li>
<li id="nav-pc.ModelComponentSystem"><a href="pc.ModelComponentSystem.html">ModelComponentSystem</a></li>
<li id="nav-pc.ModelHandler"><a href="pc.ModelHandler.html">ModelHandler</a></li>
<li id="nav-pc.Morph"><a href="pc.Morph.html">Morph</a></li>
<li id="nav-pc.MorphInstance"><a href="pc.MorphInstance.html">MorphInstance</a></li>
<li id="nav-pc.MorphTarget"><a href="pc.MorphTarget.html">MorphTarget</a></li>
<li id="nav-pc.Mouse"><a href="pc.Mouse.html">Mouse</a></li>
<li id="nav-pc.MouseEvent"><a href="pc.MouseEvent.html">MouseEvent</a></li>
<li id="nav-pc.Node"><a href="pc.Node.html">Node</a></li>
<li id="nav-pc.OrientedBox"><a href="pc.OrientedBox.html">OrientedBox</a></li>
<li id="nav-pc.ParticleSystemComponent"><a href="pc.ParticleSystemComponent.html">ParticleSystemComponent</a></li>
<li id="nav-pc.ParticleSystemComponentSystem"><a href="pc.ParticleSystemComponentSystem.html">ParticleSystemComponentSystem</a></li>
<li id="nav-pc.Picker"><a href="pc.Picker.html">Picker</a></li>
<li id="nav-pc.PostEffect"><a href="pc.PostEffect.html">PostEffect</a></li>
<li id="nav-pc.PostEffectQueue"><a href="pc.PostEffectQueue.html">PostEffectQueue</a></li>
<li id="nav-pc.Quat"><a href="pc.Quat.html">Quat</a></li>
<li id="nav-pc.Ray"><a href="pc.Ray.html">Ray</a></li>
<li id="nav-pc.RaycastResult"><a href="pc.RaycastResult.html">RaycastResult</a></li>
<li id="nav-pc.RenderTarget"><a href="pc.RenderTarget.html">RenderTarget</a></li>
<li id="nav-pc.ResourceHandler"><a href="pc.ResourceHandler.html">ResourceHandler</a></li>
<li id="nav-pc.ResourceLoader"><a href="pc.ResourceLoader.html">ResourceLoader</a></li>
<li id="nav-pc.RigidBodyComponent"><a href="pc.RigidBodyComponent.html">RigidBodyComponent</a></li>
<li id="nav-pc.RigidBodyComponentSystem"><a href="pc.RigidBodyComponentSystem.html">RigidBodyComponentSystem</a></li>
<li id="nav-pc.Scene"><a href="pc.Scene.html">Scene</a></li>
<li id="nav-pc.SceneHandler"><a href="pc.SceneHandler.html">SceneHandler</a></li>
<li id="nav-pc.ScopeId"><a href="pc.ScopeId.html">ScopeId</a></li>
<li id="nav-pc.ScopeSpace"><a href="pc.ScopeSpace.html">ScopeSpace</a></li>
<li id="nav-pc.ScreenComponent"><a href="pc.ScreenComponent.html">ScreenComponent</a></li>
<li id="nav-pc.ScreenComponentSystem"><a href="pc.ScreenComponentSystem.html">ScreenComponentSystem</a></li>
<li id="nav-pc.ScriptAttributes"><a href="pc.ScriptAttributes.html">ScriptAttributes</a></li>
<li id="nav-pc.ScriptComponent"><a href="pc.ScriptComponent.html">ScriptComponent</a></li>
<li id="nav-pc.ScriptComponentSystem"><a href="pc.ScriptComponentSystem.html">ScriptComponentSystem</a></li>
<li id="nav-pc.ScriptHandler"><a href="pc.ScriptHandler.html">ScriptHandler</a></li>
<li id="nav-pc.ScriptRegistry"><a href="pc.ScriptRegistry.html">ScriptRegistry</a></li>
<li id="nav-pc.ScriptType"><a href="pc.ScriptType.html">ScriptType</a></li>
<li id="nav-pc.ScrollbarComponent"><a href="pc.ScrollbarComponent.html">ScrollbarComponent</a></li>
<li id="nav-pc.ScrollbarComponentSystem"><a href="pc.ScrollbarComponentSystem.html">ScrollbarComponentSystem</a></li>
<li id="nav-pc.ScrollViewComponent"><a href="pc.ScrollViewComponent.html">ScrollViewComponent</a></li>
<li id="nav-pc.ScrollViewComponentSystem"><a href="pc.ScrollViewComponentSystem.html">ScrollViewComponentSystem</a></li>
<li id="nav-pc.Shader"><a href="pc.Shader.html">Shader</a></li>
<li id="nav-pc.SingleContactResult"><a href="pc.SingleContactResult.html">SingleContactResult</a></li>
<li id="nav-pc.Skeleton"><a href="pc.Skeleton.html">Skeleton</a></li>
<li id="nav-pc.Skin"><a href="pc.Skin.html">Skin</a></li>
<li id="nav-pc.SkinInstance"><a href="pc.SkinInstance.html">SkinInstance</a></li>
<li id="nav-pc.Sound"><a href="pc.Sound.html">Sound</a></li>
<li id="nav-pc.SoundComponent"><a href="pc.SoundComponent.html">SoundComponent</a></li>
<li id="nav-pc.SoundComponentSystem"><a href="pc.SoundComponentSystem.html">SoundComponentSystem</a></li>
<li id="nav-pc.SoundInstance"><a href="pc.SoundInstance.html">SoundInstance</a></li>
<li id="nav-pc.SoundInstance3d"><a href="pc.SoundInstance3d.html">SoundInstance3d</a></li>
<li id="nav-pc.SoundManager"><a href="pc.SoundManager.html">SoundManager</a></li>
<li id="nav-pc.SoundSlot"><a href="pc.SoundSlot.html">SoundSlot</a></li>
<li id="nav-pc.Sprite"><a href="pc.Sprite.html">Sprite</a></li>
<li id="nav-pc.SpriteAnimationClip"><a href="pc.SpriteAnimationClip.html">SpriteAnimationClip</a></li>
<li id="nav-pc.SpriteComponent"><a href="pc.SpriteComponent.html">SpriteComponent</a></li>
<li id="nav-pc.SpriteComponentSystem"><a href="pc.SpriteComponentSystem.html">SpriteComponentSystem</a></li>
<li id="nav-pc.SpriteHandler"><a href="pc.SpriteHandler.html">SpriteHandler</a></li>
<li id="nav-pc.StandardMaterial"><a href="pc.StandardMaterial.html">StandardMaterial</a></li>
<li id="nav-pc.StencilParameters"><a href="pc.StencilParameters.html">StencilParameters</a></li>
<li id="nav-pc.Tags"><a href="pc.Tags.html">Tags</a></li>
<li id="nav-pc.Texture"><a href="pc.Texture.html">Texture</a></li>
<li id="nav-pc.TextureAtlas"><a href="pc.TextureAtlas.html">TextureAtlas</a></li>
<li id="nav-pc.TextureAtlasHandler"><a href="pc.TextureAtlasHandler.html">TextureAtlasHandler</a></li>
<li id="nav-pc.TextureHandler"><a href="pc.TextureHandler.html">TextureHandler</a></li>
<li id="nav-pc.Touch"><a href="pc.Touch.html">Touch</a></li>
<li id="nav-pc.TouchDevice"><a href="pc.TouchDevice.html">TouchDevice</a></li>
<li id="nav-pc.TouchEvent"><a href="pc.TouchEvent.html">TouchEvent</a></li>
<li id="nav-pc.TransformFeedback"><a href="pc.TransformFeedback.html">TransformFeedback</a></li>
<li id="nav-pc.Vec2"><a href="pc.Vec2.html">Vec2</a></li>
<li id="nav-pc.Vec3"><a href="pc.Vec3.html">Vec3</a></li>
<li id="nav-pc.Vec4"><a href="pc.Vec4.html">Vec4</a></li>
<li id="nav-pc.VertexAttributeDescription"><a href="pc.VertexAttributeDescription.html">VertexAttributeDescription</a></li>
<li id="nav-pc.VertexAttributeElement"><a href="pc.VertexAttributeElement.html">VertexAttributeElement</a></li>
<li id="nav-pc.VertexBuffer"><a href="pc.VertexBuffer.html">VertexBuffer</a></li>
<li id="nav-pc.VertexFormat"><a href="pc.VertexFormat.html">VertexFormat</a></li>
<li id="nav-pc.VertexIterator"><a href="pc.VertexIterator.html">VertexIterator</a></li>
<li id="nav-pc.VertexIteratorAccessor"><a href="pc.VertexIteratorAccessor.html">VertexIteratorAccessor</a></li>
<li id="nav-pc.XrInput"><a href="pc.XrInput.html">XrInput</a></li>
<li id="nav-pc.XrInputSource"><a href="pc.XrInputSource.html">XrInputSource</a></li>
<li id="nav-pc.XrManager"><a href="pc.XrManager.html">XrManager</a></li>
</ul>
</nav>
<div class='sidebarToggle'><span></span>Class List</div>
<main class="cls">
<h1>pc.Texture</h1>
<p><p>A texture is a container for texel data that can be utilized in a fragment shader.
Typically, the texel data represents an image that is mapped over geometry.</p></p>
<pre><code class="javascript">// Create a 8x8x24-bit texture
var texture = new pc.Texture(graphicsDevice, {
width: 8,
height: 8,
format: pc.PIXELFORMAT_R8_G8_B8
});
// Fill the texture with a gradient
var pixels = texture.lock();
var count = 0;
for (var i = 0; i < 8; i++) {
for (var j = 0; j < 8; j++) {
pixels[count++] = i * 32;
pixels[count++] = j * 32;
pixels[count++] = 255;
}
}
texture.unlock();</code></pre>
<!-- summary -->
<h1>Summary</h1>
<!--type definitions-->
<!--static properties-->
<!--static methods-->
<!--properties-->
<h3>Properties</h3>
<table class="properties">
<tr>
<td><a href="#addressU">addressU</a></td><td><p>The addressing mode to be applied to the texture horizontally.</td>
</tr>
<tr>
<td><a href="#addressV">addressV</a></td><td><p>The addressing mode to be applied to the texture vertically.</td>
</tr>
<tr>
<td><a href="#addressW">addressW</a></td><td><p>The addressing mode to be applied to the 3D texture depth (WebGL2 only).</td>
</tr>
<tr>
<td><a href="#anisotropy">anisotropy</a></td><td><p>Integer value specifying the level of anisotropic to apply to the texture
ranging from 1 (no anisotropic filtering) to the <a href="pc.GraphicsDevice.html">pc.GraphicsDevice</a> property maxAnisotropy.</td>
</tr>
<tr>
<td><a href="#compareFunc">compareFunc</a></td><td><p>Comparison function when compareOnRead is enabled (WebGL2 only).</td>
</tr>
<tr>
<td><a href="#compareOnRead">compareOnRead</a></td><td><p>When enabled, and if texture format is pc.</td>
</tr>
<tr>
<td><a href="#cubemap">cubemap</a></td><td><p>Returns true if this texture is a cube map and false otherwise.<span class='readonly'>[read only]</span></td>
</tr>
<tr>
<td><a href="#depth">depth</a></td><td><p>The number of depth slices in a 3D texture (WebGL2 only).<span class='readonly'>[read only]</span></td>
</tr>
<tr>
<td><a href="#flipY">flipY</a></td><td><p>Specifies whether the texture should be flipped in the Y-direction.</td>
</tr>
<tr>
<td><a href="#format">format</a></td><td><p>The pixel format of the texture.<span class='readonly'>[read only]</span></td>
</tr>
<tr>
<td><a href="#height">height</a></td><td><p>The height of the texture in pixels.<span class='readonly'>[read only]</span></td>
</tr>
<tr>
<td><a href="#magFilter">magFilter</a></td><td><p>The magnification filter to be applied to the texture.</td>
</tr>
<tr>
<td><a href="#minFilter">minFilter</a></td><td><p>The minification filter to be applied to the texture.</td>
</tr>
<tr>
<td><a href="#mipmaps">mipmaps</a></td><td><p>Defines if texture should generate/upload mipmaps if possible.</td>
</tr>
<tr>
<td><a href="#name">name</a></td><td><p>The name of the texture.</td>
</tr>
<tr>
<td><a href="#pot">pot</a></td><td><p>Returns true if all dimensions of the texture are power of two, and false otherwise.<span class='readonly'>[read only]</span></td>
</tr>
<tr>
<td><a href="#volume">volume</a></td><td><p>Returns true if this texture is a 3D volume and false otherwise.<span class='readonly'>[read only]</span></td>
</tr>
<tr>
<td><a href="#width">width</a></td><td><p>The width of the texture in pixels.<span class='readonly'>[read only]</span></td>
</tr>
</table>
<!--methods-->
<h3>Methods</h3>
<table class="properties">
<tr>
<td><a href="#destroy">destroy</a></td><td><p>Forcibly free up the underlying WebGL resource owned by the texture.</td>
</tr>
<tr>
<td><a href="#getSource">getSource</a></td><td><p>Get the pixel data of the texture.</td>
</tr>
<tr>
<td><a href="#lock">lock</a></td><td><p>Locks a miplevel of the texture, returning a typed array to be filled with pixel data.</td>
</tr>
<tr>
<td><a href="#setSource">setSource</a></td><td><p>Set the pixel data of the texture from a canvas, image, video DOM element.</td>
</tr>
<tr>
<td><a href="#unlock">unlock</a></td><td><p>Unlocks the currently locked mip level and uploads it to VRAM.</td>
</tr>
<tr>
<td><a href="#upload">upload</a></td><td><p>Forces a reupload of the textures pixel data to graphics memory.</td>
</tr>
</table>
<!--events-->
<h1>Details</h1>
<!--type definitions-->
<!--static members-->
<!--static methods-->
<h2>Constructor</h2>
<!-- Constructor -->
<div id="Texture">
<h3 class="methodname">Texture(graphicsDevice, [options]) <a class="font-icon" href="#Texture"></a></h3>
<p><p>Creates a new texture.</p></p>
<pre><code class="javascript">// Create a 8x8x24-bit texture
var texture = new pc.Texture(graphicsDevice, {
width: 8,
height: 8,
format: pc.PIXELFORMAT_R8_G8_B8
});
// Fill the texture with a gradient
var pixels = texture.lock();
var count = 0;
for (var i = 0; i < 8; i++) {
for (var j = 0; j < 8; j++) {
pixels[count++] = i * 32;
pixels[count++] = j * 32;
pixels[count++] = 255;
}
}
texture.unlock();</code></pre>
<h4>Parameters</h4>
<table>
<tr>
<td>graphicsDevice</td><td><a href="pc.GraphicsDevice.html">pc.GraphicsDevice</a></td><td><p>The graphics device used to manage this texture.</p></td>
</tr>
<tr>
<td>options</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></td><td><p>Object for passing optional arguments.</p></td>
</tr>
<tr>
<td>options.name</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></td><td><p>The name of the texture.</p></td>
</tr>
<tr>
<td>options.width</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The width of the texture in pixels. Defaults to 4.</p></td>
</tr>
<tr>
<td>options.height</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The height of the texture in pixels. Defaults to 4.</p></td>
</tr>
<tr>
<td>options.depth</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The number of depth slices in a 3D texture (WebGL2 only). Defaults to 1 (single 2D image).</p></td>
</tr>
<tr>
<td>options.format</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The pixel format of the texture. Can be:</p>
<ul>
<li><a href="pc.html#PIXELFORMAT_A8">pc.PIXELFORMAT_A8</a></li>
<li><a href="pc.html#PIXELFORMAT_L8">pc.PIXELFORMAT_L8</a></li>
<li><a href="pc.html#PIXELFORMAT_L8_A8">pc.PIXELFORMAT_L8_A8</a></li>
<li><a href="pc.html#PIXELFORMAT_R5_G6_B5">pc.PIXELFORMAT_R5_G6_B5</a></li>
<li><a href="pc.html#PIXELFORMAT_R5_G5_B5_A1">pc.PIXELFORMAT_R5_G5_B5_A1</a></li>
<li><a href="pc.html#PIXELFORMAT_R4_G4_B4_A4">pc.PIXELFORMAT_R4_G4_B4_A4</a></li>
<li><a href="pc.html#PIXELFORMAT_R8_G8_B8">pc.PIXELFORMAT_R8_G8_B8</a></li>
<li><a href="pc.html#PIXELFORMAT_R8_G8_B8_A8">pc.PIXELFORMAT_R8_G8_B8_A8</a></li>
<li><a href="pc.html#PIXELFORMAT_DXT1">pc.PIXELFORMAT_DXT1</a></li>
<li><a href="pc.html#PIXELFORMAT_DXT3">pc.PIXELFORMAT_DXT3</a></li>
<li><a href="pc.html#PIXELFORMAT_DXT5">pc.PIXELFORMAT_DXT5</a></li>
<li><a href="pc.html#PIXELFORMAT_RGB16F">pc.PIXELFORMAT_RGB16F</a></li>
<li><a href="pc.html#PIXELFORMAT_RGBA16F">pc.PIXELFORMAT_RGBA16F</a></li>
<li><a href="pc.html#PIXELFORMAT_RGB32F">pc.PIXELFORMAT_RGB32F</a></li>
<li><a href="pc.html#PIXELFORMAT_RGBA32F">pc.PIXELFORMAT_RGBA32F</a></li>
<li><a href="pc.html#PIXELFORMAT_ETC1">pc.PIXELFORMAT_ETC1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_2BPP_RGB_1">pc.PIXELFORMAT_PVRTC_2BPP_RGB_1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_2BPP_RGBA_1">pc.PIXELFORMAT_PVRTC_2BPP_RGBA_1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_4BPP_RGB_1">pc.PIXELFORMAT_PVRTC_4BPP_RGB_1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_4BPP_RGBA_1">pc.PIXELFORMAT_PVRTC_4BPP_RGBA_1</a></li>
<li><a href="pc.html#PIXELFORMAT_111110F">pc.PIXELFORMAT_111110F</a></li>
<li><a href="pc.html#PIXELFORMAT_ASTC_4x4">pc.PIXELFORMAT_ASTC_4x4</a>>/li></li>
<li><a href="pc.html#PIXELFORMAT_ATC_RGB">pc.PIXELFORMAT_ATC_RGB</a></li>
<li><a href="pc.html#PIXELFORMAT_ATC_RGBA">pc.PIXELFORMAT_ATC_RGBA</a>
Defaults to pc.PIXELFORMAT_R8_G8_B8_A8.</li>
</ul></td>
</tr>
<tr>
<td>options.minFilter</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The minification filter type to use. Defaults to <a href="pc.html#FILTER_LINEAR_MIPMAP_LINEAR">pc.FILTER_LINEAR_MIPMAP_LINEAR</a></p></td>
</tr>
<tr>
<td>options.magFilter</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The magnification filter type to use. Defaults to <a href="pc.html#FILTER_LINEAR">pc.FILTER_LINEAR</a></p></td>
</tr>
<tr>
<td>options.anisotropy</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The level of anisotropic filtering to use. Defaults to 1</p></td>
</tr>
<tr>
<td>options.addressU</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The repeat mode to use in the U direction. Defaults to <a href="pc.html#ADDRESS_REPEAT">pc.ADDRESS_REPEAT</a></p></td>
</tr>
<tr>
<td>options.addressV</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The repeat mode to use in the V direction. Defaults to <a href="pc.html#ADDRESS_REPEAT">pc.ADDRESS_REPEAT</a></p></td>
</tr>
<tr>
<td>options.addressW</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The repeat mode to use in the W direction. Defaults to <a href="pc.html#ADDRESS_REPEAT">pc.ADDRESS_REPEAT</a></p></td>
</tr>
<tr>
<td>options.mipmaps</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>When enabled try to generate or use mipmaps for this texture. Default is true</p></td>
</tr>
<tr>
<td>options.cubemap</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Specifies whether the texture is to be a cubemap. Defaults to false.</p></td>
</tr>
<tr>
<td>options.volume</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Specifies whether the texture is to be a 3D volume (WebGL2 only). Defaults to false.</p></td>
</tr>
<tr>
<td>options.rgbm</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Specifies whether the texture contains RGBM-encoded HDR data. Defaults to false.</p></td>
</tr>
<tr>
<td>options.swizzleGGGR</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Specifies whether the texture contains swizzled GGGR data for use with tangent space normal
maps. The R component is stored in alpha and G is stored in RGB. This packing can result in higher quality when the texture data
is compressed. Defaults to false.</p></td>
</tr>
<tr>
<td>options.fixCubemapSeams</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Specifies whether this cubemap texture requires special
seam fixing shader code to look right. Defaults to false.</p></td>
</tr>
<tr>
<td>options.flipY</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Specifies whether the texture should be flipped in the Y-direction. Only affects textures
with a source that is an image, canvas or video element. Does not affect cubemaps, compressed textures or textures set from raw
pixel data. Defaults to true.</p></td>
</tr>
<tr>
<td>options.premultiplyAlpha</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>If true, the alpha channel of the texture (if present) is multiplied into the color
channels. Defaults to false.</p></td>
</tr>
<tr>
<td>options.compareOnRead</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>When enabled, and if texture format is pc.PIXELFORMAT_DEPTH or pc.PIXELFORMAT_DEPTHSTENCIL,
hardware PCF is enabled for this texture, and you can get filtered results of comparison using texture() in your shader (WebGL2 only).
Defaults to false.</p></td>
</tr>
<tr>
<td>options.compareFunc</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>Comparison function when compareOnRead is enabled (WebGL2 only). Defaults to pc.FUNC_LESS.
Possible values:</p>
<ul>
<li><a href="pc.html#FUNC_LESS">pc.FUNC_LESS</a></li>
<li><a href="pc.html#FUNC_LESSEQUAL">pc.FUNC_LESSEQUAL</a></li>
<li><a href="pc.html#FUNC_GREATER">pc.FUNC_GREATER</a></li>
<li><a href="pc.html#FUNC_GREATEREQUAL">pc.FUNC_GREATEREQUAL</a></li>
<li><a href="pc.html#FUNC_EQUAL">pc.FUNC_EQUAL</a></li>
<li><a href="pc.html#FUNC_NOTEQUAL">pc.FUNC_NOTEQUAL</a></li>
</ul></td>
</tr>
</table>
</div>
<!--properties-->
<h2>Properties</h2>
<div id="addressU">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">addressU <a class="font-icon" href="#addressU"></a></span>
<p><p>The addressing mode to be applied to the texture horizontally. Can be:</p>
<ul>
<li><a href="pc.html#ADDRESS_REPEAT">pc.ADDRESS_REPEAT</a></li>
<li><a href="pc.html#ADDRESS_CLAMP_TO_EDGE">pc.ADDRESS_CLAMP_TO_EDGE</a></li>
<li><a href="pc.html#ADDRESS_MIRRORED_REPEAT">pc.ADDRESS_MIRRORED_REPEAT</a></li>
</ul></p>
</div>
<div id="addressV">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">addressV <a class="font-icon" href="#addressV"></a></span>
<p><p>The addressing mode to be applied to the texture vertically. Can be:</p>
<ul>
<li><a href="pc.html#ADDRESS_REPEAT">pc.ADDRESS_REPEAT</a></li>
<li><a href="pc.html#ADDRESS_CLAMP_TO_EDGE">pc.ADDRESS_CLAMP_TO_EDGE</a></li>
<li><a href="pc.html#ADDRESS_MIRRORED_REPEAT">pc.ADDRESS_MIRRORED_REPEAT</a></li>
</ul></p>
</div>
<div id="addressW">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">addressW <a class="font-icon" href="#addressW"></a></span>
<p><p>The addressing mode to be applied to the 3D texture depth (WebGL2 only). Can be:</p>
<ul>
<li><a href="pc.html#ADDRESS_REPEAT">pc.ADDRESS_REPEAT</a></li>
<li><a href="pc.html#ADDRESS_CLAMP_TO_EDGE">pc.ADDRESS_CLAMP_TO_EDGE</a></li>
<li><a href="pc.html#ADDRESS_MIRRORED_REPEAT">pc.ADDRESS_MIRRORED_REPEAT</a></li>
</ul></p>
</div>
<div id="anisotropy">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">anisotropy <a class="font-icon" href="#anisotropy"></a></span>
<p><p>Integer value specifying the level of anisotropic to apply to the texture
ranging from 1 (no anisotropic filtering) to the <a href="pc.GraphicsDevice.html">pc.GraphicsDevice</a> property maxAnisotropy.</p></p>
</div>
<div id="compareFunc">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">compareFunc <a class="font-icon" href="#compareFunc"></a></span>
<p><p>Comparison function when compareOnRead is enabled (WebGL2 only).
Possible values:</p>
<ul>
<li><a href="pc.html#FUNC_LESS">pc.FUNC_LESS</a></li>
<li><a href="pc.html#FUNC_LESSEQUAL">pc.FUNC_LESSEQUAL</a></li>
<li><a href="pc.html#FUNC_GREATER">pc.FUNC_GREATER</a></li>
<li><a href="pc.html#FUNC_GREATEREQUAL">pc.FUNC_GREATEREQUAL</a></li>
<li><a href="pc.html#FUNC_EQUAL">pc.FUNC_EQUAL</a></li>
<li><a href="pc.html#FUNC_NOTEQUAL">pc.FUNC_NOTEQUAL</a></li>
</ul></p>
</div>
<div id="compareOnRead">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">compareOnRead <a class="font-icon" href="#compareOnRead"></a></span>
<p><p>When enabled, and if texture format is pc.PIXELFORMAT_DEPTH or pc.PIXELFORMAT_DEPTHSTENCIL,
hardware PCF is enabled for this texture, and you can get filtered results of comparison using texture() in your shader (WebGL2 only).</p></p>
</div>
<div id="cubemap">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">cubemap <a class="font-icon" href="#cubemap"></a></span>
<p><p>Returns true if this texture is a cube map and false otherwise.</p><span class='readonly'>[read only]</span></p>
</div>
<div id="depth">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">depth <a class="font-icon" href="#depth"></a></span>
<p><p>The number of depth slices in a 3D texture (WebGL2 only).</p><span class='readonly'>[read only]</span></p>
</div>
<div id="flipY">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">flipY <a class="font-icon" href="#flipY"></a></span>
<p><p>Specifies whether the texture should be flipped in the Y-direction. Only affects textures
with a source that is an image, canvas or video element. Does not affect cubemaps, compressed textures
or textures set from raw pixel data. Defaults to true.</p></p>
</div>
<div id="format">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">format <a class="font-icon" href="#format"></a></span>
<p><p>The pixel format of the texture. Can be:</p>
<ul>
<li><a href="pc.html#PIXELFORMAT_A8">pc.PIXELFORMAT_A8</a></li>
<li><a href="pc.html#PIXELFORMAT_L8">pc.PIXELFORMAT_L8</a></li>
<li><a href="pc.html#PIXELFORMAT_L8_A8">pc.PIXELFORMAT_L8_A8</a></li>
<li><a href="pc.html#PIXELFORMAT_R5_G6_B5">pc.PIXELFORMAT_R5_G6_B5</a></li>
<li><a href="pc.html#PIXELFORMAT_R5_G5_B5_A1">pc.PIXELFORMAT_R5_G5_B5_A1</a></li>
<li><a href="pc.html#PIXELFORMAT_R4_G4_B4_A4">pc.PIXELFORMAT_R4_G4_B4_A4</a></li>
<li><a href="pc.html#PIXELFORMAT_R8_G8_B8">pc.PIXELFORMAT_R8_G8_B8</a></li>
<li><a href="pc.html#PIXELFORMAT_R8_G8_B8_A8">pc.PIXELFORMAT_R8_G8_B8_A8</a></li>
<li><a href="pc.html#PIXELFORMAT_DXT1">pc.PIXELFORMAT_DXT1</a></li>
<li><a href="pc.html#PIXELFORMAT_DXT3">pc.PIXELFORMAT_DXT3</a></li>
<li><a href="pc.html#PIXELFORMAT_DXT5">pc.PIXELFORMAT_DXT5</a></li>
<li><a href="pc.html#PIXELFORMAT_RGB16F">pc.PIXELFORMAT_RGB16F</a></li>
<li><a href="pc.html#PIXELFORMAT_RGBA16F">pc.PIXELFORMAT_RGBA16F</a></li>
<li><a href="pc.html#PIXELFORMAT_RGB32F">pc.PIXELFORMAT_RGB32F</a></li>
<li><a href="pc.html#PIXELFORMAT_RGBA32F">pc.PIXELFORMAT_RGBA32F</a></li>
<li><a href="pc.html#PIXELFORMAT_ETC1">pc.PIXELFORMAT_ETC1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_2BPP_RGB_1">pc.PIXELFORMAT_PVRTC_2BPP_RGB_1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_2BPP_RGBA_1">pc.PIXELFORMAT_PVRTC_2BPP_RGBA_1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_4BPP_RGB_1">pc.PIXELFORMAT_PVRTC_4BPP_RGB_1</a></li>
<li><a href="pc.html#PIXELFORMAT_PVRTC_4BPP_RGBA_1">pc.PIXELFORMAT_PVRTC_4BPP_RGBA_1</a></li>
<li><a href="pc.html#PIXELFORMAT_111110F">pc.PIXELFORMAT_111110F</a></li>
<li><a href="pc.html#PIXELFORMAT_ASTC_4x4">pc.PIXELFORMAT_ASTC_4x4</a>>/li></li>
<li><a href="pc.html#PIXELFORMAT_ATC_RGB">pc.PIXELFORMAT_ATC_RGB</a></li>
<li><a href="pc.html#PIXELFORMAT_ATC_RGBA">pc.PIXELFORMAT_ATC_RGBA</a></li>
</ul><span class='readonly'>[read only]</span></p>
</div>
<div id="height">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">height <a class="font-icon" href="#height"></a></span>
<p><p>The height of the texture in pixels.</p><span class='readonly'>[read only]</span></p>
</div>
<div id="magFilter">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">magFilter <a class="font-icon" href="#magFilter"></a></span>
<p><p>The magnification filter to be applied to the texture. Can be:</p>
<ul>
<li><a href="pc.html#FILTER_NEAREST">pc.FILTER_NEAREST</a></li>
<li><a href="pc.html#FILTER_LINEAR">pc.FILTER_LINEAR</a></li>
</ul></p>
</div>
<div id="minFilter">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">minFilter <a class="font-icon" href="#minFilter"></a></span>
<p><p>The minification filter to be applied to the texture. Can be:</p>
<ul>
<li><a href="pc.html#FILTER_NEAREST">pc.FILTER_NEAREST</a></li>
<li><a href="pc.html#FILTER_LINEAR">pc.FILTER_LINEAR</a></li>
<li><a href="pc.html#FILTER_NEAREST_MIPMAP_NEAREST">pc.FILTER_NEAREST_MIPMAP_NEAREST</a></li>
<li><a href="pc.html#FILTER_NEAREST_MIPMAP_LINEAR">pc.FILTER_NEAREST_MIPMAP_LINEAR</a></li>
<li><a href="pc.html#FILTER_LINEAR_MIPMAP_NEAREST">pc.FILTER_LINEAR_MIPMAP_NEAREST</a></li>
<li><a href="pc.html#FILTER_LINEAR_MIPMAP_LINEAR">pc.FILTER_LINEAR_MIPMAP_LINEAR</a></li>
</ul></p>
</div>
<div id="mipmaps">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">mipmaps <a class="font-icon" href="#mipmaps"></a></span>
<p><p>Defines if texture should generate/upload mipmaps if possible.</p></p>
</div>
<div id="name">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span><span class="property">name <a class="font-icon" href="#name"></a></span>
<p><p>The name of the texture. Defaults to null.</p></p>
</div>
<div id="pot">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">pot <a class="font-icon" href="#pot"></a></span>
<p><p>Returns true if all dimensions of the texture are power of two, and false otherwise.</p><span class='readonly'>[read only]</span></p>
</div>
<div id="volume">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">volume <a class="font-icon" href="#volume"></a></span>
<p><p>Returns true if this texture is a 3D volume and false otherwise.</p><span class='readonly'>[read only]</span></p>
</div>
<div id="width">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">width <a class="font-icon" href="#width"></a></span>
<p><p>The width of the texture in pixels.</p><span class='readonly'>[read only]</span></p>
</div>
<!--methods-->
<h2>Methods</h2>
<div id="destroy">
<h3 class="methodname">destroy() <a class="font-icon" href="#destroy"></a></h3>
<p><p>Forcibly free up the underlying WebGL resource owned by the texture.</p></p>
</div>
<div id="getSource">
<h3 class="methodname">getSource([mipLevel]) <a class="font-icon" href="#getSource"></a></h3>
<p><p>Get the pixel data of the texture. If this is a cubemap then an array of 6 images will be returned otherwise
a single image.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>mipLevel</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>A non-negative integer specifying the image level of detail. Defaults to 0, which represents the base image source.
A level value of N, that is greater than 0, represents the image source for the Nth mipmap reduction level.</p></td>
</tr>
</table>
<h4>Returns</h4>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement">HTMLImageElement</a> <p>The source image of this texture. Can be null if source not assigned for specific image level.</p>
</div>
<div id="lock">
<h3 class="methodname">lock([options]) <a class="font-icon" href="#lock"></a></h3>
<p><p>Locks a miplevel of the texture, returning a typed array to be filled with pixel data.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>options</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></td><td><p>Optional options object. Valid properties are as follows:</p></td>
</tr>
<tr>
<td>options.level</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>The mip level to lock with 0 being the top level. Defaults to 0.</p></td>
</tr>
<tr>
<td>options.face</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>If the texture is a cubemap, this is the index of the face to lock.</p></td>
</tr>
</table>
<h4>Returns</h4>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array">Uint16Array</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array">Float32Array</a> <p>A typed array containing the pixel data of the locked mip level.</p>
</div>
<div id="setSource">
<h3 class="methodname">setSource(source, [mipLevel]) <a class="font-icon" href="#setSource"></a></h3>
<p><p>Set the pixel data of the texture from a canvas, image, video DOM element. If the
texture is a cubemap, the supplied source must be an array of 6 canvases, images or videos.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>source</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement">HTMLCanvasElement</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement">HTMLImageElement</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement">HTMLVideoElement</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement">HTMLCanvasElement[]</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement">HTMLImageElement[]</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement">HTMLVideoElement[]</a></td><td><p>A canvas, image or video element,
or an array of 6 canvas, image or video elements.</p></td>
</tr>
<tr>
<td>mipLevel</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></td><td><p>A non-negative integer specifying the image level of detail. Defaults to 0, which represents the base image source.
A level value of N, that is greater than 0, represents the image source for the Nth mipmap reduction level.</p></td>
</tr>
</table>
</div>
<div id="unlock">
<h3 class="methodname">unlock() <a class="font-icon" href="#unlock"></a></h3>
<p><p>Unlocks the currently locked mip level and uploads it to VRAM.</p></p>
</div>
<div id="upload">
<h3 class="methodname">upload() <a class="font-icon" href="#upload"></a></h3>
<p><p>Forces a reupload of the textures pixel data to graphics memory. Ordinarily, this function
is called by internally by <a href="pc.Texture.html#setSource">pc.Texture#setSource</a> and <a href="pc.Texture.html#unlock">pc.Texture#unlock</a>. However, it still needs to
be called explicitly in the case where an HTMLVideoElement is set as the source of the texture. Normally,
this is done once every frame before video textured geometry is rendered.</p></p>
</div>
<!--events-->
</main>
</div>
</body>
</html>