import * as THREE from 'three'; const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 1000); const scene = new THREE.Scene(); const renderer = new THREE.WebGLRenderer({ antialias: true }); let mesh: THREE.Mesh; init(); animate(); function init() { camera.position.z = 400; const texture = new THREE.TextureLoader().load('textures/crate.gif'); const geometry = new THREE.BoxGeometry(200, 200, 200); const material = new THREE.MeshBasicMaterial({ map: texture }); mesh = new THREE.Mesh(geometry, material); scene.add(mesh); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // window.addEventListener('resize', onWindowResize); } function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); } function animate() { requestAnimationFrame(animate); mesh.rotation.x += 0.005; mesh.rotation.y += 0.01; renderer.render(scene, camera); }