LottieLoader.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LottieLoader - 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="Loader.html">Loader</a> → </p>
  13. <h1 translate="no">LottieLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for the Lottie texture animation format.</p>
  17. <p>The loader returns an instance of <a href="CanvasTexture.html">CanvasTexture</a> to represent
  18. the animated texture. Two additional properties are added to each texture:</p>
  19. <ul>
  20. <li><code>animation</code>: The return value of <code>lottie.loadAnimation()</code> which is an object
  21. with an API for controlling the animation's playback.</li>
  22. <li><code>image</code>: The image container.</li>
  23. </ul></div>
  24. <h2>Code Example</h2>
  25. <div translate="no"><pre><code class="language-js">const loader = new LottieLoader();
  26. loader.setQuality( 2 );
  27. const texture = await loader.loadAsync( 'textures/lottie/24017-lottie-logo-animation.json' );
  28. const geometry = new THREE.BoxGeometry();
  29. const material = new THREE.MeshBasicMaterial( { map: texture } );
  30. const mesh = new THREE.Mesh( geometry, material );
  31. scene.add( mesh );
  32. </code></pre></div>
  33. </header>
  34. <article>
  35. <h2 class="subsection-title">Import</h2>
  36. <p><span translate="no">LottieLoader</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  37. <pre><code class="language-js">import { LottieLoader } from 'three/addons/loaders/LottieLoader.js';</code></pre>
  38. <div class="container-overview">
  39. <h2>Constructor</h2>
  40. <h3 class="name name-method" id="LottieLoader" translate="no">new <a href="#LottieLoader">LottieLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
  41. <div class="method">
  42. <div class="description">
  43. <p>Constructs a new Lottie loader.</p>
  44. </div>
  45. <table class="params">
  46. <tbody>
  47. <tr>
  48. <td class="name">
  49. <strong>manager</strong>
  50. </td>
  51. <td class="description last">
  52. <p>The loading manager.</p>
  53. </td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. <dl class="details">
  58. <dt class="important tag-deprecated"><strong>Deprecated:</strong> The loader has been deprecated and will be removed with r186. Use lottie-web instead and create your animated texture manually.</dt>
  59. </dl>
  60. </div>
  61. </div>
  62. <h2 class="subsection-title">Methods</h2>
  63. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type"><a href="global.html#onProgressCallback">onProgressCallback</a></span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span><span class="type-signature"> : <a href="CanvasTexture.html">CanvasTexture</a></span> </h3>
  64. <div class="method">
  65. <div class="description">
  66. <p>Starts loading from the given URL and passes the loaded Lottie asset
  67. to the <code>onLoad()</code> callback.</p>
  68. </div>
  69. <table class="params">
  70. <tbody>
  71. <tr>
  72. <td class="name">
  73. <strong>url</strong>
  74. </td>
  75. <td class="description last">
  76. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  77. </td>
  78. </tr>
  79. <tr>
  80. <td class="name">
  81. <strong>onLoad</strong>
  82. </td>
  83. <td class="description last">
  84. <p>Executed when the loading process has been finished.</p>
  85. </td>
  86. </tr>
  87. <tr>
  88. <td class="name">
  89. <strong>onProgress</strong>
  90. </td>
  91. <td class="description last">
  92. <p>Executed while the loading is in progress.</p>
  93. </td>
  94. </tr>
  95. <tr>
  96. <td class="name">
  97. <strong>onError</strong>
  98. </td>
  99. <td class="description last">
  100. <p>Executed when errors occur.</p>
  101. </td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. <dl class="details">
  106. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  107. </dl>
  108. <dl class="details">
  109. <dt class="tag-returns"><strong>Returns:</strong> The Lottie texture.</dt>
  110. </dl>
  111. </div>
  112. <h3 class="name name-method" id="setQuality" translate="no">.<a href="#setQuality">setQuality</a><span class="signature">( value : <span class="param-type">number</span> )</span> </h3>
  113. <div class="method">
  114. <div class="description">
  115. <p>Sets the texture quality.</p>
  116. </div>
  117. <table class="params">
  118. <tbody>
  119. <tr>
  120. <td class="name">
  121. <strong>value</strong>
  122. </td>
  123. <td class="description last">
  124. <p>The texture quality.</p>
  125. </td>
  126. </tr>
  127. </tbody>
  128. </table>
  129. </div>
  130. <h2 class="subsection-title">Source</h2>
  131. <p>
  132. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/LottieLoader.js" translate="no" target="_blank" rel="noopener">examples/jsm/loaders/LottieLoader.js</a>
  133. </p>
  134. </article>
  135. </section>
  136. <script src="../scripts/linenumber.js"></script>
  137. <script src="../scripts/page.js"></script>
  138. </body>
  139. </html>
粤ICP备19079148号