Three.js texture Map Cube Rotation animation effect

Source: Internet
Author: User
Tags in degrees

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:
  1. var scene = new three. Scene();
  2. var camera = new three. Perspectivecamera( //vertical field of view (from bottom to top) in degrees /c9>
  3. //aspect ratio where the height of the element divides the width
  4. 5, //near clipping plane
  5. ); //far clipping plane
  6. var renderer = new three. Webglrenderer();
  7. Renderer. SetSize(a );
  8. Document. Body. AppendChild(renderer. DomElement);
  9. var geometry = new three. Boxgeometry(1, 1, 3);
  10. var cratetexture = new three. Imageutils. Loadtexture("http://www.gbtags.com/gb/networks/themes/img/weixin.jpg");
  11. var material =new Three. Meshbasicmaterial ({map: cratetexture< Span class= "pun" >, Color: 0xffffff, Wireframe: false
  12. var cube = new three. Mesh(geometry, material);
  13. Scene. Add(cube);
  14. Camera. Position. Z = + ;
  15. Modify render scene to lens for animation
  16. function render() {
  17. Requestanimationframe(render);
  18. Cube. Rotation. X + = 0.03;
  19. Cube. Rotation. Y + = 0.03;
  20. Renderer. Render(scene, camera);
  21. }
  22. Call the Render method
  23. Render();

Three.js texture Map Cube Rotation animation effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.