Online Demo
Use the three.js generated cube to select the 3D effect.
Recommended for use in modern browsers such as Chrome (WEBGL support required)
If you are interested in Three.js, please visit the following course library:
Javascript Class Library Three.js Basics Introduction
Related code:
- var scene = new three. Scene();
- var camera = new three. Perspectivecamera( //vertical field of view (from bottom to top) in degrees /c9>
- //aspect ratio where the height of the element divides the width
- 5, //near clipping plane
- ); //far clipping plane
- var renderer = new three. Webglrenderer();
- Renderer. SetSize(a );
- Document. Body. AppendChild(renderer. DomElement);
- var geometry = new three. Boxgeometry(1, 1, 3);
- var cratetexture = new three. Imageutils. Loadtexture("http://www.gbtags.com/gb/networks/themes/img/weixin.jpg");
- var material =new Three. Meshbasicmaterial ({map: cratetexture< Span class= "pun" >, Color: 0xffffff, Wireframe: false
- var cube = new three. Mesh(geometry, material);
- Scene. Add(cube);
- Camera. Position. Z = + ;
- Modify render scene to lens for animation
- function render() {
- Requestanimationframe(render);
- Cube. Rotation. X + = 0.03;
- Cube. Rotation. Y + = 0.03;
- Renderer. Render(scene, camera);
- }
- Call the Render method
- Render();
Three.js texture Map Cube Rotation animation effect