LottieLoader.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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">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">LoadingManager</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"><code>manager</code></td>
  49. <td class="description last"><p>The loading manager.</p></td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. <dl class="details">
  54. <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>
  55. </dl>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Methods</h2>
  59. <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">onProgressCallback</span>, onError : <span class="param-type">onErrorCallback</span> )</span><span class="type-signature"> : <a href="CanvasTexture.html">CanvasTexture</a></span> </h3>
  60. <div class="method">
  61. <div class="description">
  62. <p>Starts loading from the given URL and passes the loaded Lottie asset
  63. to the <code>onLoad()</code> callback.</p>
  64. </div>
  65. <table class="params">
  66. <tbody>
  67. <tr>
  68. <td class="name"><code>url</code></td>
  69. <td class="description last"><p>The path/URL of the file to be loaded. This can also be a data URI.</p></td>
  70. </tr>
  71. <tr>
  72. <td class="name"><code>onLoad</code></td>
  73. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  74. </tr>
  75. <tr>
  76. <td class="name"><code>onProgress</code></td>
  77. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  78. </tr>
  79. <tr>
  80. <td class="name"><code>onError</code></td>
  81. <td class="description last"><p>Executed when errors occur.</p></td>
  82. </tr>
  83. </tbody>
  84. </table>
  85. <dl class="details">
  86. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  87. </dl>
  88. <dl class="details">
  89. <dt class="tag-returns"><strong>Returns:</strong> The Lottie texture.</dt>
  90. </dl>
  91. </div>
  92. <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>
  93. <div class="method">
  94. <div class="description">
  95. <p>Sets the texture quality.</p>
  96. </div>
  97. <table class="params">
  98. <tbody>
  99. <tr>
  100. <td class="name"><code>value</code></td>
  101. <td class="description last"><p>The texture quality.</p></td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. </div>
  106. <h2 class="subsection-title">Source</h2>
  107. <p>
  108. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/LottieLoader.js" target="_blank" rel="noopener" translate="no">examples/jsm/loaders/LottieLoader.js</a>
  109. </p>
  110. </article>
  111. </section>
  112. <script src="../scripts/linenumber.js"></script>
  113. <script src="../scripts/page.js"></script>
  114. </body>
  115. </html>
粤ICP备19079148号