ReferenceBaseNode.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ReferenceBaseNode - 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> → </p>
  13. <h1 translate="no">ReferenceBaseNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Base class for nodes which establishes a reference to a property of another object.
  17. In this way, the value of the node is automatically linked to the value of
  18. referenced object. Reference nodes internally represent the linked value
  19. as a uniform.</p></div>
  20. </header>
  21. <article>
  22. <div class="container-overview">
  23. <h2>Constructor</h2>
  24. <h3 class="name name-method" id="ReferenceBaseNode" translate="no">new <a href="#ReferenceBaseNode">ReferenceBaseNode</a><span class="signature">( property : <span class="param-type">string</span>, uniformType : <span class="param-type">string</span>, object : <span class="param-type">Object</span>, count : <span class="param-type">number</span> )</span> </h3>
  25. <div class="method">
  26. <div class="description">
  27. <p>Constructs a new reference base node.</p>
  28. </div>
  29. <table class="params">
  30. <tbody>
  31. <tr>
  32. <td class="name">
  33. <strong>property</strong>
  34. </td>
  35. <td class="description last">
  36. <p>The name of the property the node refers to.</p>
  37. </td>
  38. </tr>
  39. <tr>
  40. <td class="name">
  41. <strong>uniformType</strong>
  42. </td>
  43. <td class="description last">
  44. <p>The uniform type that should be used to represent the property value.</p>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td class="name">
  49. <strong>object</strong>
  50. </td>
  51. <td class="description last">
  52. <p>The object the property belongs to.</p>
  53. <p>Default is <code>null</code>.</p>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td class="name">
  58. <strong>count</strong>
  59. </td>
  60. <td class="description last">
  61. <p>When the linked property is an array-like, this parameter defines its length.</p>
  62. <p>Default is <code>null</code>.</p>
  63. </td>
  64. </tr>
  65. </tbody>
  66. </table>
  67. </div>
  68. </div>
  69. <h2 class="subsection-title">Properties</h2>
  70. <div class="member">
  71. <h3 class="name" id="count" translate="no">.<a href="#count">count</a><span class="type-signature"> : number</span> </h3>
  72. <div class="description">
  73. <p>When the linked property is an array, this parameter defines its length.</p>
  74. <p>Default is <code>null</code>.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="group" translate="no">.<a href="#group">group</a><span class="type-signature"> : <a href="UniformGroupNode.html">UniformGroupNode</a></span> </h3>
  79. <div class="description">
  80. <p>The uniform group of the internal uniform.</p>
  81. <p>Default is <code>null</code>.</p>
  82. </div>
  83. </div>
  84. <div class="member">
  85. <h3 class="name" id="node" translate="no">.<a href="#node">node</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a></span> </h3>
  86. <div class="description">
  87. <p>The uniform node that holds the value of the reference node.</p>
  88. <p>Default is <code>null</code>.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="object" translate="no">.<a href="#object">object</a><span class="type-signature"> : Object</span> </h3>
  93. <div class="description">
  94. <p>The object the property belongs to.</p>
  95. <p>Default is <code>null</code>.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="properties" translate="no">.<a href="#properties">properties</a><span class="type-signature"> : Array.&lt;string></span> </h3>
  100. <div class="description">
  101. <p>The property name might have dots so nested properties can be referred.
  102. The hierarchy of the names is stored inside this array.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="property" translate="no">.<a href="#property">property</a><span class="type-signature"> : string</span> </h3>
  107. <div class="description">
  108. <p>The name of the property the node refers to.</p>
  109. </div>
  110. </div>
  111. <div class="member">
  112. <h3 class="name" id="reference" translate="no">.<a href="#reference">reference</a><span class="type-signature"> : Object</span> </h3>
  113. <div class="description">
  114. <p>Points to the current referred object. This property exists next to <a href="ReferenceNode.html#object">ReferenceNode#object</a>
  115. since the final reference might be updated from calling code.</p>
  116. <p>Default is <code>null</code>.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="uniformType" translate="no">.<a href="#uniformType">uniformType</a><span class="type-signature"> : string</span> </h3>
  121. <div class="description">
  122. <p>The uniform type that should be used to represent the property value.</p>
  123. </div>
  124. </div>
  125. <div class="member">
  126. <h3 class="name" id="updateType" translate="no">.<a href="#updateType">updateType</a><span class="type-signature"> : string</span> </h3>
  127. <div class="description">
  128. <p>Overwritten since reference nodes are updated per object.</p>
  129. <p>Default is <code>'object'</code>.</p>
  130. </div>
  131. <dl class="details">
  132. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Node.html#updateType">Node#updateType</a></dt>
  133. </dl>
  134. </div>
  135. <h2 class="subsection-title">Methods</h2>
  136. <h3 class="name name-method" id="element" translate="no">.<a href="#element">element</a><span class="signature">( indexNode : <span class="param-type"><a href="IndexNode.html">IndexNode</a></span> )</span><span class="type-signature"> : <a href="ReferenceElementNode.html">ReferenceElementNode</a></span> </h3>
  137. <div class="method">
  138. <div class="description">
  139. <p>When the referred property is array-like, this method can be used
  140. to access elements via an index node.</p>
  141. </div>
  142. <table class="params">
  143. <tbody>
  144. <tr>
  145. <td class="name">
  146. <strong>indexNode</strong>
  147. </td>
  148. <td class="description last">
  149. <p>indexNode.</p>
  150. </td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. <dl class="details">
  155. <dt class="tag-returns"><strong>Returns:</strong> A reference to an element.</dt>
  156. </dl>
  157. </div>
  158. <h3 class="name name-method" id="getNodeType" translate="no">.<a href="#getNodeType">getNodeType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  159. <div class="method">
  160. <div class="description">
  161. <p>This method is overwritten since the node type is inferred from
  162. the type of the reference node.</p>
  163. </div>
  164. <table class="params">
  165. <tbody>
  166. <tr>
  167. <td class="name">
  168. <strong>builder</strong>
  169. </td>
  170. <td class="description last">
  171. <p>The current node builder.</p>
  172. </td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <dl class="details">
  177. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Node.html#getNodeType">Node#getNodeType</a></dt>
  178. </dl>
  179. <dl class="details">
  180. <dt class="tag-returns"><strong>Returns:</strong> The node type.</dt>
  181. </dl>
  182. </div>
  183. <h3 class="name name-method" id="getValueFromReference" translate="no">.<a href="#getValueFromReference">getValueFromReference</a><span class="signature">( object : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="global.html#any">any</a></span> </h3>
  184. <div class="method">
  185. <div class="description">
  186. <p>Returns the property value from the given referred object.</p>
  187. </div>
  188. <table class="params">
  189. <tbody>
  190. <tr>
  191. <td class="name">
  192. <strong>object</strong>
  193. </td>
  194. <td class="description last">
  195. <p>The object to retrieve the property value from.</p>
  196. <p>Default is <code>this.reference</code>.</p>
  197. </td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. <dl class="details">
  202. <dt class="tag-returns"><strong>Returns:</strong> The value.</dt>
  203. </dl>
  204. </div>
  205. <h3 class="name name-method" id="setGroup" translate="no">.<a href="#setGroup">setGroup</a><span class="signature">( group : <span class="param-type"><a href="UniformGroupNode.html">UniformGroupNode</a></span> )</span><span class="type-signature"> : <a href="ReferenceBaseNode.html">ReferenceBaseNode</a></span> </h3>
  206. <div class="method">
  207. <div class="description">
  208. <p>Sets the uniform group for this reference node.</p>
  209. </div>
  210. <table class="params">
  211. <tbody>
  212. <tr>
  213. <td class="name">
  214. <strong>group</strong>
  215. </td>
  216. <td class="description last">
  217. <p>The uniform group to set.</p>
  218. </td>
  219. </tr>
  220. </tbody>
  221. </table>
  222. <dl class="details">
  223. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  224. </dl>
  225. </div>
  226. <h3 class="name name-method" id="setNodeType" translate="no">.<a href="#setNodeType">setNodeType</a><span class="signature">( uniformType : <span class="param-type">string</span> )</span> </h3>
  227. <div class="method">
  228. <div class="description">
  229. <p>Sets the node type which automatically defines the internal
  230. uniform type.</p>
  231. </div>
  232. <table class="params">
  233. <tbody>
  234. <tr>
  235. <td class="name">
  236. <strong>uniformType</strong>
  237. </td>
  238. <td class="description last">
  239. <p>The type to set.</p>
  240. </td>
  241. </tr>
  242. </tbody>
  243. </table>
  244. </div>
  245. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">()</span><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a></span> </h3>
  246. <div class="method">
  247. <div class="description">
  248. <p>The output of the reference node is the internal uniform node.</p>
  249. </div>
  250. <dl class="details">
  251. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Node.html#setup">Node#setup</a></dt>
  252. </dl>
  253. <dl class="details">
  254. <dt class="tag-returns"><strong>Returns:</strong> The output node.</dt>
  255. </dl>
  256. </div>
  257. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  258. <div class="method">
  259. <div class="description">
  260. <p>Overwritten to update the internal uniform value.</p>
  261. </div>
  262. <table class="params">
  263. <tbody>
  264. <tr>
  265. <td class="name">
  266. <strong>frame</strong>
  267. </td>
  268. <td class="description last">
  269. <p>A reference to the current node frame.</p>
  270. </td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. <dl class="details">
  275. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Node.html#update">Node#update</a></dt>
  276. </dl>
  277. </div>
  278. <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>
  279. <div class="method">
  280. <div class="description">
  281. <p>Allows to update the reference based on the given state. The state is only
  282. evaluated <a href="ReferenceBaseNode.html#object">ReferenceBaseNode#object</a> is not set.</p>
  283. </div>
  284. <table class="params">
  285. <tbody>
  286. <tr>
  287. <td class="name">
  288. <strong>state</strong>
  289. </td>
  290. <td class="description last">
  291. <p>The current state.</p>
  292. </td>
  293. </tr>
  294. </tbody>
  295. </table>
  296. <dl class="details">
  297. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Node.html#updateReference">Node#updateReference</a></dt>
  298. </dl>
  299. <dl class="details">
  300. <dt class="tag-returns"><strong>Returns:</strong> The updated reference.</dt>
  301. </dl>
  302. </div>
  303. <h3 class="name name-method" id="updateValue" translate="no">.<a href="#updateValue">updateValue</a><span class="signature">()</span> </h3>
  304. <div class="method">
  305. <div class="description">
  306. <p>Retrieves the value from the referred object property and uses it
  307. to updated the internal uniform.</p>
  308. </div>
  309. </div>
  310. <h2 class="subsection-title">Source</h2>
  311. <p>
  312. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/ReferenceBaseNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/ReferenceBaseNode.js</a>
  313. </p>
  314. </article>
  315. </section>
  316. <script src="../scripts/linenumber.js"></script>
  317. <script src="../scripts/page.js"></script>
  318. </body>
  319. </html>
粤ICP备19079148号