1
0

Node.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Node - 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> → </p>
  13. <h1 translate="no">Node</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Base class for all nodes.</p></div>
  17. </header>
  18. <article>
  19. <div class="container-overview">
  20. <h2>Constructor</h2>
  21. <h3 class="name name-method" id="Node" translate="no">new <a href="#Node">Node</a><span class="signature">( nodeType : <span class="param-type">string</span> )</span> </h3>
  22. <div class="method">
  23. <div class="description">
  24. <p>Constructs a new node.</p>
  25. </div>
  26. <table class="params">
  27. <tbody>
  28. <tr>
  29. <td class="name">
  30. <strong>nodeType</strong>
  31. </td>
  32. <td class="description last">
  33. <p>The node type.</p>
  34. <p>Default is <code>null</code>.</p>
  35. </td>
  36. </tr>
  37. </tbody>
  38. </table>
  39. </div>
  40. </div>
  41. <h2 class="subsection-title">Properties</h2>
  42. <div class="member">
  43. <h3 class="name" id="global" translate="no">.<a href="#global">global</a><span class="type-signature"> : boolean</span> </h3>
  44. <div class="description">
  45. <p>Whether this node is global or not. This property is relevant for the internal
  46. node caching system. All nodes which should be declared just once should
  47. set this flag to <code>true</code> (a typical example is <a href="AttributeNode.html">AttributeNode</a>).</p>
  48. <p>Default is <code>false</code>.</p>
  49. </div>
  50. </div>
  51. <div class="member">
  52. <h3 class="name" id="isNode" translate="no">.<a href="#isNode">isNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  53. <div class="description">
  54. <p>This flag can be used for type testing.</p>
  55. <p>Default is <code>true</code>.</p>
  56. </div>
  57. </div>
  58. <div class="member">
  59. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  60. <div class="description">
  61. <p>The name of the node.</p>
  62. <p>Default is <code>''</code>.</p>
  63. </div>
  64. </div>
  65. <div class="member">
  66. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : boolean</span> </h3>
  67. <div class="description">
  68. <p>Set this property to <code>true</code> when the node should be regenerated.</p>
  69. <p>Default is <code>false</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="nodeType" translate="no">.<a href="#nodeType">nodeType</a><span class="type-signature"> : string</span> </h3>
  74. <div class="description">
  75. <p>The node type. This represents the result type of the node (e.g. <code>float</code> or <code>vec3</code>).</p>
  76. <p>Default is <code>null</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="parents" translate="no">.<a href="#parents">parents</a><span class="type-signature"> : boolean</span> </h3>
  81. <div class="description">
  82. <p>Create a list of parents for this node during the build process.</p>
  83. <p>Default is <code>false</code>.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="type" translate="no">.<a href="#type">type</a><span class="type-signature"> : string</span> <span class="type-signature">(readonly) </span></h3>
  88. <div class="description">
  89. <p>The type of the class. The value is usually the constructor name.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="updateAfterType" translate="no">.<a href="#updateAfterType">updateAfterType</a><span class="type-signature"> : string</span> </h3>
  94. <div class="description">
  95. <p>The update type of the node's <a href="Node.html#updateAfter">Node#updateAfter</a> method. Possible values are listed in <a href="global.html#NodeUpdateType">NodeUpdateType</a>.</p>
  96. <p>Default is <code>'none'</code>.</p>
  97. </div>
  98. </div>
  99. <div class="member">
  100. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  101. <div class="description">
  102. <p>The update type of the node's <a href="Node.html#updateBefore">Node#updateBefore</a> method. Possible values are listed in <a href="global.html#NodeUpdateType">NodeUpdateType</a>.</p>
  103. <p>Default is <code>'none'</code>.</p>
  104. </div>
  105. </div>
  106. <div class="member">
  107. <h3 class="name" id="updateType" translate="no">.<a href="#updateType">updateType</a><span class="type-signature"> : string</span> </h3>
  108. <div class="description">
  109. <p>The update type of the node's <a href="Node.html#update">Node#update</a> method. Possible values are listed in <a href="global.html#NodeUpdateType">NodeUpdateType</a>.</p>
  110. <p>Default is <code>'none'</code>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="uuid" translate="no">.<a href="#uuid">uuid</a><span class="type-signature"> : string</span> <span class="type-signature">(readonly) </span></h3>
  115. <div class="description">
  116. <p>The UUID of the node.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="version" translate="no">.<a href="#version">version</a><span class="type-signature"> : number</span> <span class="type-signature">(readonly) </span></h3>
  121. <div class="description">
  122. <p>The version of the node. The version automatically is increased when <a href="Node.html#needsUpdate">Node#needsUpdate</a> is set to <code>true</code>.</p>
  123. <p>Default is <code>0</code>.</p>
  124. </div>
  125. </div>
  126. <h2 class="subsection-title">Methods</h2>
  127. <h3 class="name name-method" id="analyze" translate="no">.<a href="#analyze">analyze</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, output : <span class="param-type"><a href="Node.html">Node</a></span> )</span> </h3>
  128. <div class="method">
  129. <div class="description">
  130. <p>Represents the analyze stage which is the second step of the build process, see <a href="Node.html#build">Node#build</a> method.
  131. This stage analyzes the node hierarchy and ensures descendent nodes are built.</p>
  132. </div>
  133. <table class="params">
  134. <tbody>
  135. <tr>
  136. <td class="name">
  137. <strong>builder</strong>
  138. </td>
  139. <td class="description last">
  140. <p>The current node builder.</p>
  141. </td>
  142. </tr>
  143. <tr>
  144. <td class="name">
  145. <strong>output</strong>
  146. </td>
  147. <td class="description last">
  148. <p>The target output node.</p>
  149. <p>Default is <code>null</code>.</p>
  150. </td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. </div>
  155. <h3 class="name name-method" id="build" translate="no">.<a href="#build">build</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, output : <span class="param-type">string | <a href="Node.html">Node</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a> | string</span> </h3>
  156. <div class="method">
  157. <div class="description">
  158. <p>This method performs the build of a node. The behavior and return value depend on the current build stage:</p>
  159. <ul>
  160. <li><strong>setup</strong>: Prepares the node and its children for the build process. This process can also create new nodes. Returns the node itself or a variant.</li>
  161. <li><strong>analyze</strong>: Analyzes the node hierarchy for optimizations in the code generation stage. Returns <code>null</code>.</li>
  162. <li><strong>generate</strong>: Generates the shader code for the node. Returns the generated shader string.</li>
  163. </ul>
  164. </div>
  165. <table class="params">
  166. <tbody>
  167. <tr>
  168. <td class="name">
  169. <strong>builder</strong>
  170. </td>
  171. <td class="description last">
  172. <p>The current node builder.</p>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td class="name">
  177. <strong>output</strong>
  178. </td>
  179. <td class="description last">
  180. <p>Can be used to define the output type.</p>
  181. <p>Default is <code>null</code>.</p>
  182. </td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. <dl class="details">
  187. <dt class="tag-returns"><strong>Returns:</strong> The result of the build process, depending on the build stage.</dt>
  188. </dl>
  189. </div>
  190. <h3 class="name name-method" id="customCacheKey" translate="no">.<a href="#customCacheKey">customCacheKey</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  191. <div class="method">
  192. <div class="description">
  193. <p>Generate a custom cache key for this node.</p>
  194. </div>
  195. <dl class="details">
  196. <dt class="tag-returns"><strong>Returns:</strong> The cache key of the node.</dt>
  197. </dl>
  198. </div>
  199. <h3 class="name name-method" id="deserialize" translate="no">.<a href="#deserialize">deserialize</a><span class="signature">( json : <span class="param-type">Object</span> )</span> </h3>
  200. <div class="method">
  201. <div class="description">
  202. <p>Deserializes the node from the given JSON.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name">
  208. <strong>json</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The JSON object.</p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. </div>
  217. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  218. <div class="method">
  219. <div class="description">
  220. <p>Calling this method dispatches the <code>dispose</code> event. This event can be used
  221. to register event listeners for clean up tasks.</p>
  222. </div>
  223. </div>
  224. <h3 class="name name-method" id="generate" translate="no">.<a href="#generate">generate</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, output : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  225. <div class="method">
  226. <div class="description">
  227. <p>Represents the generate stage which is the third step of the build process, see <a href="Node.html#build">Node#build</a> method.
  228. This state builds the output node and returns the resulting shader string.</p>
  229. </div>
  230. <table class="params">
  231. <tbody>
  232. <tr>
  233. <td class="name">
  234. <strong>builder</strong>
  235. </td>
  236. <td class="description last">
  237. <p>The current node builder.</p>
  238. </td>
  239. </tr>
  240. <tr>
  241. <td class="name">
  242. <strong>output</strong>
  243. </td>
  244. <td class="description last">
  245. <p>Can be used to define the output type.</p>
  246. </td>
  247. </tr>
  248. </tbody>
  249. </table>
  250. <dl class="details">
  251. <dt class="tag-returns"><strong>Returns:</strong> The generated shader string.</dt>
  252. </dl>
  253. </div>
  254. <h3 class="name name-method" id="getArrayCount" translate="no">.<a href="#getArrayCount">getArrayCount</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : number</span> </h3>
  255. <div class="method">
  256. <div class="description">
  257. <p>Returns the number of elements in the node array.</p>
  258. </div>
  259. <table class="params">
  260. <tbody>
  261. <tr>
  262. <td class="name">
  263. <strong>builder</strong>
  264. </td>
  265. <td class="description last">
  266. <p>The current node builder.</p>
  267. </td>
  268. </tr>
  269. </tbody>
  270. </table>
  271. <dl class="details">
  272. <dt class="tag-returns"><strong>Returns:</strong> The number of elements in the node array.</dt>
  273. </dl>
  274. </div>
  275. <h3 class="name name-method" id="getCacheKey" translate="no">.<a href="#getCacheKey">getCacheKey</a><span class="signature">( force : <span class="param-type">boolean</span>, ignores : <span class="param-type">Set.&lt;<a href="Node.html">Node</a>></span> )</span><span class="type-signature"> : number</span> </h3>
  276. <div class="method">
  277. <div class="description">
  278. <p>Returns the cache key for this node.</p>
  279. </div>
  280. <table class="params">
  281. <tbody>
  282. <tr>
  283. <td class="name">
  284. <strong>force</strong>
  285. </td>
  286. <td class="description last">
  287. <p>When set to <code>true</code>, a recomputation of the cache key is forced.</p>
  288. <p>Default is <code>false</code>.</p>
  289. </td>
  290. </tr>
  291. <tr>
  292. <td class="name">
  293. <strong>ignores</strong>
  294. </td>
  295. <td class="description last">
  296. <p>A set of nodes to ignore during the computation of the cache key.</p>
  297. <p>Default is <code>null</code>.</p>
  298. </td>
  299. </tr>
  300. </tbody>
  301. </table>
  302. <dl class="details">
  303. <dt class="tag-returns"><strong>Returns:</strong> The cache key of the node.</dt>
  304. </dl>
  305. </div>
  306. <h3 class="name name-method" id="getChildren" translate="no">.<a href="#getChildren">getChildren</a><span class="signature">()</span><span class="type-signature"> : <a href="Node.html">Node</a></span> <span class="type-signature">(generator) </span></h3>
  307. <div class="method">
  308. <div class="description">
  309. <p>Generator function that can be used to iterate over the child nodes.</p>
  310. </div>
  311. <h5>Yields:</h5>
  312. A child node.
  313. </div>
  314. <h3 class="name name-method" id="getElementType" translate="no">.<a href="#getElementType">getElementType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  315. <div class="method">
  316. <div class="description">
  317. <p>Certain types are composed of multiple elements. For example a <code>vec3</code>
  318. is composed of three <code>float</code> values. This method returns the type of
  319. these elements.</p>
  320. </div>
  321. <table class="params">
  322. <tbody>
  323. <tr>
  324. <td class="name">
  325. <strong>builder</strong>
  326. </td>
  327. <td class="description last">
  328. <p>The current node builder.</p>
  329. </td>
  330. </tr>
  331. </tbody>
  332. </table>
  333. <dl class="details">
  334. <dt class="tag-returns"><strong>Returns:</strong> The type of the node.</dt>
  335. </dl>
  336. </div>
  337. <h3 class="name name-method" id="getHash" translate="no">.<a href="#getHash">getHash</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  338. <div class="method">
  339. <div class="description">
  340. <p>Returns the hash of the node which is used to identify the node. By default it's
  341. the <a href="Node.html#uuid">Node#uuid</a> however derived node classes might have to overwrite this method
  342. depending on their implementation.</p>
  343. </div>
  344. <table class="params">
  345. <tbody>
  346. <tr>
  347. <td class="name">
  348. <strong>builder</strong>
  349. </td>
  350. <td class="description last">
  351. <p>The current node builder.</p>
  352. </td>
  353. </tr>
  354. </tbody>
  355. </table>
  356. <dl class="details">
  357. <dt class="tag-returns"><strong>Returns:</strong> The hash.</dt>
  358. </dl>
  359. </div>
  360. <h3 class="name name-method" id="getMemberType" translate="no">.<a href="#getMemberType">getMemberType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, name : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  361. <div class="method">
  362. <div class="description">
  363. <p>Returns the node member type for the given name.</p>
  364. </div>
  365. <table class="params">
  366. <tbody>
  367. <tr>
  368. <td class="name">
  369. <strong>builder</strong>
  370. </td>
  371. <td class="description last">
  372. <p>The current node builder.</p>
  373. </td>
  374. </tr>
  375. <tr>
  376. <td class="name">
  377. <strong>name</strong>
  378. </td>
  379. <td class="description last">
  380. <p>The name of the member.</p>
  381. </td>
  382. </tr>
  383. </tbody>
  384. </table>
  385. <dl class="details">
  386. <dt class="tag-returns"><strong>Returns:</strong> The type of the node.</dt>
  387. </dl>
  388. </div>
  389. <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>
  390. <div class="method">
  391. <div class="description">
  392. <p>Returns the node's type.</p>
  393. </div>
  394. <table class="params">
  395. <tbody>
  396. <tr>
  397. <td class="name">
  398. <strong>builder</strong>
  399. </td>
  400. <td class="description last">
  401. <p>The current node builder.</p>
  402. </td>
  403. </tr>
  404. </tbody>
  405. </table>
  406. <dl class="details">
  407. <dt class="tag-returns"><strong>Returns:</strong> The type of the node.</dt>
  408. </dl>
  409. </div>
  410. <h3 class="name name-method" id="getScope" translate="no">.<a href="#getScope">getScope</a><span class="signature">()</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  411. <div class="method">
  412. <div class="description">
  413. <p>Returns the references to this node which is by default <code>this</code>.</p>
  414. </div>
  415. <dl class="details">
  416. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  417. </dl>
  418. </div>
  419. <h3 class="name name-method" id="getSerializeChildren" translate="no">.<a href="#getSerializeChildren">getSerializeChildren</a><span class="signature">()</span><span class="type-signature"> : Generator.&lt;Object></span> </h3>
  420. <div class="method">
  421. <div class="description">
  422. <p>Returns the child nodes as a JSON object.</p>
  423. </div>
  424. <dl class="details">
  425. <dt class="tag-returns"><strong>Returns:</strong> An iterable list of serialized child objects as JSON.</dt>
  426. </dl>
  427. </div>
  428. <h3 class="name name-method" id="getShared" translate="no">.<a href="#getShared">getShared</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  429. <div class="method">
  430. <div class="description">
  431. <p>This method is used during the build process of a node and ensures
  432. equal nodes are not built multiple times but just once. For example if
  433. <code>attribute( 'uv' )</code> is used multiple times by the user, the build
  434. process makes sure to process just the first node.</p>
  435. </div>
  436. <table class="params">
  437. <tbody>
  438. <tr>
  439. <td class="name">
  440. <strong>builder</strong>
  441. </td>
  442. <td class="description last">
  443. <p>The current node builder.</p>
  444. </td>
  445. </tr>
  446. </tbody>
  447. </table>
  448. <dl class="details">
  449. <dt class="tag-returns"><strong>Returns:</strong> The shared node if possible. Otherwise <code>this</code> is returned.</dt>
  450. </dl>
  451. </div>
  452. <h3 class="name name-method" id="getUpdateAfterType" translate="no">.<a href="#getUpdateAfterType">getUpdateAfterType</a><span class="signature">()</span><span class="type-signature"> : <a href="global.html#NodeUpdateType">NodeUpdateType</a></span> </h3>
  453. <div class="method">
  454. <div class="description">
  455. <p>Returns the update type of <a href="Node.html#updateAfter">Node#updateAfter</a>.</p>
  456. </div>
  457. <dl class="details">
  458. <dt class="tag-returns"><strong>Returns:</strong> The update type.</dt>
  459. </dl>
  460. </div>
  461. <h3 class="name name-method" id="getUpdateBeforeType" translate="no">.<a href="#getUpdateBeforeType">getUpdateBeforeType</a><span class="signature">()</span><span class="type-signature"> : <a href="global.html#NodeUpdateType">NodeUpdateType</a></span> </h3>
  462. <div class="method">
  463. <div class="description">
  464. <p>Returns the update type of <a href="Node.html#updateBefore">Node#updateBefore</a>.</p>
  465. </div>
  466. <dl class="details">
  467. <dt class="tag-returns"><strong>Returns:</strong> The update type.</dt>
  468. </dl>
  469. </div>
  470. <h3 class="name name-method" id="getUpdateType" translate="no">.<a href="#getUpdateType">getUpdateType</a><span class="signature">()</span><span class="type-signature"> : <a href="global.html#NodeUpdateType">NodeUpdateType</a></span> </h3>
  471. <div class="method">
  472. <div class="description">
  473. <p>Returns the update type of <a href="Node.html#update">Node#update</a>.</p>
  474. </div>
  475. <dl class="details">
  476. <dt class="tag-returns"><strong>Returns:</strong> The update type.</dt>
  477. </dl>
  478. </div>
  479. <h3 class="name name-method" id="isGlobal" translate="no">.<a href="#isGlobal">isGlobal</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  480. <div class="method">
  481. <div class="description">
  482. <p>By default this method returns the value of the <a href="Node.html#global">Node#global</a> flag. This method
  483. can be overwritten in derived classes if an analytical way is required to determine the
  484. global cache referring to the current shader-stage.</p>
  485. </div>
  486. <table class="params">
  487. <tbody>
  488. <tr>
  489. <td class="name">
  490. <strong>builder</strong>
  491. </td>
  492. <td class="description last">
  493. <p>The current node builder.</p>
  494. </td>
  495. </tr>
  496. </tbody>
  497. </table>
  498. <dl class="details">
  499. <dt class="tag-returns"><strong>Returns:</strong> Whether this node is global or not.</dt>
  500. </dl>
  501. </div>
  502. <h3 class="name name-method" id="onFrameUpdate" translate="no">.<a href="#onFrameUpdate">onFrameUpdate</a><span class="signature">( callback : <span class="param-type">function</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  503. <div class="method">
  504. <div class="description">
  505. <p>Convenient method for defining <a href="Node.html#update">Node#update</a>. Similar to <a href="Node.html#onUpdate">Node#onUpdate</a>, but
  506. this method automatically sets the update type to <code>FRAME</code>.</p>
  507. </div>
  508. <table class="params">
  509. <tbody>
  510. <tr>
  511. <td class="name">
  512. <strong>callback</strong>
  513. </td>
  514. <td class="description last">
  515. <p>The update method.</p>
  516. </td>
  517. </tr>
  518. </tbody>
  519. </table>
  520. <dl class="details">
  521. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  522. </dl>
  523. </div>
  524. <h3 class="name name-method" id="onObjectUpdate" translate="no">.<a href="#onObjectUpdate">onObjectUpdate</a><span class="signature">( callback : <span class="param-type">function</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  525. <div class="method">
  526. <div class="description">
  527. <p>Convenient method for defining <a href="Node.html#update">Node#update</a>. Similar to <a href="Node.html#onUpdate">Node#onUpdate</a>, but
  528. this method automatically sets the update type to <code>OBJECT</code>.</p>
  529. </div>
  530. <table class="params">
  531. <tbody>
  532. <tr>
  533. <td class="name">
  534. <strong>callback</strong>
  535. </td>
  536. <td class="description last">
  537. <p>The update method.</p>
  538. </td>
  539. </tr>
  540. </tbody>
  541. </table>
  542. <dl class="details">
  543. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  544. </dl>
  545. </div>
  546. <h3 class="name name-method" id="onReference" translate="no">.<a href="#onReference">onReference</a><span class="signature">( callback : <span class="param-type">function</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  547. <div class="method">
  548. <div class="description">
  549. <p>Convenient method for defining <a href="Node.html#updateReference">Node#updateReference</a>.</p>
  550. </div>
  551. <table class="params">
  552. <tbody>
  553. <tr>
  554. <td class="name">
  555. <strong>callback</strong>
  556. </td>
  557. <td class="description last">
  558. <p>The update method.</p>
  559. </td>
  560. </tr>
  561. </tbody>
  562. </table>
  563. <dl class="details">
  564. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  565. </dl>
  566. </div>
  567. <h3 class="name name-method" id="onRenderUpdate" translate="no">.<a href="#onRenderUpdate">onRenderUpdate</a><span class="signature">( callback : <span class="param-type">function</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  568. <div class="method">
  569. <div class="description">
  570. <p>Convenient method for defining <a href="Node.html#update">Node#update</a>. Similar to <a href="Node.html#onUpdate">Node#onUpdate</a>, but
  571. this method automatically sets the update type to <code>RENDER</code>.</p>
  572. </div>
  573. <table class="params">
  574. <tbody>
  575. <tr>
  576. <td class="name">
  577. <strong>callback</strong>
  578. </td>
  579. <td class="description last">
  580. <p>The update method.</p>
  581. </td>
  582. </tr>
  583. </tbody>
  584. </table>
  585. <dl class="details">
  586. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  587. </dl>
  588. </div>
  589. <h3 class="name name-method" id="onUpdate" translate="no">.<a href="#onUpdate">onUpdate</a><span class="signature">( callback : <span class="param-type">function</span>, updateType : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  590. <div class="method">
  591. <div class="description">
  592. <p>Convenient method for defining <a href="Node.html#update">Node#update</a>.</p>
  593. </div>
  594. <table class="params">
  595. <tbody>
  596. <tr>
  597. <td class="name">
  598. <strong>callback</strong>
  599. </td>
  600. <td class="description last">
  601. <p>The update method.</p>
  602. </td>
  603. </tr>
  604. <tr>
  605. <td class="name">
  606. <strong>updateType</strong>
  607. </td>
  608. <td class="description last">
  609. <p>The update type.</p>
  610. </td>
  611. </tr>
  612. </tbody>
  613. </table>
  614. <dl class="details">
  615. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  616. </dl>
  617. </div>
  618. <h3 class="name name-method" id="serialize" translate="no">.<a href="#serialize">serialize</a><span class="signature">( json : <span class="param-type">Object</span> )</span> </h3>
  619. <div class="method">
  620. <div class="description">
  621. <p>Serializes the node to JSON.</p>
  622. </div>
  623. <table class="params">
  624. <tbody>
  625. <tr>
  626. <td class="name">
  627. <strong>json</strong>
  628. </td>
  629. <td class="description last">
  630. <p>The output JSON object.</p>
  631. </td>
  632. </tr>
  633. </tbody>
  634. </table>
  635. </div>
  636. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  637. <div class="method">
  638. <div class="description">
  639. <p>Represents the setup stage which is the first step of the build process, see <a href="Node.html#build">Node#build</a> method.
  640. This method is often overwritten in derived modules to prepare the node which is used as a node's output/result.
  641. If an output node is prepared, then it must be returned in the <code>return</code> statement of the derived module's setup function.</p>
  642. </div>
  643. <table class="params">
  644. <tbody>
  645. <tr>
  646. <td class="name">
  647. <strong>builder</strong>
  648. </td>
  649. <td class="description last">
  650. <p>The current node builder.</p>
  651. </td>
  652. </tr>
  653. </tbody>
  654. </table>
  655. <dl class="details">
  656. <dt class="tag-returns"><strong>Returns:</strong> The output node.</dt>
  657. </dl>
  658. </div>
  659. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">( meta : <span class="param-type">Object</span> )</span><span class="type-signature"> : Object</span> </h3>
  660. <div class="method">
  661. <div class="description">
  662. <p>Serializes the node into the three.js JSON Object/Scene format.</p>
  663. </div>
  664. <table class="params">
  665. <tbody>
  666. <tr>
  667. <td class="name">
  668. <strong>meta</strong>
  669. </td>
  670. <td class="description last">
  671. <p>An optional JSON object that already holds serialized data from other scene objects.</p>
  672. </td>
  673. </tr>
  674. </tbody>
  675. </table>
  676. <dl class="details">
  677. <dt class="tag-returns"><strong>Returns:</strong> The serialized node.</dt>
  678. </dl>
  679. </div>
  680. <h3 class="name name-method" id="traverse" translate="no">.<a href="#traverse">traverse</a><span class="signature">( callback : <span class="param-type"><a href="global.html#traverseCallback">traverseCallback</a></span> )</span> </h3>
  681. <div class="method">
  682. <div class="description">
  683. <p>Can be used to traverse through the node's hierarchy.</p>
  684. </div>
  685. <table class="params">
  686. <tbody>
  687. <tr>
  688. <td class="name">
  689. <strong>callback</strong>
  690. </td>
  691. <td class="description last">
  692. <p>A callback that is executed per node.</p>
  693. </td>
  694. </tr>
  695. </tbody>
  696. </table>
  697. </div>
  698. <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><span class="type-signature"> : boolean</span> <span class="type-signature">(abstract) </span></h3>
  699. <div class="method">
  700. <div class="description">
  701. <p>The method can be implemented to update the node's internal state when it is used to render an object.
  702. The <a href="Node.html#updateType">Node#updateType</a> property defines how often the update is executed.</p>
  703. </div>
  704. <table class="params">
  705. <tbody>
  706. <tr>
  707. <td class="name">
  708. <strong>frame</strong>
  709. </td>
  710. <td class="description last">
  711. <p>A reference to the current node frame.</p>
  712. </td>
  713. </tr>
  714. </tbody>
  715. </table>
  716. <dl class="details">
  717. <dt class="tag-returns"><strong>Returns:</strong> An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching).</dt>
  718. </dl>
  719. </div>
  720. <h3 class="name name-method" id="updateAfter" translate="no">.<a href="#updateAfter">updateAfter</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span><span class="type-signature"> : boolean</span> <span class="type-signature">(abstract) </span></h3>
  721. <div class="method">
  722. <div class="description">
  723. <p>The method can be implemented to update the node's internal state after it was used to render an object.
  724. The <a href="Node.html#updateAfterType">Node#updateAfterType</a> property defines how often the update is executed.</p>
  725. </div>
  726. <table class="params">
  727. <tbody>
  728. <tr>
  729. <td class="name">
  730. <strong>frame</strong>
  731. </td>
  732. <td class="description last">
  733. <p>A reference to the current node frame.</p>
  734. </td>
  735. </tr>
  736. </tbody>
  737. </table>
  738. <dl class="details">
  739. <dt class="tag-returns"><strong>Returns:</strong> An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching).</dt>
  740. </dl>
  741. </div>
  742. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span><span class="type-signature"> : boolean</span> <span class="type-signature">(abstract) </span></h3>
  743. <div class="method">
  744. <div class="description">
  745. <p>The method can be implemented to update the node's internal state before it is used to render an object.
  746. The <a href="Node.html#updateBeforeType">Node#updateBeforeType</a> property defines how often the update is executed.</p>
  747. </div>
  748. <table class="params">
  749. <tbody>
  750. <tr>
  751. <td class="name">
  752. <strong>frame</strong>
  753. </td>
  754. <td class="description last">
  755. <p>A reference to the current node frame.</p>
  756. </td>
  757. </tr>
  758. </tbody>
  759. </table>
  760. <dl class="details">
  761. <dt class="tag-returns"><strong>Returns:</strong> An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching).</dt>
  762. </dl>
  763. </div>
  764. <h3 class="name name-method" id="updateReference" translate="no">.<a href="#updateReference">updateReference</a><span class="signature">( state : <span class="param-type"><a href="global.html#any">any</a></span> )</span><span class="type-signature"> : <a href="global.html#any">any</a></span> </h3>
  765. <div class="method">
  766. <div class="description">
  767. <p>Nodes might refer to other objects like materials. This method allows to dynamically update the reference
  768. to such objects based on a given state (e.g. the current node frame or builder).</p>
  769. </div>
  770. <table class="params">
  771. <tbody>
  772. <tr>
  773. <td class="name">
  774. <strong>state</strong>
  775. </td>
  776. <td class="description last">
  777. <p>This method can be invocated in different contexts so <code>state</code> can refer to any object type.</p>
  778. </td>
  779. </tr>
  780. </tbody>
  781. </table>
  782. <dl class="details">
  783. <dt class="tag-returns"><strong>Returns:</strong> The updated reference.</dt>
  784. </dl>
  785. </div>
  786. <h2 class="subsection-title">Source</h2>
  787. <p>
  788. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/core/Node.js" translate="no" target="_blank" rel="noopener">src/nodes/core/Node.js</a>
  789. </p>
  790. </article>
  791. </section>
  792. <script src="../scripts/linenumber.js"></script>
  793. <script src="../scripts/page.js"></script>
  794. </body>
  795. </html>
粤ICP备19079148号