SpriteNodeMaterial.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SpriteNodeMaterial - 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="Material.html">Material</a> → <a href="NodeMaterial.html">NodeMaterial</a> → </p>
  13. <h1 translate="no">SpriteNodeMaterial</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Node material version of <a href="SpriteMaterial.html">SpriteMaterial</a>.</p></div>
  17. </header>
  18. <article>
  19. <div class="container-overview">
  20. <h2>Constructor</h2>
  21. <h3 class="name name-method" id="SpriteNodeMaterial" translate="no">new <a href="#SpriteNodeMaterial">SpriteNodeMaterial</a><span class="signature">( parameters : <span class="param-type">Object</span> )</span> </h3>
  22. <div class="method">
  23. <div class="description">
  24. <p>Constructs a new sprite node material.</p>
  25. </div>
  26. <table class="params">
  27. <tbody>
  28. <tr>
  29. <td class="name"><code>parameters</code></td>
  30. <td class="description last"><p>The configuration parameter.</p></td>
  31. </tr>
  32. </tbody>
  33. </table>
  34. </div>
  35. </div>
  36. <h2 class="subsection-title">Properties</h2>
  37. <div class="member">
  38. <h3 class="name" id="isSpriteNodeMaterial" translate="no">.<a href="#isSpriteNodeMaterial">isSpriteNodeMaterial</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  39. <div class="description">
  40. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  41. </div>
  42. </div>
  43. <div class="member">
  44. <h3 class="name" id="positionNode" translate="no">.<a href="#positionNode">positionNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec2></span> </h3>
  45. <div class="description">
  46. <p>This property makes it possible to define the position of the sprite with a
  47. node. That can be useful when the material is used with instanced rendering
  48. and node data are defined with an instanced attribute node:</p>
  49. <pre><code class="language-js">const positionAttribute = new InstancedBufferAttribute( new Float32Array( positions ), 3 );
  50. material.positionNode = instancedBufferAttribute( positionAttribute );
  51. </code></pre>
  52. <p>Another possibility is to compute the instanced data with a compute shader:</p>
  53. <pre><code class="language-js">const positionBuffer = instancedArray( particleCount, 'vec3' );
  54. particleMaterial.positionNode = positionBuffer.toAttribute();
  55. </code></pre><br/>Default is <code>null</code>.
  56. </div>
  57. <dl class="details">
  58. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="NodeMaterial.html#positionNode">NodeMaterial#positionNode</a></dt>
  59. </dl>
  60. </div>
  61. <div class="member">
  62. <h3 class="name" id="rotationNode" translate="no">.<a href="#rotationNode">rotationNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  63. <div class="description">
  64. <p>The rotation of sprite materials is by default inferred from the <code>rotation</code>,
  65. property. This node property allows to overwrite the default and define
  66. the rotation with a node instead.</p>
  67. <p>If you don't want to overwrite the rotation but modify the existing
  68. value instead, use <a href="TSL.html#materialRotation">materialRotation</a>.<br/>Default is <code>null</code>.</p>
  69. </div>
  70. </div>
  71. <div class="member">
  72. <h3 class="name" id="scaleNode" translate="no">.<a href="#scaleNode">scaleNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec2></span> </h3>
  73. <div class="description">
  74. <p>This node property provides an additional way to scale sprites next to
  75. <code>Object3D.scale</code>. The scale transformation based in <code>Object3D.scale</code>
  76. is multiplied with the scale value of this node in the vertex shader.<br/>Default is <code>null</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="sizeAttenuation" translate="no">.<a href="#sizeAttenuation">sizeAttenuation</a><span class="type-signature"> : boolean</span> </h3>
  81. <div class="description">
  82. <p>Whether to use size attenuation or not.<br/>Default is <code>true</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="transparent" translate="no">.<a href="#transparent">transparent</a><span class="type-signature"> : boolean</span> </h3>
  87. <div class="description">
  88. <p>In Sprites, the transparent property is enabled by default.<br/>Default is <code>true</code>.</p>
  89. </div>
  90. <dl class="details">
  91. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="NodeMaterial.html#transparent">NodeMaterial#transparent</a></dt>
  92. </dl>
  93. </div>
  94. <h2 class="subsection-title">Methods</h2>
  95. <h3 class="name name-method" id="setupPositionView" translate="no">.<a href="#setupPositionView">setupPositionView</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  96. <div class="method">
  97. <div class="description">
  98. <p>Setups the position node in view space. This method implements
  99. the sprite specific vertex shader.</p>
  100. </div>
  101. <table class="params">
  102. <tbody>
  103. <tr>
  104. <td class="name"><code>builder</code></td>
  105. <td class="description last"><p>The current node builder.</p></td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. <dl class="details">
  110. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="NodeMaterial.html#setupPositionView">NodeMaterial#setupPositionView</a></dt>
  111. </dl>
  112. <dl class="details">
  113. <dt class="tag-returns"><strong>Returns:</strong> The position in view space.</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/materials/nodes/SpriteNodeMaterial.js" target="_blank" rel="noopener" translate="no">src/materials/nodes/SpriteNodeMaterial.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号