Texture.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">Create a texture to apply to a surface or as a reflection or refraction map.</div>
  13. <h2>Constructor</h2>
  14. <h3>[name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy )</h3>
  15. <h2>Example</h2>
  16. <code>
  17. // load a texture, set wrap mode to repeat
  18. var texture = new THREE.TextureLoader().load( "textures/water.jpg" );
  19. texture.wrapS = THREE.RepeatWrapping;
  20. texture.wrapT = THREE.RepeatWrapping;
  21. texture.repeat.set( 4, 4 );
  22. </code>
  23. <h2>Properties</h2>
  24. <h3>[property:Integer id]</h3>
  25. <div>
  26. Readonly - unique number for this texture instance.
  27. </div>
  28. <h3>[property:String uuid]</h3>
  29. <div>
  30. [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance.
  31. This gets automatically assigned, so this shouldn't be edited.
  32. </div>
  33. <h3>[property:String name]</h3>
  34. <div>
  35. Optional name of the object (doesn't need to be unique). Default is an empty string.
  36. </div>
  37. <h3>[property:Image image]</h3>
  38. <div>
  39. An image object, typically created using the [page:TextureLoader.load] method.
  40. This can be any image (e.g., PNG, JPG, GIF, DDS) or video (e.g., MP4, OGG/OGV) type supported by three.js.<br /><br />
  41. To use video as a texture you need to have a playing HTML5
  42. video element as a source for your texture image and continuously update this texture
  43. as long as video is playing - the [page:VideoTexture VideoTexture] class handles this automatically.
  44. </div>
  45. <h3>[property:array mipmaps]</h3>
  46. <div>
  47. Array of user-specified mipmaps (optional).
  48. </div>
  49. <h3>[property:object mapping]</h3>
  50. <div>
  51. How the image is applied to the object. An object type of [page:Textures THREE.UVMapping] is the default,
  52. where the U,V coordinates are used to apply the map.<br />
  53. See the [page:Textures texture constants] page for other mapping types.
  54. </div>
  55. <h3>[property:number wrapS]</h3>
  56. <div>
  57. This defines how the texture is wrapped horizontally and corresponds to *U* in UV mapping.<br />
  58. The default is [page:Textures THREE.ClampToEdgeWrapping], where the edge is clamped to the outer edge texels.
  59. The other two choices are [page:Textures THREE.RepeatWrapping] and [page:Textures THREE.MirroredRepeatWrapping].
  60. See the [page:Textures texture constants] page for details.
  61. </div>
  62. <h3>[property:number wrapT]</h3>
  63. <div>
  64. This defines how the texture is wrapped vertically and corresponds to *V* in UV mapping.<br />
  65. The same choices are available as for [property:number wrapS].<br /><br />
  66. NOTE: tiling of images in textures only functions if image dimensions are powers of two
  67. (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...) in terms of pixels.
  68. Individual dimensions need not be equal, but each must be a power of two.
  69. This is a limitation of WebGL, not three.js.
  70. </div>
  71. <h3>[property:number magFilter]</h3>
  72. <div>
  73. How the texture is sampled when a texel covers more than one pixel. The default is
  74. [page:Textures THREE.LinearFilter], which takes the four closest texels and bilinearly interpolates among them.
  75. The other option is [page:Textures THREE.NearestFilter], which uses the value of the closest texel.<br />
  76. See the [page:Textures texture constants] page for details.
  77. </div>
  78. <h3>[property:number minFilter]</h3>
  79. <div>
  80. How the texture is sampled when a texel covers less than one pixel. The default is
  81. [page:Textures THREE.LinearMipMapLinearFilter], which uses mipmapping and a trilinear filter. <br /><br />
  82. See the [page:Textures texture constants] page for all possible choices.
  83. </div>
  84. <h3>[property:number anisotropy]</h3>
  85. <div>
  86. The number of samples taken along the axis through the pixel that has the highest density of texels.
  87. By default, this value is 1. A higher value gives a less blurry result than a basic mipmap,
  88. at the cost of more texture samples being used. Use [page:WebGLRenderer.getMaxAnisotropy renderer.getMaxAnisotropy]() to
  89. find the maximum valid anisotropy value for the GPU; this value is usually a power of 2.
  90. </div>
  91. <h3>[property:number format]</h3>
  92. <div>
  93. The default is [page:Textures THREE.RGBAFormat], although the [page:TextureLoader TextureLoader] will automatically
  94. et this to [page:Textures THREE.RGBFormat] for JPG images. <br /><br />
  95. See the [page:Textures texture constants] page for details of other formats.
  96. </div>
  97. <h3>[property:number type]</h3>
  98. <div>
  99. This must correspond to the [page:Texture.format .format]. The default is [page:Textures THREE.UnsignedByteType],
  100. which will be used for most texture formats.<br /><br />
  101. See the [page:Textures texture constants] page for details of other formats.
  102. </div>
  103. <h3>[property:Vector2 offset]</h3>
  104. <div>
  105. How much a single repetition of the texture is offset from the beginning, in each direction U and V.
  106. Typical range is *0.0* to *1.0*.
  107. </div>
  108. <h3>[property:Vector2 repeat]</h3>
  109. <div>
  110. How many times the texture is repeated across the surface, in each direction U and V.
  111. </div>
  112. <h3>[property:boolean generateMipmaps]</h3>
  113. <div>
  114. Whether to generate mipmaps (if possible) for a texture. True by default. Set this to false if you are
  115. creating mipmaps manually.
  116. </div>
  117. <h3>[property:boolean premultiplyAlpha]</h3>
  118. <div>
  119. False by default, which is the norm for PNG images. Set to true if the RGB values have
  120. been stored premultiplied by alpha.
  121. </div>
  122. <h3>[property:boolean flipY]</h3>
  123. <div>
  124. True by default. Flips the image's Y axis to match the WebGL texture coordinate space.
  125. </div>
  126. <h3>[property:number unpackAlignment]</h3>
  127. <div>
  128. 4 by default. Specifies the alignment requirements for the start of each pixel row in memory.
  129. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes),
  130. 4 (word-alignment), and 8 (rows start on double-word boundaries).
  131. See <a href="http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml">glPixelStorei</a>
  132. for more information.
  133. </div>
  134. <h3>[property:number encoding]</h3>
  135. <div>
  136. [page:Textures THREE.LinearEncoding] is the default.
  137. See the [page:Textures texture constants] page for details of other formats.<br /><br />
  138. Note that ff this value is changed on a texture after the material has been used,
  139. it is necessary to trigger a Material.needsUpdate for this value to be realized in the shader.
  140. </div>
  141. <h3>[property:Integer version]</h3>
  142. <div>
  143. This starts at *0* and counts how many times [property:Boolean needsUpdate] is set to *true*.
  144. </div>
  145. <h3>[property:Function onUpdate]</h3>
  146. <div>
  147. A callback function, called when the texture is updated (e.g., when needsUpdate has been set to true
  148. and then the texture is used).
  149. </div>
  150. <h3>[property:Boolean needsUpdate]</h3>
  151. <div>
  152. Set this to *true* to trigger an update next time the texture is used. Particularly important for setting the wrap mode.
  153. </div>
  154. <h2>Methods</h2>
  155. <h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
  156. <h3>[method:Texture clone]( [page:Texture texture] )</h3>
  157. <div>
  158. Make copy of the texture. Note this is not a "deep copy", the image is shared.
  159. </div>
  160. <h3>[method:Texture toJSON]( meta )</h3>
  161. <div>
  162. meta -- optional object containing metadata.<br />
  163. Convert the material to three.js JSON format.
  164. </div>
  165. <h3>[method:null dispose]()</h3>
  166. <div>
  167. Call [page:EventDispatcher EventDispatcher].dispatchEvent with a 'dispose' event type.
  168. </div>
  169. <h3>[method:null transformUv]( uv )</h3>
  170. <div>
  171. Transform the uv based on the value of this texture's [page:Texture.repeat .repeat], [page:Texture.offset .offset],
  172. [page:Texture.wrapS .wrapS], [page:Texture.wrapT .wrapT] and [page:Texture.flipY .flipY] properties.
  173. </div>
  174. <h2>Source</h2>
  175. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  176. </body>
  177. </html>