Threejs official website and threejs Official Website

Source: Internet
Author: User

Threejs official website and threejs Official Website

Threejs official website-Getting Started Guide (Getting Started)

Beautiful Life of the sun and fire god (http://blog.csdn.net/opengl_es)

This article follows the "signature-non-commercial use-consistency" creation public agreement

Reprinted please keep this sentence: Sun huoshen's beautiful life-this blog focuses on Agile development and mobile and IOT device research: iOS, Android, Html5, Arduino, pcDuino, otherwise, this blog post is rejected or reprinted. Thank you for your cooperation.


Getting Started (Getting Started) chinedufn edited this page On 4 Mar 2013· 9 revisions

The Three. js scenario is very easy to set. Only a few lines of code are required to complete initialization. Scenarios are constructed using several different types of objects: camera, light, and mesh ).

Three. js scenes are very easy to setup and only require a few lines of code to initialize. Scenes are constructed using a few different types of objects: cameras, lights, and meshes.

The first step in rendering the three. js scenario is to create a WebGL rendering object. The following code creates a 800x640 pixel HTML canvas (cavas) object, adds it to the document body, And initializes the three. js scenario.

The first step in rendering a three. js scene is creating the WebGL renderer object. the following code creates an HTML canvas object 800x640 pixels, adds it to the document's body, and initializes a three. js scene.

var renderer = new THREE.WebGLRenderer();renderer.setSize( 800, 640 );document.body.appendChild( renderer.domElement );var scene = new THREE.Scene();

The second step defines the camera, rendering objects will be used in rendering.

The second step is to define a camera which the renderer object will use in rendering.

var camera = new THREE.PerspectiveCamera(    35,         // Field of view    800 / 640,  // Aspect ratio    .1,         // Near    10000       // Far);camera.position.set( -15, 10, 15 );camera.lookAt( scene.position );

The first parameter determines how wide the view field is.
The second parameter is the aspect ratio, which is calculated by dividing the width of the view area by the height.
The third and fourth Parameters specify the boundary point of the object (visible area) in the Image view.
If the distance between the object and the camera is not within the range between NEAR and FAR, such an object will not be rendered. (Note: This is also an internal mechanism to reduce unnecessary rendering consumption on GPU resources and improve efficiency !).
The last line of code sets the coordinates of the image machine XYZ to-15, 10, and 15, respectively.

The first parameter passed determines how wide the field of view is. the second parameter is the aspect ratio which is calculated by dividing the viewing area's width by its height. the third and fourth parameters specify cut-off points for objects in the camera's view. if an object's distance from the camera does not fall in the range between NEAR and FAR then that object is not rendered. the last line sets the camera's XYZ coordinates to-15, 10, and 15 respectively.

Create a cube of 5 units in width, height, and depth in three steps, add the Lambert material, and add it to the scene.

Step three creates a cube that is 5 units wide, tall and deep, adds the Lambert material, and adds it to the scene.

// Note: var geometry = new THREE. cubeGeometry (5, 5, 5); // Translator's note: The paper of the Paster lantern is painted. Of course, during the Chinese new Year, the scheme is better. var material = new THREE. meshLambertMaterial ({color: 0xFF0000}); // Translator's note: sort the colored paper with the pattern according to the lantern size ratio, crop it, and paste it to the lantern skeleton. var mesh = new THREE. mesh (geometry, material); // Note: After the lantern is pasted, it can be mounted to the gate for others to see. Chinese people love to show our best side of scene. add (mesh );

The last step of setting the scene is to create a yellow light source and add it to the scene.

For the last step in setting up a scene we create a yellow light source and add it to the scene.

// Note: Do not forget to prepare a candle var light = new THREE for the lantern. pointLight (0xFFFF00); // Note: put the candle in the lantern, which is better than the amount of space. Don't scatter the lantern by yourself, so it will be white and easy to catch fire. position. set (10, 0, 10); // place the candle in a better position. Of course, when the lantern skeleton is tied, maybe you have considered the place where the candle is reserved. scene. add (light );

In the final Rendering scenario, only the scenes that can be viewed from the camera perspective are displayed.

Finally we render the scene which displays our scene through the camera's eye.

// Note: What about matches? What about lighter? Please light up renderer. render (scene, camera );

Put everything in the running example using the minimal HTML template, just like the following code:

Everything together in a working example with a minimal HTML template:

<!DOCTYPE html>

15 lines of Javascript code initialize and render a scenario.

15 lines of Javascript to initialize and render a scene.




Webgl wants to create six globes on the six faces of the cube.

We recommend that you use the webgl framework. If you write it directly, it is like writing opengl, which is very troublesome. We recommend the threejs framework, write the cube sphere, and then locate the coordinates. It will soon come out.
This is threejs.org/The threejs official website.

If a good system is ready for use, give 10 points first, and then click "add points ".

Download XP:
Www.namipan.com/..e0ad2b
Only the download link of the nano disk ......

Download Vista:
System (OEM does not activate the pure version. Make sure to select the version. Do not select the wrong version)
Www.kpsky.cn/down/sp1.htm or
Flashget: // token ==& 7365 & 1210076732
(Dedicated for express) or
Soft.zt169.com/Software/Catalog152/7778.html

If the BIOS is correct (that is, the OEM selects the correct one), it does not need to be activated. It is exactly the same as the genuine system and does not need to worry about being blocked ~~~

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.