|
27 | 27 | import * as THREE from 'three'; |
28 | 28 | import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js'; |
29 | 29 | import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js'; |
| 30 | + import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; |
30 | 31 |
|
31 | | - import lottie from 'https://cdn.jsdelivr.net/npm/lottie-web@5.12.2/+esm'; |
| 32 | + import lottie from 'https://cdn.jsdelivr.net/npm/lottie-web@5.13.0/+esm'; |
32 | 33 |
|
33 | | - let renderer, scene, camera; |
| 34 | + let renderer, scene, camera, controls; |
34 | 35 | let mesh; |
35 | 36 |
|
36 | 37 | init(); |
|
50 | 51 | loader.load( 'textures/lottie/24017-lottie-logo-animation.json', function ( data ) { |
51 | 52 |
|
52 | 53 | const container = document.createElement( 'div' ); |
53 | | - container.style.width = data.w + 'px'; |
54 | | - container.style.height = data.h + 'px'; |
| 54 | + const dpr = window.devicePixelRatio; |
| 55 | + container.style.width = data.w * dpr + 'px'; |
| 56 | + container.style.height = data.h * dpr + 'px'; |
55 | 57 | document.body.appendChild( container ); |
56 | 58 |
|
57 | 59 | const animation = lottie.loadAnimation( { |
|
60 | 62 | loop: true, |
61 | 63 | autoplay: true, |
62 | 64 | animationData: data, |
63 | | - rendererSettings: { dpr: 1 } |
| 65 | + rendererSettings: { dpr: dpr } |
64 | 66 | } ); |
65 | 67 |
|
66 | 68 | const texture = new THREE.CanvasTexture( animation.container ); |
|
99 | 101 |
|
100 | 102 | scene.environment = pmremGenerator.fromScene( environment ).texture; |
101 | 103 |
|
| 104 | + controls = new OrbitControls( camera, renderer.domElement ); |
| 105 | + controls.autoRotate = true; |
| 106 | + |
102 | 107 | // |
103 | 108 |
|
104 | 109 | window.addEventListener( 'resize', onWindowResize ); |
|
155 | 160 |
|
156 | 161 | function animate() { |
157 | 162 |
|
158 | | - if ( mesh ) { |
159 | | - |
160 | | - mesh.rotation.y -= 0.001; |
161 | | - |
162 | | - } |
| 163 | + controls.update(); |
163 | 164 |
|
164 | 165 | renderer.render( scene, camera ); |
165 | 166 |
|
|
0 commit comments