|
|
@@ -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;
|
|
|
|
|
|
@@ -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;
|