ThreeJS in the first round-start and ThreeJS in the first round-

Source: Internet
Author: User

ThreeJS in the first round-start and ThreeJS in the first round-

This article describes the general process of ThreeJS. (For more information, please advise .)

1. Download and introduce ThreeJS:

(1): https://github.com/mrdoob/three.js/archive/master.zip

(2) Introduction: <script type = "text/javascript" src = "~ /Scripts/three. js "> </script>

2. Start:

(1) define canvas

<Canvas id = "canvas" width = "1000" height = "500"> </canvas>

(2) // Renderer

Var renderer = new THREE. WebGLRenderer ({canvas: document. getElementById ("canvas"),}); renderer. setClearColor (0x000000 );

(3) // scenario

Var scene = new THREE. Scene ();

(4) // camera

Var camera = new THREE. orthographicCamera (-5, 5, 2.5,-2.5, 0, 10); camera. position. set (1, 2, 5); camera. lookAt (new THREE. vector3 (0, 0); scene. add (camera );

(5) // object

Var cube = new THREE. Mesh (new THREE. CubeGeometry (1, 1, 1), new THREE. MeshLambertMaterial ({color: 0xff0000}); scene. add (cube );

(6) // Lighting

Var light = new THREE. DirectionalLight (); light. position. set (1, 2, 5); scene. add (light );

(7) // Rendering

Renderer. render (scene, camera );

3. Run the Code with the following effect:

4. Conclusion:

This article aims to feel ThreeJS.

Related Article

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.