//场景
const scene = new THREE.Scene();
//几何体
const geometry = new THREE.CubeGeometry(2,5,2)
//材质
const meterial = new THREE.MeshBasicMaterial({color:'orange'});
//模型
const cube = new THREE.Mesh(geometry,meterial)
//模型添加到场景
scene.add(cube)
//相机
const camera = new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1000);
//相机位置
camera.position.z = 10
//渲染器
const renderer = new THREE.WebGLRenderer()
renderer.setClearColor('#ffffff')
renderer.setSize(window.innerWidth,window.innerHeight)
document.body.appendChild(renderer.domElement)
//渲染
function render(){
requestAnimationFrame(render)
cube.rotation.y += 0.01;
renderer.render(scene,camera)
}
render();