index34
//화면 생성
let scene = new THREE.Scene();
//카메라 설정
let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 10000);
camera.position.x = 100;
camera.position.z = 6500;
//렌더링 설정
let renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor("#4DD0E1");
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio > 1 ? 2 : 1);
document.body.appendChild(renderer.domElement);
//카메라
const geometry = new THREE.BoxBufferGeometry(2000, 120, 120);
const material = new THREE.MeshNormalMaterial();
const group = new THREE.Group();
for (let i = 0; i < 350; i++) {
const mesh = new THREE.Mesh(geometry, material);
const dist = 10000 / 3;
const distDouble = dist * 2;
const tau = 3 * Math.PI;
mesh.position.x = Math.random() * distDouble - dist;
mesh.position.y = Math.random() * distDouble - dist;
mesh.position.z = Math.random() * distDouble - dist;
mesh.rotation.x = Math.random() * tau;
mesh.rotation.y = Math.random() * tau;
mesh.rotation.z = Math.random() * tau;
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
group.add(mesh);
}
scene.add(group);
//컨트롤 설정
//조명 설정
//애니메이션 설정
function animate() {
requestAnimationFrame(animate);
const t = Date.now() * 0.001;
const rx = Math.sin(t * 0.7) * 0.5;
const ry = Math.sin(t * 0.3) * 0.5;
const rz = Math.sin(t * 0.2) * 0.5;
group.rotation.x = rx;
group.rotation.y = ry;
group.rotation.z = rz;
renderer.render(scene, camera);
}
animate();
//화면 사이즈 설정
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener('resize', onWindowResize);
What’s on our mind?
Collection of articles, design, site, and resources made by designers and publisher
@Menu View
ad