Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/jsm/loaders/LottieLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ import lottie from '../libs/lottie_canvas.module.js';
*/
class LottieLoader extends Loader {

/**
* Constructs a new Lottie loader.
*
* @deprecated The loader has been deprecated and will be removed with r186. Use lottie-web instead and create your animated texture manually.
* @param {LoadingManager} [manager] - The loading manager.
*/
constructor( manager ) {

super( manager );

console.warn( 'THREE.LottieLoader: The loader has been deprecated and will be removed with r186. Use lottie-web instead and create your animated texture manually.' );

}

/**
* Sets the texture quality.
*
Expand Down
1 change: 1 addition & 0 deletions examples/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"webgl_loader_ifc": [ "external" ],
"webgl_loader_ldraw": [ "lego" ],
"webgl_loader_pdb": [ "molecules", "css2d" ],
"webgl_loader_texture_lottie": [ "external" ],
"webgl_loader_texture_ultrahdr": [ "hdr", "jpg", "ultrahdr" ],
"webgl_loader_ttf": [ "text", "font" ],
"webgl_lod": [ "level", "details" ],
Expand Down
39 changes: 35 additions & 4 deletions examples/webgl_loader_texture_lottie.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
import { LottieLoader } from 'three/addons/loaders/LottieLoader.js';

import lottie from 'https://cdn.jsdelivr.net/npm/lottie-web@5.12.2/+esm';

let renderer, scene, camera;
let mesh;

Expand All @@ -42,11 +44,40 @@
scene = new THREE.Scene();
scene.background = new THREE.Color( 0x111111 );

const loader = new LottieLoader();
loader.setQuality( 2 );
loader.load( 'textures/lottie/24017-lottie-logo-animation.json', function ( texture ) {
// lottie

const loader = new THREE.FileLoader();
loader.setResponseType( 'json' );
loader.load( 'textures/lottie/24017-lottie-logo-animation.json', function ( data ) {

const container = document.createElement( 'div' );
container.style.width = data.w + 'px';
container.style.height = data.h + 'px';
document.body.appendChild( container );

const animation = lottie.loadAnimation( {
container: container,
animType: 'canvas',
loop: true,
autoplay: true,
animationData: data,
rendererSettings: { dpr: 1 }
} );

const texture = new THREE.CanvasTexture( animation.container );
texture.minFilter = THREE.NearestFilter;
texture.generateMipmaps = false;
texture.colorSpace = THREE.SRGBColorSpace;

animation.addEventListener( 'enterFrame', function () {

texture.needsUpdate = true;

} );

container.style.display = 'none'; // must be done after loadAnimation() otherwise canvas has 0 dimensions

setupControls( texture.animation );
setupControls( animation );

// texture = new THREE.TextureLoader().load( 'textures/uv_grid_directx.jpg' );
// texture.colorSpace = THREE.SRGBColorSpace;
Expand Down