How to develop HTML5 with the help of Class Library
This article mainly explains "how to develop HTML5 with the help of class libraries". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to develop HTML5 with the help of class libraries" together!
The code is as follows:
threeJSDemo
body
{
margin:0px;
background-color:#B0B0B0;
overload:hidden;
}
var camera,scene,renderer;
var mesh;
init();
animate();
function init(){
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(70,window.innerWidth / window.innerHeight,1,1000);
camera.position.z = 400;
scene.add(camera);
geometry = new THREE.CubeGeometry(200,200,200);
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
mesh = new THREE.Mesh(geometry,material);
scene.add(mesh);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth,window.innerHeight);
document.body.appendChild(renderer.domElement);
}
function animate() {
requestAnimationFrame( animate );
mesh.rotation.x += 0.05;
mesh.rotation.y += 0.05;
renderer.render( scene, camera );
}
This is the whole code, compared to the previous code using WebGL API, this is simply too simple.
The code is straightforward, just a few steps:
1. Create a scene.
2. Create a camera.
3. Create/load model geometry.
4. Load material material.
5. Rendering a mesh(consisting of geometry and material).
6. Enable animation.
Thank you for reading, the above is "HTML5 with the help of class library how to develop" the content, after the study of this article, I believe that we have a deeper understanding of HTML5 with the help of class library how to develop this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!