Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
cd90feda4This file is pinned to the selected release. Download the original to open it in your design tool.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello ThreeJS</title>
<style type="text/css">
html, body {margin:0;padding:0;overflow:hidden;}
</style>
</head>
<body>
<script type="text/javascript" src="assets/js/three.min.js"></script>
<script type="text/javascript">
/**
* three.js JavaScript 3D Library
*/
let camera, scene, renderer; // 摄像机、场景、渲染器
let geometry, material, mesh; // 几何体、材质、网格
function init() {
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 10);
camera.position.z = 1;
scene = new THREE.Scene();
geometry = new THREE.BoxGeometry(0.3, 0.3, 0.3);
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
//renderer.setAnimationLoop(animate);
document.body.appendChild(renderer.domElement);
}
function animate() {
requestAnimationFrame(animate);
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render(scene, camera);
}
init();
animate();
</script>
</body>
</html>