USDComposer.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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="_buildCamera" translate="no">.<a href="#_buildCamera">_buildCamera</a><span class="signature">()</span> </h3>
  43. <div class="method">
  44. <div class="description">
  45. <p>Build a camera from a Camera spec.</p>
  46. </div>
  47. </div>
  48. <h3 class="name name-method" id="_buildGeomPrimitive" translate="no">.<a href="#_buildGeomPrimitive">_buildGeomPrimitive</a><span class="signature">()</span> </h3>
  49. <div class="method">
  50. <div class="description">
  51. <p>Build a mesh from a USD geometric primitive (Cube, Sphere, Cylinder, Cone, Capsule).</p>
  52. </div>
  53. </div>
  54. <h3 class="name name-method" id="_buildHierarchy" translate="no">.<a href="#_buildHierarchy">_buildHierarchy</a><span class="signature">()</span> </h3>
  55. <div class="method">
  56. <div class="description">
  57. <p>Build the scene hierarchy recursively.
  58. Uses childrenByPath index for O(1) child lookup instead of O(n) iteration.</p>
  59. </div>
  60. </div>
  61. <h3 class="name name-method" id="_buildIndexes" translate="no">.<a href="#_buildIndexes">_buildIndexes</a><span class="signature">()</span> </h3>
  62. <div class="method">
  63. <div class="description">
  64. <p>Build indexes for efficient lookups.
  65. Called once during compose() to avoid O(n) scans per lookup.</p>
  66. </div>
  67. </div>
  68. <h3 class="name name-method" id="_buildLight" translate="no">.<a href="#_buildLight">_buildLight</a><span class="signature">()</span> </h3>
  69. <div class="method">
  70. <div class="description">
  71. <p>Build a light from a UsdLux light spec.</p>
  72. </div>
  73. </div>
  74. <h3 class="name name-method" id="_buildMesh" translate="no">.<a href="#_buildMesh">_buildMesh</a><span class="signature">()</span> </h3>
  75. <div class="method">
  76. <div class="description">
  77. <p>Build a mesh from a Mesh spec.</p>
  78. </div>
  79. </div>
  80. <h3 class="name name-method" id="_colorTemperature" translate="no">.<a href="#_colorTemperature">_colorTemperature</a><span class="signature">()</span> </h3>
  81. <div class="method">
  82. <div class="description">
  83. <p>Convert a color temperature in Kelvin to an RGB Color.
  84. Based on Tanner Helland's algorithm.</p>
  85. </div>
  86. </div>
  87. <h3 class="name name-method" id="_computeVertexNormals" translate="no">.<a href="#_computeVertexNormals">_computeVertexNormals</a><span class="signature">()</span> </h3>
  88. <div class="method">
  89. <div class="description">
  90. <p>Compute per-vertex normals from indexed triangle data.
  91. Accumulates area-weighted face normals at each shared vertex and normalizes.</p>
  92. </div>
  93. </div>
  94. <h3 class="name name-method" id="_findSingleMesh" translate="no">.<a href="#_findSingleMesh">_findSingleMesh</a><span class="signature">()</span> </h3>
  95. <div class="method">
  96. <div class="description">
  97. <p>Find a single mesh in the group's shallow hierarchy.
  98. Only returns a mesh if it's at depth 0 or 1, not deeply nested.
  99. This preserves transforms in complex hierarchies like Kitchen Set
  100. while supporting USDZExporter round-trip (Xform &gt; Xform &gt; Mesh pattern).</p>
  101. </div>
  102. </div>
  103. <h3 class="name name-method" id="_getAttributes" translate="no">.<a href="#_getAttributes">_getAttributes</a><span class="signature">()</span> </h3>
  104. <div class="method">
  105. <div class="description">
  106. <p>Get attributes for a path from attribute specs.</p>
  107. </div>
  108. </div>
  109. <h3 class="name name-method" id="_getBasePath" translate="no">.<a href="#_getBasePath">_getBasePath</a><span class="signature">()</span> </h3>
  110. <div class="method">
  111. <div class="description">
  112. <p>Get the base path (directory) from a file path.</p>
  113. </div>
  114. </div>
  115. <h3 class="name name-method" id="_getLocalVariantSelections" translate="no">.<a href="#_getLocalVariantSelections">_getLocalVariantSelections</a><span class="signature">()</span> </h3>
  116. <div class="method">
  117. <div class="description">
  118. <p>Extract variant selections from a spec's fields.</p>
  119. </div>
  120. </div>
  121. <h3 class="name name-method" id="_getMaterialBindingTarget" translate="no">.<a href="#_getMaterialBindingTarget">_getMaterialBindingTarget</a><span class="signature">()</span> </h3>
  122. <div class="method">
  123. <div class="description">
  124. <p>Get material binding target path, checking variant paths if needed.</p>
  125. </div>
  126. </div>
  127. <h3 class="name name-method" id="_getMaterialPath" translate="no">.<a href="#_getMaterialPath">_getMaterialPath</a><span class="signature">()</span> </h3>
  128. <div class="method">
  129. <div class="description">
  130. <p>Get the material path for a mesh, checking various binding sources.</p>
  131. </div>
  132. </div>
  133. <h3 class="name name-method" id="_getReferences" translate="no">.<a href="#_getReferences">_getReferences</a><span class="signature">()</span><span class="type-signature"> : Array.&lt;string></span> </h3>
  134. <div class="method">
  135. <div class="description">
  136. <p>Get all reference values from a prim spec.</p>
  137. </div>
  138. <dl class="details">
  139. <dt class="tag-returns"><strong>Returns:</strong> Array of reference strings like &quot;@path@&quot; or &quot;@path@<prim>&quot;</dt>
  140. </dl>
  141. </div>
  142. <h3 class="name name-method" id="_getVariantPaths" translate="no">.<a href="#_getVariantPaths">_getVariantPaths</a><span class="signature">()</span> </h3>
  143. <div class="method">
  144. <div class="description">
  145. <p>Get variant paths for a parent path based on variant selections.</p>
  146. </div>
  147. </div>
  148. <h3 class="name name-method" id="_hasNonIdentityTransform" translate="no">.<a href="#_hasNonIdentityTransform">_hasNonIdentityTransform</a><span class="signature">()</span> </h3>
  149. <div class="method">
  150. <div class="description">
  151. <p>Check if an object has a non-identity local transform.</p>
  152. </div>
  153. </div>
  154. <h3 class="name name-method" id="_isDirectChild" translate="no">.<a href="#_isDirectChild">_isDirectChild</a><span class="signature">()</span> </h3>
  155. <div class="method">
  156. <div class="description">
  157. <p>Check if a path is a direct child of parentPath.</p>
  158. </div>
  159. </div>
  160. <h3 class="name name-method" id="_resolveFilePath" translate="no">.<a href="#_resolveFilePath">_resolveFilePath</a><span class="signature">()</span> </h3>
  161. <div class="method">
  162. <div class="description">
  163. <p>Resolve a file path relative to basePath.</p>
  164. </div>
  165. </div>
  166. <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>
  167. <div class="method">
  168. <div class="description">
  169. <p>Resolve a USD reference and return the composed content.</p>
  170. </div>
  171. <table class="params">
  172. <tbody>
  173. <tr>
  174. <td class="name">
  175. <strong translate="no">refValue</strong>
  176. </td>
  177. <td class="description last">
  178. <p>Reference value like &quot;@./path/to/file.usdc@&quot;</p>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td class="name">
  183. <strong translate="no">localVariants</strong>
  184. </td>
  185. <td class="description last">
  186. <p>Variant selections to apply</p>
  187. </td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <dl class="details">
  192. <dt class="tag-returns"><strong>Returns:</strong> Composed content or null</dt>
  193. </dl>
  194. </div>
  195. <h3 class="name name-method" id="applyTransform" translate="no">.<a href="#applyTransform">applyTransform</a><span class="signature">()</span> </h3>
  196. <div class="method">
  197. <div class="description">
  198. <p>Apply USD transforms to a Three.js object.
  199. Handles xformOpOrder with proper matrix composition.
  200. USD uses row-vector convention, Three.js uses column-vector.</p>
  201. </div>
  202. </div>
  203. <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>
  204. <div class="method">
  205. <div class="description">
  206. <p>Compose a Three.js scene from parsed USD data.</p>
  207. </div>
  208. <table class="params">
  209. <tbody>
  210. <tr>
  211. <td class="name">
  212. <strong translate="no">parsedData</strong>
  213. </td>
  214. <td class="description last">
  215. <p>Data from USDCParser or USDAParser</p>
  216. </td>
  217. </tr>
  218. <tr>
  219. <td class="name">
  220. <strong translate="no">assets</strong>
  221. </td>
  222. <td class="description last">
  223. <p>Dictionary of referenced assets (specsByPath or blob URLs)</p>
  224. </td>
  225. </tr>
  226. <tr>
  227. <td class="name">
  228. <strong translate="no">variantSelections</strong>
  229. </td>
  230. <td class="description last">
  231. <p>External variant selections</p>
  232. </td>
  233. </tr>
  234. <tr>
  235. <td class="name">
  236. <strong translate="no">basePath</strong>
  237. </td>
  238. <td class="description last">
  239. <p>Base path for resolving relative references</p>
  240. </td>
  241. </tr>
  242. </tbody>
  243. </table>
  244. <dl class="details">
  245. <dt class="tag-returns"><strong>Returns:</strong> Three.js scene graph</dt>
  246. </dl>
  247. </div>
  248. <h2 class="subsection-title">Source</h2>
  249. <p>
  250. <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>
  251. </p>
  252. </article>
  253. </section>
  254. <script src="../scripts/linenumber.js"></script>
  255. <script src="../scripts/page.js"></script>
  256. </body>
  257. </html>
粤ICP备19079148号