UserDataNode.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>UserDataNode - 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="Node.html">Node</a> → <a href="ReferenceNode.html">ReferenceNode</a> → </p>
  13. <h1 translate="no">UserDataNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A special type of reference node that allows to link values in
  17. <code>userData</code> fields to node objects.</p>
  18. <p>Since <code>UserDataNode</code> is extended from <a href="ReferenceNode.html">ReferenceNode</a>, the node value
  19. will automatically be updated when the <code>rotation</code> user data field changes.</p></div>
  20. <h2>Code Example</h2>
  21. <div translate="no"><pre><code class="language-js">sprite.userData.rotation = 1; // stores individual rotation per sprite
  22. const material = new THREE.SpriteNodeMaterial();
  23. material.rotationNode = userData( 'rotation', 'float' );
  24. </code></pre></div>
  25. </header>
  26. <article>
  27. <div class="container-overview">
  28. <h2>Constructor</h2>
  29. <h3 class="name name-method" id="UserDataNode" translate="no">new <a href="#UserDataNode">UserDataNode</a><span class="signature">( property : <span class="param-type">string</span>, inputType : <span class="param-type">string</span>, userData : <span class="param-type">Object</span> )</span> </h3>
  30. <div class="method">
  31. <div class="description">
  32. <p>Constructs a new user data node.</p>
  33. </div>
  34. <table class="params">
  35. <tbody>
  36. <tr>
  37. <td class="name">
  38. <strong>property</strong>
  39. </td>
  40. <td class="description last">
  41. <p>The property name that should be referenced by the node.</p>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td class="name">
  46. <strong>inputType</strong>
  47. </td>
  48. <td class="description last">
  49. <p>The node data type of the reference.</p>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td class="name">
  54. <strong>userData</strong>
  55. </td>
  56. <td class="description last">
  57. <p>A reference to the <code>userData</code> object. If not provided, the <code>userData</code> property of the 3D object that uses the node material is evaluated.</p>
  58. <p>Default is <code>null</code>.</p>
  59. </td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. </div>
  64. </div>
  65. <h2 class="subsection-title">Properties</h2>
  66. <div class="member">
  67. <h3 class="name" id="userData" translate="no">.<a href="#userData">userData</a><span class="type-signature"> : Object</span> </h3>
  68. <div class="description">
  69. <p>A reference to the <code>userData</code> object. If not provided, the <code>userData</code>
  70. property of the 3D object that uses the node material is evaluated.</p>
  71. <p>Default is <code>null</code>.</p>
  72. </div>
  73. </div>
  74. <h2 class="subsection-title">Methods</h2>
  75. <h3 class="name name-method" id="updateReference" translate="no">.<a href="#updateReference">updateReference</a><span class="signature">( state : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a> | <a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : Object</span> </h3>
  76. <div class="method">
  77. <div class="description">
  78. <p>Overwritten to make sure <a href="ReferenceNode.html#reference">ReferenceNode#reference</a> points to the correct
  79. <code>userData</code> field.</p>
  80. </div>
  81. <table class="params">
  82. <tbody>
  83. <tr>
  84. <td class="name">
  85. <strong>state</strong>
  86. </td>
  87. <td class="description last">
  88. <p>The current state to evaluate.</p>
  89. </td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <dl class="details">
  94. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ReferenceNode.html#updateReference">ReferenceNode#updateReference</a></dt>
  95. </dl>
  96. <dl class="details">
  97. <dt class="tag-returns"><strong>Returns:</strong> A reference to the <code>userData</code> field.</dt>
  98. </dl>
  99. </div>
  100. <h2 class="subsection-title">Source</h2>
  101. <p>
  102. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/UserDataNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/UserDataNode.js</a>
  103. </p>
  104. </article>
  105. </section>
  106. <script src="../scripts/linenumber.js"></script>
  107. <script src="../scripts/page.js"></script>
  108. </body>
  109. </html>
粤ICP备19079148号