1
0

USDComposer.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>USDComposer - 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. <h1 translate="no">USDComposer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>USDComposer handles scene composition from parsed USD data.
  16. This includes reference resolution, variant selection, transform handling,
  17. and building the Three.js scene graph.</p>
  18. <p>Works with specsByPath format from USDCParser.</p></div>
  19. </header>
  20. <article>
  21. <div class="container-overview">
  22. <h2>Constructor</h2>
  23. <h3 class="name name-method" id="USDComposer" translate="no">new <a href="#USDComposer">USDComposer</a><span class="signature">()</span> </h3>
  24. <div class="method">
  25. </div>
  26. </div>
  27. <h2 class="subsection-title">Methods</h2>
  28. <h3 class="name name-method" id="_applyMaterialBinding" translate="no">.<a href="#_applyMaterialBinding">_applyMaterialBinding</a><span class="signature">()</span> </h3>
  29. <div class="method">
  30. <div class="description">
  31. <p>Apply material binding from a prim path to a mesh.
  32. Used when merging referenced geometry into a prim that has material binding.</p>
  33. </div>
  34. </div>
  35. <h3 class="name name-method" id="_applyTextureOrValue" translate="no">.<a href="#_applyTextureOrValue">_applyTextureOrValue</a><span class="signature">()</span> </h3>
  36. <div class="method">
  37. <div class="description">
  38. <p>Shared helper for applying texture or value from shader attribute.
  39. Reduces duplication between _applyPreviewSurface and _applyOpenPBRSurface.</p>
  40. </div>
  41. </div>
  42. <h3 class="name name-method" id="_buildHierarchy" translate="no">.<a href="#_buildHierarchy">_buildHierarchy</a><span class="signature">()</span> </h3>
  43. <div class="method">
  44. <div class="description">
  45. <p>Build the scene hierarchy recursively.
  46. Uses childrenByPath index for O(1) child lookup instead of O(n) iteration.</p>
  47. </div>
  48. </div>
  49. <h3 class="name name-method" id="_buildIndexes" translate="no">.<a href="#_buildIndexes">_buildIndexes</a><span class="signature">()</span> </h3>
  50. <div class="method">
  51. <div class="description">
  52. <p>Build indexes for efficient lookups.
  53. Called once during compose() to avoid O(n) scans per lookup.</p>
  54. </div>
  55. </div>
  56. <h3 class="name name-method" id="_buildMesh" translate="no">.<a href="#_buildMesh">_buildMesh</a><span class="signature">()</span> </h3>
  57. <div class="method">
  58. <div class="description">
  59. <p>Build a mesh from a Mesh spec.</p>
  60. </div>
  61. </div>
  62. <h3 class="name name-method" id="_findSingleMesh" translate="no">.<a href="#_findSingleMesh">_findSingleMesh</a><span class="signature">()</span> </h3>
  63. <div class="method">
  64. <div class="description">
  65. <p>Find a single mesh in the group's shallow hierarchy.
  66. Only returns a mesh if it's at depth 0 or 1, not deeply nested.
  67. This preserves transforms in complex hierarchies like Kitchen Set
  68. while supporting USDZExporter round-trip (Xform &gt; Xform &gt; Mesh pattern).</p>
  69. </div>
  70. </div>
  71. <h3 class="name name-method" id="_getAttributes" translate="no">.<a href="#_getAttributes">_getAttributes</a><span class="signature">()</span> </h3>
  72. <div class="method">
  73. <div class="description">
  74. <p>Get attributes for a path from attribute specs.</p>
  75. </div>
  76. </div>
  77. <h3 class="name name-method" id="_getBasePath" translate="no">.<a href="#_getBasePath">_getBasePath</a><span class="signature">()</span> </h3>
  78. <div class="method">
  79. <div class="description">
  80. <p>Get the base path (directory) from a file path.</p>
  81. </div>
  82. </div>
  83. <h3 class="name name-method" id="_getLocalVariantSelections" translate="no">.<a href="#_getLocalVariantSelections">_getLocalVariantSelections</a><span class="signature">()</span> </h3>
  84. <div class="method">
  85. <div class="description">
  86. <p>Extract variant selections from a spec's fields.</p>
  87. </div>
  88. </div>
  89. <h3 class="name name-method" id="_getMaterialBindingTarget" translate="no">.<a href="#_getMaterialBindingTarget">_getMaterialBindingTarget</a><span class="signature">()</span> </h3>
  90. <div class="method">
  91. <div class="description">
  92. <p>Get material binding target path, checking variant paths if needed.</p>
  93. </div>
  94. </div>
  95. <h3 class="name name-method" id="_getMaterialPath" translate="no">.<a href="#_getMaterialPath">_getMaterialPath</a><span class="signature">()</span> </h3>
  96. <div class="method">
  97. <div class="description">
  98. <p>Get the material path for a mesh, checking various binding sources.</p>
  99. </div>
  100. </div>
  101. <h3 class="name name-method" id="_getReference" translate="no">.<a href="#_getReference">_getReference</a><span class="signature">()</span> </h3>
  102. <div class="method">
  103. <div class="description">
  104. <p>Get reference value from a prim spec.</p>
  105. </div>
  106. </div>
  107. <h3 class="name name-method" id="_getVariantPaths" translate="no">.<a href="#_getVariantPaths">_getVariantPaths</a><span class="signature">()</span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>Get variant paths for a parent path based on variant selections.</p>
  111. </div>
  112. </div>
  113. <h3 class="name name-method" id="_hasNonIdentityTransform" translate="no">.<a href="#_hasNonIdentityTransform">_hasNonIdentityTransform</a><span class="signature">()</span> </h3>
  114. <div class="method">
  115. <div class="description">
  116. <p>Check if an object has a non-identity local transform.</p>
  117. </div>
  118. </div>
  119. <h3 class="name name-method" id="_isDirectChild" translate="no">.<a href="#_isDirectChild">_isDirectChild</a><span class="signature">()</span> </h3>
  120. <div class="method">
  121. <div class="description">
  122. <p>Check if a path is a direct child of parentPath.</p>
  123. </div>
  124. </div>
  125. <h3 class="name name-method" id="_resolveFilePath" translate="no">.<a href="#_resolveFilePath">_resolveFilePath</a><span class="signature">()</span> </h3>
  126. <div class="method">
  127. <div class="description">
  128. <p>Resolve a file path relative to basePath.</p>
  129. </div>
  130. </div>
  131. <h3 class="name name-method" id="_resolveReference" translate="no">.<a href="#_resolveReference">_resolveReference</a><span class="signature">( refValue : <span class="param-type">string</span>, localVariants : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="Group.html">Group</a> | null</span> </h3>
  132. <div class="method">
  133. <div class="description">
  134. <p>Resolve a USD reference and return the composed content.</p>
  135. </div>
  136. <table class="params">
  137. <tbody>
  138. <tr>
  139. <td class="name">
  140. <strong translate="no">refValue</strong>
  141. </td>
  142. <td class="description last">
  143. <p>Reference value like &quot;@./path/to/file.usdc@&quot;</p>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td class="name">
  148. <strong translate="no">localVariants</strong>
  149. </td>
  150. <td class="description last">
  151. <p>Variant selections to apply</p>
  152. </td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. <dl class="details">
  157. <dt class="tag-returns"><strong>Returns:</strong> Composed content or null</dt>
  158. </dl>
  159. </div>
  160. <h3 class="name name-method" id="applyTransform" translate="no">.<a href="#applyTransform">applyTransform</a><span class="signature">()</span> </h3>
  161. <div class="method">
  162. <div class="description">
  163. <p>Apply USD transforms to a Three.js object.
  164. Handles xformOpOrder with proper matrix composition.
  165. USD uses row-vector convention, Three.js uses column-vector.</p>
  166. </div>
  167. </div>
  168. <h3 class="name name-method" id="compose" translate="no">.<a href="#compose">compose</a><span class="signature">( parsedData : <span class="param-type">Object</span>, assets : <span class="param-type">Object</span>, variantSelections : <span class="param-type">Object</span>, basePath : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Group.html">Group</a></span> </h3>
  169. <div class="method">
  170. <div class="description">
  171. <p>Compose a Three.js scene from parsed USD data.</p>
  172. </div>
  173. <table class="params">
  174. <tbody>
  175. <tr>
  176. <td class="name">
  177. <strong translate="no">parsedData</strong>
  178. </td>
  179. <td class="description last">
  180. <p>Data from USDCParser or USDAParser</p>
  181. </td>
  182. </tr>
  183. <tr>
  184. <td class="name">
  185. <strong translate="no">assets</strong>
  186. </td>
  187. <td class="description last">
  188. <p>Dictionary of referenced assets (specsByPath or blob URLs)</p>
  189. </td>
  190. </tr>
  191. <tr>
  192. <td class="name">
  193. <strong translate="no">variantSelections</strong>
  194. </td>
  195. <td class="description last">
  196. <p>External variant selections</p>
  197. </td>
  198. </tr>
  199. <tr>
  200. <td class="name">
  201. <strong translate="no">basePath</strong>
  202. </td>
  203. <td class="description last">
  204. <p>Base path for resolving relative references</p>
  205. </td>
  206. </tr>
  207. </tbody>
  208. </table>
  209. <dl class="details">
  210. <dt class="tag-returns"><strong>Returns:</strong> Three.js scene graph</dt>
  211. </dl>
  212. </div>
  213. <h2 class="subsection-title">Source</h2>
  214. <p>
  215. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/usd/USDComposer.js" translate="no" target="_blank" rel="noopener">examples/jsm/loaders/usd/USDComposer.js</a>
  216. </p>
  217. </article>
  218. </section>
  219. <script src="../scripts/linenumber.js"></script>
  220. <script src="../scripts/page.js"></script>
  221. </body>
  222. </html>
粤ICP备19079148号