فهرست منبع

LottieLoader: Added setQuality()

Mr.doob 4 سال پیش
والد
کامیت
940fe933da
3فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 2 0
      examples/jsm/loaders/LottieLoader.d.ts
  2. 9 1
      examples/jsm/loaders/LottieLoader.js
  3. 2 0
      examples/webgl_loader_texture_lottie.html

+ 2 - 0
examples/jsm/loaders/LottieLoader.d.ts

@@ -10,4 +10,6 @@ export class LottieLoader extends Loader {
 
 
 	load( url: string, onLoad: ( texture: CanvasTexture ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ) : void;
 	load( url: string, onLoad: ( texture: CanvasTexture ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ) : void;
 
 
+	setQuality( value: Number ) : void;
+
 }
 }

+ 9 - 1
examples/jsm/loaders/LottieLoader.js

@@ -14,8 +14,16 @@ LottieLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 
 	constructor: LottieLoader,
 	constructor: LottieLoader,
 
 
+	setQuality: function ( value ) {
+
+		this._quality = value;
+
+	},
+
 	load: function ( url, onLoad, onProgress, onError ) {
 	load: function ( url, onLoad, onProgress, onError ) {
 
 
+		const quality = this._quality || 1;
+
 		const texture = new CanvasTexture();
 		const texture = new CanvasTexture();
 
 
 		const loader = new FileLoader( this.manager );
 		const loader = new FileLoader( this.manager );
@@ -40,7 +48,7 @@ LottieLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				loop: true,
 				loop: true,
 				autoplay: true,
 				autoplay: true,
 				animationData: data,
 				animationData: data,
-				rendererSettings: { dpr: 1 }
+				rendererSettings: { dpr: quality }
 			} );
 			} );
 
 
 			texture.animation = animation;
 			texture.animation = animation;

+ 2 - 0
examples/webgl_loader_texture_lottie.html

@@ -35,6 +35,7 @@
 				scene.background = new THREE.Color( 0x222222 );
 				scene.background = new THREE.Color( 0x222222 );
 
 
 				const loader = new LottieLoader();
 				const loader = new LottieLoader();
+				loader.setQuality( 2 );
 				loader.load( 'textures/lottie/24017-lottie-logo-animation.json', function ( texture ) {
 				loader.load( 'textures/lottie/24017-lottie-logo-animation.json', function ( texture ) {
 
 
 					setupControls( texture.animation );
 					setupControls( texture.animation );
@@ -96,6 +97,7 @@
 
 
 			function onWindowResize() {
 			function onWindowResize() {
 
 
+				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();
 				camera.updateProjectionMatrix();
 
 
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );