Skip to content

Commit 940fe93

Browse files
committed
LottieLoader: Added setQuality()
1 parent 48c73d1 commit 940fe93

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

examples/jsm/loaders/LottieLoader.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ export class LottieLoader extends Loader {
1010

1111
load( url: string, onLoad: ( texture: CanvasTexture ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ) : void;
1212

13+
setQuality( value: Number ) : void;
14+
1315
}

examples/jsm/loaders/LottieLoader.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ LottieLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
1414

1515
constructor: LottieLoader,
1616

17+
setQuality: function ( value ) {
18+
19+
this._quality = value;
20+
21+
},
22+
1723
load: function ( url, onLoad, onProgress, onError ) {
1824

25+
const quality = this._quality || 1;
26+
1927
const texture = new CanvasTexture();
2028

2129
const loader = new FileLoader( this.manager );
@@ -40,7 +48,7 @@ LottieLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
4048
loop: true,
4149
autoplay: true,
4250
animationData: data,
43-
rendererSettings: { dpr: 1 }
51+
rendererSettings: { dpr: quality }
4452
} );
4553

4654
texture.animation = animation;

examples/webgl_loader_texture_lottie.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
scene.background = new THREE.Color( 0x222222 );
3636

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

4041
setupControls( texture.animation );
@@ -96,6 +97,7 @@
9697

9798
function onWindowResize() {
9899

100+
camera.aspect = window.innerWidth / window.innerHeight;
99101
camera.updateProjectionMatrix();
100102

101103
renderer.setSize( window.innerWidth, window.innerHeight );

0 commit comments

Comments
 (0)