Sprite.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Sprite - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Object3D.html">Object3D</a> → </p>
  13. <h1 translate="no">Sprite</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A sprite is a plane that always faces towards the camera, generally with a
  17. partially transparent texture applied.</p>
  18. <p>Sprites do not cast shadows, setting <a href="Object3D.html#castShadow">Object3D#castShadow</a> to <code>true</code> will
  19. have no effect.</p></div>
  20. <h2>Code Example</h2>
  21. <div translate="no"><pre><code class="language-js">const map = new THREE.TextureLoader().load( 'sprite.png' );
  22. const material = new THREE.SpriteMaterial( { map: map } );
  23. const sprite = new THREE.Sprite( material );
  24. scene.add( sprite );
  25. </code></pre></div>
  26. </header>
  27. <article>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="Sprite" translate="no">new <a href="#Sprite">Sprite</a><span class="signature">( material : <span class="param-type"><a href="SpriteMaterial.html">SpriteMaterial</a> | <a href="SpriteNodeMaterial.html">SpriteNodeMaterial</a></span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new sprite.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name">
  39. <strong>material</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The sprite material.</p>
  43. </td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="center" translate="no">.<a href="#center">center</a><span class="type-signature"> : <a href="Vector2.html">Vector2</a></span> </h3>
  52. <div class="description">
  53. <p>The sprite's anchor point, and the point around which the sprite rotates.
  54. A value of <code>(0.5, 0.5)</code> corresponds to the midpoint of the sprite. A value
  55. of <code>(0, 0)</code> corresponds to the lower left corner of the sprite.</p>
  56. <p>Default is <code>(0.5,0.5)</code>.</p>
  57. </div>
  58. </div>
  59. <div class="member">
  60. <h3 class="name" id="count" translate="no">.<a href="#count">count</a><span class="type-signature"> : number</span> </h3>
  61. <div class="description">
  62. <p>The number of instances of this sprite.
  63. Can only be used with <a href="WebGPURenderer.html">WebGPURenderer</a>.</p>
  64. <p>Default is <code>1</code>.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="geometry" translate="no">.<a href="#geometry">geometry</a><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  69. <div class="description">
  70. <p>The sprite geometry.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="isSprite" translate="no">.<a href="#isSprite">isSprite</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  75. <div class="description">
  76. <p>This flag can be used for type testing.</p>
  77. <p>Default is <code>true</code>.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="material" translate="no">.<a href="#material">material</a><span class="type-signature"> : <a href="SpriteMaterial.html">SpriteMaterial</a> | <a href="SpriteNodeMaterial.html">SpriteNodeMaterial</a></span> </h3>
  82. <div class="description">
  83. <p>The sprite material.</p>
  84. </div>
  85. </div>
  86. <h2 class="subsection-title">Methods</h2>
  87. <h3 class="name name-method" id="raycast" translate="no">.<a href="#raycast">raycast</a><span class="signature">( raycaster : <span class="param-type"><a href="Raycaster.html">Raycaster</a></span>, intersects : <span class="param-type">Array.&lt;Object></span> )</span> </h3>
  88. <div class="method">
  89. <div class="description">
  90. <p>Computes intersection points between a casted ray and this sprite.</p>
  91. </div>
  92. <table class="params">
  93. <tbody>
  94. <tr>
  95. <td class="name">
  96. <strong>raycaster</strong>
  97. </td>
  98. <td class="description last">
  99. <p>The raycaster.</p>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td class="name">
  104. <strong>intersects</strong>
  105. </td>
  106. <td class="description last">
  107. <p>The target array that holds the intersection points.</p>
  108. </td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. <dl class="details">
  113. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Object3D.html#raycast">Object3D#raycast</a></dt>
  114. </dl>
  115. </div>
  116. <h2 class="subsection-title">Source</h2>
  117. <p>
  118. <a href="https://github.com/mrdoob/three.js/blob/master/src/objects/Sprite.js" translate="no" target="_blank" rel="noopener">src/objects/Sprite.js</a>
  119. </p>
  120. </article>
  121. </section>
  122. <script src="../scripts/linenumber.js"></script>
  123. <script src="../scripts/page.js"></script>
  124. </body>
  125. </html>
粤ICP备19079148号